Class Curve

  • All Implemented Interfaces:
    java.io.Serializable

    @Immutable
    public final class Curve
    extends java.lang.Object
    implements java.io.Serializable
    Cryptographic curve. This class is immutable.

    Includes constants for the following standard cryptographic curves:

    See

    • "Digital Signature Standard (DSS)", FIPS PUB 186-3, June 2009, National Institute of Standards and Technology (NIST).
    • CFRG Elliptic Curve Diffie-Hellman (ECDH) and Signatures in JSON Object Signing and Encryption (JOSE) (RFC 8037).
    Version:
    2021-07-02
    Author:
    Vladimir Dzhuvinov, Aleksei Doroganov
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Curve Ed25519
      Ed25519 signature algorithm key pairs.
      static Curve Ed448
      Ed448 signature algorithm key pairs.
      static Curve P_256
      P-256 curve (secp256r1, also called prime256v1, OID = 1.2.840.10045.3.1.7).
      static Curve P_256K
      Deprecated.
      static Curve P_384
      P-384 curve (secp384r1, OID = 1.3.132.0.34).
      static Curve P_521
      P-521 curve (secp521r1).
      static Curve SECP256K1
      secp256k1 curve (secp256k1, OID = 1.3.132.0.10).
      static Curve X25519
      X25519 function key pairs.
      static Curve X448
      X448 function key pairs.
    • Constructor Summary

      Constructors 
      Constructor Description
      Curve​(java.lang.String name)
      Creates a new cryptographic curve with the specified JOSE name.
      Curve​(java.lang.String name, java.lang.String stdName, java.lang.String oid)
      Creates a new cryptographic curve with the specified JOSE name, standard name and object identifier (OID).
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)  
      static Curve forECParameterSpec​(java.security.spec.ECParameterSpec spec)
      Gets the cryptographic curve for the specified parameter specification.
      static java.util.Set<Curve> forJWSAlgorithm​(JWSAlgorithm alg)
      Gets the cryptographic curve(s) for the specified JWS algorithm.
      static Curve forOID​(java.lang.String oid)
      Gets the cryptographic curve for the specified object identifier (OID).
      static Curve forStdName​(java.lang.String stdName)
      Gets the cryptographic curve for the specified standard name.
      java.lang.String getName()
      Returns the JOSE name of this cryptographic curve.
      java.lang.String getOID()
      Returns the standard object identifier (OID) of this cryptographic curve.
      java.lang.String getStdName()
      Returns the standard name of this cryptographic curve.
      int hashCode()  
      static Curve parse​(java.lang.String s)
      Parses a cryptographic curve from the specified string.
      java.security.spec.ECParameterSpec toECParameterSpec()
      Returns the parameter specification for this cryptographic curve.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • P_256

        public static final Curve P_256
        P-256 curve (secp256r1, also called prime256v1, OID = 1.2.840.10045.3.1.7).
      • SECP256K1

        public static final Curve SECP256K1
        secp256k1 curve (secp256k1, OID = 1.3.132.0.10).
      • P_256K

        @Deprecated
        public static final Curve P_256K
        Deprecated.
        P-256K curve.
      • P_384

        public static final Curve P_384
        P-384 curve (secp384r1, OID = 1.3.132.0.34).
      • P_521

        public static final Curve P_521
        P-521 curve (secp521r1).
      • Ed25519

        public static final Curve Ed25519
        Ed25519 signature algorithm key pairs.
      • Ed448

        public static final Curve Ed448
        Ed448 signature algorithm key pairs.
      • X25519

        public static final Curve X25519
        X25519 function key pairs.
      • X448

        public static final Curve X448
        X448 function key pairs.
    • Constructor Detail

      • Curve

        public Curve​(java.lang.String name)
        Creates a new cryptographic curve with the specified JOSE name. A standard curve name and object identifier (OID) are not unspecified.
        Parameters:
        name - The JOSE name of the cryptographic curve. Must not be null.
      • Curve

        public Curve​(java.lang.String name,
                     java.lang.String stdName,
                     java.lang.String oid)
        Creates a new cryptographic curve with the specified JOSE name, standard name and object identifier (OID).
        Parameters:
        name - The JOSE name of the cryptographic curve. Must not be null.
        stdName - The standard name of the cryptographic curve, null if not specified.
        oid - The object identifier (OID) of the cryptographic curve, null if not specified.
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns the JOSE name of this cryptographic curve.
        Returns:
        The JOSE name.
      • getStdName

        public java.lang.String getStdName()
        Returns the standard name of this cryptographic curve.
        Returns:
        The standard name, null if not specified.
      • getOID

        public java.lang.String getOID()
        Returns the standard object identifier (OID) of this cryptographic curve.
        Returns:
        The OID, null if not specified.
      • toECParameterSpec

        public java.security.spec.ECParameterSpec toECParameterSpec()
        Returns the parameter specification for this cryptographic curve.
        Returns:
        The EC parameter specification, null if it cannot be determined.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        getName()
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • parse

        public static Curve parse​(java.lang.String s)
        Parses a cryptographic curve from the specified string.
        Parameters:
        s - The string to parse. Must not be null or empty.
        Returns:
        The cryptographic curve.
      • forStdName

        public static Curve forStdName​(java.lang.String stdName)
        Gets the cryptographic curve for the specified standard name.
        Parameters:
        stdName - The standard curve name. May be null.
        Returns:
        The curve, null if it cannot be determined.
      • forOID

        public static Curve forOID​(java.lang.String oid)
        Gets the cryptographic curve for the specified object identifier (OID).
        Parameters:
        oid - The object OID. May be null.
        Returns:
        The curve, null if it cannot be determined.
      • forJWSAlgorithm

        public static java.util.Set<Curve> forJWSAlgorithm​(JWSAlgorithm alg)
        Gets the cryptographic curve(s) for the specified JWS algorithm.
        Parameters:
        alg - The JWS algorithm. May be null.
        Returns:
        The curve(s), null if the JWS algorithm is not curve based, or the JWS algorithm is not supported.
      • forECParameterSpec

        public static Curve forECParameterSpec​(java.security.spec.ECParameterSpec spec)
        Gets the cryptographic curve for the specified parameter specification.
        Parameters:
        spec - The EC parameter spec. May be null.
        Returns:
        The curve, null if it cannot be determined.