Class EdDSAUtils
java.lang.Object
org.apache.sshd.common.util.security.eddsa.generic.EdDSAUtils
Utilities to extract the raw key bytes from ed25519 or ed448 keys or to construct such keys from the raw key bytes,
in a manner that is independent of the actual concrete key implementation classes.
- Author:
- Apache MINA SSHD Project
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic KeySpeccreateKeySpec(PrivateKey key) Creates aKeySpecfor re-creating the given ed25519 or ed448 private key.static KeySpeccreateKeySpec(PublicKey key) Creates aKeySpecfor re-creating the given ed25519 or ed448 public key.static KeySpeccreatePrivateKeySpec(byte[] keyData) Creates aKeySpecfor re-creating an ed25519 or ed448 public key from the raw key bytes.static KeySpeccreatePublicKeySpec(byte[] keyData) Creates aKeySpecfor re-creating an ed25519 or ed448 public key from the raw key bytes.static booleanequals(PrivateKey k1, PrivateKey k2) Compares two ed25519 or two ed448PrivateKeys.static booleanCompares two ed25519 or two ed448PublicKeys.static byte[]getBytes(PrivateKey key) Retrieves the raw key bytes from an ed25519 or ed448PrivateKey.static byte[]Retrieves the raw key bytes from an ed25519 or ed448PublicKey.static PrivateKeygetPrivateKey(byte[] keyData) Creates aPrivateKeyfrom the raw key bytes of an ed25519 or ed448 key.static PublicKeygetPublicKey(byte[] keyData) Creates aPublicKeyfrom the raw key bytes of an ed25519 or ed448 key.
-
Field Details
-
ED25519_OID
- See Also:
-
ED448_OID
- See Also:
-
ED25519_LENGTH
public static final int ED25519_LENGTH- See Also:
-
ED448_LENGTH
public static final int ED448_LENGTH- See Also:
-
-
Method Details
-
getBytes
Retrieves the raw key bytes from an ed25519 or ed448PublicKey.- Parameters:
key-PublicKeyto get the bytes of- Returns:
- the raw key bytes
- Throws:
IllegalArgumentException- if the key is not an ed25519 or ed448 key, or if it doesn't use X.509 encoding
-
getBytes
Retrieves the raw key bytes from an ed25519 or ed448PrivateKey.- Parameters:
key-PrivateKeyto get the bytes of- Returns:
- the raw key bytes
- Throws:
IllegalArgumentException- if the key is not an ed25519 or ed448 key, or if it doesn't use PKCS#8 encoding
-
createKeySpec
Creates aKeySpecfor re-creating the given ed25519 or ed448 public key.- Parameters:
key- ed25519 or ed448 key to create aKeySpecfor- Returns:
- the
KeySpec - Throws:
InvalidKeyException- if the key is neither an ed25519 nor an ed448 key
-
createKeySpec
Creates aKeySpecfor re-creating the given ed25519 or ed448 private key.- Parameters:
key- ed25519 or ed448 key to create aKeySpecfor- Returns:
- the
KeySpec - Throws:
InvalidKeyException- if the key is neither an ed25519 nor an ed448 key
-
createPublicKeySpec
Creates aKeySpecfor re-creating an ed25519 or ed448 public key from the raw key bytes.- Parameters:
keyData- the raw key bytes- Returns:
- the
KeySpec - Throws:
InvalidKeyException- if the key bytes do not have the appropriate length for an ed25519 or ed448 key
-
createPrivateKeySpec
Creates aKeySpecfor re-creating an ed25519 or ed448 public key from the raw key bytes.- Parameters:
keyData- the raw key bytes- Returns:
- the
KeySpec - Throws:
InvalidKeyException- if the key bytes do not have the appropriate length for an ed25519 or ed448 key
-
getPublicKey
Creates aPublicKeyfrom the raw key bytes of an ed25519 or ed448 key.- Parameters:
keyData- the raw key bytes- Returns:
- the
PublicKey - Throws:
GeneralSecurityException- if the key cannot be created
-
getPrivateKey
Creates aPrivateKeyfrom the raw key bytes of an ed25519 or ed448 key.- Parameters:
keyData- the raw key bytes- Returns:
- the
PrivateKey - Throws:
GeneralSecurityException- if the key cannot be created
-
equals
Compares two ed25519 or two ed448PublicKeys.- Parameters:
k1- firstPublicKeyk2- secondPublicKey- Returns:
- if the two keys are equal
- Throws:
IllegalArgumentException- if one of the keys is neither an ed25519 nor an ed448 key
-
equals
Compares two ed25519 or two ed448PrivateKeys.- Parameters:
k1- firstPrivateKeyk2- secondPrivateKey- Returns:
- if the two keys are equal
- Throws:
IllegalArgumentException- if one of the keys is neither an ed25519 nor an ed448 key
-