}
BigInteger mod = MakwaPrivateKey.decodePublic(PUB2048);
MakwaPrivateKey pkey = new MakwaPrivateKey(PRIV2048);
check(mod.equals(pkey.getModulus()));
Makwa mpub = new Makwa(mod, Makwa.SHA256, false, 0, 1024);
Makwa mpriv = new Makwa(pkey, Makwa.SHA256, false, 0, 1024);
/*
* Some KDF test vectors.
*/
for (int i = 0; i < 200; i ++) {
byte[] input = new byte[i];
for (int j = 0; j < i; j ++) {
input[j] = (byte)(7 * i + 83 * j);
}
printKDF("KDF/SHA-256", Makwa.SHA256, input, 100);
printKDF("KDF/SHA-512", Makwa.SHA512, input, 100);
}
/*
* The detailed test vector from the specification.
*/
byte[] pi;
try {
String pwd = "Gego beshwaji'aaken awe makwa;"
+ " onzaam naniizaanizi.";
pi = pwd.getBytes("UTF-8");
} catch (Exception e) {
throw new Error(e);
}
byte[] salt = new byte[] {
(byte)0xC7, (byte)0x27, (byte)0x03, (byte)0xC2,
(byte)0x2A, (byte)0x96, (byte)0xD9, (byte)0x99,
(byte)0x2F, (byte)0x3D, (byte)0xEA, (byte)0x87,
(byte)0x64, (byte)0x97, (byte)0xE3, (byte)0x92
};
byte[] ref = new byte[] {
(byte)0xC9, (byte)0xCE, (byte)0xA0, (byte)0xE6,
(byte)0xEF, (byte)0x09, (byte)0x39, (byte)0x3A,
(byte)0xB1, (byte)0x71, (byte)0x0A, (byte)0x08
};
check(equals(ref, mpub.doHash(pi, salt, false, 12, 4096)));
String detailed = mpub.encodeOutput(salt, false, 12, 4096, ref);
System.out.println("2048-bit modulus, SHA-256");
println("input", pi);
println("salt", salt);
System.out.println("pre-hashing: false");
System.out.println("post-hashing: 12");
println("bin4096", ref);
System.out.println("str4096: " + detailed);
System.out.println();
sha256.update(ref);
sha256.update(detailed.getBytes("UTF-8"));
/*
* A lot of test vectors of various sizes and parameters.
*/
printKAT("2048-bit modulus, SHA-256", mpub, mpriv);
mpub = new Makwa(mod, Makwa.SHA512, false, 0, 1024);
mpriv = new Makwa(pkey, Makwa.SHA512, false, 0, 1024);
printKAT("2048-bit modulus, SHA-512", mpub, mpriv);
println("KAT digest", sha256.digest());
}