Convert private to public keys in helpers to prevent locked errors (#66)

This commit is contained in:
wussler 2020-08-04 10:04:40 +02:00 committed by GitHub
parent 979fdb3f4b
commit b152448673
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 7 deletions

View file

@ -53,7 +53,7 @@ func TestArmoredTextMessageEncryptionVerification(t *testing.T) {
var plaintext = "Secret message"
armored, err := EncryptSignMessageArmored(
readTestFile("keyring_publicKey", false),
readTestFile("keyring_privateKey", false),
readTestFile("keyring_privateKey", false),
testMailboxPassword, // Password defined in base_test
plaintext,
@ -65,7 +65,7 @@ func TestArmoredTextMessageEncryptionVerification(t *testing.T) {
assert.Exactly(t, true, crypto.IsPGPMessage(armored))
_, err = DecryptVerifyMessageArmored(
readTestFile("mime_publicKey", false), // Wrong public key
readTestFile("mime_privateKey", false), // Wrong public key
readTestFile("keyring_privateKey", false),
testMailboxPassword, // Password defined in base_test
armored,
@ -73,7 +73,7 @@ func TestArmoredTextMessageEncryptionVerification(t *testing.T) {
assert.EqualError(t, err, "Signature Verification Error: No matching signature")
decrypted, err := DecryptVerifyMessageArmored(
readTestFile("keyring_publicKey", false),
readTestFile("keyring_privateKey", false),
readTestFile("keyring_privateKey", false),
testMailboxPassword, // Password defined in base_test
armored,
@ -90,7 +90,7 @@ func TestAttachmentEncryptionVerification(t *testing.T) {
var attachment = []byte("Secret file\r\nRoot password:hunter2")
keyPacket, dataPacket, signature, err := EncryptSignAttachment(
readTestFile("keyring_publicKey", false),
readTestFile("keyring_privateKey", false),
readTestFile("keyring_privateKey", false),
testMailboxPassword, // Password defined in base_test
"password.txt",
@ -107,7 +107,7 @@ func TestAttachmentEncryptionVerification(t *testing.T) {
}
_, err = DecryptVerifyAttachment(
readTestFile("mime_publicKey", false), // Wrong public key
readTestFile("mime_privateKey", false), // Wrong public key
readTestFile("keyring_privateKey", false),
testMailboxPassword, // Password defined in base_test
keyPacket,
@ -117,7 +117,7 @@ func TestAttachmentEncryptionVerification(t *testing.T) {
assert.EqualError(t, err, "gopenpgp: unable to verify attachment")
decrypted, err := DecryptVerifyAttachment(
readTestFile("keyring_publicKey", false),
readTestFile("keyring_privateKey", false),
readTestFile("keyring_privateKey", false),
testMailboxPassword, // Password defined in base_test
keyPacket,
@ -134,7 +134,7 @@ func TestAttachmentEncryptionVerification(t *testing.T) {
func TestArmoredBinaryMessageEncryption(t *testing.T) {
plainData := []byte("Secret message")
armored, err := EncryptBinaryMessageArmored(readTestFile("keyring_publicKey", false), plainData)
armored, err := EncryptBinaryMessageArmored(readTestFile("keyring_privateKey", false), plainData)
if err != nil {
t.Fatal("Expected no error when encrypting, got:", err)