|
From: <pe...@us...> - 2004-03-06 21:05:35
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/channels In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9462/src/java/org/neuclear/commons/crypto/channels Modified Files: AbstractSignatureChannel.java DigestChannel.java Log Message: Added Unit tests for DigestChannel and SigningChannel. The SigningChannel passes for Signing on straight signing of byte arrays as well as from Files Currently the Verifying channel fails, need to investigate. The DigestChannel passes for all types. Index: AbstractSignatureChannel.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/channels/AbstractSignatureChannel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractSignatureChannel.java 5 Mar 2004 23:43:06 -0000 1.1 --- AbstractSignatureChannel.java 6 Mar 2004 20:50:28 -0000 1.2 *************** *** 28,31 **** --- 28,37 ---- $Id$ $Log$ + Revision 1.2 2004/03/06 20:50:28 pelle + Added Unit tests for DigestChannel and SigningChannel. + The SigningChannel passes for Signing on straight signing of byte arrays as well as from Files + Currently the Verifying channel fails, need to investigate. + The DigestChannel passes for all types. + Revision 1.1 2004/03/05 23:43:06 pelle New Channels package with nio based channels for various crypto related tasks such as digests, signing, verifying and encoding. *************** *** 57,69 **** if (closed) throw new ClosedChannelException(); ! final byte[] bytes = buffer.array(); try { ! sig.update(buffer.array()); } catch (SignatureException e) { throw new IOException(e.getLocalizedMessage()); } ! return bytes.length; } protected final Signature sig; } --- 63,80 ---- if (closed) throw new ClosedChannelException(); ! final int size = buffer.limit()-buffer.position(); ! if (bytes ==null) ! bytes=new byte[size]; ! final int count=Math.min(size,bytes.length); ! buffer.get(bytes,0,count); try { ! sig.update(bytes,0,count); } catch (SignatureException e) { throw new IOException(e.getLocalizedMessage()); } ! return count; } protected final Signature sig; + private byte[] bytes; } Index: DigestChannel.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/crypto/channels/DigestChannel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DigestChannel.java 5 Mar 2004 23:43:06 -0000 1.1 --- DigestChannel.java 6 Mar 2004 20:50:28 -0000 1.2 *************** *** 27,30 **** --- 27,36 ---- $Id$ $Log$ + Revision 1.2 2004/03/06 20:50:28 pelle + Added Unit tests for DigestChannel and SigningChannel. + The SigningChannel passes for Signing on straight signing of byte arrays as well as from Files + Currently the Verifying channel fails, need to investigate. + The DigestChannel passes for all types. + Revision 1.1 2004/03/05 23:43:06 pelle New Channels package with nio based channels for various crypto related tasks such as digests, signing, verifying and encoding. *************** *** 40,43 **** --- 46,50 ---- public DigestChannel() throws NoSuchAlgorithmException { this("SHA1"); + } *************** *** 53,59 **** if (closed) throw new ClosedChannelException(); ! final byte[] bytes = buffer.array(); ! digest.update(bytes); ! return bytes.length; } --- 60,70 ---- if (closed) throw new ClosedChannelException(); ! final int size = buffer.limit()-buffer.position(); ! if (bytes ==null) ! bytes=new byte[size]; ! final int count=Math.min(size,bytes.length); ! buffer.get(bytes,0,count); ! digest.update(bytes,0,count); ! return count; } *************** *** 68,70 **** --- 79,82 ---- private final MessageDigest digest; + private byte[] bytes; } |