Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.sec.SECObjectIdentifiers;
import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers;
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyPair;
Expand Down Expand Up @@ -183,6 +184,7 @@ public abstract PGPKeyPair generateLegacyX25519KeyPair()

/**
* Generate an ECDH elliptic curve encryption key over the NIST p-256 curve.
* <pre>NIST P-256</pre> is equivalent to <pre>prime256v1</pre> and <pre>secp256r1</pre>.
*
* @return NIST p-256 ECDSA encryption key pair
* @throws PGPException if the key pair cannot be generated
Expand All @@ -198,6 +200,7 @@ public PGPKeyPair generateNistP256ECDHKeyPair()

/**
* Generate an ECDH elliptic curve encryption key over the NIST p-384 curve.
* <pre>NIST P-384</pre> is equivalent to <pre>secp384r1</pre>.
*
* @return NIST p-384 ECDSA encryption key pair
* @throws PGPException if the key pair cannot be generated
Expand All @@ -213,6 +216,7 @@ public PGPKeyPair generateNistP384ECDHKeyPair()

/**
* Generate an ECDH elliptic curve encryption key over the NIST p-521 curve.
* <pre>NIST P-521</pre> is equivalent to <pre>secp521r1</pre>.
*
* @return NIST p-521 ECDSA encryption key pair
* @throws PGPException if the key pair cannot be generated
Expand All @@ -226,8 +230,54 @@ public PGPKeyPair generateNistP521ECDHKeyPair()
return generateECDHKeyPair(SECObjectIdentifiers.secp521r1);
}

/**
* Generate an ECDH elliptic curve encryption key over the brainpoolP256r1 curve.
*
* @return BrainpoolP256r1 ECDH encryption key pair
* @throws PGPException if the key pair cannot be generated
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9580.html#name-ecc-curves-for-openpgp">
* RFC9580 - ECC Curves for OpenPGP</a>
*/
public PGPKeyPair generateBrainpoolP256r1ECDHKeyPair()
throws PGPException
{
return generateECDHKeyPair(TeleTrusTObjectIdentifiers.brainpoolP256r1);
}

/**
* Generate an ECDH elliptic curve encryption key over the brainpoolP384r1 curve.
*
* @return BrainpoolP384r1 ECDH encryption key pair
* @throws PGPException if the key pair cannot be generated
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9580.html#name-ecc-curves-for-openpgp">
* RFC9580 - ECC Curves for OpenPGP</a>
*/
public PGPKeyPair generateBrainpoolP384r1ECDHKeyPair()
throws PGPException
{
return generateECDHKeyPair(TeleTrusTObjectIdentifiers.brainpoolP384r1);
}

/**
* Generate an ECDH elliptic curve encryption key over the brainpoolP512r1 curve.
*
* @return BrainpoolP512r1 ECDH encryption key pair
* @throws PGPException if the key pair cannot be generated
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9580.html#name-ecc-curves-for-openpgp">
* RFC9580 - ECC Curves for OpenPGP</a>
*/
public PGPKeyPair generateBrainpoolP512r1ECDHKeyPair()
throws PGPException
{
return generateECDHKeyPair(TeleTrusTObjectIdentifiers.brainpoolP512r1);
}

/**
* Generate an ECDSA elliptic curve signing key over the NIST p-256 curve.
* <pre>NIST P-256</pre> is equivalent to <pre>prime256v1</pre> and <pre>secp256r1</pre>.
*
* @return NIST p-256 ECDSA signing key pair
* @throws PGPException if the key pair cannot be generated
Expand All @@ -243,6 +293,7 @@ public PGPKeyPair generateNistP256ECDSAKeyPair()

/**
* Generate an ECDSA elliptic curve signing key over the NIST p-384 curve.
* <pre>NIST P-384</pre> is equivalent to <pre>secp384r1</pre>.
*
* @return NIST p-384 ECDSA signing key pair
* @throws PGPException if the key pair cannot be generated
Expand All @@ -258,6 +309,7 @@ public PGPKeyPair generateNistP384ECDSAKeyPair()

/**
* Generate an ECDSA elliptic curve signing key over the NIST p-521 curve.
* <pre>NIST P-521</pre> is equivalent to <pre>secp521r1</pre>.
*
* @return NIST p-521 ECDSA signing key pair
* @throws PGPException if the key pair cannot be generated
Expand All @@ -271,6 +323,51 @@ public PGPKeyPair generateNistP521ECDSAKeyPair()
return generateECDSAKeyPair(SECObjectIdentifiers.secp521r1);
}

/**
* Generate an ECDSA elliptic curve signing key over the brainpoolP256r1 curve.
*
* @return BrainpoolP256r1 ECDSA signing key pair
* @throws PGPException if the key pair cannot be generated
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9580.html#name-ecc-curves-for-openpgp">
* RFC9580 - ECC Curves for OpenPGP</a>
*/
public PGPKeyPair generateBrainpoolP256r1ECDSAKeyPair()
throws PGPException
{
return generateECDSAKeyPair(TeleTrusTObjectIdentifiers.brainpoolP256r1);
}

/**
* Generate an ECDSA elliptic curve signing key over the brainpoolP384r1 curve.
*
* @return BrainpoolP384r1 ECDSA signing key pair
* @throws PGPException if the key pair cannot be generated
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9580.html#name-ecc-curves-for-openpgp">
* RFC9580 - ECC Curves for OpenPGP</a>
*/
public PGPKeyPair generateBrainpoolP384r1ECDSAKeyPair()
throws PGPException
{
return generateECDSAKeyPair(TeleTrusTObjectIdentifiers.brainpoolP384r1);
}

/**
* Generate an ECDSA elliptic curve signing key over the brainpoolP512r1 curve.
*
* @return BrainpoolP512r1 ECDSA signing key pair
* @throws PGPException if the key pair cannot be generated
*
* @see <a href="https://www.rfc-editor.org/rfc/rfc9580.html#name-ecc-curves-for-openpgp">
* RFC9580 - ECC Curves for OpenPGP</a>
*/
public PGPKeyPair generateBrainpoolP512r1ECDSAKeyPair()
throws PGPException
{
return generateECDSAKeyPair(TeleTrusTObjectIdentifiers.brainpoolP512r1);
}

/**
* Generate an elliptic curve Diffie-Hellman encryption key pair over the curve identified by the given OID.
*
Expand Down
Loading
Loading