本文整理汇总了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));
}
示例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");
}
示例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");
}
}
示例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");
}
}
示例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);
}
示例6: PSSSignerOutputStream
import org.bouncycastle.crypto.signers.PSSSigner; //导入依赖的package包/类
PSSSignerOutputStream(PSSSigner pssSigner) {
this.pssSigner = pssSigner;
}
示例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);
}