当前位置: 首页>>代码示例>>Java>>正文


Java PSSSigner.generateSignature方法代码示例

本文整理汇总了Java中org.bouncycastle.crypto.signers.PSSSigner.generateSignature方法的典型用法代码示例。如果您正苦于以下问题:Java PSSSigner.generateSignature方法的具体用法?Java PSSSigner.generateSignature怎么用?Java PSSSigner.generateSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.crypto.signers.PSSSigner的用法示例。


在下文中一共展示了PSSSigner.generateSignature方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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.generateSignature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。