Skip to content

EC Curve name is different among various keys #917

@JinhangZhang

Description

@JinhangZhang

I did a simple test

public static void main(String[] args) throws Exception {
        KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
        kpg.initialize(new ECGenParameterSpec("secp224r1"));
}

and simply add a printout command to print the ecPubKeyNamedCurve.getName() in my recent PR #826 in the ECDHKeyAgreement class to see what it will return for various EC curve including secp224r1, secp256r1, secp384r1 and secp521r1.

ECNamedCurve ecPubKeyNamedCurve = ECParameters.getNamedCurve(this.ecPublicKey.getParams());
ECNamedCurve ecPriKeyNamedCurve = ECParameters.getNamedCurve(this.ecPrivateKey.getParams());
ObjectIdentifier oidPubKey = ECNamedCurve.getOIDFromName(ecPubKeyNamedCurve.getName());
ObjectIdentifier oidPriKey = ECNamedCurve.getOIDFromName(ecPriKeyNamedCurve.getName());

System.out.println("Public key is: " + ecPubKeyNamedCurve.getName());
System.out.println("Private key is: " + ecPriKeyNamedCurve.getName());

However,
I got different name:

  • by passing secp224r1 in kpg.initialize(new ECGenParameterSpec("secp224r1")); I got the print out value is Public key is: secp224r1 Private key is: secp224r1

  • by passing secp256r1 in kpg.initialize(new ECGenParameterSpec("secp256r1")); I got the print out value is Public key is: NIST P-256 Private key is: NIST P-256

  • by passing secp384r1 in kpg.initialize(new ECGenParameterSpec("secp384r1")); I got the print out value is Public key is: NIST P-384 Private key is: NIST P-384

  • by passing secp521r1 in kpg.initialize(new ECGenParameterSpec("secp521r1")); I got the print out value is Public key is: NIST P-521 Private key is: NIST P-521

As you can see the name is different there

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions