DSAPrivateKeyImpl



com.licel.jcardsim.crypto
Class DSAPrivateKeyImpl

java.lang.Object
  extended by com.licel.jcardsim.crypto.KeyImpl
      extended by com.licel.jcardsim.crypto.DSAKeyImpl
          extended by com.licel.jcardsim.crypto.DSAPrivateKeyImpl
All Implemented Interfaces:
KeyWithParameters, DSAKey, DSAPrivateKey, Key, PrivateKey

public class DSAPrivateKeyImpl
extends DSAKeyImpl
implements DSAPrivateKey

Implementation DSAPrivateKey based on BouncyCastle CryptoAPI

See Also:
DSAPrivateKey, DSAPrivateKeyParameters

Field Summary
protected  ByteContainer x
           
 
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
DSAPrivateKeyImpl(org.bouncycastle.crypto.params.DSAPrivateKeyParameters params)
          Construct and initialize dsa key with DSAPrivateKeyParameters.
DSAPrivateKeyImpl(short keySize)
          Construct not-initialized dsa private key
 
Method Summary
 void clearKey()
          Clears the key and sets its initialized state to false.
 org.bouncycastle.crypto.CipherParameters getParameters()
          Get DSAKeyParameters
 short getX(byte[] buffer, short offset)
          Returns the value of the key in plain text.
 boolean isInitialized()
          Reports the initialized state of the key.
 void setX(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

x

protected ByteContainer x
Constructor Detail

DSAPrivateKeyImpl

public DSAPrivateKeyImpl(short keySize)
Construct not-initialized dsa private key

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

DSAPrivateKeyImpl

public DSAPrivateKeyImpl(org.bouncycastle.crypto.params.DSAPrivateKeyParameters params)
Construct and initialize dsa key with DSAPrivateKeyParameters. Use in KeyPairImpl

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

setX

public void setX(byte[] buffer,
                 short offset,
                 short length)
          throws CryptoException
Description copied from interface: DSAPrivateKey
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:
setX in interface DSAPrivateKey
Parameters:
buffer - the input buffer
offset - the offset into the input buffer at which the modulus value begins
length - the length of the modulus
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.

getX

public short getX(byte[] buffer,
                  short offset)
Description copied from interface: DSAPrivateKey
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:
getX in interface DSAPrivateKey
Parameters:
buffer - the output buffer
offset - the offset into the output 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