includes/clientside/static/rijndael.js
changeset 348 87e08a6e4fec
parent 1 fe660c52c48f
--- a/includes/clientside/static/rijndael.js	Thu Jan 03 18:39:19 2008 -0500
+++ b/includes/clientside/static/rijndael.js	Wed Jan 16 13:55:49 2008 -0500
@@ -577,3 +577,34 @@
   return result;
 }
 
+function aes_self_test()
+{
+  //
+  // Encryption test
+  //
+  
+  var str = '';
+  for(i=0;i<keySizeInBits/4;i++)
+  {
+    str+='0';
+  }
+  str = hexToByteArray(str);
+  var ct  = rijndaelEncrypt(str, str, 'ECB');
+  ct      = byteArrayToHex(ct);
+  var v;
+  switch(keySizeInBits)
+  {
+    // These test vectors are for 128-bit block size.
+    case 128:
+      v = '66e94bd4ef8a2c3b884cfa59ca342b2e';
+      break;
+    case 192:
+      v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7';
+      break;
+    case 256:
+      v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087';
+      break;
+  }
+  return ( ct == v && md5_vm_test() );
+}
+