Class ECUtil

java.lang.Object
org.bouncycastle.jcajce.provider.asymmetric.util.ECUtil

public class ECUtil extends Object
utility class for converting jce/jca ECDSA, ECDH, and ECDHC objects into their org.bouncycastle.crypto counterparts.
  • Constructor Details

    • ECUtil

      public ECUtil()
  • Method Details

    • getDomainParameters

      public static ECDomainParameters getDomainParameters(ProviderConfiguration configuration, ECParameterSpec params)
    • getDomainParameters

      public static ECDomainParameters getDomainParameters(ProviderConfiguration configuration, X962Parameters params)
    • generatePublicKeyParameter

      public static AsymmetricKeyParameter generatePublicKeyParameter(PublicKey key) throws InvalidKeyException
      Throws:
      InvalidKeyException
    • generatePrivateKeyParameter

      public static AsymmetricKeyParameter generatePrivateKeyParameter(PrivateKey key) throws InvalidKeyException
      Throws:
      InvalidKeyException
    • getOrderBitLength

      public static int getOrderBitLength(ProviderConfiguration configuration, BigInteger order, BigInteger privateValue)
    • getNamedCurveOid

      public static ASN1ObjectIdentifier getNamedCurveOid(String curveName)
    • getNamedCurveOid

      public static ASN1ObjectIdentifier getNamedCurveOid(ECParameterSpec ecParameterSpec)
    • getUncompressedSubjectPublicKeyBytes

      public static byte[] getUncompressedSubjectPublicKeyBytes(SubjectPublicKeyInfo spki, ProviderConfiguration configuration)
      Return the subjectPublicKey bytes of a SubjectPublicKeyInfo with an EC point normalised to its uncompressed encoding, and the bytes of any other key type unchanged.

      The composite drafts (draft-ietf-lamps-pq-composite-sigs / -kem sec. 4) require an EC component to be carried as an uncompressed point, so a component key that would encode itself compressed - a BC EC key whose point format has been set through ECPointEncoder, or a key from a provider that preserves a compressed encoding - has to be normalised on the way out rather than passed through as it came. This is a write-side normalisation only: a compressed component is still accepted on decode, as the component key factories decode either form.

      Parameters:
      spki - the key to take the component bytes from.
      configuration - provider configuration, consulted only for implicitlyCA and additional curve parameters.
      Returns:
      the component key bytes, uncompressed if they are an EC point.
    • getNamedCurveByOid

      public static X9ECParameters getNamedCurveByOid(ASN1ObjectIdentifier oid)
    • getNamedCurveByName

      public static X9ECParameters getNamedCurveByName(String curveName)
    • getCurveName

      public static String getCurveName(ASN1ObjectIdentifier oid)
    • namedCurveToString

      public static String namedCurveToString(String name)
      Describe a named curve for toString() in the "name (oid)" form SunEC's own named curves use, so messages read the same whichever provider made the key. A name that is itself an OID is shown once, after the table name when there is one, and a name with no known OID is shown as given.
      Parameters:
      name - the curve name, or an OID in dotted form.
      Returns:
      the description, or null if name is null.
    • curveToString

      public static String curveToString(ECCurve curve)
      Describe EC domain parameters that carry no name for toString(), by field type and size, for example "EC parameters (Fp, 256-bit field)".
      Parameters:
      curve - the curve, may be null.
      Returns:
      the description.
    • privateKeyToString

      public static String privateKeyToString(String algorithm, BigInteger d, ECParameterSpec spec)
    • publicKeyToString

      public static String publicKeyToString(String algorithm, ECPoint q, ECParameterSpec spec)
    • generateKeyFingerprint

      public static String generateKeyFingerprint(ECPoint publicPoint, ECParameterSpec spec)
    • getNameFrom

      public static String getNameFrom(AlgorithmParameterSpec paramSpec)
    • privateKeyHashCode

      public static int privateKeyHashCode(BigInteger d, ECParameterSpec spec)
      Hash code for an EC private scalar derived from the public point and domain parameters.