diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-02 10:09:49 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-02 10:09:49 +0100 |
| commit | 1c4d04c2089f719e8344f6c4f5cd8488c2320e9f (patch) | |
| tree | b4d3f432f7ebf558af01186601745e0402e135e4 /crypto/pgpainless/src/test/kotlin | |
| parent | 9b8a56cb859f45845a620d7de344079e6a91d7c9 (diff) | |
| download | HardenedPass-1c4d04c2089f719e8344f6c4f5cd8488c2320e9f.tar.gz HardenedPass-1c4d04c2089f719e8344f6c4f5cd8488c2320e9f.zip | |
build(deps): update Bouncy Castle to 1.86 and PGPainless to 1.7.8
Bouncy Castle 1.78.1 is affected by GHSA-574f-3g2m-x479,
GHSA-9pwp-9qqc-pr26, GHSA-c3fc-8qff-9hwx and GHSA-qp49-qgx5-5m26, all
fixed by 1.85. PGPainless 1.7.8 is the newest 1.x release. A root
resolution rule keeps every Bouncy Castle module on the catalog version;
before, bcpg 1.77 shipped next to bcprov 1.78.1.
The new stack decrypts the OCB (LibrePGP) packets GnuPG 2.3+ emits by
default, which the old one rejected as "non-standard AEAD". Drop the
NonStandardAEAD error, its bottom sheet and strings, and replace the
mislabelled aead_* fixtures (SHA-1 self-signed keys plus a message
encrypted to an unrelated key) with a real GnuPG 2.5 key and OCB message
that the tests now decrypt. The new fixture is a throwaway test key, so
it is allowlisted in .gitleaksignore by fingerprint.
Fix KeyUtils.isKeyUsable, which compared a Boolean to null and so
accepted every key that parsed, including keys with no encryption
subkey. A signing-only key fixture now covers the rejection path.
Also: migrate the removed SelectUserId.firstMatch and deprecated
addDecryptionPassphrase APIs, keep one copy of the Bouncy Castle
META-INF/LICENSE.md in the APK, and move the existing InvalidPackage
lint baseline entries to the bcpkix 1.86 jar.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'crypto/pgpainless/src/test/kotlin')
4 files changed, 16 insertions, 14 deletions
diff --git a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/KeyUtilsTest.kt b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/KeyUtilsTest.kt index 4aa83f5f..e6e3d7d1 100644 --- a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/KeyUtilsTest.kt +++ b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/KeyUtilsTest.kt @@ -31,7 +31,7 @@ class KeyUtilsTest { @Test fun isKeyUsable() { - val params = AllKeys.entries.map { it to (it != AllKeys.AEAD_PUB && it != AllKeys.AEAD_SEC) } + val params = AllKeys.entries.map { it to (it != AllKeys.SIGN_ONLY_PUB) } params.forEach { (allKeys, isUsable) -> val key = PGPKey(allKeys.keyMaterial) assertEquals(isUsable, isKeyUsable(key), "${allKeys.name} failed expectation:") diff --git a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt index 7603cfe2..0525c28a 100644 --- a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt +++ b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPKeyManagerTest.kt @@ -76,7 +76,7 @@ class PGPKeyManagerTest { @Test fun addKeyWithUnusableKey() = runTest(dispatcher) { - val error = keyManager.addKey(PGPKey(TestUtils.getAEADSecretKey())).unwrapError() + val error = keyManager.addKey(PGPKey(TestUtils.getSignOnlyPublicKey())).unwrapError() assertEquals(UnusableKeyException, error) } diff --git a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt index 42677337..2bfffd61 100644 --- a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt +++ b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/PGPainlessCryptoHandlerTest.kt @@ -9,7 +9,6 @@ package app.passwordstore.crypto import app.passwordstore.crypto.CryptoConstants.KEY_PASSPHRASE import app.passwordstore.crypto.CryptoConstants.PLAIN_TEXT import app.passwordstore.crypto.errors.IncorrectPassphraseException -import app.passwordstore.crypto.errors.NonStandardAEAD import com.github.michaelbull.result.getError import com.google.testing.junit.testparameterinjector.TestParameter import com.google.testing.junit.testparameterinjector.TestParameterInjector @@ -139,10 +138,10 @@ class PGPainlessCryptoHandlerTest { } @Test - fun aeadEncryptedMaterialIsSurfacedProperly() { - val secKey = PGPKey(TestUtils.getAEADSecretKey()) + fun decryptsGnuPGOcbEncryptedMaterial() { + val secKey = PGPKey(TestUtils.getGnuPGOcbSecretKey()) val plaintextStream = ByteArrayOutputStream() - val ciphertextStream = TestUtils.getAEADEncryptedFile().inputStream() + val ciphertextStream = TestUtils.getGnuPGOcbEncryptedFile().inputStream() val res = cryptoHandler.decrypt( listOf(secKey), @@ -151,8 +150,8 @@ class PGPainlessCryptoHandlerTest { plaintextStream, PGPDecryptOptions.Builder().build(), ) - assertTrue(res.isErr) - assertIs<NonStandardAEAD>(res.error, message = "${res.error.cause}") + assertTrue(res.isOk, "${res.component2()?.cause}") + assertEquals("hunter2", plaintextStream.toString(Charsets.UTF_8).trim()) } @Test diff --git a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/TestUtils.kt b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/TestUtils.kt index 7170b558..001fdafd 100644 --- a/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/TestUtils.kt +++ b/crypto/pgpainless/src/test/kotlin/app/passwordstore/crypto/TestUtils.kt @@ -17,19 +17,22 @@ object TestUtils { fun getArmoredPublicKeyWithMultipleIdentities() = this::class.java.classLoader.getResource("public_key_multiple_identities").readBytes() - fun getAEADPublicKey() = this::class.java.classLoader.getResource("aead_pub").readBytes() + /** A secret key generated by GnuPG 2.5 with default settings, passphrase "Password". */ + fun getGnuPGOcbSecretKey() = this::class.java.classLoader.getResource("gnupg_ocb_sec").readBytes() - fun getAEADSecretKey() = this::class.java.classLoader.getResource("aead_sec").readBytes() + /** "hunter2" encrypted to [getGnuPGOcbSecretKey] by GnuPG using its OCB (LibrePGP) packet. */ + fun getGnuPGOcbEncryptedFile() = + this::class.java.classLoader.getResource("gnupg_ocb_encrypted_file").readBytes() - fun getAEADEncryptedFile() = - this::class.java.classLoader.getResource("aead_encrypted_file").readBytes() + /** A public key with no encryption-capable subkey. */ + fun getSignOnlyPublicKey() = this::class.java.classLoader.getResource("sign_only_pub").readBytes() enum class AllKeys(val keyMaterial: ByteArray) { ARMORED_SEC(getArmoredSecretKey()), ARMORED_PUB(getArmoredPublicKey()), MULTIPLE_IDENTITIES_SEC(getArmoredSecretKeyWithMultipleIdentities()), MULTIPLE_IDENTITIES_PUB(getArmoredPublicKeyWithMultipleIdentities()), - AEAD_SEC(getAEADSecretKey()), - AEAD_PUB(getAEADPublicKey()), + GNUPG_OCB_SEC(getGnuPGOcbSecretKey()), + SIGN_ONLY_PUB(getSignOnlyPublicKey()), } } |
