public void doTest6() throws Exception { byte[] salt = Hex.decode("61DF870C4890FE85D6E3DD87C3DCE3723F91DB49"); RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6); RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6); ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt); RSAEngine rsa = new RSAEngine(); byte[] data; // // ISO 9796-2 - PSS Signing // ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 20, true); eng.init(true, sigParameters); data = eng.generateSignature(); if (eng.getRecoveredMessage().length != 0) { fail("failed zero check"); } eng.init(false, pubParameters); if (!isSameAs(sig6, 1, data)) { fail("failed ISO9796-2 generation Test 6"); } if (!eng.verifySignature(data)) { fail("failed ISO9796-2 verify Test 6"); } }
public void doTest8() throws Exception { byte[] salt = Hex.decode("78E293203CBA1B7F92F05F4D171FF8CA3E738FF8"); RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6); RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6); ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt); RSAEngine rsa = new RSAEngine(); byte[] data; // // ISO 9796-2 - PSS Signing // ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 20, false); eng.init(true, sigParameters); eng.update(msg8[0]); eng.update(msg8, 1, msg8.length - 1); data = eng.generateSignature(); eng.init(false, pubParameters); if (!isSameAs(sig8, 0, data)) { fail("failed ISO9796-2 generation Test 8"); } eng.update(msg8[0]); eng.update(msg8, 1, msg8.length - 1); if (!eng.verifySignature(sig8)) { fail("failed ISO9796-2 verify Test 8"); } }
public void doTest6() throws Exception { byte[] salt = Hex.decode("61DF870C4890FE85D6E3DD87C3DCE3723F91DB49"); RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6); RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6); ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt); RSAEngine rsa = new RSAEngine(); byte[] data; // // ISO 9796-2 - PSS Signing // ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new RIPEMD160Digest(), 20, true); eng.init(true, sigParameters); data = eng.generateSignature(); eng.init(false, pubParameters); if (!isSameAs(sig6, 1, data)) { fail("failed ISO9796-2 generation Test 6"); } if (!eng.verifySignature(data)) { fail("failed ISO9796-2 verify Test 6"); } }
public void doTest7() throws Exception { byte[] salt = new byte[0]; RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6); RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6); ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt); RSAEngine rsa = new RSAEngine(); byte[] data; // // ISO 9796-2 - PSS Signing // ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new SHA1Digest(), 0, false); eng.init(true, sigParameters); eng.update(msg7[0]); eng.update(msg7, 1, msg7.length - 1); data = eng.generateSignature(); if (!eng.hasFullMessage()) { fail("full message not detected"); } byte[] recovered = new byte[eng.getRecoveredMessage().length]; System.arraycopy(eng.getRecoveredMessage(), 0, recovered, 0, recovered.length); eng.init(false, pubParameters); if (!isSameAs(sig7, 0, data)) { fail("failed ISO9796-2 generation Test 7"); } eng.update(msg7[0]); eng.update(msg7, 1, msg7.length - 1); if (!eng.verifySignature(sig7)) { fail("failed ISO9796-2 verify Test 7"); } if (!eng.hasFullMessage()) { fail("full message not detected"); } if (!isSameAs(msg7, 0, eng.getRecoveredMessage())) { fail("failed ISO9796-2 recovery Test 7"); } if (!isSameAs(recovered, 0, eng.getRecoveredMessage())) { fail("failed ISO9796-2 recovery Test 7 recover"); } }
public void doTest7() throws Exception { byte[] salt = new byte[0]; RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod6, pub6); RSAKeyParameters privParameters = new RSAKeyParameters(true, mod6, pri6); ParametersWithSalt sigParameters = new ParametersWithSalt(privParameters, salt); RSAEngine rsa = new RSAEngine(); byte[] data; // // ISO 9796-2 - PSS Signing // ISO9796d2PSSSigner eng = new ISO9796d2PSSSigner(rsa, new SHA1Digest(), 0, false); eng.init(true, sigParameters); eng.update(msg7[0]); eng.update(msg7, 1, msg7.length - 1); data = eng.generateSignature(); eng.init(false, pubParameters); if (!isSameAs(sig7, 0, data)) { fail("failed ISO9796-2 generation Test 7"); } eng.update(msg7[0]); eng.update(msg7, 1, msg7.length - 1); if (!eng.verifySignature(sig7)) { fail("failed ISO9796-2 verify Test 7"); } if (!isSameAs(msg7, 0, eng.getRecoveredMessage())) { fail("failed ISO9796-2 recovery Test 7"); } }