use aes256 for password encryption (#75)

This commit is contained in:
Ilya Chesnokov 2020-08-31 13:42:06 +03:00 committed by GitHub
parent 39c2fa863e
commit 1f4d966115
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View file

@ -3,6 +3,7 @@ package crypto
import (
"bytes"
"encoding/base64"
"io"
"testing"
"time"
@ -18,6 +19,24 @@ func TestTextMessageEncryptionWithPassword(t *testing.T) {
if err != nil {
t.Fatal("Expected no error when encrypting, got:", err)
}
packets := packet.NewReader(bytes.NewReader(encrypted.GetBinary()))
var foundSk bool
for {
var p packet.Packet
var errEOF error
if p, errEOF = packets.Next(); errEOF == io.EOF {
break
}
sessionKey, ok := p.(*packet.SymmetricKeyEncrypted)
if ok {
assert.Equal(t, sessionKey.CipherFunc, packet.CipherAES256)
foundSk = true
break
}
}
if !foundSk {
t.Fatal("Expect to found encrypted session key")
}
// Decrypt data with wrong password
_, err = DecryptMessageWithPassword(encrypted, []byte("Wrong password"))
assert.NotNil(t, err)