Commit Graph

606 Commits

Author SHA1 Message Date
Paul Schaub 963b678a9e Enable test for decryption of messages without ESKs 2022-11-23 20:42:17 +01:00
Paul Schaub 58195c19b1 Properly handle failed decryption caused by removed private keys 2022-11-23 20:40:40 +01:00
Paul Schaub 58aa9f5712 Move classes related to GNU dummy keys to gnupg package 2022-11-23 20:40:40 +01:00
Paul Schaub df4fc94ce7 Add test for decryption with removed private key 2022-11-23 20:40:40 +01:00
Paul Schaub 3af6ab1b85 Rename GnuPGDummyExtension + GnuPGDummyKeyUtil 2022-11-23 20:40:40 +01:00
Paul Schaub 033beaa8f2 Use S2K usage SHA1 in GnuDummyKeyUtil 2022-11-23 20:40:40 +01:00
Paul Schaub 2487e3300a Add and test GnuDummyKeyUtil 2022-11-23 20:40:40 +01:00
Paul Schaub 7467170bcc Move CachingBcPublicKeyDataDecryptorFactoryTest to correct package 2022-11-23 20:40:40 +01:00
Paul Schaub 8c0d096fc6 Fix CachingBcPublicKeyDataDecryptorFactory 2022-11-23 20:40:40 +01:00
Paul Schaub ec793c66ff More cleanup and better error reporting 2022-11-23 20:40:40 +01:00
Paul Schaub 8ca0cfd3ae Rename *Alphabet to *Symbol and add javadoc 2022-11-23 20:40:40 +01:00
Paul Schaub 7e8841abf3 Handle unknown packet versions gracefully 2022-11-23 20:40:40 +01:00
Paul Schaub 192aa98326 Add missing REUSE license headers 2022-11-23 20:40:40 +01:00
Paul Schaub 3f8653cf2e Fix CRCing test and fully depend on new stream for decryption 2022-11-23 20:40:40 +01:00
Paul Schaub 54cb9dad71 Further increase coverage of PDA class 2022-11-23 20:40:40 +01:00
Paul Schaub 3977d1f407 Add more direct PDA tests 2022-11-23 20:40:40 +01:00
Paul Schaub 977f8c4101 Rename automaton package to syntax_check 2022-11-23 20:40:40 +01:00
Paul Schaub a39c6bc881 Identify custom decryptor factories by subkey id 2022-11-23 20:40:40 +01:00
Paul Schaub 228918f96b Change HardwareSecurity DecryptionCallback to emit key-id 2022-11-23 20:40:40 +01:00
Paul Schaub 529c64cf43 Implement exploratory support for custom decryption factories
This may enable decryption of messages with hardware-backed keys
2022-11-23 20:40:40 +01:00
Paul Schaub d39d062a0d WIP: Explore Hardware Decryption 2022-11-23 20:40:40 +01:00
Paul Schaub dfbb01d61c Enfore max recursion depth and fix CRC test 2022-11-23 20:40:40 +01:00
Paul Schaub 6fd705b1dc Fix checkstyle issues 2022-11-23 20:40:40 +01:00
Paul Schaub fbcde13df3 Reinstate integrity-protection and fix tests
Integrity Protection is now checked when reading from the stream,
not only when closing.
2022-11-23 20:40:40 +01:00
Paul Schaub 654493dfcc Properly expose signatures 2022-11-23 20:40:40 +01:00
Paul Schaub a9f77ea100 Cleaning up and collect signature verifications 2022-11-23 20:40:40 +01:00
Paul Schaub 43c369f1f9 It was the buffering. 2022-11-23 20:40:40 +01:00
Paul Schaub bdc968dd43 Create TeeBCPGInputStream to move teeing logic out of OpenPgpMessageInputStream 2022-11-23 20:40:40 +01:00
Paul Schaub e420678076 2/3 the way to working sig verification 2022-11-23 20:40:40 +01:00
Paul Schaub 5e37d8038a WIP: So close to working notarizations 2022-11-23 20:40:39 +01:00
Paul Schaub 2ce4486e89 Convert links in javadoc to html 2022-11-23 20:40:03 +01:00
Paul Schaub babd1542e3 DO NOT MERGE: Disable broken test 2022-11-23 20:40:03 +01:00
Paul Schaub 09f94944b3 Remove unnecessary throws declarations 2022-11-23 20:40:03 +01:00
Paul Schaub 81bb8cba54 Use BCs Arrays.constantTimeAreEqual(char[], char[]) 2022-11-23 20:40:03 +01:00
Paul Schaub ec28ba2924 SIGNATURE VERIFICATION IN OPENPGP SUCKS BIG TIME 2022-11-23 20:40:03 +01:00
Paul Schaub e25f6e1712 Fix checkstyle issues 2022-11-23 20:40:03 +01:00
Paul Schaub 5c93eb3705 Wip: Introduce MessageMetadata class 2022-11-23 20:40:03 +01:00
Paul Schaub efdf2bca0d WIP: Play around with TeeInputStreams 2022-11-23 20:40:03 +01:00
Paul Schaub 54d7d0c7ae Implement experimental signature verification (correctness only) 2022-11-23 20:40:03 +01:00
Paul Schaub d81c0d4400 Fix tests 2022-11-23 20:40:02 +01:00
Paul Schaub e86062c427 WIP: Replace nesting with independent instancing 2022-11-23 20:40:02 +01:00
Paul Schaub bf8949d7f4 WIP: Implement custom PGPDecryptionStream 2022-11-23 20:40:02 +01:00
Paul Schaub bc73d26118 Add Pushdown Automaton for checking OpenPGP message syntax
The automaton implements what is described in
https://github.com/pgpainless/pgpainless/blob/main/misc/OpenPGPMessageFormat.md

However, some differences exist to adopt it to BouncyCastle

Part of #237
2022-11-23 20:40:02 +01:00
Paul Schaub 754fcf72a1
Implement ProducerOptions.setHideArmorHeaders()
Fixes #328
2022-10-31 11:43:24 +01:00
Paul Schaub 8834d8ad10
Increase timeframe for some tests which check expiration dates 2022-10-18 15:13:49 +02:00
Paul Schaub 6a2a604ba4
Update TODO for BC 173 2022-09-27 16:47:23 +02:00
Paul Schaub d74a8d0408
Add PGPainless.asciiArmor(PGPSignature) 2022-09-27 16:28:31 +02:00
Paul Schaub dac059c702
Add test for PGPainless.asciiArmor(key, stream) 2022-09-27 16:17:22 +02:00
Paul Schaub 8dfabf1842 Test decryption of messages using Session Key 2022-09-12 15:26:06 +02:00
Paul Schaub 7480c47fa7
Add behavior test to ensure that ArmoredInputStream cuts away any data outside of the armor 2022-09-08 18:15:52 +02:00
Paul Schaub 0dd54f27b7
Add test for processing message byte by byte 2022-09-05 15:43:32 +02:00
Paul Schaub 9106d98449
Add tests for Certificate merging 2022-09-05 15:25:29 +02:00
Paul Schaub 5be42b22bd
Add test for KeyRingUtils.keysPlusPublicKey 2022-09-05 14:45:22 +02:00
Paul Schaub 4ec38bb63b
Add tests for ArmoredInputStreamFactory 2022-09-05 14:37:23 +02:00
Paul Schaub 3a33bb126a
Add RNGPerformanceTest to help diagnose performance bottlenecks
Related to https://github.com/pgpainless/pgpainless/issues/309
2022-09-03 14:24:37 +02:00
Paul Schaub c3dc3c9d87 Allow modification of keys with custom reference date
Also, bind subkeys using SubkeyBindingSignatureBuilder
2022-09-03 13:42:58 +02:00
Paul Schaub 15046cdc32
Switch default S2K for secret key protection over to use SHA256 and add documentation 2022-08-31 21:37:31 +02:00
Paul Schaub c6676d3c91
Add support for generating keys without user-ids
Fixes #296
2022-08-29 14:12:02 +02:00
Paul Schaub 1b04d67e1a
Remove unused SignatureSubpacketGeneratorUtil class and tests 2022-08-29 11:30:26 +02:00
Paul Schaub 0cc884523c
Integrate RevocationState into KeyRingInfo class 2022-08-29 11:30:10 +02:00
Paul Schaub c73905d179
Import RevocationStateTest from wot branch 2022-08-29 11:12:42 +02:00
Paul Schaub b9845912ee
Add tests for readKeyRing() 2022-08-08 13:20:28 +02:00
Paul Schaub ca09ac62ca
KeyRingInfo.isUsableFor*(): Check if primary key is revoked 2022-08-03 13:37:18 +02:00
Paul Schaub 895fcced9a
Add gradle CI action 2022-07-22 20:21:02 +02:00
Paul Schaub cb23cad625
Fix checkstyle issues and java API compatibility 2022-07-22 13:59:15 +02:00
Jérôme Charaoui 5a86d9db62 Fix tests that read from jar-embedded resources
It seems that none of the functions used here actually require a File
object as arguments, and will happily work on InputStream objects.
This also changes readFromResource() to use InputStream.readAllBytes()
instead of File.readAllBytes(), which is available from Java 9.
2022-07-22 13:55:05 +02:00
Paul Schaub c4bffad478
Abort (skip) tests reading from resources 2022-07-21 21:34:44 +02:00
Paul Schaub f966c1ed07
Explicitly cast Long to long to fix ambiguity in debian tests 2022-07-20 18:07:42 +02:00
Paul Schaub cd5982cd47
Add AEADAlgorithm class and test 2022-07-18 11:30:37 +02:00
Paul Schaub 6fc1d25db8 Merge branch 'fix298' 2022-07-16 12:37:20 +02:00
Paul Schaub ba191a1d0f
Prevent adding NULL to symmetric algorithm preference when generating key
Fixes #301
2022-07-15 14:19:45 +02:00
Paul Schaub dec3c8be60
Add SecretKeyRingEditor.replaceUserId(old,new,protector) 2022-07-15 14:00:41 +02:00
Paul Schaub 2ad67a85fb
Add test to make sure we do not allow unencrypted as sym alg preference 2022-07-15 13:20:23 +02:00
Paul Schaub 4730ac427b
Add test for #298 2022-07-13 14:54:16 +02:00
Paul Schaub 223cf009fc
Fix User-ID format in documentation and note invalid user-id formats in tests 2022-07-12 10:33:43 +02:00
Paul Schaub 3842aa9ced
Add test to explore behavior when dealing with V3 keys 2022-07-08 15:08:45 +02:00
Paul Schaub 8b66b3527e
Add tests for pet name certification and scoped delegation 2022-06-30 13:16:15 +02:00
Paul Schaub b8f4cc3935 Merge branch 'certification' 2022-06-29 16:01:03 +02:00
Paul Schaub b2a5351cc3
Delete unused KeyRingValidator class 2022-06-29 16:00:21 +02:00
Paul Schaub b6975b38f1
Add tests for KeyFlag bitmask methods 2022-06-20 19:03:52 +02:00
Paul Schaub 0690a21360
Increase coverage of Policy class 2022-06-20 18:48:27 +02:00
Paul Schaub 37441a81e8
Add OpenPgpV5Fingerprint constructor tests using mocked v5 keys 2022-06-20 18:35:48 +02:00
Paul Schaub fed3080ae8
Add tests to increase coverage of v5 fingerprint class 2022-06-20 18:19:24 +02:00
Paul Schaub ca39efda99
Add test for CleartextSignedMessageUtil 2022-06-20 18:10:44 +02:00
Paul Schaub a944d2a6b9
Fix build errors 2022-06-20 15:09:02 +02:00
Paul Schaub 1483ff9e24 Add another test for Trustworthiness 2022-06-20 12:44:40 +02:00
Paul Schaub d2b48e83d9 Implement certifying of certifications 2022-06-20 12:44:40 +02:00
Paul Schaub fa5ddfd112 WIP: Implement delegations
THERE ARE THINGS BROKEN NOW. DO NOT MERGE!
2022-06-20 12:44:40 +02:00
Paul Schaub c1170773bc Implement certification of third party keys 2022-06-20 12:44:40 +02:00
Paul Schaub 75455f1a3c
Add OpenPgpMetadata.isCleartextSigned and use it in sop to determine if message was cleartext signed 2022-06-19 17:31:48 +02:00
Paul Schaub dd26b5230d Use newly introduced modernKeyRing(userId) method 2022-06-19 16:59:42 +02:00
Paul Schaub 44c32d0620
When setting expiration dates: Prevent integer overflow 2022-06-01 13:36:00 +02:00
Paul Schaub 9921fc6ff6
Add and test OpenPgpFingerprint.parseFromBinary(bytes) 2022-05-18 14:19:08 +02:00
Paul Schaub 3a9bfd57ac Add test for SignatureUtils.getSignaturesForUserIdBy() 2022-05-17 18:38:48 +02:00
Paul Schaub 12e62d381c
Make readSignatures skip over compressed data packets without decompression. 2022-05-08 11:24:34 +02:00
Paul Schaub 49d65788b4 Remove support for processing compressed detached signatures
Signatures are indistinguishable from randomness, so there is no point in
compressing them, apart from attempting to exploit flaws in compression
algorithms.
Thanks to @DemiMarie for pointing this out

Fixes #286
2022-05-07 21:46:12 +02:00
Paul Schaub 64a50266f1
Test for detection of uncompressed, signed messages, and improve decryption of seip messages 2022-05-05 12:43:44 +02:00
Paul Schaub 69f84f24b6
Implement heavy duty packet inspection to figure out nature of data 2022-05-04 20:55:29 +02:00
Paul Schaub b980fcd7b1
EncryptionOptions.addRecipients(collection): Disallow empty collections
Fixes #281
2022-04-29 22:49:45 +02:00
Paul Schaub 6c983d66e0
Take hash algorithm usage date into account when checking algorithm acceptance 2022-04-22 22:45:39 +02:00
Paul Schaub 6c442e9568 Merge remote-tracking branch 'origin/hashContextSigner' 2022-04-22 21:36:47 +02:00
Paul Schaub 46f69b9fa5
Introduce OpenPgpInputStream to distinguish between armored, binary and non-OpenPGP data 2022-04-22 20:53:44 +02:00
Paul Schaub 73b7f1b9bb
Refactoring 2022-04-19 21:07:46 +02:00
Paul Schaub c3dfb254b1
Experimental implementation of signing of existing hash contexts (MessageDigest instances) 2022-04-16 00:23:20 +02:00
Paul Schaub 864bfad80c Add test for encryption / decryption, signing with missing secret subkey 2022-04-07 19:42:58 +02:00
Paul Schaub a22336a795 Create dedicated KeyException class for key-related exceptions. 2022-04-07 19:42:58 +02:00
Paul Schaub 0bce68d6ee
Add shortcut SigningOptions.addSignature() method 2022-04-04 20:18:15 +02:00
Paul Schaub e601f8dbda
In Encrypt example: Read keys from string 2022-04-04 19:49:28 +02:00
Paul Schaub c8a1ca5b29
Make use of DateUtil.now() in test 2022-04-04 12:53:47 +02:00
Paul Schaub 50bcb6a135 Fix changelog and change method signature 2022-04-02 16:18:12 +02:00
Paul Schaub f8e66f4d61 Add ProducerOptions.applyCRLFEncoding()
Enabling it will automatically apply CRLF encoding to input data.
Further, disentangle signing from the encryption stream
2022-04-02 16:18:12 +02:00
Paul Schaub 6bef376992
Fix signature generation with all format and signature type combinations
This comes at the cost of that we no longer CR/LF encode literal data before encryption/signing.
That means that applications that rely on PGPainless to do the CR/LF encoding must manually
do the encoding before feeding the message to PGPainless.
The newly introduced CRLFGeneratorStream has documentation on how to do that.
Fixes #264
2022-03-30 16:13:08 +02:00
Paul Schaub b0eb32d550
Fix checkstyle 2022-03-30 12:21:53 +02:00
Paul Schaub 82936c5499 Add investigative test for broken messages when using different data/sig encodings 2022-03-27 17:01:31 +02:00
Paul Schaub e8b03834cb
Annotate fromId(code) methods with Nullable and add Nonnull requireFromId(code) methods 2022-03-22 15:09:09 +01:00
Paul Schaub 3585203557
Prettify user-id info on armor 2022-03-21 16:44:59 +01:00
Simon Frankenberger e569c2c991
ArmorUtils now prints out the primary user-id and brief information about other user-ids 2022-03-21 16:09:45 +01:00
Paul Schaub 9e0aa95a5a
Add documentation for the DecryptOrVerify examples 2022-03-16 21:29:34 +01:00
Paul Schaub d4d29553ec
Add decryption example 2022-03-15 15:10:23 +01:00
Paul Schaub ffdbd21491 Implement configuration option for SignerUserId subpacket verification level.
By default we ignore SignerUserId subpackets on signatures.
This behavior can be changed by calling Policy.setSignerUserIdValidationLevel().
Right now, STRICT and DISABLED are available as options, but it may make sense to implement
another option PARTIALLY, which will accept signatures made by key with user-id 'A <foo@bar>'
but where the sig contains a signer user id of value 'foo@bar' for example.
2022-03-14 11:10:12 +01:00
Paul Schaub 6b9b956c2c
Add OpenPgpFingerprint.parse(String) 2022-03-10 12:22:02 +01:00
Paul Schaub 8f473b513f
Add support for OpenPGP v5 fingerprints.
Obviously we need support for key.getFingerprint() in BC, but once
that is there, this should magically start working.
2022-03-10 12:01:12 +01:00
Paul Schaub 0824bbd37c
Add investigative test for signers user-ids 2022-03-09 21:05:17 +01:00
Paul Schaub 9d160ef047
Reject subkeys with predating binding signatures 2022-03-07 12:17:45 +01:00
Paul Schaub 10e72f6773
Allow custom key creation dates during generation 2022-03-07 11:08:59 +01:00
Paul Schaub 5b9e72d42c
Add KeyRingInfo.isUsableForEncryption() 2022-03-06 14:58:36 +01:00
Paul Schaub 1949cc5eea
Fix generics of CertificationSubpackets callback 2022-03-02 11:15:07 +01:00
Paul Schaub 35dd4f9a67
Fix unused import 2022-03-01 17:37:24 +01:00
Paul Schaub d55d6a1686
Improve RegExs for extracting email addresses from keys
Based on https://github.com/pgpainless/pgpainless/pull/257/
Thanks @bratkartoffel for the initial proposed changes
2022-03-01 12:14:09 +01:00
feri 7a77d0847a Support multiline comments in ProducerOption.setComment(). 2022-02-24 17:46:45 +01:00
feri 928fa12b51
Add new ProducerOption setComment() for Ascii armored EncryptionStreams. (#254)
* Add new ProducerOption setComment() for Ascii armored EncryptionStreams.
2022-02-24 00:51:16 +01:00
Paul Schaub 1753cef10e Simplify handling of cleartext-signed data 2022-02-23 18:45:29 +01:00
Paul Schaub e8da3b30d8 Yet another patch for ASCII armor detection -.- 2022-02-15 14:23:03 +01:00
Paul Schaub 458b4f1f78 Fix detection of unarmored data in detached signature verification 2022-02-11 14:07:29 +01:00
Paul Schaub 01839728f0 Remove workaround for publicKey.getBitStrength() == -1 in BC
see https://github.com/bcgit/bc-java/issues/972
2022-01-15 02:46:41 +01:00
Paul Schaub e374951ed0 Remove ProofUtil.
This does not belong here.
2022-01-15 02:46:41 +01:00
Paul Schaub d9e3c6ed91 Remove investigative test with expired key 2022-01-15 02:46:41 +01:00
Paul Schaub e7f583c1af Fix KeyRingInfo.get*Algorithm(keyId) 2022-01-15 02:45:21 +01:00
Paul Schaub 9de196d6c5 Fix test for algorithm preference extraction 2022-01-15 02:45:10 +01:00
Paul Schaub b1bde161b4
Fix typos and wording 2021-12-28 13:53:25 +01:00
Paul Schaub ce7b69269b
Various code cleanup 2021-12-28 13:32:50 +01:00
Paul Schaub 59f1a85887
Fix more code issues 2021-12-28 12:30:52 +01:00
Paul Schaub f3b7286eaf Introduce and use DateUtil.toSecondsPrecision 2021-12-28 01:42:12 +01:00
Paul Schaub d0ef8581e8
Add RevokeUserIdsTest 2021-12-27 13:49:31 +01:00
Paul Schaub a0e9c1f555
Add SelectUserId.byEmail() 2021-12-27 13:36:13 +01:00
Paul Schaub 245376d7d0
Remove KeyRingUtils.deleteUserId() in favor of revoking SecretKeyRingEditor.removeUserId() methods 2021-12-27 13:35:58 +01:00
Paul Schaub 3aa9e2915a
Re-certify expired user-ids when changing key expiration date 2021-12-20 13:28:16 +01:00
Paul Schaub 710f961984 Rework key modification API.
Fixes #225
2021-12-20 13:01:58 +01:00
Paul Schaub 78b668880b
Delete unused TestImplementationFactoryProvider 2021-12-14 16:57:50 +01:00
Paul Schaub cf90c25afc
rename invocationContextProvider to TestAllImplementations 2021-12-14 16:56:29 +01:00