|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.security.AlgorithmParametersSpi | +--iaik.security.dh.ESDHKEKParameters
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);
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 |
public ESDHKEKParameters()
ESDHKEKParameters
object.
Applications shall use
AlgorithmParameters.getInstance("ESDHKEK");for obtaining ESDHKEKParameters.
Method Detail |
protected byte[] engineGetEncoded() throws IOException
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) }
engineGetEncoded
in class AlgorithmParametersSpi
IOException
- if an encoding error occursprotected byte[] engineGetEncoded(String format) throws IOException
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.
engineGetEncoded
in class AlgorithmParametersSpi
format
- the encoding format; ignoredIOException
- if an encoding error occursprotected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec) throws InvalidParameterSpecException
engineGetParameterSpec
in class AlgorithmParametersSpi
paramSpec
- the desired parameter specification classInvalidParameterSpecException
- if the paramters cannot be
converted to the desired parameter specificationESDHKEKParameterSpec
protected void engineInit(AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException
engineInit
in class AlgorithmParametersSpi
paramSpec
- the parameter specification, which has to be a ESDHKEKParameterSpecInvalidParameterSpecException
- if the given parameter specification is
not a ESDHKEKParameterSpecprotected void engineInit(byte[] params) throws IOException
engineInit
in class AlgorithmParametersSpi
params
- the DER encoded byte arrayIOException
- if an error occurs when decoding the given byte arrayprotected void engineInit(byte[] params, String format) throws IOException
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.
engineInit
in class AlgorithmParametersSpi
params
- the DER encoded byte arrayformat
- the encoding format; ignoredIOException
- if an error occurs when decoding the given byte arraypublic void resetCounter()
public void incrementCounter()
protected String engineToString()
engineToString
in class AlgorithmParametersSpi
|
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). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |