From 712c9f7153c59bc5487e781cdeab0a60dcfd6d6e Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 13 May 2021 21:42:24 +0400 Subject: Changed workflow of saving messages, so that server now saves signed messages. --- http-server/cryptography.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'http-server/cryptography.go') diff --git a/http-server/cryptography.go b/http-server/cryptography.go index 3340446..beaba71 100644 --- a/http-server/cryptography.go +++ b/http-server/cryptography.go @@ -6,7 +6,6 @@ import ( "crypto/sha256" "crypto/x509" "encoding/base64" - "encoding/json" "encoding/pem" "errors" "fmt" @@ -30,10 +29,8 @@ func decodeMessage(ciphertext []byte, stringKey string) ([]byte, error) { return plaintext, err } -func checkSignature(req Request, signature string, key string) (bool, error) { - reqBytes, _ := json.Marshal(req) - req64 := base64.StdEncoding.EncodeToString(reqBytes) - h := sha256.Sum256([]byte(req64)) +func checkSignature(payload string, signature string, key string) (bool, error) { + h := sha256.Sum256([]byte(payload)) requestHash := fmt.Sprintf("%x", h) decodedSign, err := base64.StdEncoding.DecodeString(signature) -- cgit v1.2.3