public abstract class KeyAgreement extends Object
KeyAgreement
class is the base class for key agreement
algorithms such as Diffie-Hellman and EC Diffie-Hellman [IEEE P1363].
Implementations of KeyAgreement
algorithms must extend this
class and implement all the abstract methods.
A tear or card reset event resets an initialized KeyAgreement
object to the state it was in when previously initialized via a call to
init()
.Modifier and Type | Field and Description |
---|---|
static byte |
ALG_DH_PLAIN
Diffie-Hellman (DH) secret value derivation primitive as per NIST Special Publication 800-56Ar2.
|
static byte |
ALG_EC_PACE_GM
Elliptic curve Generic Mapping according to TR03110 v2.
|
static byte |
ALG_EC_SVDP_DH
Elliptic curve secret value derivation primitive, Diffie-Hellman version,
as per [IEEE P1363].
|
static byte |
ALG_EC_SVDP_DH_KDF
Elliptic curve secret value derivation primitive, Diffie-Hellman version,
as per [IEEE P1363].
|
static byte |
ALG_EC_SVDP_DH_PLAIN
Elliptic curve secret value derivation primitive, Diffie-Hellman version,
as per [IEEE P1363].
|
static byte |
ALG_EC_SVDP_DH_PLAIN_XY
Elliptic curve secret value derivation primitive, Diffie-Hellman version,
as per [IEEE P1363].
|
static byte |
ALG_EC_SVDP_DHC
Elliptic curve secret value derivation primitive, Diffie-Hellman version,
with cofactor multiplication and compatibility mode, as per [IEEE P1363].
|
static byte |
ALG_EC_SVDP_DHC_KDF
Elliptic curve secret value derivation primitive, Diffie-Hellman version,
with cofactor multiplication and compatibility mode, as per [IEEE P1363].
|
static byte |
ALG_EC_SVDP_DHC_PLAIN
Elliptic curve secret value derivation primitive, Diffie-Hellman version,
with cofactor multiplication and compatibility mode, as per [IEEE P1363].
|
Modifier | Constructor and Description |
---|---|
protected |
KeyAgreement()
Protected constructor.
|
Modifier and Type | Method and Description |
---|---|
abstract short |
generateSecret(byte[] publicData,
short publicOffset,
short publicLength,
byte[] secret,
short secretOffset)
Generates the secret data as per the requested algorithm using the
PrivateKey specified during initialization and the public
key data provided. |
abstract byte |
getAlgorithm()
Gets the KeyAgreement algorithm.
|
static KeyAgreement |
getInstance(byte algorithm,
boolean externalAccess)
Creates a
KeyAgreement object instance of the selected
algorithm. |
abstract void |
init(PrivateKey privKey)
Initializes the object with the given private key.
|
public static final byte ALG_EC_SVDP_DH
Note:
public static final byte ALG_EC_SVDP_DH_KDF
Note:
public static final byte ALG_EC_SVDP_DHC
ALG_EC_SVDP_DH
)
Note:
public static final byte ALG_EC_SVDP_DHC_KDF
ALG_EC_SVDP_DH_KDF
)
Note:
public static final byte ALG_EC_SVDP_DH_PLAIN
Note:
public static final byte ALG_EC_SVDP_DHC_PLAIN
ALG_EC_SVDP_DH_PLAIN
)
Note:
public static final byte ALG_EC_PACE_GM
Note:
public static final byte ALG_EC_SVDP_DH_PLAIN_XY
Note:
public static final byte ALG_DH_PLAIN
public static final KeyAgreement getInstance(byte algorithm, boolean externalAccess) throws CryptoException
KeyAgreement
object instance of the selected
algorithm.algorithm
- the desired key agreement algorithm Valid codes listed in
ALG_*
constants above, for example,
ALG_EC_SVDP_DH
.externalAccess
- if true
indicates that the instance will be
shared among multiple applet instances and that the
KeyAgreement
instance will also be accessed
(via a Shareable
interface) when the owner of
the KeyAgreement
instance is not the currently
selected applet. If true
the implementation
must not allocate CLEAR_ON_DESELECT
transient
space for internal data.CryptoException
- with the following reason codes:
CryptoException.NO_SUCH_ALGORITHM
if
the requested algorithm or shared access mode is not
supported.
public abstract void init(PrivateKey privKey) throws CryptoException
The Key
is checked for consistency with the KeyAgreement
algorithm. For example, the key type must be matched.
For elliptic curve algorithms, the key must represent a valid point on the
curve's domain parameters. Additional key component/domain parameter
strength checks are implementation specific.
privKey
- the private keyCryptoException
- with the following reason codes:
CryptoException.ILLEGAL_VALUE
if the
input key type is inconsistent with the
KeyAgreement
algorithm, for example, if the
KeyAgreement
algorithm is
ALG_EC_SVDP_DH
and the key type is
TYPE_RSA_PRIVATE
, or if
privKey
is inconsistent with the
implementation.CryptoException.UNINITIALIZED_KEY
if
privKey
is uninitialized, or if the
KeyAgreement
algorithm is set to
ALG_EC_SVDP_DHC
and the cofactor, K, has
not been successfully initialized since the time the
initialized state of the key was set to false.public abstract byte getAlgorithm()
public abstract short generateSecret(byte[] publicData, short publicOffset, short publicLength, byte[] secret, short secretOffset) throws CryptoException
PrivateKey
specified during initialization and the public
key data provided.
Note that in the case of the algorithms ALG_EC_SVDP_DH
and
ALG_EC_SVDP_DHC
the public key data provided should be the
public elliptic curve point of the second party in the protocol,
specified as per ANSI X9.62. A specific implementation need not support
the compressed form, but must support the uncompressed form of the point.
In case of the algorithm 7 the expected public data consists of an unsigned big endian encoding of the public parameter y. The maximum size in bytes is the size of the prime p.
publicData
- buffer holding the public data of the second partypublicOffset
- offset into the publicData buffer at which the data beginspublicLength
- byte length of the public datasecret
- buffer to hold the secret outputsecretOffset
- offset into the secret array at which to start writing the
secretCryptoException
- with the following reason codes:
CryptoException.ILLEGAL_VALUE
if the
publicData
data format is incorrect, or if
the publicData
data is inconsistent with
the PrivateKey
specified during
initialization.
CryptoException.INVALID_INIT
if this
KeyAgreement
object is not initialized.
Copyright © 1998, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms