use of org.bouncycastle.crypto.macs.SkeinMac in project Skein3Fish by wernerd.
the class SkeinTest method checkKATVectors.
boolean checkKATVectors() {
KatResult kr = new KatResult();
ParametersForSkein pfs;
while (scanner.fillResult(kr)) {
// Skip Tree vectors in this test function
if (kr.restOfLine.contains("Tree")) {
notProcessed++;
continue;
}
if (kr.restOfLine.contains("MAC")) {
pfs = new ParametersForSkein(new KeyParameter(kr.macKey), kr.stateSize, kr.hashBitLength);
SkeinMac sm = new SkeinMac();
sm.init(pfs);
sm.updateBits(kr.msg, 0, kr.msgLength);
byte[] mac = new byte[sm.getMacSize()];
sm.doFinal(mac, 0);
if (!Arrays.equals(mac, kr.result)) {
System.out.println(kr.stateSize + "-" + kr.hashBitLength + "-" + kr.msgLength + "-" + kr.restOfLine);
hexdump("Computed mac", mac, mac.length);
hexdump("Expected result", kr.result, kr.result.length);
return false;
}
processed++;
continue;
}
Skein skein = new Skein(kr.stateSize, kr.hashBitLength);
skein.updateBits(kr.msg, 0, kr.msgLength);
byte[] hash = skein.doFinal();
if (!Arrays.equals(hash, kr.result)) {
System.out.println(kr.stateSize + "-" + kr.hashBitLength + "-" + kr.msgLength + "-" + kr.restOfLine);
hexdump("Computed hash", hash, hash.length);
hexdump("Expected result", kr.result, kr.result.length);
return false;
}
// Enable the next few line so you can check some results manually
// if ((kr.msgLength & 1) == 1) {
// System.out.println(kr.stateSize + "-" + kr.hashBitLength + "-"
// + kr.msgLength + "-" + kr.restOfLine);
// hexdump("Computed hash", hash, hash.length);
// hexdump("Expected result", kr.result, kr.result.length);
// }
processed++;
}
return true;
}
Aggregations