本文整理汇总了Java中org.bouncycastle.crypto.signers.ISO9796d2Signer.update方法的典型用法代码示例。如果您正苦于以下问题:Java ISO9796d2Signer.update方法的具体用法?Java ISO9796d2Signer.update怎么用?Java ISO9796d2Signer.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.signers.ISO9796d2Signer
的用法示例。
在下文中一共展示了ISO9796d2Signer.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sign
import org.bouncycastle.crypto.signers.ISO9796d2Signer; //导入方法依赖的package包/类
private static byte[] sign() throws Exception {
RSAEngine rsa = new RSAEngine();
Digest dig = new SHA1Digest();
RSAPrivateKey privateKey = (RSAPrivateKey) getPrivate(privateKeyFilename);
BigInteger big = ((RSAKey) privateKey).getModulus();
ISO9796d2Signer eng = new ISO9796d2Signer(rsa, dig, true);
RSAKeyParameters rsaPriv = new RSAKeyParameters(true, big, privateKey.getPrivateExponent());
eng.init(true, rsaPriv);
eng.update(message[0]);
eng.update(message, 1, message.length - 1);
byte[] signature = eng.generateSignature();
return signature;
}
示例2: doTest12
import org.bouncycastle.crypto.signers.ISO9796d2Signer; //导入方法依赖的package包/类
public void doTest12()
throws Exception
{
BigInteger mod = new BigInteger("B3ABE6D91A4020920F8B3847764ECB34C4EB64151A96FDE7B614DC986C810FF2FD73575BDF8532C06004C8B4C8B64F700A50AEC68C0701ED10E8D211A4EA554D", 16);
BigInteger pubExp = new BigInteger("65537", 10);
BigInteger priExp = new BigInteger("AEE76AE4716F77C5782838F328327012C097BD67E5E892E75C1356E372CCF8EE1AA2D2CBDFB4DA19F703743F7C0BA42B2D69202BA7338C294D1F8B6A5771FF41", 16);
RSAKeyParameters pubParameters = new RSAKeyParameters(false, mod, pubExp);
RSAKeyParameters privParameters = new RSAKeyParameters(true, mod, priExp);
RSAEngine rsa = new RSAEngine();
byte[] data;
byte[] m1 = {1, 2, 3, 4, 5, 6, 7, 8, 9};
byte[] m2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
byte[] m3 = {1, 2, 3, 4, 5, 6, 7, 8};
//
// ISO 9796-2 - Signing
//
Digest dig = new SHA1Digest();
ISO9796d2Signer eng = new ISO9796d2Signer(rsa, dig);
//
// check message bounds
//
eng.init(true, privParameters);
eng.update(m1, 0, m1.length);
data = eng.generateSignature();
eng.init(false, pubParameters);
eng.update(m2, 0, m2.length);
if (eng.verifySignature(data))
{
fail("failed ISO9796-2 m2 verify Test 12");
}
eng.init(false, pubParameters);
eng.update(m3, 0, m3.length);
if (eng.verifySignature(data))
{
fail("failed ISO9796-2 m3 verify Test 12");
}
eng.init(false, pubParameters);
eng.update(m1, 0, m1.length);
if (!eng.verifySignature(data))
{
fail("failed ISO9796-2 verify Test 12");
}
}