1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-11 22:24:53 +02:00
pgpainless/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/EncryptionBuilderInterface.java

105 lines
3.7 KiB
Java
Raw Normal View History

/*
* Copyright 2018 Paul Schaub.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pgpainless.encryption_signing;
2018-06-04 19:45:18 +02:00
import javax.annotation.Nonnull;
2018-06-05 01:30:58 +02:00
import java.io.IOException;
2018-06-04 19:45:18 +02:00
import java.io.OutputStream;
2018-06-05 01:30:58 +02:00
import org.bouncycastle.openpgp.PGPException;
2018-06-04 19:45:18 +02:00
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
2018-06-11 01:33:49 +02:00
import org.bouncycastle.openpgp.PGPSecretKey;
2018-06-04 19:45:18 +02:00
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
import org.pgpainless.algorithm.CompressionAlgorithm;
import org.pgpainless.algorithm.HashAlgorithm;
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
import org.pgpainless.exception.SecretKeyNotFoundException;
import org.pgpainless.key.protection.SecretKeyRingProtector;
import org.pgpainless.key.selection.keyring.PublicKeyRingSelectionStrategy;
import org.pgpainless.key.selection.keyring.SecretKeyRingSelectionStrategy;
import org.pgpainless.util.MultiMap;
2018-06-04 19:45:18 +02:00
public interface EncryptionBuilderInterface {
ToRecipients onOutputStream(@Nonnull OutputStream outputStream);
2018-06-04 19:45:18 +02:00
interface ToRecipients {
WithAlgorithms toRecipients(@Nonnull PGPPublicKey... keys);
2018-06-04 19:45:18 +02:00
WithAlgorithms toRecipients(@Nonnull PGPPublicKeyRing... keys);
2018-06-04 19:45:18 +02:00
WithAlgorithms toRecipients(@Nonnull PGPPublicKeyRingCollection... keys);
<O> WithAlgorithms toRecipients(@Nonnull PublicKeyRingSelectionStrategy<O> selectionStrategy,
@Nonnull MultiMap<O, PGPPublicKeyRingCollection> keys);
2018-06-04 19:45:18 +02:00
2020-08-24 14:55:06 +02:00
DetachedSign doNotEncrypt();
2018-06-04 19:45:18 +02:00
}
interface WithAlgorithms {
WithAlgorithms andToSelf(@Nonnull PGPPublicKey... keys);
2018-06-07 18:12:13 +02:00
WithAlgorithms andToSelf(@Nonnull PGPPublicKeyRing... keys);
2018-06-11 01:33:49 +02:00
WithAlgorithms andToSelf(@Nonnull PGPPublicKeyRingCollection keys);
2018-07-08 18:05:55 +02:00
<O> WithAlgorithms andToSelf(@Nonnull PublicKeyRingSelectionStrategy<O> selectionStrategy,
@Nonnull MultiMap<O, PGPPublicKeyRingCollection> keys);
2018-06-04 19:45:18 +02:00
2020-08-24 14:55:06 +02:00
DetachedSign usingAlgorithms(@Nonnull SymmetricKeyAlgorithm symmetricKeyAlgorithm,
@Nonnull HashAlgorithm hashAlgorithm,
@Nonnull CompressionAlgorithm compressionAlgorithm);
2018-06-04 19:45:18 +02:00
2020-08-24 14:55:06 +02:00
DetachedSign usingSecureAlgorithms();
}
interface DetachedSign extends SignWith {
SignWith createDetachedSignature();
Armor doNotSign();
2018-06-07 18:12:13 +02:00
2018-06-04 19:45:18 +02:00
}
interface SignWith {
<O> Armor signWith(@Nonnull SecretKeyRingProtector decryptor, @Nonnull PGPSecretKey... keys);
2018-06-04 19:45:18 +02:00
<O> Armor signWith(@Nonnull SecretKeyRingProtector decryptor, @Nonnull PGPSecretKeyRing... keyRings);
2018-06-04 19:45:18 +02:00
<O> Armor signWith(@Nonnull SecretKeyRingSelectionStrategy<O> selectionStrategy,
@Nonnull SecretKeyRingProtector decryptor,
@Nonnull MultiMap<O, PGPSecretKeyRingCollection> keys)
2018-06-05 01:30:58 +02:00
throws SecretKeyNotFoundException;
2018-06-04 19:45:18 +02:00
}
interface Armor {
EncryptionStream asciiArmor() throws IOException, PGPException;
2018-06-04 19:45:18 +02:00
EncryptionStream noArmor() throws IOException, PGPException;
2018-06-04 19:45:18 +02:00
}
}