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


Java ECKey类代码示例

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


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

示例1: init

import org.bouncycastle.jce.interfaces.ECKey; //导入依赖的package包/类
public void init(int mode, byte[] key, byte[] iv, AlgorithmParameterSpec params) {
  Preconditions.checkNotNull(key);

  this.mode = mode;
  try {
    if (mode == TRANSFORM_MODE)
    {
      reKey = new BBS98ReEncryptionKeySpec(key);
      this.params = params;
    } else {
      Preconditions.checkNotNull(iv);
      BBS98KeySpec keySpec = new BBS98KeySpec(key, "BBS98");
      this.blockSize = 30;
      this.key = (ECKey) SerializationUtils.deserialize(keySpec.getKeyMaterial());
      this.params = this.key.getParameters();
    }
    engine = new WrapperBBS98(this.params, random);
  } catch (InvalidAlgorithmParameterException e) {
    e.printStackTrace();
  }

  this.iv = iv;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:BBS98BCCipher.java

示例2: engineInitSign

import org.bouncycastle.jce.interfaces.ECKey; //导入依赖的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

示例3: engineInitSign

import org.bouncycastle.jce.interfaces.ECKey; //导入依赖的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

示例4: engineGetOutputSize

import org.bouncycastle.jce.interfaces.ECKey; //导入依赖的package包/类
public int engineGetOutputSize(int inputLen)
{
    int len1, len2, len3;

    len1 = engine.getMac().getMacSize();

    if (key != null)
    {
        len2 = 1 + 2 * (((ECKey)key).getParameters().getCurve().getFieldSize() + 7) / 8;
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }

    if (engine.getCipher() == null)
    {
        len3 = inputLen;
    }
    else if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        len3 = engine.getCipher().getOutputSize(inputLen);
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        len3 = engine.getCipher().getOutputSize(inputLen - len1 - len2);
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }

    if (state == Cipher.ENCRYPT_MODE || state == Cipher.WRAP_MODE)
    {
        return buffer.size() + len1 + len2 + len3;
    }
    else if (state == Cipher.DECRYPT_MODE || state == Cipher.UNWRAP_MODE)
    {
        return buffer.size() - len1 - len2 + len3;
    }
    else
    {
        throw new IllegalStateException("cipher not initialised");
    }

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

示例5: engineInitSign

import org.bouncycastle.jce.interfaces.ECKey; //导入依赖的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 (appRandom != null)
    {
        signer.init(true, new ParametersWithRandom(param, appRandom));
    }
    else
    {
        signer.init(true, param);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:27,代码来源:SignatureSpi.java

示例6: engineInitSign

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

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

    digest.reset();

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

示例7: engineGetKeySize

import org.bouncycastle.jce.interfaces.ECKey; //导入依赖的package包/类
public int engineGetKeySize(Key key)
{
    if (key instanceof ECKey)
    {
        return ((ECKey)key).getParameters().getCurve().getFieldSize();
    }
    else
    {
        throw new IllegalArgumentException("not an EC key");
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:12,代码来源:IESCipher.java

示例8: doEngineInitSign

import org.bouncycastle.jce.interfaces.ECKey; //导入依赖的package包/类
protected void doEngineInitSign(
    PrivateKey privateKey,
    SecureRandom random)
    throws InvalidKeyException
{
    CipherParameters param;

    if (privateKey instanceof ECKey)
    {
        param = ECUtil.generatePrivateKeyParameter(privateKey);
    }
    else
    {
        throw new InvalidKeyException("can't recognise key type in ECDSA based signer");
    }

    digest.reset();

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

示例9: engineInitVerify

import org.bouncycastle.jce.interfaces.ECKey; //导入依赖的package包/类
protected void engineInitVerify(
    PublicKey   publicKey)
    throws InvalidKeyException
{
    CipherParameters    param = null;

    if (publicKey instanceof ECKey)
    {
        param = ECUtil.generatePublicKeyParameter(publicKey);
    }
    else if (publicKey instanceof DSAKey)
    {
        param = DSAUtil.generatePublicKeyParameter(publicKey);
    }
    else
    {
        try
        {
        	/*
            byte[]  bytes = publicKey.getEncoded();

            publicKey = JDKKeyFactory.createPublicKeyFromDERStream(
                                    new ByteArrayInputStream(bytes));

            if (publicKey instanceof ECKey)
            {
                param = ECUtil.generatePublicKeyParameter(publicKey);
            }
            else if (publicKey instanceof DSAKey)
            {
                param = DSAUtil.generatePublicKeyParameter(publicKey);
            }
            else
            {
            */
                throw new InvalidKeyException("can't recognise key type in DSA based signer");
            //}
        }
        catch (Exception e)
        {
            throw new InvalidKeyException("can't recognise key type in DSA based signer");
        }
    }

    digest.reset();
    signer.init(false, param);
}
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:48,代码来源:JDKDSASigner.java


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