use of org.openecard.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.openecard.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.openecard.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.openecard.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);
}
use of org.openecard.bouncycastle.asn1.ASN1ObjectIdentifier in project xipki by xipki.
the class AlgorithmUtil method getRSASigAlgId.
// CHECKSTYLE:SKIP
private static AlgorithmIdentifier getRSASigAlgId(HashAlgo hashAlgo, boolean mgf1) throws NoSuchAlgorithmException {
ParamUtil.requireNonNull("hashAlgo", hashAlgo);
if (mgf1) {
return buildRSAPSSAlgId(hashAlgo);
}
ASN1ObjectIdentifier sigAlgOid = digestToRSASigAlgMap.get(hashAlgo);
if (sigAlgOid == null) {
throw new NoSuchAlgorithmException("unsupported hash " + hashAlgo + " for RSA key");
}
return new AlgorithmIdentifier(sigAlgOid, DERNull.INSTANCE);
}
Aggregations