本文整理汇总了Java中org.bouncycastle.operator.DigestCalculator类的典型用法代码示例。如果您正苦于以下问题:Java DigestCalculator类的具体用法?Java DigestCalculator怎么用?Java DigestCalculator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DigestCalculator类属于org.bouncycastle.operator包,在下文中一共展示了DigestCalculator类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: generateOCSPRequest
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
/**
* Generates an OCSP request using BouncyCastle.
* @param issuerCert certificate of the issues
* @param serialNumber serial number
* @return an OCSP request
* @throws OCSPException
* @throws IOException
*/
private static OCSPReq generateOCSPRequest(X509Certificate issuerCert, BigInteger serialNumber) throws OCSPException, IOException, OperatorException, CertificateEncodingException {
//Add provider BC
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
JcaDigestCalculatorProviderBuilder digestCalculatorProviderBuilder = new JcaDigestCalculatorProviderBuilder();
DigestCalculatorProvider digestCalculatorProvider = digestCalculatorProviderBuilder.build();
DigestCalculator digestCalculator = digestCalculatorProvider.get(CertificateID.HASH_SHA1);
// Generate the id for the certificate we are looking for
CertificateID id = new CertificateID(digestCalculator, new JcaX509CertificateHolder(issuerCert), serialNumber);
// basic request generation with nonce
OCSPReqBuilder gen = new OCSPReqBuilder();
gen.addRequest(id);
// create details for nonce extension
Extension ext = new Extension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce, false, new DEROctetString(new DEROctetString(PdfEncryption.createDocumentId()).getEncoded()));
gen.setRequestExtensions(new Extensions(new Extension[]{ext}));
return gen.build();
}
开发者ID:albfernandez,项目名称:itext2,代码行数:30,代码来源:OcspClientBouncyCastle.java
示例2: isVerified
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
public boolean isVerified(X509CertificateHolder certHolder, DigestCalculatorProvider digesterProvider)
throws CMPException
{
AlgorithmIdentifier digAlg = digestAlgFinder.find(certHolder.toASN1Structure().getSignatureAlgorithm());
if (digAlg == null)
{
throw new CMPException("cannot find algorithm for digest from signature");
}
DigestCalculator digester;
try
{
digester = digesterProvider.get(digAlg);
}
catch (OperatorCreationException e)
{
throw new CMPException("unable to create digester: " + e.getMessage(), e);
}
CMPUtil.derEncodeToStream(certHolder.toASN1Structure(), digester.getOutputStream());
return Arrays.areEqual(certStatus.getCertHash().getOctets(), digester.getDigest());
}
开发者ID:Appdome,项目名称:ipack,代码行数:25,代码来源:CertificateStatus.java
示例3: RespID
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
/**
* Calculate a RespID based on the public key of the responder.
*
* @param subjectPublicKeyInfo the info structure for the responder public key.
* @param digCalc a SHA-1 digest calculator.
* @throws OCSPException on exception creating ID.
*/
public RespID(
SubjectPublicKeyInfo subjectPublicKeyInfo,
DigestCalculator digCalc)
throws OCSPException
{
try
{
if (!digCalc.getAlgorithmIdentifier().equals(HASH_SHA1))
{
throw new IllegalArgumentException("only SHA-1 can be used with RespID");
}
OutputStream digOut = digCalc.getOutputStream();
digOut.write(subjectPublicKeyInfo.getPublicKeyData().getBytes());
digOut.close();
this.id = new ResponderID(new DEROctetString(digCalc.getDigest()));
}
catch (Exception e)
{
throw new OCSPException("problem creating ID: " + e, e);
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:32,代码来源:RespID.java
示例4: get
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
public DigestCalculator get(final AlgorithmIdentifier algorithm)
throws OperatorCreationException
{
Digest dig = digestProvider.get(algorithm);
final DigestOutputStream stream = new DigestOutputStream(dig);
return new DigestCalculator()
{
public AlgorithmIdentifier getAlgorithmIdentifier()
{
return algorithm;
}
public OutputStream getOutputStream()
{
return stream;
}
public byte[] getDigest()
{
return stream.getDigest();
}
};
}
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:BcDigestCalculatorProvider.java
示例5: CmsAuthenticatedDataOutputStream
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
public CmsAuthenticatedDataOutputStream(
MacCalculator macCalculator,
DigestCalculator digestCalculator,
ASN1ObjectIdentifier contentType,
OutputStream dataStream,
BERSequenceGenerator cGen,
BERSequenceGenerator envGen,
BERSequenceGenerator eiGen)
{
this.macCalculator = macCalculator;
this.digestCalculator = digestCalculator;
this.contentType = contentType;
this.dataStream = dataStream;
this.cGen = cGen;
this.envGen = envGen;
this.eiGen = eiGen;
}
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:CMSAuthenticatedDataStreamGenerator.java
示例6: getMessageImprintDigestCalculator
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
DigestCalculator getMessageImprintDigestCalculator(DigestCalculatorProvider calculatorProvider)
throws OperatorCreationException
{
TimeStampToken token;
try
{
token = this.getTimeStampToken(timeStamps[0]);
TimeStampTokenInfo info = token.getTimeStampInfo();
ASN1ObjectIdentifier algOID = info.getMessageImprintAlgOID();
DigestCalculator calc = calculatorProvider.get(new AlgorithmIdentifier(algOID));
initialiseMessageImprintDigestCalculator(calc);
return calc;
}
catch (CMSException e)
{
throw new OperatorCreationException("unable to extract algorithm ID: " + e.getMessage(), e);
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:24,代码来源:TimeStampDataUtil.java
示例7: calculateNextHash
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
byte[] calculateNextHash(DigestCalculator calculator)
throws CMSException
{
TimeStampAndCRL tspToken = timeStamps[timeStamps.length - 1];
OutputStream out = calculator.getOutputStream();
try
{
out.write(tspToken.getEncoded(ASN1Encoding.DER));
out.close();
return calculator.getDigest();
}
catch (IOException e)
{
throw new CMSException("exception calculating hash: " + e.getMessage(), e);
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:TimeStampDataUtil.java
示例8: get
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
@Override
public DigestCalculator get(final AlgorithmIdentifier digestAlgorithmIdentifier) throws OperatorCreationException {
ASN1ObjectIdentifier algorithmOid = digestAlgorithmIdentifier.getAlgorithm();
final String digestBase64 = digestDocument.getDigest(DigestAlgorithm.forOID(algorithmOid.getId()));
return new DigestCalculator() {
@Override
public OutputStream getOutputStream() {
OutputStream os = new ByteArrayOutputStream();
try {
Utils.write(getDigest(), os);
} catch (IOException e) {
throw new DSSException("Unable to get outputstream", e);
}
return os;
}
@Override
public byte[] getDigest() {
return Utils.fromBase64(digestBase64);
}
@Override
public AlgorithmIdentifier getAlgorithmIdentifier() {
return digestAlgorithmIdentifier;
}
};
}
开发者ID:esig,项目名称:dss,代码行数:32,代码来源:PrecomputedDigestCalculatorProvider.java
示例9: metadataCheck
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
private void metadataCheck(byte[] timeStampedData)
throws Exception
{
CMSTimeStampedData cmsTspData = new CMSTimeStampedData(timeStampedData);
DigestCalculatorProvider newCalculatorProvider = new BcDigestCalculatorProvider();
DigestCalculator imprintCalculator = cmsTspData.getMessageImprintDigestCalculator(newCalculatorProvider);
byte[] newContent = cmsTspData.getContent();
assertEquals("Content expected and verified are different", true, Arrays.areEqual(newContent, baseData));
imprintCalculator.getOutputStream().write(newContent);
assertEquals(fileInput, cmsTspData.getFileName());
assertEquals("TXT", cmsTspData.getMediaType());
byte[] digest = imprintCalculator.getDigest();
TimeStampToken[] tokens = cmsTspData.getTimeStampTokens();
assertEquals("TimeStampToken expected and verified are different", 4, tokens.length);
for (int i = 0; i < tokens.length; i++)
{
cmsTspData.validate(newCalculatorProvider, digest, tokens[i]);
}
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:25,代码来源:CMSTimeStampedDataGeneratorTest.java
示例10: testValidateAllTokens
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
public void testValidateAllTokens()
throws Exception
{
DigestCalculatorProvider digestCalculatorProvider = new BcDigestCalculatorProvider();
DigestCalculator imprintCalculator = cmsTimeStampedData.getMessageImprintDigestCalculator(digestCalculatorProvider);
imprintCalculator.getOutputStream().write(cmsTimeStampedData.getContent());
byte[] digest = imprintCalculator.getDigest();
TimeStampToken[] tokens = cmsTimeStampedData.getTimeStampTokens();
for (int i = 0; i < tokens.length; i++)
{
cmsTimeStampedData.validate(digestCalculatorProvider, digest, tokens[i]);
}
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:18,代码来源:CMSTimeStampedDataTest.java
示例11: testValidateAllTokens
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
public void testValidateAllTokens()
throws Exception
{
DigestCalculatorProvider digestCalculatorProvider = new BcDigestCalculatorProvider();
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
Streams.pipeAll(cmsTimeStampedData.getContent(), bOut);
DigestCalculator imprintCalculator = cmsTimeStampedData.getMessageImprintDigestCalculator(digestCalculatorProvider);
Streams.pipeAll(new ByteArrayInputStream(bOut.toByteArray()), imprintCalculator.getOutputStream());
byte[] digest = imprintCalculator.getDigest();
TimeStampToken[] tokens = cmsTimeStampedData.getTimeStampTokens();
for (int i = 0; i < tokens.length; i++)
{
cmsTimeStampedData.validate(digestCalculatorProvider, digest, tokens[i]);
}
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:21,代码来源:CMSTimeStampedDataParserTest.java
示例12: build
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
public CertificateConfirmationContent build(DigestCalculatorProvider digesterProvider)
throws CMPException
{
ASN1EncodableVector v = new ASN1EncodableVector();
for (int i = 0; i != acceptedCerts.size(); i++)
{
X509CertificateHolder certHolder = (X509CertificateHolder)acceptedCerts.get(i);
BigInteger reqID = (BigInteger)acceptedReqIds.get(i);
AlgorithmIdentifier digAlg = digestAlgFinder.find(certHolder.toASN1Structure().getSignatureAlgorithm());
if (digAlg == null)
{
throw new CMPException("cannot find algorithm for digest from signature");
}
DigestCalculator digester;
try
{
digester = digesterProvider.get(digAlg);
}
catch (OperatorCreationException e)
{
throw new CMPException("unable to create digest: " + e.getMessage(), e);
}
CMPUtil.derEncodeToStream(certHolder.toASN1Structure(), digester.getOutputStream());
v.add(new CertStatus(digester.getDigest(), reqID));
}
return new CertificateConfirmationContent(CertConfirmContent.getInstance(new DERSequence(v)), digestAlgFinder);
}
开发者ID:Appdome,项目名称:ipack,代码行数:35,代码来源:CertificateConfirmationContentBuilder.java
示例13: createCertID
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
private static CertID createCertID(DigestCalculator digCalc, X509CertificateHolder issuerCert, ASN1Integer serialNumber)
throws OCSPException
{
try
{
OutputStream dgOut = digCalc.getOutputStream();
dgOut.write(issuerCert.toASN1Structure().getSubject().getEncoded(ASN1Encoding.DER));
dgOut.close();
ASN1OctetString issuerNameHash = new DEROctetString(digCalc.getDigest());
SubjectPublicKeyInfo info = issuerCert.getSubjectPublicKeyInfo();
dgOut = digCalc.getOutputStream();
dgOut.write(info.getPublicKeyData().getBytes());
dgOut.close();
ASN1OctetString issuerKeyHash = new DEROctetString(digCalc.getDigest());
return new CertID(digCalc.getAlgorithmIdentifier(), issuerNameHash, issuerKeyHash, serialNumber);
}
catch (Exception e)
{
throw new OCSPException("problem creating ID: " + e, e);
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:CertificateID.java
示例14: BasicOCSPRespBuilder
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
/**
* construct with the responderID to be the SHA-1 keyHash of the passed in public key.
*
* @param key the key info of the responder public key.
* @param digCalc a SHA-1 digest calculator
*/
public BasicOCSPRespBuilder(
SubjectPublicKeyInfo key,
DigestCalculator digCalc)
throws OCSPException
{
this.responderID = new RespID(key, digCalc);
}
开发者ID:Appdome,项目名称:ipack,代码行数:14,代码来源:BasicOCSPRespBuilder.java
示例15: open
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
public OutputStream open(
OutputStream out,
MacCalculator macCalculator,
DigestCalculator digestCalculator)
throws CMSException
{
return open(CMSObjectIdentifiers.data, out, macCalculator, digestCalculator);
}
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:CMSAuthenticatedDataStreamGenerator.java
示例16: TimeStampTokenGenerator
import org.bouncycastle.operator.DigestCalculator; //导入依赖的package包/类
/**
* basic creation - only the default attributes will be included here.
* @deprecated use SignerInfoGenerator constructor that takes a digest calculator
*/
public TimeStampTokenGenerator(
final SignerInfoGenerator signerInfoGen,
ASN1ObjectIdentifier tsaPolicy)
throws IllegalArgumentException, TSPException
{
this(new DigestCalculator()
{
private ByteArrayOutputStream bOut = new ByteArrayOutputStream();
public AlgorithmIdentifier getAlgorithmIdentifier()
{
return new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
}
public OutputStream getOutputStream()
{
return bOut;
}
public byte[] getDigest()
{
try
{
return MessageDigest.getInstance("SHA-1").digest(bOut.toByteArray());
}
catch (NoSuchAlgorithmException e)
{
throw new IllegalStateException("cannot find sha-1: "+ e.getMessage());
}
}
}, signerInfoGen, tsaPolicy);
}
开发者ID:Appdome,项目名称:ipack,代码行数:37,代码来源:TimeStampTokenGenerator.java
注:本文中的org.bouncycastle.operator.DigestCalculator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论