From a67c60d0913f5f565a57542d9b5732470f415579 Mon Sep 17 00:00:00 2001
From: Carl Michael Skog <cm@äger.com>
Date: Thu, 3 Oct 2019 14:48:55 +0200
Subject: [PATCH 1/4] Add an init test with a key with multiple subkeys
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Using pass with a primary key with multiple subkeys fails the subkey
enumeration check, since gpg when encrypting with such a key only uses
the most recently added encryption subkey, not all encryption subkeys.

Signed-off-by: Carl Michael Skog <cm@äger.com>
---
 ...EFA1387A43F03768F13E6B25D345AD342F5386.key | Bin 0 -> 978 bytes
 ...3D633B6519FCE7187F66277EEE66F174BECFA0.key | Bin 0 -> 978 bytes
 ...745D43D2A2AF9D646DEC73F62109861A59C5E7.key | Bin 0 -> 978 bytes
 tests/gnupg/pubring.gpg                       | Bin 5875 -> 7911 bytes
 tests/gnupg/trustdb.gpg                       | Bin 1600 -> 1680 bytes
 tests/setup.sh                                |   1 +
 tests/t0300-reencryption.sh                   |   5 +++++
 7 files changed, 6 insertions(+)
 create mode 100644 tests/gnupg/private-keys-v1.d/06EFA1387A43F03768F13E6B25D345AD342F5386.key
 create mode 100644 tests/gnupg/private-keys-v1.d/0E3D633B6519FCE7187F66277EEE66F174BECFA0.key
 create mode 100644 tests/gnupg/private-keys-v1.d/A5745D43D2A2AF9D646DEC73F62109861A59C5E7.key

diff --git a/tests/gnupg/private-keys-v1.d/06EFA1387A43F03768F13E6B25D345AD342F5386.key b/tests/gnupg/private-keys-v1.d/06EFA1387A43F03768F13E6B25D345AD342F5386.key
new file mode 100644
index 0000000000000000000000000000000000000000..daf876b26e23c3098f0c859872d15e21a370d3c0
GIT binary patch
diff --git a/tests/gnupg/private-keys-v1.d/0E3D633B6519FCE7187F66277EEE66F174BECFA0.key b/tests/gnupg/private-keys-v1.d/0E3D633B6519FCE7187F66277EEE66F174BECFA0.key
new file mode 100644
index 0000000000000000000000000000000000000000..666aa3140be551125cfb6c4ce2c98862aa4747ed
GIT binary patch
diff --git a/tests/gnupg/private-keys-v1.d/A5745D43D2A2AF9D646DEC73F62109861A59C5E7.key b/tests/gnupg/private-keys-v1.d/A5745D43D2A2AF9D646DEC73F62109861A59C5E7.key
new file mode 100644
index 0000000000000000000000000000000000000000..30a660c226359e850a4eb1f68ccba91a5693ac51
GIT binary patch
diff --git a/tests/gnupg/pubring.gpg b/tests/gnupg/pubring.gpg
index 0573fd3abdd95ee082b79394a840a60a9fe83dc2..e6e33d19ebe5e392dbfe7259845a0d24174832ca 100644
GIT binary patch
diff --git a/tests/gnupg/trustdb.gpg b/tests/gnupg/trustdb.gpg
index cb5ec15078c2d1f07150f49f8ba2061ea3b6ce82..6990b8639619b98f79686a4afd6728f6bb8ad39a 100644
GIT binary patch
diff --git a/tests/setup.sh b/tests/setup.sh
index 5d1e794..e49d8cc 100644
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -62,3 +62,4 @@ KEY2="D774A374"  # pass test key 2
 KEY3="EB7D54A8"  # pass test key 3
 KEY4="E4691410"  # pass test key 4
 KEY5="39E5020C"  # pass test key 5
+KEY6="B25B8FEE"  # pass test key 6
diff --git a/tests/t0300-reencryption.sh b/tests/t0300-reencryption.sh
index 3c88987..e61d796 100755
--- a/tests/t0300-reencryption.sh
+++ b/tests/t0300-reencryption.sh
@@ -45,6 +45,11 @@ test_expect_success 'Reencryption root multiple key with string' '
 	[[ $(canonicalize_gpg_keys $KEY2 $KEY3 $KEY1 $KEY4) == "$(gpg_keys_from_encrypted_file "$PASSWORD_STORE_DIR/folder/cred1.gpg")" ]]
 '
 
+test_expect_success 'Reencryption root single key with multiple subkeys' '
+	"$PASS" init $KEY6 &&
+	[[ $(canonicalize_gpg_keys "$KEY6") == "$(gpg_keys_from_encrypted_file "$PASSWORD_STORE_DIR/folder/cred1.gpg")" ]]
+'
+
 test_expect_success 'Reencryption root group' '
 	"$PASS" init group1 &&
 	[[ $(gpg_keys_from_group group1) == "$(gpg_keys_from_encrypted_file "$PASSWORD_STORE_DIR/folder/cred1.gpg")" ]]
-- 
2.23.0

