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


Java ParametersWithRandom类代码示例

本文整理汇总了Java中org.bouncycastle.crypto.params.ParametersWithRandom的典型用法代码示例。如果您正苦于以下问题:Java ParametersWithRandom类的具体用法?Java ParametersWithRandom怎么用?Java ParametersWithRandom使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: generateRawSignature

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public byte[] generateRawSignature(SignatureAndHashAlgorithm algorithm,
    AsymmetricKeyParameter privateKey, byte[] hash)
    throws CryptoException
{
    Signer signer = makeSigner(algorithm, true, true,
        new ParametersWithRandom(privateKey, this.context.getSecureRandom()));
    if (algorithm == null)
    {
        // Note: Only use the SHA1 part of the (MD5/SHA1) hash
        signer.update(hash, 16, 20);
    }
    else
    {
        signer.update(hash, 0, hash.length);
    }
    return signer.generateSignature();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:18,代码来源:TlsDSASigner.java

示例2: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
/**
 * initialise the cipher.
 *
 * @param forEncryption if true the cipher is initialised for
 *  encryption, if false for decryption.
 * @param params the key and other data required by the cipher.
 * @exception IllegalArgumentException if the params argument is
 * inappropriate.
 */
public void init(
    boolean             forEncryption,
    CipherParameters    params)
    throws IllegalArgumentException
{
    this.forEncryption = forEncryption;

    reset();

    if (params instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)params;

        padding.init(p.getRandom());

        cipher.init(forEncryption, p.getParameters());
    }
    else
    {
        padding.init(null);

        cipher.init(forEncryption, params);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:34,代码来源:PaddedBufferedBlockCipher.java

示例3: generateWrappedKey

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public byte[] generateWrappedKey(GenericKey encryptionKey)
    throws OperatorException
{
    byte[] contentEncryptionKeySpec = OperatorUtils.getKeyBytes(encryptionKey);

    if (random == null)
    {
        wrapper.init(true, wrappingKey);
    }
    else
    {
        wrapper.init(true, new ParametersWithRandom(wrappingKey, random));
    }

    return wrapper.wrap(contentEncryptionKeySpec, 0, contentEncryptionKeySpec.length);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:BcSymmetricKeyWrapper.java

示例4: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public void init(boolean forEncryption, CipherParameters parameters)
{
    this.forEncryption = forEncryption;
    if (forEncryption)
    {
        if (parameters instanceof ParametersWithRandom)
        {
            ParametersWithRandom p = (ParametersWithRandom)parameters;

            this.random = p.getRandom();
            this.pubKey = (NTRUEncryptionPublicKeyParameters)p.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.pubKey = (NTRUEncryptionPublicKeyParameters)parameters;
        }

        this.params = pubKey.getParameters();
    }
    else
    {
        this.privKey = (NTRUEncryptionPrivateKeyParameters)parameters;
        this.params = privKey.getParameters();
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:NTRUEngine.java

示例5: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public void init(
    boolean             forWrapping,
    CipherParameters    param)
{
    this.forWrapping = forWrapping;

    if (param instanceof ParametersWithRandom)
    {
        param = ((ParametersWithRandom) param).getParameters();
    }

    if (param instanceof KeyParameter)
    {
        this.param = (KeyParameter)param;
    }
    else if (param instanceof ParametersWithIV)
    {
        this.iv = ((ParametersWithIV)param).getIV();
        this.param = (KeyParameter)((ParametersWithIV) param).getParameters();
        if (this.iv.length != 8)
        {
           throw new IllegalArgumentException("IV not equal to 8");
        }
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:RFC3394WrapEngine.java

示例6: decryptPreMasterSecret

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public byte[] decryptPreMasterSecret(byte[] encryptedPreMasterSecret)
    throws IOException
{

    PKCS1Encoding encoding = new PKCS1Encoding(new RSABlindedEngine());
    encoding.init(false, new ParametersWithRandom(this.privateKey, context.getSecureRandom()));

    try
    {
        return encoding.processBlock(encryptedPreMasterSecret, 0,
            encryptedPreMasterSecret.length);
    }
    catch (InvalidCipherTextException e)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:DefaultTlsEncryptionCredentials.java

示例7: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public void init(
    boolean             forEncryption,
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom  rParam = (ParametersWithRandom)param;

        this.random = rParam.getRandom();
    }
    else
    {   
        this.random = new SecureRandom();
    }

    engine.init(forEncryption, param);

    this.forEncryption = forEncryption;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:OAEPEncoding.java

示例8: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
/**
 * initialise the EC Elgamal engine.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:31,代码来源:ECNewPublicKeyTransform.java

示例9: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
/**
 * initialise the encryptor.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:31,代码来源:ECElGamalEncryptor.java

示例10: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public void init(boolean forSigning, CipherParameters param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            param = rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
        }

        this.key = (ECPrivateKeyParameters)param;
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }

}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:DSTU4145Signer.java

示例11: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public void init(
    boolean                 forSigning,
    CipherParameters        param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:ECDSASigner.java

示例12: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public void init(
    boolean          forSigning, 
    CipherParameters param) 
{
    this.forSigning = forSigning;
    
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:ECNRSigner.java

示例13: init

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
public void init(
    boolean                 forSigning,
    CipherParameters        param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (DSAPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (DSAPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (DSAPublicKeyParameters)param;
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:DSASigner.java

示例14: engineInitSign

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
protected void engineInitSign(
    PrivateKey privateKey)
    throws InvalidKeyException
{
    CipherParameters param = null;

    if (privateKey instanceof ECKey)
    {
        param = ECUtil.generatePrivateKeyParameter(privateKey);
    }

    digest = new GOST3411Digest(DEFAULT_SBOX);

    if (appRandom != null)
    {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    }
    else
    {
        signer.init(true, param);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:23,代码来源:SignatureSpi.java

示例15: engineInitSign

import org.bouncycastle.crypto.params.ParametersWithRandom; //导入依赖的package包/类
protected void engineInitSign(
    PrivateKey  privateKey)
    throws InvalidKeyException
{
    CipherParameters    param;

    if (privateKey instanceof ECKey)
    {
        param = ECUtil.generatePrivateKeyParameter(privateKey);
    }
    else
    {
        param = GOST3410Util.generatePrivateKeyParameter(privateKey);
    }

    digest.reset();

    if (random != null)
    {
        signer.init(true, new ParametersWithRandom(param, random));
    }
    else
    {
        signer.init(true, param);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:SignatureSpi.java


注:本文中的org.bouncycastle.crypto.params.ParametersWithRandom类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。