org.bouncycastle.crypto.engines
Class DESedeWrapEngine

java.lang.Object
  extended by org.bouncycastle.crypto.engines.DESedeWrapEngine
All Implemented Interfaces:
Wrapper

public class DESedeWrapEngine
extends java.lang.Object
implements Wrapper

Wrap keys according to draft-ietf-smime-key-wrap-01.txt.

Note:


Field Summary
(package private)  byte[] digest
           
private  CBCBlockCipher engine
          Field engine
private  boolean forWrapping
          Field forWrapping
private  byte[] iv
          Field iv
private static byte[] IV2
          Field IV2
private  KeyParameter param
          Field param
private  ParametersWithIV paramPlusIV
          Field paramPlusIV
(package private)  Digest sha1
           
 
Constructor Summary
DESedeWrapEngine()
           
 
Method Summary
private  byte[] calculateCMSKeyChecksum(byte[] key)
          Some key wrap algorithms make use of the Key Checksum defined in CMS [CMS-Algorithms].
private  boolean checkCMSKeyChecksum(byte[] key, byte[] checksum)
           
 java.lang.String getAlgorithmName()
          Method getAlgorithmName
 void init(boolean forWrapping, CipherParameters param)
          Method init
 byte[] unwrap(byte[] in, int inOff, int inLen)
          Method unwrap
 byte[] wrap(byte[] in, int inOff, int inLen)
          Method wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

engine

private CBCBlockCipher engine
Field engine


param

private KeyParameter param
Field param


paramPlusIV

private ParametersWithIV paramPlusIV
Field paramPlusIV


iv

private byte[] iv
Field iv


forWrapping

private boolean forWrapping
Field forWrapping


IV2

private static final byte[] IV2
Field IV2


sha1

Digest sha1

digest

byte[] digest
Constructor Detail

DESedeWrapEngine

public DESedeWrapEngine()
Method Detail

init

public void init(boolean forWrapping,
                 CipherParameters param)
Method init

Specified by:
init in interface Wrapper
Parameters:
forWrapping -
param -

getAlgorithmName

public java.lang.String getAlgorithmName()
Method getAlgorithmName

Specified by:
getAlgorithmName in interface Wrapper
Returns:
the algorithm name "DESede".

wrap

public byte[] wrap(byte[] in,
                   int inOff,
                   int inLen)
Method wrap

Specified by:
wrap in interface Wrapper
Parameters:
in -
inOff -
inLen -
Returns:
the wrapped bytes.

unwrap

public byte[] unwrap(byte[] in,
                     int inOff,
                     int inLen)
              throws InvalidCipherTextException
Method unwrap

Specified by:
unwrap in interface Wrapper
Parameters:
in -
inOff -
inLen -
Returns:
the unwrapped bytes.
Throws:
InvalidCipherTextException

calculateCMSKeyChecksum

private byte[] calculateCMSKeyChecksum(byte[] key)
Some key wrap algorithms make use of the Key Checksum defined in CMS [CMS-Algorithms]. This is used to provide an integrity check value for the key being wrapped. The algorithm is - Compute the 20 octet SHA-1 hash on the key being wrapped. - Use the first 8 octets of this hash as the checksum value.

Parameters:
key -
Returns:
the CMS checksum.
Throws:
java.lang.RuntimeException
See Also:
http://www.w3.org/TR/xmlenc-core/#sec-CMSKeyChecksum

checkCMSKeyChecksum

private boolean checkCMSKeyChecksum(byte[] key,
                                    byte[] checksum)
Parameters:
key -
checksum -
Returns:
true if okay, false otherwise.
See Also:
http://www.w3.org/TR/xmlenc-core/#sec-CMSKeyChecksum