use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class X509CertificateObject method verify.
public final void verify(PublicKey key, Provider sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
String sigName = X509SignatureUtil.getSignatureName(c.getSignatureAlgorithm());
Signature signature;
if (sigProvider != null) {
signature = Signature.getInstance(sigName, sigProvider);
} else {
signature = Signature.getInstance(sigName);
}
checkSignature(key, signature);
}
use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class X509V1CertificateGenerator method generate.
/**
* generate an X509 certificate, based on the current issuer and subject using the default
* provider and the passed in source of randomness
* <p>
* <b>Note:</b> this differs from the deprecated method in that the default provider is
* used - not "BC".
* </p>
*/
public X509Certificate generate(PrivateKey key, SecureRandom random) throws CertificateEncodingException, IllegalStateException, NoSuchAlgorithmException, SignatureException, InvalidKeyException {
TBSCertificate tbsCert = tbsGen.generateTBSCertificate();
byte[] signature;
try {
signature = X509Util.calculateSignature(sigOID, signatureAlgorithm, key, random, tbsCert);
} catch (IOException e) {
throw new ExtCertificateEncodingException("exception encoding TBS cert", e);
}
return generateJcaObject(tbsCert, signature);
}
use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class X509V1CertificateGenerator method generate.
/**
* generate an X509 certificate, based on the current issuer and subject, using the passed in
* provider for the signing, and the passed in source of randomness (if required).
*/
public X509Certificate generate(PrivateKey key, String provider, SecureRandom random) throws CertificateEncodingException, IllegalStateException, NoSuchProviderException, NoSuchAlgorithmException, SignatureException, InvalidKeyException {
TBSCertificate tbsCert = tbsGen.generateTBSCertificate();
byte[] signature;
try {
signature = X509Util.calculateSignature(sigOID, signatureAlgorithm, provider, key, random, tbsCert);
} catch (IOException e) {
throw new ExtCertificateEncodingException("exception encoding TBS cert", e);
}
return generateJcaObject(tbsCert, signature);
}
use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class TBSCertList method toASN1Primitive.
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector(7);
if (version != null) {
v.add(version);
}
v.add(signature);
v.add(issuer);
v.add(thisUpdate);
if (nextUpdate != null) {
v.add(nextUpdate);
}
// Add CRLEntries if they exist
if (revokedCertificates != null) {
v.add(revokedCertificates);
}
if (crlExtensions != null) {
v.add(new DERTaggedObject(0, crlExtensions));
}
return new DERSequence(v);
}
use of com.github.zhenwei.core.asn1.ocsp.Signature in project LinLong-Java by zhenwei1108.
the class V2AttributeCertificateInfoGenerator method generateAttributeCertificateInfo.
public AttributeCertificateInfo generateAttributeCertificateInfo() {
if ((serialNumber == null) || (signature == null) || (issuer == null) || (startDate == null) || (endDate == null) || (holder == null) || (attributes == null)) {
throw new IllegalStateException("not all mandatory fields set in V2 AttributeCertificateInfo generator");
}
ASN1EncodableVector v = new ASN1EncodableVector(9);
v.add(version);
v.add(holder);
v.add(issuer);
v.add(signature);
v.add(serialNumber);
//
// before and after dates => AttCertValidityPeriod
//
AttCertValidityPeriod validity = new AttCertValidityPeriod(startDate, endDate);
v.add(validity);
// Attributes
v.add(new DERSequence(attributes));
if (issuerUniqueID != null) {
v.add(issuerUniqueID);
}
if (extensions != null) {
v.add(extensions);
}
return AttributeCertificateInfo.getInstance(new DERSequence(v));
}
Aggregations