Enum MontgomeryCurve

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      x25519
      X25519 uses Curve25519 and SHA-256 with a 32-byte key size.
      x448
      X448 uses Curve448 and SHA-512 with a 56-byte key size.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MontgomeryCurve​(java.lang.String algorithm, int keySize, byte[] encodedPublicKeyPrefix)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.crypto.KeyAgreement createKeyAgreement()  
      java.security.PublicKey decode​(byte[] key)  
      byte[] encode​(java.security.PublicKey key)  
      java.security.KeyPair generateKeyPair()  
      java.lang.String getAlgorithm()  
      int getKeySize()  
      boolean isSupported()  
      static MontgomeryCurve valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static MontgomeryCurve[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • x25519

        public static final MontgomeryCurve x25519
        X25519 uses Curve25519 and SHA-256 with a 32-byte key size.
      • x448

        public static final MontgomeryCurve x448
        X448 uses Curve448 and SHA-512 with a 56-byte key size.
    • Field Detail

      • algorithm

        private final java.lang.String algorithm
      • keySize

        private final int keySize
      • supported

        private final boolean supported
      • keyPairGenerator

        private final java.security.KeyPairGenerator keyPairGenerator
      • keyFactory

        private final java.security.KeyFactory keyFactory
      • encodedPublicKeyPrefix

        private final byte[] encodedPublicKeyPrefix
    • Constructor Detail

      • MontgomeryCurve

        private MontgomeryCurve​(java.lang.String algorithm,
                                int keySize,
                                byte[] encodedPublicKeyPrefix)
    • Method Detail

      • values

        public static MontgomeryCurve[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (MontgomeryCurve c : MontgomeryCurve.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static MontgomeryCurve valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getAlgorithm

        public java.lang.String getAlgorithm()
      • getKeySize

        public int getKeySize()
        Specified by:
        getKeySize in interface KeySizeIndicator
        Returns:
        The number of bits used in the key
      • createKeyAgreement

        public javax.crypto.KeyAgreement createKeyAgreement()
                                                     throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • generateKeyPair

        public java.security.KeyPair generateKeyPair()
      • encode

        public byte[] encode​(java.security.PublicKey key)
                      throws java.security.InvalidKeyException
        Throws:
        java.security.InvalidKeyException
      • decode

        public java.security.PublicKey decode​(byte[] key)
                                       throws java.security.spec.InvalidKeySpecException
        Throws:
        java.security.spec.InvalidKeySpecException