Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.licel.jcardsim.crypto
Class ECKeyImpl

    java.lang.Object
      com.licel.jcardsim.crypto.KeyImpl
          com.licel.jcardsim.crypto.ECKeyImpl

All Implemented Interfaces:
  KeyWithParameters, ECKey, Key

Direct Known Subclasses:
  ECPrivateKeyImpl, ECPublicKeyImpl

    public abstract class ECKeyImpl

extends KeyImpl
implements ECKey

Base class for `ECPublicKeyImpl/ECPrivateKeyImpl` on BouncyCastle CryptoAPI

See Also:
  `ECKey`

Field Summary
`protected ByteContainer` | `a`
`protected ByteContainer` | `b`
`protected short` | `e1`
`protected short` | `e2`
`protected short` | `e3`
`protected ByteContainer` | `fp`
`protected ByteContainer` | `g`
`protected boolean` | `isKInitialized`
`protected short` | `k`
`protected ByteContainer` | `r`

Fields inherited from class com.licel.jcardsim.crypto.KeyImpl
`size, type`

Constructor Summary
`ECKeyImpl(byte keyType, short keySize)` Construct not-initialized ecc key
`ECKeyImpl(org.bouncycastle.crypto.params.ECKeyParameters parameters)` Construct and initialize ecc key with ECKeyParameters.

Method Summary
`void` | `clearKey()` Clears the key and sets its initialized state to false.
`short` | `getA(byte[] buffer, short offset)` Returns the first coefficient of the curve of the key.
`short` | `getB(byte[] buffer, short offset)` Returns the second coefficient of the curve of the key.
`org.bouncycastle.crypto.params.ECDomainParameters` | `getDomainParameters()` Get `ECDomainParameters`
`short` | `getField(byte[] buffer, short offset)` Returns the field specification parameter value of the key.
`short` | `getG(byte[] buffer, short offset)` Returns the fixed point of the curve.
`short` | `getK()` Returns the cofactor of the order of the fixed point G of the curve.
`org.bouncycastle.crypto.KeyGenerationParameters` | `getKeyGenerationParameters(SecureRandom rnd)` Get `ECKeyGenerationParameters`
`short` | `getR(byte[] buffer, short offset)` Returns the order of the fixed point G of the curve.
`boolean` | `isInitialized()` Reports the initialized state of the key.
`void` | `setA(byte[] buffer, short offset, short length)` Sets the first coefficient of the curve of the key.
`void` | `setB(byte[] buffer, short offset, short length)` Sets the second coefficient of the curve of the key.
`void` | `setFieldF2M(short e)` Sets the field specification parameter value for keys of type `TYPE_EC_F2M_PUBLIC` or `TYPE_EC_F2M_PRIVATE` in the case where the polynomial is a trinomial, of the form x^n + x^e + 1 (where n is the bit length of the key).
`void` | `setFieldF2M(short e1, short e2, short e3)` Sets the field specification parameter value for keys of type `TYPE_EC_F2M_PUBLIC` or `TYPE_EC_F2M_PRIVATE` in the case where the polynomial is a pentanomial, of the form x^n + x^e1 + x^e2 + x^e3 + 1 (where n is the bit length of the key).
`void` | `setFieldFP(byte[] buffer, short offset, short length)` Sets the field specification parameter value for keys of type `TYPE_EC_FP_PRIVATE` or `TYPE_EC_FP_PUBLIC`.
`void` | `setG(byte[] buffer, short offset, short length)` Sets the fixed point of the curve.
`void` | `setK(short K)` Sets the cofactor of the order of the fixed point G of the curve.
`void` | `setR(byte[] buffer, short offset, short length)` Sets the order of the fixed point G of the curve.

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 com.licel.jcardsim.crypto.KeyWithParameters
`getParameters`

Field Detail

### a

    protected ByteContainer a

### b

    protected ByteContainer b

### g

    protected ByteContainer g

### r

    protected ByteContainer r

### fp

    protected ByteContainer fp

### k

    protected short k

### e1

    protected short e1

### e2

    protected short e2

### e3

    protected short e3

### isKInitialized

    protected boolean isKInitialized

Constructor Detail

### ECKeyImpl

    public ECKeyImpl(byte keyType,
                     short keySize)

  Construct not-initialized ecc key

  Parameters:
    `keyType` - - key type
    `keySize` - - key size in bits
  See Also:
    `KeyPair`, `KeyBuilder`

### ECKeyImpl

    public ECKeyImpl(org.bouncycastle.crypto.params.ECKeyParameters parameters)

  Construct and initialize ecc key with ECKeyParameters. Use in KeyPairImpl

  See Also:
    `KeyPair`, `ECKeyParameters`

Method Detail

### 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`

### 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`
  Returns:
    `true` if the key has been initialized

### setFieldFP

    public void setFieldFP(byte[] buffer,
                           short offset,
                           short length)
                    throws CryptoException

  Description copied from interface: `ECKey`
  Sets the field specification parameter value for keys of type `TYPE_EC_FP_PRIVATE` or `TYPE_EC_FP_PUBLIC`. The specified value is the prime p corresponding to the field GF(p). The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input parameter 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:
    `setFieldFP` in interface `ECKey`
  Parameters:
    `buffer` - the input buffer
    `offset` - the offset into the input buffer at which the parameter value begins
    `length` - the byte length of the parameter value
  Throws:
    `CryptoException` - with the following reason codes:
    - `CryptoException.ILLEGAL_VALUE` if the input parameter data is inconsistent with the key length or if input data decryption is required and fails.
    - `CryptoException.NO_SUCH_ALGORITHM` if the key is neither of type `TYPE_EC_FP_PUBLIC` nor `TYPE_EC_FP_PRIVATE`.

### setFieldF2M

    public void setFieldF2M(short e)
                     throws CryptoException

  Description copied from interface: `ECKey`
  Sets the field specification parameter value for keys of type `TYPE_EC_F2M_PUBLIC` or `TYPE_EC_F2M_PRIVATE` in the case where the polynomial is a trinomial, of the form x^n + x^e + 1 (where n is the bit length of the key). It is required that n > e > 0.

  Specified by:
    `setFieldF2M` in interface `ECKey`
  Parameters:
    `e` - the value of the intermediate exponent of the trinomial
  Throws:
    `CryptoException` - with the following reason codes:
    - `CryptoException.ILLEGAL_VALUE` if the input parameter e is not such that 0 < e < n.
    - `CryptoException.NO_SUCH_ALGORITHM` if the key is neither of type `TYPE_EC_F2M_PUBLIC` nor `TYPE_EC_F2M_PRIVATE`.

### setFieldF2M

    public void setFieldF2M(short e1,
                            short e2,
                            short e3)
                     throws CryptoException

  Description copied from interface: `ECKey`
  Sets the field specification parameter value for keys of type `TYPE_EC_F2M_PUBLIC` or `TYPE_EC_F2M_PRIVATE` in the case where the polynomial is a pentanomial, of the form x^n + x^e1 + x^e2 + x^e3 + 1 (where n is the bit length of the key). It is required for all ei where ei = {e1, e2, e3} that n > ei > 0.

  Specified by:
    `setFieldF2M` in interface `ECKey`
  Parameters:
    `e1` - the value of the first of the intermediate exponents of the pentanomial
    `e2` - the value of the second of the intermediate exponent of the pentanomial
    `e3` - the value of the third of the intermediate exponents
  Throws:
    `CryptoException` - with the following reason codes:
    - `CryptoException.ILLEGAL_VALUE` if the input parameters ei where ei = {`e1`, `e2`, `e3`} are not such that for all ei, n > ei > 0.
    - `CryptoException.NO_SUCH_ALGORITHM` if the key is neither of type `TYPE_EC_F2M_PUBLIC` nor `TYPE_EC_F2M_PRIVATE`.

### setA

    public void setA(byte[] buffer,
                     short offset,
                     short length)
              throws CryptoException

  Description copied from interface: `ECKey`
  Sets the first coefficient of the curve of the key. For keys of type `TYPE_EC_FP_PRIVATE` or `TYPE_EC_FP_PUBLIC`, this is the value of A as an integer modulo the field specification parameter p, that is, an integer in the range `0` to p-1. For keys of type `TYPE_EC_F2M_PRIVATE` or `TYPE_EC_F2M_PUBLIC`, the bit representation of this value specifies a polynomial with binary coefficients which represents the value of A in the field. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input parameter 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:
    `setA` in interface `ECKey`
  Parameters:
    `buffer` - the input buffer
    `offset` - the offset into the input buffer at which the coefficient value begins
    `length` - the byte length of the coefficient value
  Throws:
    `CryptoException` - with the following reason codes:
    - `CryptoException.ILLEGAL_VALUE` if the input parameter data is inconsistent with the key length or if input data decryption is required and fails.

### setB

    public void setB(byte[] buffer,
                     short offset,
                     short length)
              throws CryptoException

  Description copied from interface: `ECKey`
  Sets the second coefficient of the curve of the key. For keys of type `TYPE_EC_FP_PRIVATE` or `TYPE_EC_FP_PUBLIC`, this is the value of B as an integer modulo the field specification parameter p, that is, an integer in the range `0` to p-1. For keys of type `TYPE_EC_F2M_PRIVATE` or `TYPE_EC_F2M_PUBLIC`, the bit representation of this value specifies a polynomial with binary coefficients which represents the value of B in the field. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input parameter 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:
    `setB` in interface `ECKey`
  Parameters:
    `buffer` - the input buffer
    `offset` - the offset into the input buffer at which the coefficient value begins
    `length` - the byte length of the coefficient value
  Throws:
    `CryptoException` - with the following reason codes:
    - `CryptoException.ILLEGAL_VALUE` if the input parameter data is inconsistent with the key length or if input data decryption is required and fails.

### setG

    public void setG(byte[] buffer,
                     short offset,
                     short length)
              throws CryptoException

  Description copied from interface: `ECKey`
  Sets the fixed point of the curve. The point should be specified as an octet string as per ANSI X9.62. A specific implementation need not support the compressed form, but must support the uncompressed form of the point. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input parameter 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:
    `setG` in interface `ECKey`
  Parameters:
    `buffer` - the input buffer
    `offset` - the offset into the input buffer at which the point specification begins
    `length` - the byte length of the point specification
  Throws:
    `CryptoException` - with the following reason codes:
    - `CryptoException.ILLEGAL_VALUE` if the input parameter data format is incorrect, or if the input parameter data is inconsistent with the key length, or if input data decryption is required and fails.

### setR

    public void setR(byte[] buffer,
                     short offset,
                     short length)
              throws CryptoException

  Description copied from interface: `ECKey`
  Sets the order of the fixed point G of the curve. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input parameter data is copied into the internal representation.

  Specified by:
    `setR` in interface `ECKey`
  Parameters:
    `buffer` - the input buffer
    `offset` - the offset into the input buffer at which the order begins
    `length` - the byte length of the order
  Throws:
    `CryptoException` - with the following reason codes:
    - `CryptoException.ILLEGAL_VALUE` if the input parameter data is inconsistent with the key length, or if input data decryption is required and fails.

    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.

### setK

    public void setK(short K)

  Description copied from interface: `ECKey`
  Sets the cofactor of the order of the fixed point G of the curve. The cofactor need not be specified for the key to be initialized. However, the `KeyAgreement` algorithm type `ALG_EC_SVDP_DHC` requires that the cofactor, K, be initialized.

  Specified by:
    `setK` in interface `ECKey`
  Parameters:
    `K` - the value of the cofactor

### getField

    public short getField(byte[] buffer,
                          short offset)
                   throws CryptoException

  Description copied from interface: `ECKey`
  Returns the field specification parameter value of the key. For keys of type `TYPE_EC_FP_PRIVATE` or `TYPE_EC_FP_PUBLIC`, this is the value of the prime p corresponding to the field GF(p). For keys of type `TYPE_EC_F2M_PRIVATE` or `TYPE_EC_F2M_PUBLIC`, it is the value whose bit representation specifies the polynomial with binary coefficients used to define the arithmetic operations in the field GF(2^n) The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte).

  Specified by:
    `getField` in interface `ECKey`
  Parameters:
    `buffer` - the output buffer
    `offset` - the offset into the output buffer at which the parameter value is to begin
  Returns:
    the byte length of the parameter
  Throws:
    `CryptoException` - with the following reason code:
    - `CryptoException.UNINITIALIZED_KEY` if the field specification parameter value of the key has not been successfully initialized since the time the initialized state of the key was set to false.
  See Also:
    `Key`

### getA

    public short getA(byte[] buffer,
                      short offset)
               throws CryptoException

  Description copied from interface: `ECKey`
  Returns the first coefficient of the curve of the key. For keys of type `TYPE_EC_FP_PRIVATE` or `TYPE_EC_FP_PUBLIC`, this is the value of A as an integer modulo the field specification parameter p, that is, an integer in the range `0` to p-1. For keys of type `TYPE_EC_F2M_PRIVATE` or `TYPE_EC_F2M_PUBLIC`, the bit representation of this value specifies a polynomial with binary coefficients which represents the value of A in the field. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte).

  Specified by:
    `getA` in interface `ECKey`
  Parameters:
    `buffer` - the output buffer
    `offset` - the offset into the output buffer at which the coefficient value is to begin
  Returns:
    the byte length of the coefficient
  Throws:
    `CryptoException` - with the following reason code:
    - `CryptoException.UNINITIALIZED_KEY` if the coefficient of the curve of the key has not been successfully initialized since the time the initialized state of the key was set to false.
  See Also:
    `Key`

### getB

    public short getB(byte[] buffer,
                      short offset)
               throws CryptoException

  Description copied from interface: `ECKey`
  Returns the second coefficient of the curve of the key. For keys of type `TYPE_EC_FP_PRIVATE` or `TYPE_EC_FP_PUBLIC`, this is the value of B as an integer modulo the field specification parameter p, that is, an integer in the range 0 to p-1. For keys of type `TYPE_EC_F2M_PRIVATE` or `TYPE_EC_F2M_PUBLIC`, the bit representation of this value specifies a polynomial with binary coefficients which represents the value of B in the field. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte).

  Specified by:
    `getB` in interface `ECKey`
  Parameters:
    `buffer` - the output buffer
    `offset` - the offset into the output buffer at which the coefficient value is to begin
  Returns:
    the byte length of the coefficient
  Throws:
    `CryptoException` - with the following reason code:
    - `CryptoException.UNINITIALIZED_KEY` if the second coefficient of the curve of the key has not been successfully initialized since the time the initialized state of the key was set to false.
  See Also:
    `Key`

### getG

    public short getG(byte[] buffer,
                      short offset)
               throws CryptoException

  Description copied from interface: `ECKey`
  Returns the fixed point of the curve. The point is represented as an octet string in compressed or uncompressed forms as per ANSI X9.62. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte).

  Specified by:
    `getG` in interface `ECKey`
  Parameters:
    `buffer` - the output buffer
    `offset` - the offset into the output buffer at which the point specification data is to begin
  Returns:
    the byte length of the point specificiation
  Throws:
    `CryptoException` - with the following reason code:
    - `CryptoException.UNINITIALIZED_KEY` if the fixed point of the curve of the key has not been successfully initialized since the time the initialized state of the key was set to false.
  See Also:
    `Key`

### getR

    public short getR(byte[] buffer,
                      short offset)
               throws CryptoException

  Description copied from interface: `ECKey`
  Returns the order of the fixed point G of the curve. The plain text data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte).

  Specified by:
    `getR` in interface `ECKey`
  Parameters:
    `buffer` - the output buffer
    `offset` - the offset into the input buffer at which the order begins
  Returns:
    the byte length of the order
  Throws:
    `CryptoException` - with the following reason code:
    - `CryptoException.UNINITIALIZED_KEY` if the order of the fixed point G of the curve of the key has not been successfully initialized since the time the initialized state of the key was set to false.
  See Also:
    `Key`

### getK

    public short getK()
               throws CryptoException

  Description copied from interface: `ECKey`
  Returns the cofactor of the order of the fixed point G of the curve.

  Specified by:
    `getK` in interface `ECKey`
  Returns:
    the value of the cofactor
  Throws:
    `CryptoException` - with the following reason codes:
    - `CryptoException.UNINITIALIZED_KEY` if the cofactor of the order of the fixed point G of the curve of the key has not been successfully initialized since the time the initialized state of the key was set to false.
  See Also:
    `Key`

### getDomainParameters

    public org.bouncycastle.crypto.params.ECDomainParameters getDomainParameters()

  Get `ECDomainParameters`

  Returns:
    parameters for use with BouncyCastle API
  See Also:
    `ECDomainParameters`

### getKeyGenerationParameters

    public org.bouncycastle.crypto.KeyGenerationParameters getKeyGenerationParameters(SecureRandom rnd)

  Get `ECKeyGenerationParameters`

  Specified by:
    `getKeyGenerationParameters` in interface `KeyWithParameters`
  Parameters:
    `rnd` - Secure Random Generator
  Returns:
    parameters for use with BouncyCastle API

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD