use of com.github.zhenwei.core.asn1.ASN1Primitive in project jruby-openssl by jruby.
the class PKey method readRSAPrivateKey.
public static KeyPair readRSAPrivateKey(final KeyFactory rsaFactory, final byte[] input) throws IOException, InvalidKeySpecException {
ASN1Sequence seq;
ASN1Primitive obj = new ASN1InputStream(input).readObject();
if (obj instanceof ASN1Sequence && (seq = (ASN1Sequence) obj).size() == 9) {
BigInteger mod = ((ASN1Integer) seq.getObjectAt(1)).getValue();
BigInteger pubexp = ((ASN1Integer) seq.getObjectAt(2)).getValue();
BigInteger privexp = ((ASN1Integer) seq.getObjectAt(3)).getValue();
BigInteger primep = ((ASN1Integer) seq.getObjectAt(4)).getValue();
BigInteger primeq = ((ASN1Integer) seq.getObjectAt(5)).getValue();
BigInteger primeep = ((ASN1Integer) seq.getObjectAt(6)).getValue();
BigInteger primeeq = ((ASN1Integer) seq.getObjectAt(7)).getValue();
BigInteger crtcoeff = ((ASN1Integer) seq.getObjectAt(8)).getValue();
PrivateKey priv = rsaFactory.generatePrivate(new RSAPrivateCrtKeySpec(mod, pubexp, privexp, primep, primeq, primeep, primeeq, crtcoeff));
PublicKey pub = rsaFactory.generatePublic(new RSAPublicKeySpec(mod, pubexp));
return new KeyPair(pub, priv);
}
return null;
}
use of com.github.zhenwei.core.asn1.ASN1Primitive in project jans by JanssenProject.
the class CRLCertificateVerifier method getCrlUri.
public String getCrlUri(X509Certificate certificate) throws IOException {
ASN1Primitive obj;
try {
obj = getExtensionValue(certificate, Extension.cRLDistributionPoints.getId());
} catch (IOException ex) {
log.error("Failed to get CRL URL", ex);
return null;
}
if (obj == null) {
return null;
}
CRLDistPoint distPoint = CRLDistPoint.getInstance(obj);
DistributionPoint[] distributionPoints = distPoint.getDistributionPoints();
for (DistributionPoint distributionPoint : distributionPoints) {
DistributionPointName distributionPointName = distributionPoint.getDistributionPoint();
if (DistributionPointName.FULL_NAME != distributionPointName.getType()) {
continue;
}
GeneralNames generalNames = (GeneralNames) distributionPointName.getName();
GeneralName[] names = generalNames.getNames();
for (GeneralName name : names) {
if (name.getTagNo() != GeneralName.uniformResourceIdentifier) {
continue;
}
DERIA5String derStr = DERIA5String.getInstance((ASN1TaggedObject) name.toASN1Primitive(), false);
return derStr.getString();
}
}
return null;
}
use of com.github.zhenwei.core.asn1.ASN1Primitive in project LinLong-Java by zhenwei1108.
the class ObjectStoreData method toASN1Primitive.
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector(6);
v.add(new ASN1Integer(version));
v.add(integrityAlgorithm);
v.add(creationDate);
v.add(lastModifiedDate);
v.add(objectDataSequence);
if (comment != null) {
v.add(new DERUTF8String(comment));
}
return new DERSequence(v);
}
use of com.github.zhenwei.core.asn1.ASN1Primitive in project LinLong-Java by zhenwei1108.
the class SecretKeyData method toASN1Primitive.
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector(2);
v.add(keyAlgorithm);
v.add(keyBytes);
return new DERSequence(v);
}
use of com.github.zhenwei.core.asn1.ASN1Primitive in project LinLong-Java by zhenwei1108.
the class SignatureCheck method toASN1Primitive.
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector(3);
v.add(signatureAlgorithm);
if (certificates != null) {
v.add(new DERTaggedObject(0, certificates));
}
v.add(signatureValue);
return new DERSequence(v);
}
Aggregations