Class ECUtil


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

      • ECUtil

        public ECUtil()
    • Method Detail

      • generatePublicKeyParameter

        public static AsymmetricKeyParameter generatePublicKeyParameter​(java.security.PublicKey key)
                                                                 throws java.security.InvalidKeyException
        Throws:
        java.security.InvalidKeyException
      • generatePrivateKeyParameter

        public static AsymmetricKeyParameter generatePrivateKeyParameter​(java.security.PrivateKey key)
                                                                  throws java.security.InvalidKeyException
        Throws:
        java.security.InvalidKeyException
      • getOrderBitLength

        public static int getOrderBitLength​(ProviderConfiguration configuration,
                                            java.math.BigInteger order,
                                            java.math.BigInteger privateValue)
      • getNamedCurveOid

        public static ASN1ObjectIdentifier getNamedCurveOid​(java.lang.String curveName)
      • 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.
      • getNamedCurveByName

        public static X9ECParameters getNamedCurveByName​(java.lang.String curveName)
      • privateKeyToString

        public static java.lang.String privateKeyToString​(java.lang.String algorithm,
                                                          java.math.BigInteger d,
                                                          ECParameterSpec spec)
      • publicKeyToString

        public static java.lang.String publicKeyToString​(java.lang.String algorithm,
                                                         ECPoint q,
                                                         ECParameterSpec spec)
      • generateKeyFingerprint

        public static java.lang.String generateKeyFingerprint​(ECPoint publicPoint,
                                                              ECParameterSpec spec)
      • getNameFrom

        public static java.lang.String getNameFrom​(java.security.spec.AlgorithmParameterSpec paramSpec)
      • privateKeyHashCode

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