1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-22 19:08:00 +01:00
pgpainless/pgpainless-sop
2024-03-30 19:20:12 +01:00
..
src Document nature of tests in pgpainless-sop 2024-03-30 19:20:12 +01:00
build.gradle Add Automatic-Module-Name to pgpainless-core and pgpainless-sop 2024-03-19 15:56:49 +01:00
README.md Bump sop-java to 10.0.0-SNAPSHOT and implement sopv interface subset 2024-03-24 10:52:15 +01:00

PGPainless-SOP

Spec Revision: 10 Maven Central javadoc

Implementation of the Stateless OpenPGP Protocol using PGPainless.

This module implements sop-java using pgpainless-core. If your code depends on sop-java, this module can be used as a realization of those interfaces.

Get started

To start using pgpainless-sop in your code, include the following lines in your build script:

// If you use Gradle
...
dependencies {
    ...
    implementation "org.pgpainless:pgpainless-sop:1.6.6"
    ...
}

// If you use Maven
...
<dependencies>
    ...
    <dependency>
        <groupId>org.pgpainless</groupId>
        <artifactId>pgpainless-sop</artifactId>
        <version>1.6.6</version>
    </dependency>
    ...
</dependencies>

pgpainless-sop will transitively pull in its dependencies, such as sop-java and pgpainless-core.

Usage Examples

SOP sop = new SOPImpl();
        
// Generate an OpenPGP key
byte[] key = sop.generateKey()
        .userId("Alice <alice@example.org>")
        .generate()
        .getBytes();

// Extract the certificate (public key)
byte[] cert = sop.extractCert()
        .key(key)
        .getBytes();

// Encrypt a message
byte[] message = ...
byte[] encrypted = sop.encrypt()
        .withCert(cert)
        .signWith(key)
        .plaintext(message)
        .getBytes();

// Decrypt a message
ByteArrayAndResult<DecryptionResult> messageAndVerifications = sop.decrypt()
        .verifyWith(cert)
        .withKey(key)
        .ciphertext(encrypted)
        .toByteArrayAndResult();
byte[] decrypted = messageAndVerifications.getBytes();
// Signature Verifications
DecryptionResult messageInfo = messageAndVerifications.getResult();
List<Verification> signatureVerifications = messageInfo.getVerifications();