public class DSAPublicKey extends java.lang.Object implements PublicKey, ASN1Object, java.security.interfaces.DSAPublicKey
The OID used to identify the key algorithm may be set via setKeyAlgOID. The encoding used for keys of this class is based on the SubjectPublicKeyInfo structure of X.509, and is compatible with that used in JDK 1.2.
DSA, Serialized Form| Constructor and Description |
|---|
DSAPublicKey()
Makes a new, uninitialized instance.
|
DSAPublicKey(ASN1Sequence s)
Deprecated.
Use
DSAPublicKey(InputStream is) instead. |
DSAPublicKey(java.math.BigInteger y, DSAParams params)
Makes a new instance with the given set of parameters and value of y.
|
DSAPublicKey(byte[] data)
Makes a new instance by reading its encoding from the given byte array.
|
DSAPublicKey(java.io.InputStream is)
Makes a new instance by reading its encoding from the given input stream.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Creates a deep copy of this
DSAPublicKey instance. |
void |
erase()
Erases the sensitive key material of a private or symmetric key, making the key un-usable.
|
void |
finalize()
Erases this object prior to being reclaimed by the garbage collector.
|
AlgorithmIdentifier |
getAlgID()
Returns the algorithm identifier for this key.
|
java.lang.String |
getAlgorithm()
Gets the algorithm name for this key.
|
boolean |
getAllowExport()
Always returns
true. |
int |
getBitLength()
Returns the number of bits needed to represent the DSAPublicKey's public component P.
|
ASN1Object |
getContents()
Returns the contents of this key.
|
byte[] |
getEncoded()
Returns the encoded form of this key.
|
java.lang.String |
getFormat()
Returns a string which indicates the format of this object's encoding.
|
ASN1ObjectID |
getKeyAlgOID()
Returns the key algorithm OID.
|
DSAParams |
getParams()
Returns the DSA algorithm parameters for this public key.
|
java.math.BigInteger |
getY()
Gets y.
|
void |
initialize(AlgorithmIdentifier algID, ASN1Object contents)
Initializes this instance from the given algorithm paramters and key contents.
|
void |
input(ASN1Sequence s)
Deprecated.
use
input(InputStream is) instead. |
void |
input(java.io.InputStream is)
Inputs a
DSAPublicKey object by reading its encoding from the given input stream. |
int |
length()
Gets the length of the encoding of this object.
|
void |
output(java.io.OutputStream os)
Outputs encoding of this object to a given output stream.
|
void |
readExternal(java.io.ObjectInput is)
Reads the input stream and initializes the DSA public key.
|
void |
setKeyAlgOID(ASN1ObjectID oid)
Sets the key algorithm OID.
|
void |
setParams(DSAParams params)
Sets the DSA algorithm parameters for this public key.
|
java.lang.String |
toString()
Returns a string which describes this object.
|
void |
writeExternal(java.io.ObjectOutput os)
Writes to the output stream the DER encoding of this object.
|
public DSAPublicKey()
public DSAPublicKey(java.math.BigInteger y,
DSAParams params)
y - The value of y.params - The DSAParams of this DSAPublicKey.
public DSAPublicKey(byte[] data)
throws java.io.IOException
data - The byte array from which this object will be read.java.io.IOException - If an input exception occured.
public DSAPublicKey(java.io.InputStream is)
throws java.io.IOException
is - The input stream from from which this object will be read.java.io.IOException - If an input exception occured.public DSAPublicKey(ASN1Sequence s) throws java.io.IOException
DSAPublicKey(InputStream is) instead.java.io.IOExceptionpublic byte[] getEncoded()
KeygetEncoded in interface java.security.Keypublic java.lang.String getAlgorithm()
getAlgorithm in interface java.security.Keypublic int getBitLength()
0 will be returned if the key has not been initialized.
public java.lang.String getFormat()
getFormat in interface java.security.Keypublic void erase()
KeyNote: After erase() has been invoked, no other methods of the Key object are guaranteed to function correctly. In particular, invoking another method after erase() may result in a NullPointerException being thrown.
public void finalize()
Note: There is no guarantee of when, if ever, finalize will be invoked by the Java runtime.
finalize in class java.lang.Objectpublic java.lang.Object clone()
DSAPublicKey instance.clone in class java.lang.Objectpublic boolean getAllowExport()
true.FIPS_140_2.getAllowKeyExport()public void initialize(AlgorithmIdentifier algID, ASN1Object contents) throws AlgorithmIdentifierException, InvalidInputException
PublicKeypublic AlgorithmIdentifier getAlgID()
PublicKeypublic ASN1Object getContents()
PublicKeypublic ASN1ObjectID getKeyAlgOID()
DSA.dsaKeyOID, is returned.DSA.dsaKeyOIDpublic void setKeyAlgOID(ASN1ObjectID oid)
oid - the key algorithm OIDpublic java.math.BigInteger getY()
getY in interface java.security.interfaces.DSAPublicKeypublic void setParams(DSAParams params)
public DSAParams getParams()
getParams in interface java.security.interfaces.DSAKeypublic java.lang.String toString()
toString in class java.lang.Object
public void input(java.io.InputStream is)
throws java.io.IOException
DSAPublicKey object by reading its encoding from the given input stream.input in interface Streamableis - The input stream from which this object will be read.java.io.IOException - If an input exception occured.public void input(ASN1Sequence s) throws java.io.IOException
input(InputStream is) instead.java.io.IOException
public void output(java.io.OutputStream os)
throws java.io.IOException
output in interface Streamableos - The output stream to which the encoding of this object will be written.java.io.IOException - If an output exception occured.public int length()
length in interface Streamable
public void writeExternal(java.io.ObjectOutput os)
throws java.io.IOException
writeExternal in interface java.io.Externalizableos - The output stream to write the encoding to.java.io.IOException
public void readExternal(java.io.ObjectInput is)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizableis - The stream to read from.java.io.IOExceptionjava.lang.ClassNotFoundException