From: <gel...@mx...> - 2003-02-15 13:34:30
|
gelderen 03/02/15 08:42:36 Modified: jce/src/cryptix.jce.provider.cipher RC4.java BlockCipher.java Log: - Add engineGetKeySize implementations to the symmetric ciphers. Revision Changes Path 1.6 +19 -2 projects/jce/src/cryptix.jce.provider.cipher/RC4.java Index: RC4.java =================================================================== RCS file: /home/cryptix-cvs/cvsroot/projects/jce/src/cryptix.jce.provider.cipher/RC4.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- RC4.java 10 Feb 2000 20:58:20 -0000 1.5 +++ RC4.java 15 Feb 2003 13:42:36 -0000 1.6 @@ -1,4 +1,4 @@ -/* $Id: RC4.java,v 1.5 2000/02/10 20:58:20 gelderen Exp $ +/* $Id: RC4.java,v 1.6 2003/02/15 13:42:36 gelderen Exp $ * * Copyright (C) 1995-2000 The Cryptix Foundation Limited. * All rights reserved. @@ -47,7 +47,7 @@ * John Wiley & Sons, 1996. * </ul> * - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ * @author Raif S. Naffah * @author David Hopwood * @since Cryptix 2.2.2 @@ -123,6 +123,23 @@ public int engineGetBlockSize () { return BLOCK_SIZE; + } + + + protected int engineGetKeySize(Key key) + throws InvalidKeyException + { + if( key==null ) + throw new IllegalArgumentException("Key missing"); + + if( !key.getFormat().equalsIgnoreCase("RAW") ) + throw new InvalidKeyException("Wrong format: RAW bytes needed"); + + byte[] userkey = key.getEncoded(); + if(userkey == null) + throw new InvalidKeyException("RAW bytes missing"); + + return (userkey.length * 8); } 1.15 +19 -2 projects/jce/src/cryptix.jce.provider.cipher/BlockCipher.java Index: BlockCipher.java =================================================================== RCS file: /home/cryptix-cvs/cvsroot/projects/jce/src/cryptix.jce.provider.cipher/BlockCipher.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- BlockCipher.java 3 Aug 2000 13:21:57 -0000 1.14 +++ BlockCipher.java 15 Feb 2003 13:42:36 -0000 1.15 @@ -1,4 +1,4 @@ -/* $Id: BlockCipher.java,v 1.14 2000/08/03 13:21:57 pw Exp $ +/* $Id: BlockCipher.java,v 1.15 2003/02/15 13:42:36 gelderen Exp $ * * Copyright (C) 1995-2000 The Cryptix Foundation Limited. * All rights reserved. @@ -57,7 +57,7 @@ * * @author Jeroen C. van Gelderen (gel...@cr...) * @author Paul Waserbrot (pw...@cr...) - * @version $Revision: 1.14 $ + * @version $Revision: 1.15 $ */ public abstract class BlockCipher extends CipherSpi @@ -165,6 +165,23 @@ protected final int engineGetBlockSize() { return padding.getBlockSize(); + } + + + protected int engineGetKeySize(Key key) + throws InvalidKeyException + { + if( key==null ) + throw new IllegalArgumentException("Key missing"); + + if( !key.getFormat().equalsIgnoreCase("RAW") ) + throw new InvalidKeyException("Wrong format: RAW bytes needed"); + + byte[] userkey = key.getEncoded(); + if(userkey == null) + throw new InvalidKeyException("RAW bytes missing"); + + return (userkey.length * 8); } |