use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project xipki by xipki.
the class AlgorithmUtil method getSigOrMacAlgoCode.
// method getHashOutputSizeInOctets
public static AlgorithmCode getSigOrMacAlgoCode(AlgorithmIdentifier algId) throws NoSuchAlgorithmException {
ASN1ObjectIdentifier oid = algId.getAlgorithm();
AlgorithmCode code = algOidToCodeMap.get(oid);
if (code != null) {
return code;
}
if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(oid)) {
RSASSAPSSparams param = RSASSAPSSparams.getInstance(algId.getParameters());
ASN1ObjectIdentifier digestAlgOid = param.getHashAlgorithm().getAlgorithm();
code = digestToMgf1AlgCodeMap.get(digestAlgOid);
if (code == null) {
throw new NoSuchAlgorithmException("unsupported digest algorithm " + digestAlgOid);
}
return code;
} else {
throw new NoSuchAlgorithmException("unsupported signature algorithm " + oid.getId());
}
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project xipki by xipki.
the class AlgorithmUtil method getSigAlgId.
// method getMacAlgId
public static AlgorithmIdentifier getSigAlgId(String sigAlgName) throws NoSuchAlgorithmException {
ParamUtil.requireNonNull("sigAlgName", sigAlgName);
String algoS = sigAlgName.toUpperCase();
algoS = canonicalizeAlgoText(algoS);
AlgorithmIdentifier signatureAlgId;
if (algoS.contains("MGF1")) {
HashAlgo ha = mgf1SigNameToDigestOidMap.get(algoS);
if (ha == null) {
throw new NoSuchAlgorithmException("unknown algorithm " + algoS);
}
signatureAlgId = buildRSAPSSAlgId(ha);
} else {
ASN1ObjectIdentifier algOid = sigAlgNameToOidMap.get(algoS);
if (algOid == null) {
throw new NoSuchAlgorithmException("unknown algorithm " + algoS);
}
boolean withNullParam = algoS.contains("RSA");
signatureAlgId = withNullParam ? new AlgorithmIdentifier(algOid, DERNull.INSTANCE) : new AlgorithmIdentifier(algOid);
}
return signatureAlgId;
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project xipki by xipki.
the class AlgorithmUtil method extractHashAlgoFromMacAlg.
// method getECDSASigAlgId
public static HashAlgo extractHashAlgoFromMacAlg(AlgorithmIdentifier macAlg) {
ASN1ObjectIdentifier oid = macAlg.getAlgorithm();
HashAlgo hashAlgo = macAlgOidToDigestMap.get(oid);
if (hashAlgo == null) {
throw new IllegalArgumentException("unknown algorithm identifier " + oid.getId());
}
return hashAlgo;
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project xipki by xipki.
the class AlgorithmUtil method isPlainECDSASigAlg.
// CHECKSTYLE:SKIP
public static boolean isPlainECDSASigAlg(AlgorithmIdentifier algId) {
ParamUtil.requireNonNull("algId", algId);
ASN1ObjectIdentifier oid = algId.getAlgorithm();
if (BSIObjectIdentifiers.ecdsa_plain_SHA1.equals(oid) || BSIObjectIdentifiers.ecdsa_plain_SHA224.equals(oid) || BSIObjectIdentifiers.ecdsa_plain_SHA256.equals(oid) || BSIObjectIdentifiers.ecdsa_plain_SHA384.equals(oid) || BSIObjectIdentifiers.ecdsa_plain_SHA512.equals(oid)) {
return true;
}
return false;
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project xipki by xipki.
the class AlgorithmUtil method getMacAlgId.
public static AlgorithmIdentifier getMacAlgId(String macAlgName) throws NoSuchAlgorithmException {
ParamUtil.requireNonNull("macAlgName", macAlgName);
String algoS = macAlgName.toUpperCase();
algoS = canonicalizeAlgoText(algoS);
ASN1ObjectIdentifier oid = macAlgNameToOidMap.get(algoS);
if (oid == null) {
throw new NoSuchAlgorithmException("unsupported signature algorithm " + algoS);
}
return new AlgorithmIdentifier(oid, DERNull.INSTANCE);
}
Aggregations