gnu.crypto.key

Class GnuSecretKey

Implemented Interfaces:
Key

public class GnuSecretKey
extends java.lang.Object
implements Key

A secret key composed of a sequence of raw, unformatted octets. This class is analogous to the javax.crypto.spec.SecretKeySpec class, but is provided for platforms that do not or cannot contain that class.

Version:
$Revision: 1.1 $

Constructor Summary

GnuSecretKey(byte[] key, String algorithm)
Creates a new secret key.
GnuSecretKey(byte[] key, int offset, int length, String algorithm)
Creates a new secret key from a portion of a byte array.

Method Summary

boolean
equals(Object o)
String
getAlgorithm()
Returns the algorithm name, if any.
byte[]
getEncoded()
Returns the encoded key, which is merely the byte array this class was created with.
String
getFormat()
Returns the string "RAW".
String
toString()

Constructor Details

GnuSecretKey

public GnuSecretKey(byte[] key,
                    String algorithm)
Creates a new secret key. The supplied byte array is copied by this constructor.

Parameters:
key - The raw, secret key.
algorithm - The algorithm name, which can be null or empty.


GnuSecretKey

public GnuSecretKey(byte[] key,
                    int offset,
                    int length,
                    String algorithm)
Creates a new secret key from a portion of a byte array.

Parameters:
key - The raw, secret key.
offset - The offset at which the key begins.
length - The number of bytes that comprise the key.
algorithm - The algorithm name, which can be null or empty.

Method Details

equals

public boolean equals(Object o)


getAlgorithm

public String getAlgorithm()
Returns the algorithm name, if any.

Returns:
The algorithm name.


getEncoded

public byte[] getEncoded()
Returns the encoded key, which is merely the byte array this class was created with. A reference to the internal byte array is returned, so the caller can delete this key from memory by modifying the returned array.

Returns:
The raw key.


getFormat

public String getFormat()
Returns the string "RAW".

Returns:
The string "RAW".


toString

public String toString()


Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.