Raw public key material embedded in this structure need not be ASN.1/DER
encoded. Some crypto systems such as elliptic curve systems use specific
encodings of keys. For this reason, keys can be retrieved by means of two
alternative ways:
- Raw encoded keys, returned as byte arrays, and
- Raw decoded keys, returned as ASN.1 types.
Only ASN.1/DER is supported as decoding method. Keys encoded in another code
must be decoded externally.
Creation date: (18.08.99 15:23:09)
- Version:
- "$Id: SubjectPublicKeyInfo.java,v 1.3 2004/08/16 08:53:58 pebinger
Exp $"
- Author:
- Markus Tak
- See Also:
- Serialized Form
| Methods inherited from class codec.asn1.ASN1AbstractCollection |
checkConstraints, decode, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, toString, writeExternal |
| Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
SubjectPublicKeyInfo
public SubjectPublicKeyInfo()
- Creates an instance that is ready for decoding.
SubjectPublicKeyInfo
public SubjectPublicKeyInfo(AlgorithmIdentifier aid,
byte[] key)
- Creates an instance with the given
AlgorithmIdentifier and encoded public key. The public key is wrapped
into an ASN1BitString as required by the
specification of this structure. Hence, the encoded key is taken "as
is".
The given arguments are put into this instance literally. The arguments
are not copied or cloned. Therefor side effects can occur when the given
arguments are modified after this constructor was called.
- Parameters:
aid - AlgorithmIdentifier of the public key algorithmkey - The encoded key material.- Throws:
NullPointerException - if either argument is null.
SubjectPublicKeyInfo
public SubjectPublicKeyInfo(AlgorithmIdentifier aid,
ASN1Type key)
- Creates an instance with the given
AlgorithmIdentifier and key. The given key must be a raw key
structure represented by means of an ASN.1 structure. The key structure
is encoded into a bit string which is put into this instance.
- Parameters:
aid - The AlgorithmIdentifier of the public key algorithm.key - The public key as a ASN.1 data structure.
SubjectPublicKeyInfo
public SubjectPublicKeyInfo(PublicKey key)
throws InvalidKeyException
- Creates an instance that is initialized from the given public key.
- Parameters:
key - The public key.- Throws:
InvalidKeyException - if the key cannot be decoded properly.NullPointerException - if the given key is null.
getPublicKey
public PublicKey getPublicKey()
throws NoSuchAlgorithmException
- Returns the public key embedded in this structure.
This method creates an X509EncodedKeySpec of this instance and feeds it
into a key factory. In order to locate a suitable key factory, the
installed providers must define appropriate OID mappings.
- Returns:
- The public key.
- Throws:
InconsistentStateException - if the key spec generated by this method is rejected by
the key factory that is used to generate the key.NoSuchAlgorithmException - if there is no key factory registered for the algorithm
of the embedded key or no appropriate OID mapping is
defined by the installed providers.
setPublicKey
public void setPublicKey(PublicKey key)
throws InvalidKeyException
- Initializes this instance with the given public key.
- Parameters:
key - The public key from which this instance is initialized.- Throws:
InvalidKeyException - if the given key cannot be decoded properly.NullPointerException - if the given key is null.
setRawKey
protected void setRawKey(ASN1Type key)
- Encodes and sets the given ASN.1 key structure as the raw key.
- Throws:
InconsistentStateException - if an internal error occurs while the key is encoded.
This should never happen.
getRawKey
public byte[] getRawKey()
- Returns the raw key material. The key material consists of an encoded
key structure. ASN.1/DER is often used as the encoding. However,
this need not always be the case. Elliptic curve cryptosystems use
specific encodings.
If the key encoding is ASN.1/DER then the raw key can be retrieved as an
ASN.1 type by means of the getDecodedRawKey()
method.
- Returns:
- The raw key bytes as a byte array.
getDecodedRawKey
public ASN1Type getDecodedRawKey()
throws CorruptedCodeException
- Returns an ASN.1 type that represents the decoded raw key. Decoding is
done by means of ASN.1/DER. Be careful, not all public keys are
encoded according to DER. Elliptic curve cryptosystems use specific
encodings.
- Returns:
- The raw key decoded according to DER.
getAlgorithmIdentifier
public AlgorithmIdentifier getAlgorithmIdentifier()
- Returns the
AlgorithmIdentifier of the public
key.
- Returns:
- The key algorithm's AlgorithmIdentifier.
setAlgorithmIdentifier
public void setAlgorithmIdentifier(AlgorithmIdentifier aid)
- sets the AlgorithmIdentifier for this public key
- Parameters:
aid - AlgorithmIdentifier of this public key
getKeyStruct
public ASN1Type getKeyStruct()
throws CorruptedCodeException
- Deprecated. This method is no longer used.
getKeyStruct
public ASN1Type getKeyStruct(boolean derDecode)
throws CorruptedCodeException
- Deprecated. This method is no longer used.
- Parameters:
derDecode - true if the raw key shall be decoded.
setKeyStruct
public void setKeyStruct(ASN1Type key)
- Deprecated. This method is no longer used.
- Parameters:
key - The key structure.
Copyright © Fraunhofer Gesellschaft. All Rights Reserved.