gnu.javax.crypto.kwa

Interface IKeyWrappingAlgorithm

Known Implementing Classes:
AESKeyWrap, BaseKeyWrappingAlgorithm, TripleDESKeyWrap

public interface IKeyWrappingAlgorithm

Constants and visible methods available to all GNU Key Wrapping Algorithm implementations.

Field Summary

static String
INITIAL_VALUE
Name of the property, in the attributes map, that references the Initial Value (IV) material.
static String
KEY_ENCRYPTION_KEY_MATERIAL
Name of the property, in the attributes map, that references the Key Wrapping Algorithm KEK (Key Encryption Key) material.
static String
SOURCE_OF_RANDOMNESS
Property name of an optional SecureRandom instance to use.

Method Summary

void
init(Map<K,V> attributes)
Initializes this instance with the designated algorithm specific attributes.
String
name()
Returns the canonical name of this Key Wrapping Algorithm.
byte[]
unwrap(byte[] in, int inOffset, int length)
Unwraps the designated cipher text bytes.
int
unwrap(byte[] in, int inOffset, int length, byte[] out, int outOffset)
Unwraps the designated cipher text bytes.
byte[]
wrap(byte[] in, int inOffset, int length)
Wraps the designated plain text bytes.
int
wrap(byte[] in, int inOffset, int length, byte[] out, int outOffset)
Wraps the designated plain text bytes.

Field Details

INITIAL_VALUE

public static final String INITIAL_VALUE
Name of the property, in the attributes map, that references the Initial Value (IV) material. The object referenced by this property is a byte array containing the initial integrity check register value.
Field Value:
"gnu.crypto.kwa.iv"

KEY_ENCRYPTION_KEY_MATERIAL

public static final String KEY_ENCRYPTION_KEY_MATERIAL
Name of the property, in the attributes map, that references the Key Wrapping Algorithm KEK (Key Encryption Key) material. The object referenced by this property is a byte array containing the keying material for the underlying block cipher.
Field Value:
"gnu.crypto.kwa.kek"

SOURCE_OF_RANDOMNESS

public static final String SOURCE_OF_RANDOMNESS
Property name of an optional SecureRandom instance to use. The default is to use a PRNG instance.
Field Value:
"gnu.crypto.kwa.prng"

Method Details

init

public void init(Map<K,V> attributes)
            throws InvalidKeyException
Initializes this instance with the designated algorithm specific attributes.
Parameters:
attributes - a map of name-to-value pairs the Key Wrapping Algorithm must use for its setup.
Throws:
InvalidKeyException - if an exception is encountered while seting up the Key Wrapping Algorithm keying material (KEK).

name

public String name()
Returns the canonical name of this Key Wrapping Algorithm.
Returns:
the canonical name of this Key Wrapping Algorithm.

unwrap

public byte[] unwrap(byte[] in,
                     int inOffset,
                     int length)
            throws KeyUnwrappingException
Unwraps the designated cipher text bytes.
Parameters:
in - the input byte array containing the cipher text.
inOffset - the offset into in where the first byte of the cipher text (already wrapped key material) to unwrap is located.
length - the number of bytes to unwrap.
Returns:
a newly allocated byte array containing the plain text.
Throws:
KeyUnwrappingException - if after unwrapping the cipher text, the bytes at the begining did not match the initial value.

unwrap

public int unwrap(byte[] in,
                  int inOffset,
                  int length,
                  byte[] out,
                  int outOffset)
            throws ShortBufferException,
                   KeyUnwrappingException
Unwraps the designated cipher text bytes.
Parameters:
in - the input byte array containing the cipher text.
inOffset - the offset into in where the first byte of the cipher text (already wrapped key material) to unwrap is located.
length - the number of bytes to unwrap.
out - the output byte array where the unwrapped key material will be stored.
outOffset - the offset into out of the first unwrapped byte.
Returns:
the number of bytes of the unwrapped key material; i.e. the length, in out, starting from outOffset where the plain text (unwrapped key material) are stored.
Throws:
ShortBufferException - if the output buffer is not long enough to accomodate the number of bytes resulting from unwrapping the cipher text.
KeyUnwrappingException - if after unwrapping the cipher text, the bytes at the begining did not match the initial value.

wrap

public byte[] wrap(byte[] in,
                   int inOffset,
                   int length)
Wraps the designated plain text bytes.
Parameters:
in - the input byte array containing the plain text.
inOffset - the offset into in where the first byte of the plain text (key material) to wrap is located.
length - the number of bytes to wrap.
Returns:
a newly allocated byte array containing the cipher text.

wrap

public int wrap(byte[] in,
                int inOffset,
                int length,
                byte[] out,
                int outOffset)
            throws ShortBufferException
Wraps the designated plain text bytes.
Parameters:
in - the input byte array containing the plain text.
inOffset - the offset into in where the first byte of the plain text (key material) to wrap is located.
length - the number of bytes to wrap.
out - the output byte array where the wrapped key material will be stored.
outOffset - the offset into out of the first wrapped byte.
Returns:
the number of bytes of the wrapped key material; i.e. the length, in out, starting from outOffset where the cipher text (wrapped key material) are stored.
Throws:
ShortBufferException - if the output buffer is not long enough to accomodate the number of bytes resulting from wrapping the plain text.

IKeyWrappingAlgorithm.java -- FIXME: briefly describe file purpose Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.