use of org.bouncycastle.asn1.x509.AlgorithmIdentifier in project robovm by robovm.
the class DefaultSignatureAlgorithmIdentifierFinder method generate.
private static AlgorithmIdentifier generate(String signatureAlgorithm) {
AlgorithmIdentifier sigAlgId;
AlgorithmIdentifier encAlgId;
AlgorithmIdentifier digAlgId;
String algorithmName = Strings.toUpperCase(signatureAlgorithm);
ASN1ObjectIdentifier sigOID = (ASN1ObjectIdentifier) algorithms.get(algorithmName);
if (sigOID == null) {
throw new IllegalArgumentException("Unknown signature type requested: " + algorithmName);
}
if (noParams.contains(sigOID)) {
sigAlgId = new AlgorithmIdentifier(sigOID);
} else if (params.containsKey(algorithmName)) {
sigAlgId = new AlgorithmIdentifier(sigOID, (ASN1Encodable) params.get(algorithmName));
} else {
sigAlgId = new AlgorithmIdentifier(sigOID, DERNull.INSTANCE);
}
if (pkcs15RsaEncryption.contains(sigOID)) {
encAlgId = new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE);
} else {
encAlgId = sigAlgId;
}
if (sigAlgId.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS)) {
digAlgId = ((RSASSAPSSparams) sigAlgId.getParameters()).getHashAlgorithm();
} else {
digAlgId = new AlgorithmIdentifier((ASN1ObjectIdentifier) digestOids.get(sigOID), DERNull.INSTANCE);
}
return sigAlgId;
}
use of org.bouncycastle.asn1.x509.AlgorithmIdentifier in project robovm by robovm.
the class BcDefaultDigestProvider method createTable.
private static Map createTable() {
Map table = new HashMap();
table.put(OIWObjectIdentifiers.idSHA1, new BcDigestProvider() {
public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier) {
return new SHA1Digest();
}
});
// BEGIN android-removed
// table.put(NISTObjectIdentifiers.id_sha224, new BcDigestProvider()
// {
// public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier)
// {
// return new SHA224Digest();
// }
// });
// END android-removed
table.put(NISTObjectIdentifiers.id_sha256, new BcDigestProvider() {
public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier) {
return new SHA256Digest();
}
});
table.put(NISTObjectIdentifiers.id_sha384, new BcDigestProvider() {
public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier) {
return new SHA384Digest();
}
});
table.put(NISTObjectIdentifiers.id_sha512, new BcDigestProvider() {
public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier) {
return new SHA512Digest();
}
});
table.put(PKCSObjectIdentifiers.md5, new BcDigestProvider() {
public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier) {
return new MD5Digest();
}
});
return Collections.unmodifiableMap(table);
}
use of org.bouncycastle.asn1.x509.AlgorithmIdentifier in project robovm by robovm.
the class CertUtils method generateAttrStructure.
private static AttributeCertificate generateAttrStructure(AttributeCertificateInfo attrInfo, AlgorithmIdentifier sigAlgId, byte[] signature) {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(attrInfo);
v.add(sigAlgId);
v.add(new DERBitString(signature));
return AttributeCertificate.getInstance(new DERSequence(v));
}
use of org.bouncycastle.asn1.x509.AlgorithmIdentifier in project robovm by robovm.
the class CertUtils method generateStructure.
private static Certificate generateStructure(TBSCertificate tbsCert, AlgorithmIdentifier sigAlgId, byte[] signature) {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(tbsCert);
v.add(sigAlgId);
v.add(new DERBitString(signature));
return Certificate.getInstance(new DERSequence(v));
}
use of org.bouncycastle.asn1.x509.AlgorithmIdentifier in project robovm by robovm.
the class CertUtils method generateCRLStructure.
private static CertificateList generateCRLStructure(TBSCertList tbsCertList, AlgorithmIdentifier sigAlgId, byte[] signature) {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(tbsCertList);
v.add(sigAlgId);
v.add(new DERBitString(signature));
return CertificateList.getInstance(new DERSequence(v));
}
Aggregations