public class ElGamalPublicKey extends PublicKeyInfo
public_key_algorithm
Constructor and Description |
---|
ElGamalPublicKey(ASN1Object obj)
Creates a new ElGamalPublicKey from the given ASN.1 object.
|
ElGamalPublicKey(java.math.BigInteger y,
ElGamalParameterSpec parameters)
Creates a new ElGamalPublicKey from public key value and ElGamal parameter
specification
|
ElGamalPublicKey(byte[] pk)
Creates a new ElGamalPublicKey from the given DER encoded byte array.
|
ElGamalPublicKey(ElGamalPublicKeySpec keySpec)
Creates a new ElGamalPublicKey from the given ElGamalPublicKeySpec representing the
ElGamal public key value y, and the public values p, g and l.
|
ElGamalPublicKey(java.io.InputStream is)
Creates a new ElGamalPublicKey from an InputStream.
|
Modifier and Type | Method and Description |
---|---|
protected void |
decode(byte[] publicKey)
Decodes a ElGamalPublicKey, encoded in DER format.
|
byte[] |
encode()
Returns the raw ElGamal public key (not wrapped in a X.509 PublicKeyInfo) as DER
encoded ASN.1 object.
|
java.lang.String |
getAlgorithm()
Returns the name of the appertaining algorithm.
|
byte[] |
getFingerprint()
Returns the fingerprint of this ElGamal public key.
|
ElGamalParameterSpec |
getParams()
Returns the key parameters.
|
java.math.BigInteger |
getY()
Returns the public value
y as BigInteger. |
int |
hashCode()
Returns a hash code for this object.
|
java.lang.String |
toString()
Returns a string that represents the contents of this public key.
|
clone, createPublicKeyInfo, decode, equals, getAlgorithmID, getEncoded, getFormat, getPublicKey, getPublicKey, getPublicKey, getPublicKey, getPublicKey, getPublicKey, toASN1Object, writeTo
public ElGamalPublicKey(java.math.BigInteger y, ElGamalParameterSpec parameters)
y
- the BigInteger value representing the ElGamal public key value yparameters
- the ElGamal parameters p (prime modulus), g (base generator) and l
(length of the private value x) as ElGamalParameterSpecpublic ElGamalPublicKey(ElGamalPublicKeySpec keySpec)
keySpec
- the ElGamalPublicKeySpec representing the public key value
y
, the prime modulus p
, the base
generator g
, and the length l
of the
private valuepublic ElGamalPublicKey(byte[] pk) throws java.security.InvalidKeyException
This constructor may be used for parsing an already existing ElGamal public key,
wrapped into a X.509 PublicKeyInfo
that is
supplied as DER encoded byte array.
pk
- the byte array holding the DER encoded public key infojava.security.InvalidKeyException
- if something is wrong with the key encodingpublic ElGamalPublicKey(ASN1Object obj) throws java.security.InvalidKeyException
PublicKeyInfo
holding the ElGamal public key.obj
- the public key ASN.1 data structurejava.security.InvalidKeyException
- if something is wrong with the key encodingpublic ElGamalPublicKey(java.io.InputStream is) throws java.io.IOException, java.security.InvalidKeyException
This constructor may be used for parsing an already existing ElGamal public key,
wrapped into a X.509 PublicKeyInfo
that is
supplied as DER encoded byte array.
is
- the 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
From the given DER encoded byte array an ASN.1 object is created and parsed
for the public key value y
and the ElGamal parameters prime
p
and base g
, and - if included - the length
l
of the private value x
.
This method is protected and typically will not be used by an application.
Rather it is used by the parent X.509 PublicKeyInfo
class for decoding the inherent ElGamal public key.
decode
in class PublicKeyInfo
publicKey
- the public key as DER encoded ASN.1 objectjava.security.InvalidKeyException
- if the given key is not a ElGamal public keypublic byte[] encode()
This method typically may not be used by an application. Rather it is used
by the parent X.509 PublicKeyInfo
class for
encoding the inherent ElGamal public key.
encode
in class PublicKeyInfo
public java.lang.String getAlgorithm()
getAlgorithm
in interface java.security.Key
getAlgorithm
in class PublicKeyInfo
public java.math.BigInteger getY()
y
as BigInteger.
y
as BigIntegerpublic ElGamalParameterSpec getParams()
public byte[] getFingerprint()
getFingerprint
in class PublicKeyInfo
public int hashCode()
hashCode
in class PublicKeyInfo
public java.lang.String toString()
toString
in class PublicKeyInfo