|
1 | 1 | package org.bouncycastle.openpgp.operator;
|
2 | 2 |
|
| 3 | +import org.bouncycastle.asn1.ASN1ObjectIdentifier; |
| 4 | +import org.bouncycastle.asn1.sec.SECObjectIdentifiers; |
3 | 5 | import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
|
4 | 6 | import org.bouncycastle.openpgp.PGPException;
|
5 | 7 | import org.bouncycastle.openpgp.PGPKeyPair;
|
@@ -178,4 +180,114 @@ public abstract PGPKeyPair generateLegacyEd25519KeyPair()
|
178 | 180 | */
|
179 | 181 | public abstract PGPKeyPair generateLegacyX25519KeyPair()
|
180 | 182 | throws PGPException;
|
| 183 | + |
| 184 | + /** |
| 185 | + * Generate an ECDH elliptic curve encryption key over the NIST p-256 curve. |
| 186 | + * |
| 187 | + * @return NIST p-256 ECDSA encryption key pair |
| 188 | + * @throws PGPException if the key pair cannot be generated |
| 189 | + * |
| 190 | + * @see <a href="https://www.rfc-editor.org/rfc/rfc6637.html"> |
| 191 | + * RFC6637 - Elliptic Curve Cryptography in OpenPGP</a> |
| 192 | + */ |
| 193 | + public PGPKeyPair generateNistP256ECDHKeyPair() |
| 194 | + throws PGPException |
| 195 | + { |
| 196 | + return generateECDHKeyPair(SECObjectIdentifiers.secp256r1); |
| 197 | + } |
| 198 | + |
| 199 | + /** |
| 200 | + * Generate an ECDH elliptic curve encryption key over the NIST p-384 curve. |
| 201 | + * |
| 202 | + * @return NIST p-384 ECDSA encryption key pair |
| 203 | + * @throws PGPException if the key pair cannot be generated |
| 204 | + * |
| 205 | + * @see <a href="https://www.rfc-editor.org/rfc/rfc6637.html"> |
| 206 | + * RFC6637 - Elliptic Curve Cryptography in OpenPGP</a> |
| 207 | + */ |
| 208 | + public PGPKeyPair generateNistP384ECDHKeyPair() |
| 209 | + throws PGPException |
| 210 | + { |
| 211 | + return generateECDHKeyPair(SECObjectIdentifiers.secp384r1); |
| 212 | + } |
| 213 | + |
| 214 | + /** |
| 215 | + * Generate an ECDH elliptic curve encryption key over the NIST p-521 curve. |
| 216 | + * |
| 217 | + * @return NIST p-521 ECDSA encryption key pair |
| 218 | + * @throws PGPException if the key pair cannot be generated |
| 219 | + * |
| 220 | + * @see <a href="https://www.rfc-editor.org/rfc/rfc6637.html"> |
| 221 | + * RFC6637 - Elliptic Curve Cryptography in OpenPGP</a> |
| 222 | + */ |
| 223 | + public PGPKeyPair generateNistP521ECDHKeyPair() |
| 224 | + throws PGPException |
| 225 | + { |
| 226 | + return generateECDHKeyPair(SECObjectIdentifiers.secp521r1); |
| 227 | + } |
| 228 | + |
| 229 | + /** |
| 230 | + * Generate an ECDSA elliptic curve signing key over the NIST p-256 curve. |
| 231 | + * |
| 232 | + * @return NIST p-256 ECDSA signing key pair |
| 233 | + * @throws PGPException if the key pair cannot be generated |
| 234 | + * |
| 235 | + * @see <a href="https://www.rfc-editor.org/rfc/rfc6637.html"> |
| 236 | + * RFC6637 - Elliptic Curve Cryptography in OpenPGP</a> |
| 237 | + */ |
| 238 | + public PGPKeyPair generateNistP256ECDSAKeyPair() |
| 239 | + throws PGPException |
| 240 | + { |
| 241 | + return generateECDSAKeyPair(SECObjectIdentifiers.secp256r1); |
| 242 | + } |
| 243 | + |
| 244 | + /** |
| 245 | + * Generate an ECDSA elliptic curve signing key over the NIST p-384 curve. |
| 246 | + * |
| 247 | + * @return NIST p-384 ECDSA signing key pair |
| 248 | + * @throws PGPException if the key pair cannot be generated |
| 249 | + * |
| 250 | + * @see <a href="https://www.rfc-editor.org/rfc/rfc6637.html"> |
| 251 | + * RFC6637 - Elliptic Curve Cryptography in OpenPGP</a> |
| 252 | + */ |
| 253 | + public PGPKeyPair generateNistP384ECDSAKeyPair() |
| 254 | + throws PGPException |
| 255 | + { |
| 256 | + return generateECDSAKeyPair(SECObjectIdentifiers.secp384r1); |
| 257 | + } |
| 258 | + |
| 259 | + /** |
| 260 | + * Generate an ECDSA elliptic curve signing key over the NIST p-521 curve. |
| 261 | + * |
| 262 | + * @return NIST p-521 ECDSA signing key pair |
| 263 | + * @throws PGPException if the key pair cannot be generated |
| 264 | + * |
| 265 | + * @see <a href="https://www.rfc-editor.org/rfc/rfc6637.html"> |
| 266 | + * RFC6637 - Elliptic Curve Cryptography in OpenPGP</a> |
| 267 | + */ |
| 268 | + public PGPKeyPair generateNistP521ECDSAKeyPair() |
| 269 | + throws PGPException |
| 270 | + { |
| 271 | + return generateECDSAKeyPair(SECObjectIdentifiers.secp521r1); |
| 272 | + } |
| 273 | + |
| 274 | + /** |
| 275 | + * Generate an elliptic curve Diffie-Hellman encryption key pair over the curve identified by the given OID. |
| 276 | + * |
| 277 | + * @param curveOID OID of the elliptic curve |
| 278 | + * @return PGP key pair |
| 279 | + * @throws PGPException if the key pair cannot be generated |
| 280 | + */ |
| 281 | + public abstract PGPKeyPair generateECDHKeyPair(ASN1ObjectIdentifier curveOID) |
| 282 | + throws PGPException; |
| 283 | + |
| 284 | + /** |
| 285 | + * Generate an elliptic curve signing key over the curve identified by the given OID. |
| 286 | + * |
| 287 | + * @param curveOID OID of the elliptic curve |
| 288 | + * @return PGP key pair |
| 289 | + * @throws PGPException if the key pair cannot be generated |
| 290 | + */ |
| 291 | + public abstract PGPKeyPair generateECDSAKeyPair(ASN1ObjectIdentifier curveOID) |
| 292 | + throws PGPException; |
181 | 293 | }
|
0 commit comments