This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Update to TestOfCipherEngineInit


Hi,

I have updated the TestOfCipherEngineInit.testInitWithIvParameterSpec to
properly fail when expected exceptions do not occur.

The following patch has already been commited.

Thanks,

Matt Wringe

Changelog: 

2006-07-14  Matt Wringe  <mwringe@redhat.com>

 * gnu/testlet/gnu/javax/crypto/jce/TestOfCipherEngineInit.java 
 (testInitWithIVParameterSpec): Properly fail when expected 
 exception does not occur.
Index: TestOfCipherEngineInit.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/gnu/javax/crypto/jce/TestOfCipherEngineInit.java,v
retrieving revision 1.5
diff -u -r1.5 TestOfCipherEngineInit.java
--- TestOfCipherEngineInit.java	11 Jul 2006 15:46:17 -0000	1.5
+++ TestOfCipherEngineInit.java	14 Jul 2006 14:07:56 -0000
@@ -285,38 +285,44 @@
         IvParameterSpec IVSpec = new IvParameterSpec(new byte[blocksize -1]);
  
         // check if short IV are properly throwing exceptions
+        String msg = "(CBC Encrypt + short IV) MUST throw InvalidAlgorithmParameterException";
         try{
           cipher.init(Cipher.ENCRYPT_MODE, key, IVSpec);
+          harness.fail(msg);
         } catch (Exception e) {
           String type = e.getClass().getName();
-          harness.check(type.equals(InvalidAlgorithmParameterException.class.getName()),
-                        "(CBC Encrypt + short IV) MUST throw InvalidAlgorithmParameterException");
+          harness.debug(e);
+          harness.check(type.equals(InvalidAlgorithmParameterException.class.getName()),msg);
         }
+        
+        msg = "(CBC Decrypt + short IV) MUST throw InvalidAlgorithmParameterException";
         try {
           cipher.init(Cipher.DECRYPT_MODE, key, IVSpec);
+          harness.fail(msg);
         } catch (Exception e) {
           String type = e.getClass().getName();
-          harness.check(type.equals(InvalidAlgorithmParameterException.class.getName()),
-                        "(CBC Decrypt + short IV) MUST throw InvalidAlgorithmParameterException");
+          harness.check(type.equals(InvalidAlgorithmParameterException.class.getName()),msg);
         }
         
         IVSpec = new IvParameterSpec(new byte[blocksize +1]);
         
         // check if long IV are properly throwing exceptions
+        msg = "(CBC Encrypt + long IV) MUST throw InvalidAlgorithmParameterException";
         try{
           cipher.init(Cipher.ENCRYPT_MODE, key, IVSpec);
+          harness.fail(msg);
         } catch (Exception e) {
           String type = e.getClass().getName();
-          harness.check(type.equals(InvalidAlgorithmParameterException.class.getName()),
-                        "(CBC Encrypt + long IV) MUST throw InvalidAlgorithmParameterException");
+          harness.check(type.equals(InvalidAlgorithmParameterException.class.getName()), msg);
         }
-                
+        
+        msg = "(CBC Decrypt + long IV) MUST throw InvalidAlgorithmParameterException";
         try {
           cipher.init(Cipher.DECRYPT_MODE, key, IVSpec);
+          harness.fail(msg);
         } catch (Exception e) {
           String type = e.getClass().getName();
-          harness.check(type.equals(InvalidAlgorithmParameterException.class.getName()),
-                        "(CBC Decrypt + long IV) MUST throw InvalidAlgorithmParameterException");
+          harness.check(type.equals(InvalidAlgorithmParameterException.class.getName()), msg);
         }
         
         byte[] iv = new byte[] { '0', '1', '1', '2', '3', '5', '8', '9'};

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]