Search code examples
javabouncycastle

EC.generateKeyPair() missing in Bouncy Castle FIPS library


The Bouncy Castle FIPS Java API in 100 Examples suggests multiple times the use of EC.generateKeyPair(). Assuming this references org.bouncycastle.crypto.general.EC (as this is the only class with name EC) I'm not able to find a method generateKeyPair(). Where's the error and how to generate an according key pair?


Solution

  • From the PDF provided (https://www.bouncycastle.org/fips-java/BCFipsIn100.pdf):

    Example 31 – Key Pair Generation

    public static KeyPair generateKeyPair() throws GeneralSecurityException {
        KeyPairGenerator keyPair = KeyPairGenerator.getInstance("EC", "BCFIPS");
        keyPair.initialize(384);
        return keyPair.generateKeyPair();
    }
    

    The example will result in a key pair on the curve P-384. Other default curves available include P-224, P-256, and P-521.