本文整理汇总了Java中org.bouncycastle.asn1.x509.DigestInfo类的典型用法代码示例。如果您正苦于以下问题:Java DigestInfo类的具体用法?Java DigestInfo怎么用?Java DigestInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DigestInfo类属于org.bouncycastle.asn1.x509包,在下文中一共展示了DigestInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MacData
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
private MacData(
ASN1Sequence seq)
{
this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));
this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();
if (seq.size() == 3)
{
this.iterationCount = ((ASN1Integer)seq.getObjectAt(2)).getValue();
}
else
{
this.iterationCount = ONE;
}
}
示例2: getInstance
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
public static Data getInstance(Object obj)
{
if (obj instanceof Data)
{
return (Data)obj;
}
else if (obj instanceof ASN1OctetString)
{
return new Data((ASN1OctetString)obj);
}
else if (obj instanceof ASN1Sequence)
{
return new Data(DigestInfo.getInstance(obj));
}
else if (obj instanceof ASN1TaggedObject)
{
return new Data(ASN1Sequence.getInstance((ASN1TaggedObject)obj, false));
}
throw new IllegalArgumentException("Unknown object submitted to getInstance: " + obj.getClass().getName());
}
示例3: DVCSCertInfo
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
public DVCSCertInfo(
DVCSRequestInformation dvReqInfo,
DigestInfo messageImprint,
ASN1Integer serialNumber,
DVCSTime responseTime)
{
this.dvReqInfo = dvReqInfo;
this.messageImprint = messageImprint;
this.serialNumber = serialNumber;
this.responseTime = responseTime;
}
示例4: OtherCertID
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
/**
* constructor
*/
private OtherCertID(ASN1Sequence seq)
{
if (seq.size() < 1 || seq.size() > 2)
{
throw new IllegalArgumentException("Bad sequence size: "
+ seq.size());
}
if (seq.getObjectAt(0).toASN1Primitive() instanceof ASN1OctetString)
{
otherCertHash = ASN1OctetString.getInstance(seq.getObjectAt(0));
}
else
{
otherCertHash = DigestInfo.getInstance(seq.getObjectAt(0));
}
if (seq.size() > 1)
{
issuerSerial = IssuerSerial.getInstance(seq.getObjectAt(1));
}
}
示例5: build
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
public MessageImprint build(byte[] message)
throws DVCSException
{
try
{
OutputStream dOut = digestCalculator.getOutputStream();
dOut.write(message);
dOut.close();
return new MessageImprint(new DigestInfo(digestCalculator.getAlgorithmIdentifier(), digestCalculator.getDigest()));
}
catch (Exception e)
{
throw new DVCSException("unable to build MessageImprint: " + e.getMessage(), e);
}
}
示例6: MacData
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
public MacData(
ASN1Sequence seq)
{
this.digInfo = DigestInfo.getInstance(seq.getObjectAt(0));
this.salt = ((ASN1OctetString)seq.getObjectAt(1)).getOctets();
if (seq.size() == 3)
{
this.iterationCount = ((DERInteger)seq.getObjectAt(2)).getValue();
}
else
{
this.iterationCount = BigInteger.valueOf(1);
}
}
示例7: testPlainTextAuthn
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
@Test
@QualityAssurance(firmware = Firmware.V015Z, approved = true)
public void testPlainTextAuthn() throws Exception {
// operate
String testMessage = "Test Application @ 14/2/2012 14:48:21";
byte[] signatureValue = this.pcscEid.sign(testMessage.getBytes(), "2.16.56.1.2.1.3.1", (byte) 0x82, false);
// verify
List<X509Certificate> authnCertChain = this.pcscEid.getAuthnCertificateChain();
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, authnCertChain.get(0));
byte[] signatureDigestInfoValue = cipher.doFinal(signatureValue);
ASN1InputStream aIn = new ASN1InputStream(signatureDigestInfoValue);
DigestInfo signatureDigestInfo = new DigestInfo((ASN1Sequence) aIn.readObject());
LOG.debug("result algo Id: " + signatureDigestInfo.getAlgorithmId().getObjectId().getId());
assertEquals("2.16.56.1.2.1.3.1", signatureDigestInfo.getAlgorithmId().getObjectId().getId());
assertArrayEquals(testMessage.getBytes(), signatureDigestInfo.getDigest());
}
示例8: __verifyNonRepSignature
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
private boolean __verifyNonRepSignature(final byte[] expectedDigestValue, final byte[] signatureValue,
final X509Certificate certificate) throws NoSuchAlgorithmException, NoSuchPaddingException,
InvalidKeyException, IllegalBlockSizeException, BadPaddingException, IOException {
final PublicKey publicKey = certificate.getPublicKey();
final Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, publicKey);
final byte[] actualSignatureDigestInfoValue = cipher.doFinal(signatureValue);
final ASN1InputStream asnInputStream = new ASN1InputStream(actualSignatureDigestInfoValue);
final DigestInfo actualSignatureDigestInfo = new DigestInfo((ASN1Sequence) asnInputStream.readObject());
asnInputStream.close();
final byte[] actualDigestValue = actualSignatureDigestInfo.getDigest();
return Arrays.equals(expectedDigestValue, actualDigestValue);
}
示例9: computeProxy
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
/**
* Compute the content proxy for a given node. This should likely move somewhere else
* @param nodeContent the content stored at this node
* @param isDigest is the content already digested
* @return the proxy digest (for example, the computed root of the Merkle hash tree) for this node
* @throws CertificateEncodingException if we cannot decode the witness
*/
public byte[] computeProxy(byte[] nodeContent, boolean isDigest) throws CertificateEncodingException {
if (null == witness())
return null;
DigestInfo info = CCNDigestHelper.digestDecoder(witness());
byte [] proxy = null;
if (MerklePath.isMerklePath(info)) {
MerklePath mp = new MerklePath(info.getDigest());
proxy = mp.root(nodeContent, isDigest);
} else {
Log.warning("Unexpected witness type: " + info.getAlgorithmId().toString());
}
return proxy;
}
示例10: build
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
public MacData build(char[] password, byte[] data)
throws PKCSException
{
MacCalculator macCalculator;
try
{
macCalculator = builder.build(password);
OutputStream out = macCalculator.getOutputStream();
out.write(data);
out.close();
}
catch (Exception e)
{
throw new PKCSException("unable to process data: " + e.getMessage(), e);
}
AlgorithmIdentifier algId = macCalculator.getAlgorithmIdentifier();
DigestInfo dInfo = new DigestInfo(builder.getDigestAlgorithmIdentifier(), macCalculator.getMac());
PKCS12PBEParams params = PKCS12PBEParams.getInstance(algId.getParameters());
return new MacData(dInfo, params.getIV(), params.getIterations().intValue());
}
示例11: derEncode
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
private byte[] derEncode(
byte[] hash)
throws IOException
{
DigestInfo dInfo = new DigestInfo(algId, hash);
return dInfo.getEncoded(ASN1Encoding.DER);
}
示例12: DVCSCertInfoBuilder
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
public DVCSCertInfoBuilder(
DVCSRequestInformation dvReqInfo,
DigestInfo messageImprint,
ASN1Integer serialNumber,
DVCSTime responseTime)
{
this.dvReqInfo = dvReqInfo;
this.messageImprint = messageImprint;
this.serialNumber = serialNumber;
this.responseTime = responseTime;
}
示例13: getAlgorithmHash
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
public AlgorithmIdentifier getAlgorithmHash()
{
if (otherCertHash.toASN1Primitive() instanceof ASN1OctetString)
{
// SHA-1
return new AlgorithmIdentifier("1.3.14.3.2.26");
}
else
{
return DigestInfo.getInstance(otherCertHash).getAlgorithmId();
}
}
示例14: getCertHash
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
public byte[] getCertHash()
{
if (otherCertHash.toASN1Primitive() instanceof ASN1OctetString)
{
// SHA-1
return ((ASN1OctetString)otherCertHash.toASN1Primitive()).getOctets();
}
else
{
return DigestInfo.getInstance(otherCertHash).getDigest();
}
}
示例15: derEncode
import org.bouncycastle.asn1.x509.DigestInfo; //导入依赖的package包/类
private byte[] derEncode(
byte[] hash)
throws IOException
{
if (algId == null)
{
// For raw RSA, the DigestInfo must be prepared externally
return hash;
}
DigestInfo dInfo = new DigestInfo(algId, hash);
return dInfo.getEncoded(ASN1Encoding.DER);
}