Skip to content

Commit

Permalink
Copy AEADSecretKeyEncryptorBuilder from 1857 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
gefeili committed Dec 16, 2024
1 parent 6b80483 commit cd9bd33
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.bouncycastle.openpgp.operator;

import org.bouncycastle.bcpg.PublicKeyPacket;

/**
* Implementation provider for AEAD-based {@link PBESecretKeyEncryptor PBESecretKeyEncryptors}.
*/
public interface AEADSecretKeyEncryptorBuilder
{
/**
* Build a new {@link PBESecretKeyEncryptor} using the given passphrase.
* Note: As the AEAD protection mechanism includes the public key packet of the key into the calculation,
* if the key you want to protect is supposed to be a subkey, you need to convert it to one <b>before</b>
* calling this method. See {@link org.bouncycastle.openpgp.PGPKeyPair#asSubkey(KeyFingerPrintCalculator)}.
*
* @param passphrase passphrase
* @param pubKey public primary or subkey packet
* @return encryptor using AEAD
*/
PBESecretKeyEncryptor build(char[] passphrase, PublicKeyPacket pubKey);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import org.bouncycastle.bcpg.PublicKeyPacket;
import org.bouncycastle.bcpg.S2K;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.operator.AEADSecretKeyEncryptorBuilder;
import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor;

public class BcAEADSecretKeyEncryptorBuilder
implements AEADSecretKeyEncryptorBuilder
{

private int aeadAlgorithm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
import org.bouncycastle.jcajce.util.NamedJcaJceHelper;
import org.bouncycastle.jcajce.util.ProviderJcaJceHelper;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.operator.AEADSecretKeyEncryptorBuilder;
import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor;

public class JcaAEADSecretKeyEncryptorBuilder
implements AEADSecretKeyEncryptorBuilder
{
private int aeadAlgorithm;
private int symmetricAlgorithm;
Expand Down

0 comments on commit cd9bd33

Please sign in to comment.