includes/clientside/static/rijndael.js
changeset 348 87e08a6e4fec
parent 1 fe660c52c48f
equal deleted inserted replaced
347:299a90e28abc 348:87e08a6e4fec
   575     result[result.length] = text.charCodeAt(i);
   575     result[result.length] = text.charCodeAt(i);
   576   }
   576   }
   577   return result;
   577   return result;
   578 }
   578 }
   579 
   579 
       
   580 function aes_self_test()
       
   581 {
       
   582   //
       
   583   // Encryption test
       
   584   //
       
   585   
       
   586   var str = '';
       
   587   for(i=0;i<keySizeInBits/4;i++)
       
   588   {
       
   589     str+='0';
       
   590   }
       
   591   str = hexToByteArray(str);
       
   592   var ct  = rijndaelEncrypt(str, str, 'ECB');
       
   593   ct      = byteArrayToHex(ct);
       
   594   var v;
       
   595   switch(keySizeInBits)
       
   596   {
       
   597     // These test vectors are for 128-bit block size.
       
   598     case 128:
       
   599       v = '66e94bd4ef8a2c3b884cfa59ca342b2e';
       
   600       break;
       
   601     case 192:
       
   602       v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7';
       
   603       break;
       
   604     case 256:
       
   605       v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087';
       
   606       break;
       
   607   }
       
   608   return ( ct == v && md5_vm_test() );
       
   609 }
       
   610