spostate alcune funzioni. implementato il decifratore. funziona regolarmente con input hex da 128-192-256 bit

This commit is contained in:
2015-05-16 04:15:40 +02:00
parent 8ecdcf9c7a
commit dea61985ae
3 changed files with 289 additions and 270 deletions

View File

@@ -6,55 +6,19 @@
</head>
<body>
<script src="aes.js"></script>
<script src="support.js"></script>
<script>
/*
Input = 32 43 f6 a8 88 5a 30 8d 31 31 98 a2 e0 37 07 34
Cipher Key = 2b 7e 15 16 28 ae d2 a6 ab f7 15 88 09 cf 4f 3c
*/
var i = [
new byte(hex_to_bin("32")),
new byte(hex_to_bin("43")),
new byte(hex_to_bin("f6")),
new byte(hex_to_bin("a8")),
new byte(hex_to_bin("88")),
new byte(hex_to_bin("5a")),
new byte(hex_to_bin("30")),
new byte(hex_to_bin("8d")),
new byte(hex_to_bin("31")),
new byte(hex_to_bin("31")),
new byte(hex_to_bin("98")),
new byte(hex_to_bin("a2")),
new byte(hex_to_bin("e0")),
new byte(hex_to_bin("37")),
new byte(hex_to_bin("07")),
new byte(hex_to_bin("34")),
];
var k = [
new byte(hex_to_bin("2b")),
new byte(hex_to_bin("7e")),
new byte(hex_to_bin("15")),
new byte(hex_to_bin("16")),
new byte(hex_to_bin("28")),
new byte(hex_to_bin("ae")),
new byte(hex_to_bin("d2")),
new byte(hex_to_bin("a6")),
new byte(hex_to_bin("ab")),
new byte(hex_to_bin("f7")),
new byte(hex_to_bin("15")),
new byte(hex_to_bin("88")),
new byte(hex_to_bin("09")),
new byte(hex_to_bin("cf")),
new byte(hex_to_bin("4f")),
new byte(hex_to_bin("3c")),
];
var i = "00112233445566778899aabbccddeeff";
var k = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
KeyExpansion(k);
console.log("Result " + print_result( encrypt(i)));
var c = encrypt(i);
console.log(c);
var p = decrypt(c);
console.log(p);