use aes256 for password encryption (#75)
This commit is contained in:
parent
39c2fa863e
commit
1f4d966115
3 changed files with 22 additions and 1 deletions
|
|
@ -41,6 +41,7 @@ DecryptBinaryMessageArmored(privateKey string, passphrase []byte, ciphertext str
|
|||
- Improved key and message armoring testing
|
||||
- `EncryptSessionKey` now creates encrypted key packets for each valid encryption key in the provided keyring.
|
||||
Returns a byte slice with all the concatenated key packets.
|
||||
- Use aes256 chiper for message encryption with password.
|
||||
|
||||
### Fixed
|
||||
- Public key armoring headers
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ func passwordEncrypt(message []byte, password []byte, isBinary bool) ([]byte, er
|
|||
var outBuf bytes.Buffer
|
||||
|
||||
config := &packet.Config{
|
||||
DefaultCipher: packet.CipherAES256,
|
||||
Time: getTimeGenerator(),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue