Skip to content

Commit cd9bd33

Browse files
author
gefeili
committed
Copy AEADSecretKeyEncryptorBuilder from 1857 branch
1 parent 6b80483 commit cd9bd33

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.bouncycastle.openpgp.operator;
2+
3+
import org.bouncycastle.bcpg.PublicKeyPacket;
4+
5+
/**
6+
* Implementation provider for AEAD-based {@link PBESecretKeyEncryptor PBESecretKeyEncryptors}.
7+
*/
8+
public interface AEADSecretKeyEncryptorBuilder
9+
{
10+
/**
11+
* Build a new {@link PBESecretKeyEncryptor} using the given passphrase.
12+
* Note: As the AEAD protection mechanism includes the public key packet of the key into the calculation,
13+
* if the key you want to protect is supposed to be a subkey, you need to convert it to one <b>before</b>
14+
* calling this method. See {@link org.bouncycastle.openpgp.PGPKeyPair#asSubkey(KeyFingerPrintCalculator)}.
15+
*
16+
* @param passphrase passphrase
17+
* @param pubKey public primary or subkey packet
18+
* @return encryptor using AEAD
19+
*/
20+
PBESecretKeyEncryptor build(char[] passphrase, PublicKeyPacket pubKey);
21+
}

pg/src/main/java/org/bouncycastle/openpgp/operator/bc/BcAEADSecretKeyEncryptorBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import org.bouncycastle.bcpg.PublicKeyPacket;
99
import org.bouncycastle.bcpg.S2K;
1010
import org.bouncycastle.openpgp.PGPException;
11+
import org.bouncycastle.openpgp.operator.AEADSecretKeyEncryptorBuilder;
1112
import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor;
1213

1314
public class BcAEADSecretKeyEncryptorBuilder
15+
implements AEADSecretKeyEncryptorBuilder
1416
{
1517

1618
private int aeadAlgorithm;

pg/src/main/java/org/bouncycastle/openpgp/operator/jcajce/JcaAEADSecretKeyEncryptorBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
import org.bouncycastle.jcajce.util.NamedJcaJceHelper;
1414
import org.bouncycastle.jcajce.util.ProviderJcaJceHelper;
1515
import org.bouncycastle.openpgp.PGPException;
16+
import org.bouncycastle.openpgp.operator.AEADSecretKeyEncryptorBuilder;
1617
import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor;
1718

1819
public class JcaAEADSecretKeyEncryptorBuilder
20+
implements AEADSecretKeyEncryptorBuilder
1921
{
2022
private int aeadAlgorithm;
2123
private int symmetricAlgorithm;

0 commit comments

Comments
 (0)