本文整理汇总了Java中org.bouncycastle.openpgp.operator.PGPDigestCalculator.getOutputStream方法的典型用法代码示例。如果您正苦于以下问题:Java PGPDigestCalculator.getOutputStream方法的具体用法?Java PGPDigestCalculator.getOutputStream怎么用?Java PGPDigestCalculator.getOutputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.openpgp.operator.PGPDigestCalculator
的用法示例。
在下文中一共展示了PGPDigestCalculator.getOutputStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: KDF
import org.bouncycastle.openpgp.operator.PGPDigestCalculator; //导入方法依赖的package包/类
private static byte[] KDF(PGPDigestCalculator digCalc, ECPoint s, int keyLen, byte[] param)
throws IOException
{
byte[] ZB = s.getXCoord().getEncoded();
OutputStream dOut = digCalc.getOutputStream();
dOut.write(0x00);
dOut.write(0x00);
dOut.write(0x00);
dOut.write(0x01);
dOut.write(ZB);
dOut.write(param);
byte[] digest = digCalc.getDigest();
byte[] key = new byte[keyLen];
System.arraycopy(digest, 0, key, 0, key.length);
return key;
}
示例2: build
import org.bouncycastle.openpgp.operator.PGPDigestCalculator; //导入方法依赖的package包/类
public PGPContentSigner build(final int signatureType, final PGPPrivateKey privateKey)
throws PGPException
{
final PGPDigestCalculator digestCalculator = digestCalculatorProvider.get(hashAlgorithm);
final Signer signer = BcImplProvider.createSigner(keyAlgorithm, hashAlgorithm);
if (random != null)
{
signer.init(true, new ParametersWithRandom(keyConverter.getPrivateKey(privateKey), random));
}
else
{
signer.init(true, keyConverter.getPrivateKey(privateKey));
}
return new PGPContentSigner()
{
public int getType()
{
return signatureType;
}
public int getHashAlgorithm()
{
return hashAlgorithm;
}
public int getKeyAlgorithm()
{
return keyAlgorithm;
}
public long getKeyID()
{
return privateKey.getKeyID();
}
public OutputStream getOutputStream()
{
return new TeeOutputStream(new SignerOutputStream(signer), digestCalculator.getOutputStream());
}
public byte[] getSignature()
{
try
{
return signer.generateSignature();
}
catch (CryptoException e)
{ // TODO: need a specific runtime exception for PGP operators.
throw new IllegalStateException("unable to create signature");
}
}
public byte[] getDigest()
{
return digestCalculator.getDigest();
}
};
}