summaryrefslogtreecommitdiff
path: root/http-server/cryptography.go
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2021-05-13 21:42:24 +0400
committerAndrew <saintruler@gmail.com>2021-05-13 21:42:24 +0400
commit712c9f7153c59bc5487e781cdeab0a60dcfd6d6e (patch)
tree6300faa4bd7653841b574cb45c1605603679f454 /http-server/cryptography.go
parent587ac4f7fecc417b4877c5f3c0fdefa58990b3c8 (diff)
Changed workflow of saving messages, so that server now saves signed messages.
Diffstat (limited to 'http-server/cryptography.go')
-rw-r--r--http-server/cryptography.go7
1 files changed, 2 insertions, 5 deletions
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)