public class RawPublicKey extends PublicKeyInfo implements java.io.Serializable, java.lang.Cloneable
When parsing the public key contained in a, e.g., certificate, method PublicKeyInfo.getPublicKey(ASN1Object)
tries to instantiate a KeyFactory for the key algorithm. If no KeyFactory is
available a generic raw public key is created allowing to get some information about
the key (algorithm, encoding).
public_key_algorithm
Constructor and Description |
---|
RawPublicKey(ASN1Object obj)
Creates a raw X509PublicKey from the given ASN.1 object.
|
RawPublicKey(byte[] pk)
Creates a raw X509 PublicKey from the given DER encoded byte array.
|
RawPublicKey(java.io.InputStream is)
Creates a raw X509PublicKey from an InputStream.
|
Modifier and Type | Method and Description |
---|---|
protected void |
decode(byte[] publicKey)
Decodes a raw X509PublicKey, encoded in DER format.
|
byte[] |
encode()
Returns the raw public key (not wrapped in a X.509 PublicKeyInfo)
as DER encoded ASN.1 object.
|
java.lang.String |
getAlgorithm()
Returns the name of the key algorithm.
|
java.lang.String |
toString()
Returns a string representation of this key.
|
clone, createPublicKeyInfo, decode, equals, getAlgorithmID, getEncoded, getFingerprint, getFormat, getPublicKey, getPublicKey, getPublicKey, getPublicKey, getPublicKey, getPublicKey, hashCode, toASN1Object, writeTo
public RawPublicKey(byte[] pk) throws java.security.InvalidKeyException
pk
- the byte array holding the DER encoded public key infojava.security.InvalidKeyException
- if something is wrong with the key encodingpublic RawPublicKey(ASN1Object obj) throws java.security.InvalidKeyException
obj
- the public key ASN.1 structurejava.security.InvalidKeyException
- if something is wrong with the key encodingpublic RawPublicKey(java.io.InputStream is) throws java.io.IOException, java.security.InvalidKeyException
is
- an input stream with the data to be read to initialize the public keyjava.io.IOException
- if an I/O error occursjava.security.InvalidKeyException
- if something is wrong with the key encodingprotected void decode(byte[] publicKey) throws java.security.InvalidKeyException
This method only keeps the key encoding.
decode
in class PublicKeyInfo
publicKey
- the public key as DER encoded ASN.1 objectjava.security.InvalidKeyException
- if something is wrong with the encoding of the keypublic byte[] encode()
This method typically may not be used by an application. Rather
it is used by the parent X.509 PublicKeyInfo.getEncoded()
method for encoding the public key.
encode
in class PublicKeyInfo
public java.lang.String getAlgorithm()
getAlgorithm
in interface java.security.Key
getAlgorithm
in class PublicKeyInfo
public java.lang.String toString()
toString
in class PublicKeyInfo