This commit is contained in:
Mike Schwörer 2023-02-03 01:05:36 +01:00
parent be4de07eb8
commit fd33b43f31
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF

View File

@ -21,7 +21,6 @@ type aesPayload struct {
Data []byte `json:"d"`
Rounds int `json:"r"`
Version uint `json:"v"`
Algorithm string `json:"a"`
}
func EncryptAESSimple(password []byte, data []byte, rounds int) (string, error) {
@ -70,7 +69,6 @@ func EncryptAESSimple(password []byte, data []byte, rounds int) (string, error)
Data: ciphertext,
Version: 1,
Rounds: rounds,
Algorithm: "AES",
}
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