iaik.security.dh
Class ESDHKEKParameters

java.lang.Object
  |
  +--java.security.AlgorithmParametersSpi
        |
        +--iaik.security.dh.ESDHKEKParameters

public class ESDHKEKParameters
extends AlgorithmParametersSpi

Ephemeral Static Diffie Hellman parameters (opaque form).

This class represents parameters (OtherInfo structure) for the ephemaral static Diffie Hellman key material creation algorithm as described in RFC 2631.

RFC 2631 gives a special variant of the Diffie Hellman algorithm, based on the ANSI X9.42 draft. From the shared secret value ZZ shared keying material -- typically used as key encryption key (KEK) for encrypting (wrapping) a content encryption key (CEK) -- is created by repeatedly calculating the SHA-1 hash of ZZ and additional other information:

 KM = H ( ZZ || OtherInfo)
 
where OtherInfo is specified as:
 OtherInfo ::= SEQUENCE {
   keyInfo KeySpecificInfo,
   partyAInfo  [0] OCTET STRING OPTIONAL,
   suppPubInfo [2] OCTET STRING }

 KeySpecificInfo ::= SEQUENCE {
   algorithm OBJECT IDENTIFIER,
   counter OCTET STRING SIZE (4..4) }
 
KeySpecificInfo specifies the CEK wrapping algorithm with which this KEK will be used and a counter (32 bit number, represented in network byte order, initial value is 1 for any ZZ) that is incremented by one every time the above key generation function is run for a given KEK. partyAInfo is a random string provided by the sender, especially required in static-static mode (where the sender has a static key pair with the public key placed in a certificate). suppPubInfo id the length of the generated KEK , in bits, represented as a 32 bit number in network byte order. E.g. for 3DES it would be the byte sequence 00 00 00 C0.

For generating a KEK, the KM above (SHA-1 hash of ZZ || OtherInfo) is calcualted as often as necessary to give the required keying material by concatenating the KM blocks resulting from the several steps. In each step the counter is incremented by 1. For 3DES, e.g., which requires 192 bits of keying material, the algorithm must be run twice, once with a counter value of 1 (to generate K1', K2', and the first 32 bits of K3') and once with a counter value of 2 (to generate the last 32 bits of K3). K1',K2' and K3' are then parity adjusted to generate the 3 DES keys K1,K2 and K3. For RC2-128, which requires 128 bits of keying material, the algorithm is run once, with a counter value of 1, and the left-most 128 bits are directly converted to an RC2 key. Similarly, for RC2-40, which requires 40 bits of keying material, the algorithm is run once, with a counter value of 1, and the leftmost 40 bits are used as the key.

Please note that the parameters represented by this class are different from the Diffie Hellman parameters (p,g,l) represeneted by class DHParameters (see ESDHKEKParameterSpec ESDHKEKParameterSpec} for more information).

This class can be used for converting ESDH OtherInfo parameters from its encoding and its specification (represented by ESDHKEKParameterSpec ESDHKEKParameterSpec}), e.g.:

 // OtherInfo for TripleDES key wrap
 AlgorithmID tripleDesWrap = AlgorithmID.cms_3DES_wrap;
 // key length of KEK:
 int keyLength = 192;
 // generate the OtherInfo
 ESDHKEKParameterSpec otherInfo = new ESDHKEKParameterSpec(tripleDesWrap.getAlgorithm(), keyLength);
 // perhaps some random partyAInfo from the sender:
 otherInfo.setPartyAInfo(partyAInfo);
 // now prepare for encoding (convert into ESDHKEKParameters):
 esdhKEKParams = AlgorithmParameters.getInstance("ESDHKEK");
 esdhKEKParams.init(otherInfo);
 byte[] encodedParams = esdhKEKParams.getEncoded();
 // convert back into specification:
 esdhKEKParams.init(encodedParams);
 esdhKEK = (ESDHKEKParameterSpec)esdhKEKParams.getParameterSpec(ESDHKEKParameterSpec.class);
 

Version:
File Revision 7
See Also:
ESDHKEKParameterSpec

Constructor Summary
ESDHKEKParameters()
          The default constructor.
 
Method Summary
protected  byte[] engineGetEncoded()
          Returns the parameters as DER byte array.
protected  byte[] engineGetEncoded(String format)
          Returns the parameters as DER byte array.
protected  AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec)
          Returns the ESDH KEK parameters as transparent ESDH KEK parameter specification of the given class type.
protected  void engineInit(AlgorithmParameterSpec paramSpec)
          Initializes this ESDHKEKParameters with the given ESDHKEKParameterSpec.
protected  void engineInit(byte[] params)
          Initializes this ESDHKEKParameters object from the given DER encoded byte array.
protected  void engineInit(byte[] params, String format)
          Inits the parameters from a DER encoded byte array.
protected  String engineToString()
          Returns a String representation of the parameters.
 void incrementCounter()
          Increments the counter by 1.
 void resetCounter()
          Resets counter to its initial value 00 00 00 01.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ESDHKEKParameters

public ESDHKEKParameters()
The default constructor. Only internally used for creating a ESDHKEKParameters object. Applications shall use
 AlgorithmParameters.getInstance("ESDHKEK");
 
for obtaining ESDHKEKParameters.
Method Detail

engineGetEncoded

protected byte[] engineGetEncoded()
                           throws IOException
Returns the parameters as DER byte array.

This method returns the OtherInfo structure in DER encoded format.

 OtherInfo ::= SEQUENCE {
   keyInfo KeySpecificInfo,
   partyAInfo  [0] OCTET STRING OPTIONAL,
   suppPubInfo [2] OCTET STRING }

 KeySpecificInfo ::= SEQUENCE {
   algorithm OBJECT IDENTIFIER,
   counter OCTET STRING SIZE (4..4) }
 
Overrides:
engineGetEncoded in class AlgorithmParametersSpi
Returns:
the ESDH KEK parameters as DER byte array
Throws:
IOException - if an encoding error occurs

engineGetEncoded

protected byte[] engineGetEncoded(String format)
                           throws IOException
Returns the parameters as DER byte array.

Format is ignored. Only DER encoding is supported at this time. Only calls engineGetEncoded() for returning the ESDH KEK paramters as DER encoded byte array, regardless of what is specified in the format string.

Overrides:
engineGetEncoded in class AlgorithmParametersSpi
Parameters:
format - the encoding format; ignored
Returns:
the ESDH KEK parameters as DER byte array
Throws:
IOException - if an encoding error occurs

engineGetParameterSpec

protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec)
                                                 throws InvalidParameterSpecException
Returns the ESDH KEK parameters as transparent ESDH KEK parameter specification of the given class type.

Overrides:
engineGetParameterSpec in class AlgorithmParametersSpi
Parameters:
paramSpec - the desired parameter specification class
Returns:
the ESDH KEK parameters as AlgorithmParaneterSpec
Throws:
InvalidParameterSpecException - if the paramters cannot be converted to the desired parameter specification
See Also:
ESDHKEKParameterSpec

engineInit

protected void engineInit(AlgorithmParameterSpec paramSpec)
                   throws InvalidParameterSpecException
Initializes this ESDHKEKParameters with the given ESDHKEKParameterSpec.
Overrides:
engineInit in class AlgorithmParametersSpi
Parameters:
paramSpec - the parameter specification, which has to be a ESDHKEKParameterSpec
Throws:
InvalidParameterSpecException - if the given parameter specification is not a ESDHKEKParameterSpec

engineInit

protected void engineInit(byte[] params)
                   throws IOException
Initializes this ESDHKEKParameters object from the given DER encoded byte array.

Overrides:
engineInit in class AlgorithmParametersSpi
Parameters:
params - the DER encoded byte array
Throws:
IOException - if an error occurs when decoding the given byte array

engineInit

protected void engineInit(byte[] params,
                          String format)
                   throws IOException
Inits the parameters from a DER encoded byte array. Format is ignored.

Only calls engineInit(params) for initializing this ESDHKEKParamters object from the given DER encoded byte array, regardless of what is specified in the format string.

Overrides:
engineInit in class AlgorithmParametersSpi
Parameters:
params - the DER encoded byte array
format - the encoding format; ignored
Throws:
IOException - if an error occurs when decoding the given byte array

resetCounter

public void resetCounter()
Resets counter to its initial value 00 00 00 01.

incrementCounter

public void incrementCounter()
Increments the counter by 1.

engineToString

protected String engineToString()
Returns a String representation of the parameters.
Overrides:
engineToString in class AlgorithmParametersSpi
Returns:
a String representation of this ESDHKEKParameters object

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK