public class EdDSAPublicKey extends java.lang.Object implements EdDSAKey, java.security.PublicKey
Warning: Public key encoding is is based on the current curdle WG draft, and is subject to change. See getEncoded().
For compatibility with older releases, decoding supports both the old and new draft specifications. See decode().
Ref: https://tools.ietf.org/html/draft-ietf-curdle-pkix-04
Old Ref: https://tools.ietf.org/html/draft-josefsson-pkix-eddsa-04
Modifier and Type | Field and Description |
---|---|
private GroupElement |
A |
private byte[] |
Abyte |
private GroupElement |
Aneg |
private EdDSAParameterSpec |
edDsaSpec |
private static int |
IDLEN_BYTE |
private static int |
OID_BYTE |
private static int |
OID_ED25519 |
private static int |
OID_OLD |
private static long |
serialVersionUID |
KEY_ALGORITHM
Constructor and Description |
---|
EdDSAPublicKey(EdDSAPublicKeySpec spec) |
EdDSAPublicKey(java.security.spec.X509EncodedKeySpec spec) |
Modifier and Type | Method and Description |
---|---|
private static byte[] |
decode(byte[] d)
Extracts the public key bytes from the provided encoding.
|
boolean |
equals(java.lang.Object o) |
GroupElement |
getA() |
byte[] |
getAbyte() |
java.lang.String |
getAlgorithm() |
byte[] |
getEncoded()
Returns the public key in its canonical encoding.
|
java.lang.String |
getFormat() |
GroupElement |
getNegativeA() |
EdDSAParameterSpec |
getParams() |
int |
hashCode() |
private static final long serialVersionUID
private final GroupElement A
private GroupElement Aneg
private final byte[] Abyte
private final EdDSAParameterSpec edDsaSpec
private static final int OID_OLD
private static final int OID_ED25519
private static final int OID_BYTE
private static final int IDLEN_BYTE
public EdDSAPublicKey(EdDSAPublicKeySpec spec)
public EdDSAPublicKey(java.security.spec.X509EncodedKeySpec spec) throws java.security.spec.InvalidKeySpecException
java.security.spec.InvalidKeySpecException
public java.lang.String getAlgorithm()
getAlgorithm
in interface java.security.Key
public java.lang.String getFormat()
getFormat
in interface java.security.Key
public byte[] getEncoded()
This implements the following specs:
For keys in older formats, decoding and then re-encoding is sufficient to migrate them to the canonical encoding.
Relevant spec quotes:In the X.509 certificate, the subjectPublicKeyInfo field has the SubjectPublicKeyInfo type, which has the following ASN.1 syntax: SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, subjectPublicKey BIT STRING }
AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL } For all of the OIDs, the parameters MUST be absent.
id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 }
getEncoded
in interface java.security.Key
private static byte[] decode(byte[] d) throws java.security.spec.InvalidKeySpecException
This will decode data conforming to the current spec at https://tools.ietf.org/html/draft-ietf-curdle-pkix-04 or the old spec at https://tools.ietf.org/html/draft-josefsson-pkix-eddsa-04.
Contrary to draft-ietf-curdle-pkix-04, it WILL accept a parameter value of NULL, as it is required for interoperability with the default Java keystore. Other implementations MUST NOT copy this behaviour from here unless they also need to read keys from the default Java keystore.
This is really dumb for now. It does not use a general-purpose ASN.1 decoder. See also getEncoded().
java.security.spec.InvalidKeySpecException
public EdDSAParameterSpec getParams()
public GroupElement getA()
public GroupElement getNegativeA()
public byte[] getAbyte()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object