Java 类org.bouncycastle.crypto.params.ParametersWithRandom 实例源码

项目:keepass2android    文件:PaddedBufferedBlockCipher.java   
/**
 * 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);
    }
}
项目:ipack    文件:BcSymmetricKeyWrapper.java   
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);
}
项目:ipack    文件:NTRUEngine.java   
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();
    }
}
项目:ipack    文件:RFC3394WrapEngine.java   
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");
        }
    }
}
项目:ipack    文件:DefaultTlsEncryptionCredentials.java   
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);
    }
}
项目:ipack    文件:OAEPEncoding.java   
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;
}
项目:ipack    文件:ECNewPublicKeyTransform.java   
/**
 * 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();
    }
}
项目:ipack    文件:ECElGamalEncryptor.java   
/**
 * 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();
    }
}
项目:ipack    文件:DSTU4145Signer.java   
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;
    }

}
项目:ipack    文件:ECDSASigner.java   
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;
    }
}
项目:ipack    文件:ECNRSigner.java   
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;
    }
}
项目:ipack    文件:DSASigner.java   
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;
    }
}
项目:ipack    文件:PaddedBufferedBlockCipher.java   
/**
 * 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);
    }
}
项目:ipack    文件:SignatureSpi.java   
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);
    }
}
项目:ipack    文件:SignatureSpi.java   
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);
    }
}
项目:ipack    文件:SignatureSpi.java   
protected void engineInitSign(
    PrivateKey privateKey)
    throws InvalidKeyException
{
    CipherParameters param = ECUtil.generatePrivateKeyParameter(privateKey);

    digest.reset();

    if (appRandom != null)
    {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    }
    else
    {
        signer.init(true, param);
    }
}
项目:ipack    文件:SignatureSpi.java   
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 (appRandom != null)
    {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    }
    else
    {
        signer.init(true, param);
    }
}
项目:xitk    文件:P11RSAPSSSignatureSpi.java   
protected void engineInitSign(PrivateKey privateKey, SecureRandom random)
        throws InvalidKeyException {
    if (!(privateKey instanceof P11PrivateKey)) {
        throw new InvalidKeyException("privateKey is not instanceof "
                + P11PrivateKey.class.getName());
    }

    String algo = privateKey.getAlgorithm();
    if (!"RSA".equals(algo)) {
        throw new InvalidKeyException("privateKey is not an RSA private key: " + algo);
    }

    this.signingKey = (P11PrivateKey) privateKey;

    pss = new org.bouncycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest,
            saltLength, trailer);

    P11RSAKeyParameter p11KeyParam = P11RSAKeyParameter.getInstance(
            signingKey.p11CryptService(), signingKey.identityId());
    if (random == null) {
        pss.init(true, p11KeyParam);
    } else {
        pss.init(true, new ParametersWithRandom(p11KeyParam, random));
    }
}
项目:KeePass2Android    文件:PaddedBufferedBlockCipher.java   
/**
 * 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);
    }
}
项目:Direct-File-Downloader    文件:ECDSASigner.java   
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;
       }
}
项目:gwt-crypto    文件:BcSymmetricKeyWrapper.java   
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);
}
项目:Aki-SSL    文件:ECGOST3410Signer.java   
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;
    }
}
项目:Aki-SSL    文件:PaddedBufferedBlockCipher.java   
/**
 * 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);
    }
}
项目:gwt-crypto    文件:RFC3211WrapEngine.java   
public void init(
    boolean          forWrapping,
    CipherParameters param)
{
    this.forWrapping = forWrapping;

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

        rand = p.getRandom();
        this.param = (ParametersWithIV)p.getParameters();
    }
    else
    {
        if (forWrapping)
        {
            rand = new SecureRandom();
        }

        this.param = (ParametersWithIV)param;
    }
}
项目:gwt-crypto    文件:RFC3394WrapEngine.java   
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");
        }
    }
}
项目:gwt-crypto    文件:RFC5649WrapEngine.java   
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.preIV = ((ParametersWithIV)param).getIV();
        this.param = (KeyParameter)((ParametersWithIV)param).getParameters();
        if (this.preIV.length != 4)
        {
            throw new IllegalArgumentException("IV length not equal to 4");
        }
    }
}
项目:gwt-crypto    文件:TlsDSASigner.java   
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();
}
项目:Aki-SSL    文件:SignatureSpi.java   
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 (appRandom != null)
    {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    }
    else
    {
        signer.init(true, param);
    }
}
项目:Aki-SSL    文件:OAEPEncoding.java   
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;
}
项目:gwt-crypto    文件:OAEPEncoding.java   
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;
}
项目:gwt-crypto    文件:ECNewPublicKeyTransform.java   
/**
 * 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();
    }
}
项目:gwt-crypto    文件:ECElGamalEncryptor.java   
/**
 * 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();
    }
}
项目:gwt-crypto    文件:GOST3410Signer.java   
public void init(
    boolean                 forSigning,
    CipherParameters        param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (GOST3410PrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (GOST3410PrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (GOST3410PublicKeyParameters)param;
    }
}
项目:gwt-crypto    文件:DSTU4145Signer.java   
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;
    }

}
项目:Aki-SSL    文件:SignatureSpi.java   
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);
    }
}
项目:gwt-crypto    文件:ECNRSigner.java   
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;
    }
}
项目:gwt-crypto    文件:ECGOST3410Signer.java   
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;
    }
}
项目:gwt-crypto    文件:GCFBBlockCipher.java   
public void init(boolean forEncryption, CipherParameters params)
    throws IllegalArgumentException
{
    counter = 0;
    cfbEngine.init(forEncryption, params);

    this.forEncryption = forEncryption;

    if (params instanceof ParametersWithIV)
    {
        params = ((ParametersWithIV)params).getParameters();
    }

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

    if (params instanceof ParametersWithSBox)
    {
        params = ((ParametersWithSBox)params).getParameters();
    }

    key = (KeyParameter)params;
}
项目:gwt-crypto    文件:PaddedBufferedBlockCipher.java   
/**
 * 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);
    }
}
项目:Aki-SSL    文件:ECNewPublicKeyTransform.java   
/**
 * 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();
    }
}