• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PSSSigner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Arithmetic类代码示例发布时间:2022-05-22
下一篇:
Java ServiceInstanceUpdateNotSupportedException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap