本文整理汇总了Java中org.bouncycastle.crypto.signers.PSSSigner类的典型用法代码示例。如果您正苦于以下问题:Java PSSSigner类的具体用法?Java PSSSigner怎么用?Java PSSSigner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PSSSigner类属于org.bouncycastle.crypto.signers包,在下文中一共展示了PSSSigner类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createPSSRSASigner
import org.bouncycastle.crypto.signers.PSSSigner; //导入依赖的package包/类
public static PSSSigner createPSSRSASigner(AlgorithmIdentifier sigAlgId,
AsymmetricBlockCipher cipher) throws XiSecurityException {
ParamUtil.requireNonNull("sigAlgId", sigAlgId);
if (!PKCSObjectIdentifiers.id_RSASSA_PSS.equals(sigAlgId.getAlgorithm())) {
throw new XiSecurityException("signature algorithm " + sigAlgId.getAlgorithm()
+ " is not allowed");
}
AlgorithmIdentifier digAlgId;
try {
digAlgId = AlgorithmUtil.extractDigesetAlgFromSigAlg(sigAlgId);
} catch (NoSuchAlgorithmException ex) {
throw new XiSecurityException(ex.getMessage(), ex);
}
RSASSAPSSparams param = RSASSAPSSparams.getInstance(sigAlgId.getParameters());
AlgorithmIdentifier mfgDigAlgId = AlgorithmIdentifier.getInstance(
param.getMaskGenAlgorithm().getParameters());
Digest dig = getDigest(digAlgId);
Digest mfgDig = getDigest(mfgDigAlgId);
int saltSize = param.getSaltLength().intValue();
int trailerField = param.getTrailerField().intValue();
AsymmetricBlockCipher tmpCipher = (cipher == null) ? new RSABlindedEngine() : cipher;
return new PSSSigner(tmpCipher, dig, mfgDig, saltSize, getTrailer(trailerField));
}
开发者ID:xipki,项目名称:xitk,代码行数:30,代码来源:SignerUtil.java
示例2: getTrailer
import org.bouncycastle.crypto.signers.PSSSigner; //导入依赖的package包/类
private static byte getTrailer(int trailerField) {
if (trailerField == 1) {
return org.bouncycastle.crypto.signers.PSSSigner.TRAILER_IMPLICIT;
}
throw new IllegalArgumentException("unknown trailer field");
}
开发者ID:xipki,项目名称:xitk,代码行数:8,代码来源:SignerUtil.java
示例3: testSig
import org.bouncycastle.crypto.signers.PSSSigner; //导入依赖的package包/类
private void testSig(
int id,
RSAKeyParameters pub,
RSAKeyParameters prv,
byte[] slt,
byte[] msg,
byte[] sig)
throws Exception
{
RSABlindingFactorGenerator blindFactorGen = new RSABlindingFactorGenerator();
RSABlindingEngine blindingEngine = new RSABlindingEngine();
PSSSigner blindSigner = new PSSSigner(blindingEngine, new SHA1Digest(), 20);
PSSSigner signer = new PSSSigner(new RSAEngine(), new SHA1Digest(), 20);
blindFactorGen.init(pub);
BigInteger blindFactor = blindFactorGen.generateBlindingFactor();
RSABlindingParameters params = new RSABlindingParameters(pub, blindFactor);
// generate a blind signature
blindSigner.init(true, new ParametersWithRandom(params, new FixedRandom(slt)));
blindSigner.update(msg, 0, msg.length);
byte[] blindedData = blindSigner.generateSignature();
RSAEngine signerEngine = new RSAEngine();
signerEngine.init(true, prv);
byte[] blindedSig = signerEngine.processBlock(blindedData, 0, blindedData.length);
// unblind the signature
blindingEngine.init(false, params);
byte[] s = blindingEngine.processBlock(blindedSig, 0, blindedSig.length);
//signature verification
if (!areEqual(s, sig))
{
fail("test " + id + " failed generation");
}
//verify signature with PSSSigner
signer.init(false, pub);
signer.update(msg, 0, msg.length);
if (!signer.verifySignature(s))
{
fail("test " + id + " failed PSSSigner verification");
}
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:53,代码来源:PSSBlindTest.java
示例4: testSig
import org.bouncycastle.crypto.signers.PSSSigner; //导入依赖的package包/类
private void testSig(
int id,
RSAKeyParameters pub,
RSAKeyParameters prv,
byte[] slt,
byte[] msg,
byte[] sig)
throws Exception
{
PSSSigner eng = new PSSSigner(new RSAEngine(), new SHA1Digest(), 20);
eng.init(true, new ParametersWithRandom(prv, new FixedRandom(slt)));
eng.update(msg, 0, msg.length);
byte[] s = eng.generateSignature();
if (!areEqual(s, sig))
{
fail("test " + id + " failed generation");
}
eng.init(false, pub);
eng.update(msg, 0, msg.length);
if (!eng.verifySignature(s))
{
fail("test " + id + " failed verification");
}
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:32,代码来源:PSSTest.java
示例5: verify
import org.bouncycastle.crypto.signers.PSSSigner; //导入依赖的package包/类
/**
* Verifies that a text matches the given signature
* @param key Public key that pairs up with the used private key to generate the given signature
* @param msg The message to check upon
* @param sig The signature that has to match the given msg text
* @return True if the given text is valid upon the given signature, false otherwise
*/
public static boolean verify(CipherParameters key, byte[] msg, byte[] sig) {
/*
* Typical methods and arguments
*/
PSSSigner signer = new PSSSigner(new RSAEngine(), new SHA1Digest(), saltLength);
signer.init(false, key);
signer.update(msg,0,msg.length);
return signer.verifySignature(sig);
}
开发者ID:nmldiegues,项目名称:easy-vote,代码行数:19,代码来源:CriptoUtils.java
示例6: PSSSignerOutputStream
import org.bouncycastle.crypto.signers.PSSSigner; //导入依赖的package包/类
PSSSignerOutputStream(PSSSigner pssSigner) {
this.pssSigner = pssSigner;
}
开发者ID:xipki,项目名称:xitk,代码行数:4,代码来源:P11RSAPSSContentSigner.java
示例7: isProcessingOkay
import org.bouncycastle.crypto.signers.PSSSigner; //导入依赖的package包/类
private boolean isProcessingOkay(
RSAKeyParameters pub,
RSAKeyParameters prv,
byte[] data,
SecureRandom random)
throws Exception
{
RSABlindingFactorGenerator blindFactorGen = new RSABlindingFactorGenerator();
RSABlindingEngine blindingEngine = new RSABlindingEngine();
PSSSigner blindSigner = new PSSSigner(blindingEngine, new SHA1Digest(), 20);
PSSSigner pssEng = new PSSSigner(new RSAEngine(), new SHA1Digest(), 20);
random.nextBytes(data);
blindFactorGen.init(pub);
BigInteger blindFactor = blindFactorGen.generateBlindingFactor();
RSABlindingParameters params = new RSABlindingParameters(pub, blindFactor);
// generate a blind signature
blindSigner.init(true, new ParametersWithRandom(params, random));
blindSigner.update(data, 0, data.length);
byte[] blindedData = blindSigner.generateSignature();
RSAEngine signerEngine = new RSAEngine();
signerEngine.init(true, prv);
byte[] blindedSig = signerEngine.processBlock(blindedData, 0, blindedData.length);
// unblind the signature
blindingEngine.init(false, params);
byte[] s = blindingEngine.processBlock(blindedSig, 0, blindedSig.length);
//verify signature with PSSSigner
pssEng.init(false, pub);
pssEng.update(data, 0, data.length);
return pssEng.verifySignature(s);
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:44,代码来源:PSSBlindTest.java
注:本文中的org.bouncycastle.crypto.signers.PSSSigner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论