本文整理汇总了Java中org.bouncycastle.crypto.EphemeralKeyPair.getEncodedPublicKey方法的典型用法代码示例。如果您正苦于以下问题:Java EphemeralKeyPair.getEncodedPublicKey方法的具体用法?Java EphemeralKeyPair.getEncodedPublicKey怎么用?Java EphemeralKeyPair.getEncodedPublicKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.crypto.EphemeralKeyPair
的用法示例。
在下文中一共展示了EphemeralKeyPair.getEncodedPublicKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processBlock
import org.bouncycastle.crypto.EphemeralKeyPair; //导入方法依赖的package包/类
public byte[] processBlock(
byte[] in,
int inOff,
int inLen)
throws InvalidCipherTextException
{
if (forEncryption)
{
if (keyPairGenerator != null)
{
EphemeralKeyPair ephKeyPair = keyPairGenerator.generate();
this.privParam = ephKeyPair.getKeyPair().getPrivate();
this.V = ephKeyPair.getEncodedPublicKey();
}
}
else
{
if (keyParser != null)
{
ByteArrayInputStream bIn = new ByteArrayInputStream(in, inOff, inLen);
try
{
this.pubParam = keyParser.readKey(bIn);
}
catch (IOException e)
{
throw new InvalidCipherTextException("unable to recover ephemeral public key: " + e.getMessage(), e);
}
int encLength = (inLen - bIn.available());
this.V = Arrays.copyOfRange(in, inOff, inOff + encLength);
}
}
// Compute the common value and convert to byte array.
agree.init(privParam);
BigInteger z = agree.calculateAgreement(pubParam);
byte[] Z = BigIntegers.asUnsignedByteArray(agree.getFieldSize(), z);
// Create input to KDF.
byte[] VZ;
if (V.length != 0)
{
VZ = new byte[V.length + Z.length];
System.arraycopy(V, 0, VZ, 0, V.length);
System.arraycopy(Z, 0, VZ, V.length, Z.length);
}
else
{
VZ = Z;
}
// Initialise the KDF.
KDFParameters kdfParam = new KDFParameters(VZ, param.getDerivationV());
kdf.init(kdfParam);
return forEncryption
? encryptBlock(in, inOff, inLen)
: decryptBlock(in, inOff, inLen);
}
示例2: processBlock
import org.bouncycastle.crypto.EphemeralKeyPair; //导入方法依赖的package包/类
public byte[] processBlock(
byte[] in,
int inOff,
int inLen)
throws InvalidCipherTextException
{
if (forEncryption)
{
if (keyPairGenerator != null)
{
EphemeralKeyPair ephKeyPair = keyPairGenerator.generate();
this.privParam = ephKeyPair.getKeyPair().getPrivate();
this.V = ephKeyPair.getEncodedPublicKey();
}
}
else
{
if (keyParser != null)
{
ByteArrayInputStream bIn = new ByteArrayInputStream(in, inOff, inLen);
try
{
this.pubParam = keyParser.readKey(bIn);
}
catch (IOException e)
{
throw new InvalidCipherTextException("unable to recover ephemeral public key: " + e.getMessage(), e);
}
int encLength = (inLen - bIn.available());
this.V = Arrays.copyOfRange(in, inOff, inOff + encLength);
}
}
// Compute the common value and convert to byte array.
agree.init(privParam);
BigInteger z = agree.calculateAgreement(pubParam);
byte[] Z = BigIntegers.asUnsignedByteArray(agree.getFieldSize(), z);
// Create input to KDF.
if (V.length != 0)
{
byte[] VZ = Arrays.concatenate(V, Z);
Arrays.fill(Z, (byte)0);
Z = VZ;
}
try
{
// Initialise the KDF.
KDFParameters kdfParam = new KDFParameters(Z, param.getDerivationV());
kdf.init(kdfParam);
return forEncryption
? encryptBlock(in, inOff, inLen)
: decryptBlock(in, inOff, inLen);
}
finally
{
Arrays.fill(Z, (byte)0);
}
}