From fd33b43f311636d888f12b1ae85d2c1f2b3b340d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Fri, 3 Feb 2023 01:05:36 +0100 Subject: [PATCH] v0.0.78 --- cryptext/aes.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cryptext/aes.go b/cryptext/aes.go index 9f9ff41..653fe83 100644 --- a/cryptext/aes.go +++ b/cryptext/aes.go @@ -16,12 +16,11 @@ import ( // https://stackoverflow.com/a/18819040/1761622 type aesPayload struct { - Salt []byte `json:"s"` - IV []byte `json:"i"` - Data []byte `json:"d"` - Rounds int `json:"r"` - Version uint `json:"v"` - Algorithm string `json:"a"` + Salt []byte `json:"s"` + IV []byte `json:"i"` + Data []byte `json:"d"` + Rounds int `json:"r"` + Version uint `json:"v"` } func EncryptAESSimple(password []byte, data []byte, rounds int) (string, error) { @@ -65,12 +64,11 @@ func EncryptAESSimple(password []byte, data []byte, rounds int) (string, error) cfb.XORKeyStream(ciphertext, combinedData) pl := aesPayload{ - Salt: salt, - IV: iv, - Data: ciphertext, - Version: 1, - Rounds: rounds, - Algorithm: "AES", + Salt: salt, + IV: iv, + Data: ciphertext, + Version: 1, + Rounds: rounds, } jbin, err := json.Marshal(pl) @@ -96,6 +94,10 @@ func DecryptAESSimple(password []byte, encText string) ([]byte, error) { return nil, err } + if pl.Version != 1 { + return nil, errors.New("unsupported version") + } + key, err := scrypt.Key(password, pl.Salt, pl.Rounds, 8, 1, 32) // this is not 100% correct, rounds too low and salt is missing if err != nil { return nil, err