package au.net.aba.crypto.provider;
/*
* $Id: BlowfishKey.java,v 1.4 1998/10/26 01:46:27 leachbj Exp $
* $Author: leachbj $
*
* Copyright (C) 1996-1998 Australian Business Access Pty Ltd.
* All rights reserved.
*
* Use, modification, copying and distribution of this software is subject the
* terms and conditions of the ABA Public Licence. See the file
* "PUBLIC_LICENCE" for additional information.
*
* If you have not received a copy of the Public Licence, you must destroy all
* copies of this file immediately.
*
* $Source: /aba/CVSROOT/jdk1.1/src/au.net.aba/crypto/provider/BlowfishKey.java,v $
* $Revision: 1.4 $
* $Date: 1998/10/26 01:46:27 $
* $State: Exp $
*/
import java.io.*;
import java.security.*;
import java.util.StringTokenizer;
import javax.crypto.*;
/**
* A class wrapper for Blowfish keys.
*/
public class BlowfishKey implements SecretKey
{
public final static String ident = "$Id: BlowfishKey.java,v 1.4 1998/10/26 01:46:27 leachbj Exp $";
private byte[] key;
private static int MAXBFKEY_LENGTH = 56;
/**
* The basic constructor
*
* Keylength is variable up to 448 bits. (56 bytes)
*
* @param rawKey the bytes making up the key.
*/
public BlowfishKey(
byte[] rawKey)
{
int l;
if (rawKey.length > MAXBFKEY_LENGTH)
{
l = MAXBFKEY_LENGTH;
}
else
{
l = rawKey.length;
}
key = new byte[l];
System.arraycopy(rawKey, 0, key, 0, l);
}
/**
* returns the algorithm for this key.
*
* @return the string "Blowfish"
*/
public String getAlgorithm()
{
return "Blowfish";
}
/**
* returns an encoded representation of this key.
*
* @return the key as a byte array
*/
public byte[] getEncoded()
{
byte[] tmp;
tmp = new byte[key.length];
System.arraycopy(key, 0, tmp, 0, key.length);
return tmp;
}
/**
* returns the format for this key.
*
* @return the string "RAW"
*/
public String getFormat()
{
return "RAW";
}
}