本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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");
}
}
示例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);
}
}
示例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);
}
}
示例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");
}
}
示例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);
}
}
示例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);
}