Skip to content

High-Level OpenPGP API - #1911

Closed
vanitasvitae wants to merge 200 commits into
bcgit:mainfrom
pgpainless:valiadateAPI
Closed

High-Level OpenPGP API#1911
vanitasvitae wants to merge 200 commits into
bcgit:mainfrom
pgpainless:valiadateAPI

Conversation

@vanitasvitae

@vanitasvitae vanitasvitae commented Nov 15, 2024

Copy link
Copy Markdown
Contributor

This PR contains a high-level API for OpenPGP, which simplifies the following tasks:

  • Message Creation
    • OpenPGPMessageGenerator sets up an OpenPGPMessageOutputStream based on user configuration
  • Message Consumption
    • OpenPGPMessageProcessor processes encrypted / signed / compressed OpenPGP messages and emits the plaintext along with metadata
  • Certificate / Key Evaluation
    • OpenPGPCertificate acts as high-level API pendant to PGPPublicKeyRing, evaluating expiration / revocation / key signatures and allows the user to get verified information about the cert
    • OpenPGPKey provides similar high-level API pendant to PGPSecretKeyRing

I decided to use a common OpenPGP* naming scheme for the new HighLevel API classes and also decided to make use of general terminology from the book "OpenPGP for application developers" (https://openpgp.dev).

This PR is still pretty much very early work in progress (as is #1857, which will eventually integrate with this API), but I want you to be able to comment on it during the development phase already :)

@vanitasvitae
vanitasvitae marked this pull request as draft November 15, 2024 23:28
@vanitasvitae
vanitasvitae force-pushed the valiadateAPI branch 3 times, most recently from c5856b5 to b096e10 Compare December 3, 2024 11:48
@vanitasvitae

Copy link
Copy Markdown
Contributor Author

This PR is now based on #1926

@vanitasvitae

Copy link
Copy Markdown
Contributor Author

This PR contains #1931 and may need to be rebased if the other patch is merged.

@vanitasvitae

vanitasvitae commented Jan 2, 2025

Copy link
Copy Markdown
Contributor Author

@dghgit I noticed, that in many places you replaced

for (item : collection)
{

with

for (Iterator it = collection.iterator(); it.hasNext();)
{
    Item item = iterator.next();

I was under the impression that BC was now targeting Java 1.8 primarily, which already supports the former method of collection iteration.
Am I missing something? Why are the Iterators not using generics?

Edit: I see you recently made some changes for Java 4 and 5 compatibility.

@ligefeiBouncycastle

Copy link
Copy Markdown
Collaborator

@vanitasvitae Thank you for the update. I've reviewed the code and have merged the majority of it into the main branch — about 20 files remain to be merged. Two test classes, DoubleBufferedInputStreamTest and PGPKeyPairGeneratorTest, will be merged into master at a later stage. Please take a look at the latest changes on the main branch.

@vanitasvitae

Copy link
Copy Markdown
Contributor Author

Looking good! Thank you for your work! :)
One thing: If its not too much of a hassle, I'd prefer if you keep the commit authorship intact :)

@ligefeiBouncycastle

Copy link
Copy Markdown
Collaborator

@vanitasvitae Apologies — the commit authorship information was lost during the branch merges (I had split the work across about 7 branches). I’ll do my best to recover and restore the original authorship.

@ligefeiBouncycastle

Copy link
Copy Markdown
Collaborator

@vanitasvitae Thank you for your greater contribution to this PR. Now all tests related to this PR have been merged with related code. The remaining classes include:
core/src/main/java/org/bouncycastle/util/Objects.java
pg/src/main/java/org/bouncycastle/openpgp/api/exception/PolicyException.java
pg/src/main/java/org/bouncycastle/openpgp/api/util/OpenPGPKeyPrinter.java
pg/src/main/java/org/bouncycastle/openpgp/api/EncryptedDataPacketType.java
pg/src/main/java/org/bouncycastle/openpgp/api/MessageEncryptionMechanism.java
pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPSignature.java
pg/src/main/java/org/bouncycastle/openpgp/PGPEncryptedDataList.java
pg/src/main/java/org/bouncycastle/openpgp/PGPKeyRing.java
pg/src/main/java/org/bouncycastle/openpgp/PGPKeyRingGenerator.java
pg/src/main/java/org/bouncycastle/openpgp/PGPPublicKey.java
pg/src/main/java/org/bouncycastle/openpgp/PGPSecretKey.java
pg/src/main/java/org/bouncycastle/openpgp/PGPSignatureSubpacketVector.java

Some of these classes will be merged later.

@vanitasvitae

Copy link
Copy Markdown
Contributor Author

Nice!
Would it serve you if I rebased the remaining unmerged changes into smaller PRs?

@ligefeiBouncycastle

Copy link
Copy Markdown
Collaborator

@vanitasvitae Thank you! If you're planning to build new functionality that depends on the unmerged changes, feel free to break them into smaller PRs—this will help with quicker reviews and integration. Otherwise, I’ll take care of merging the remaining changes into the main branch later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants