本文整理汇总了Java中org.bouncycastle.crypto.signers.ISO9796d2Signer类的典型用法代码示例。如果您正苦于以下问题:Java ISO9796d2Signer类的具体用法?Java ISO9796d2Signer怎么用?Java ISO9796d2Signer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISO9796d2Signer类属于org.bouncycastle.crypto.signers包,在下文中一共展示了ISO9796d2Signer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:true-gler,项目名称:ISO9796SignerVerifier,代码行数:17,代码来源:App.java
示例2: verify
import org.bouncycastle.crypto.signers.ISO9796d2Signer; //导入依赖的package包/类
private static String verify() throws Exception {
RSAEngine engine = new RSAEngine();
Digest digest = new SHA1Digest();
RSAPublicKey publicKey = (RSAPublicKey) getPublic(publicKeyFilename);
BigInteger big = ((RSAKey) publicKey).getModulus();
RSAKeyParameters rsaPublic = new RSAKeyParameters(false, big, publicKey.getPublicExponent());
ISO9796d2Signer verifier = new ISO9796d2Signer(engine, digest, true);
verifier.init(false, rsaPublic); // false for verify
if (!verifier.verifySignature(signature)) {
System.err.println("Signature was modified, could not verify correctness!");
return "";
}
String recoveredMessage = "";
try {
if (verifier.hasFullMessage()) {
verifier.updateWithRecoveredMessage(signature);
}
byte[] message = verifier.getRecoveredMessage();
recoveredMessage = new String(message, "UTF-8");
} catch (Exception exception) {
System.err.println("Recover failed!");
}
return recoveredMessage;
}
开发者ID:true-gler,项目名称:ISO9796SignerVerifier,代码行数:29,代码来源:App.java
示例3: ISOSignatureSpi
import org.bouncycastle.crypto.signers.ISO9796d2Signer; //导入依赖的package包/类
protected ISOSignatureSpi(
Digest digest,
AsymmetricBlockCipher cipher)
{
super(digest.getAlgorithmName() + "withRSA/ISO9796-2");
signer = new ISO9796d2Signer(cipher, digest, true);
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:8,代码来源:ISOSignatureSpi.java
示例4: ISOSignatureSpi
import org.bouncycastle.crypto.signers.ISO9796d2Signer; //导入依赖的package包/类
protected ISOSignatureSpi(
Digest digest,
AsymmetricBlockCipher cipher)
{
signer = new ISO9796d2Signer(cipher, digest, true);
}
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:ISOSignatureSpi.java
示例5: 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");
}
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:57,代码来源:ISO9796Test.java
注:本文中的org.bouncycastle.crypto.signers.ISO9796d2Signer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论