DSAPublicKeyImpl



com.licel.jcardsim.crypto
Class DSAPublicKeyImpl

java.lang.Object
  extended by com.licel.jcardsim.crypto.KeyImpl
      extended by com.licel.jcardsim.crypto.DSAKeyImpl
          extended by com.licel.jcardsim.crypto.DSAPublicKeyImpl
All Implemented Interfaces:
KeyWithParameters, DSAKey, DSAPublicKey, Key, PublicKey

public class DSAPublicKeyImpl
extends DSAKeyImpl
implements DSAPublicKey

Implementation DSAPublicKey based on BouncyCastle CryptoAPI

See Also:
DSAPublicKey, DSAPublicKeyParameters

Field Summary
protected  ByteContainer y
           
 
Fields inherited from class com.licel.jcardsim.crypto.DSAKeyImpl
g, isPrivate, p, q
 
Fields inherited from class com.licel.jcardsim.crypto.KeyImpl
size, type
 
Constructor Summary
DSAPublicKeyImpl(org.bouncycastle.crypto.params.DSAPublicKeyParameters params)
          Construct and initialize ecc key with DSAPublicKeyParameters.
DSAPublicKeyImpl(short keySize)
          Construct not-initialized dsa public key
 
Method Summary
 void clearKey()
          Clears the key and sets its initialized state to false.
 org.bouncycastle.crypto.CipherParameters getParameters()
          Get DSAKeyParameters
 short getY(byte[] buffer, short offset)
          Returns the value of the key in plain text.
 boolean isInitialized()
          Reports the initialized state of the key.
 void setY(byte[] buffer, short offset, short length)
          Sets the value of the key.
 
Methods inherited from class com.licel.jcardsim.crypto.DSAKeyImpl
getG, getKeyGenerationParameters, getP, getQ, setG, setP, setQ
 
Methods inherited from class com.licel.jcardsim.crypto.KeyImpl
getSize, getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javacard.security.Key
getSize, getType
 
Methods inherited from interface javacard.security.DSAKey
getG, getP, getQ, setG, setP, setQ
 

Field Detail

y

protected ByteContainer y
Constructor Detail

DSAPublicKeyImpl

public DSAPublicKeyImpl(short keySize)
Construct not-initialized dsa public key

Parameters:
size - key size it bits
See Also:
KeyBuilder

DSAPublicKeyImpl

public DSAPublicKeyImpl(org.bouncycastle.crypto.params.DSAPublicKeyParameters params)
Construct and initialize ecc key with DSAPublicKeyParameters. Use in KeyPairImpl

Parameters:
params - key params from BouncyCastle API
See Also:
KeyPair, DSAPublicKeyParameters
Method Detail

setY

public void setY(byte[] buffer,
                 short offset,
                 short length)
          throws CryptoException
Description copied from interface: DSAPublicKey
Sets the value of the key. When the base, prime and subprime parameters are initialized and the key value is set, the key is ready for use. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input key data is copied into the internal representation.

Note:

  • If the key object implements the javacardx.crypto.KeyEncryption interface and the Cipher object specified via setKeyCipher() is not null, the key value is decrypted using the Cipher object.

Specified by:
setY in interface DSAPublicKey
Parameters:
buffer - the input buffer
offset - the offset into the input buffer at which the key value begins
length - the length of the key value
Throws:
CryptoException - with the following reason code:
  • CryptoException.ILLEGAL_VALUE if the input key data length is inconsistent with the implementation or if input data decryption is required and fails.

getY

public short getY(byte[] buffer,
                  short offset)
Description copied from interface: DSAPublicKey
Returns the value of the key in plain text. The data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte).

Specified by:
getY in interface DSAPublicKey
Parameters:
buffer - the output buffer
offset - the offset into the input buffer at which the key value starts
Returns:
the byte length of the key value returned
See Also:
Key

isInitialized

public boolean isInitialized()
Description copied from interface: Key
Reports the initialized state of the key. Keys must be initialized before being used.

A Key object sets its initialized state to true only when all the associated Key object parameters have been set at least once since the time the initialized state was set to false.

A newly created Key object sets its initialized state to false. Invocation of the clearKey() method sets the initialized state to false. A key with transient key data sets its initialized state to false on the associated clear events.

Specified by:
isInitialized in interface Key
Overrides:
isInitialized in class DSAKeyImpl
Returns:
true if the key has been initialized

clearKey

public void clearKey()
Description copied from interface: Key
Clears the key and sets its initialized state to false.

Specified by:
clearKey in interface Key
Overrides:
clearKey in class DSAKeyImpl

getParameters

public org.bouncycastle.crypto.CipherParameters getParameters()
Description copied from class: DSAKeyImpl
Get DSAKeyParameters

Specified by:
getParameters in interface KeyWithParameters
Overrides:
getParameters in class DSAKeyImpl
Returns:
parameters for use with BouncyCastle API
See Also:
DSAKeyParameters