private static void addHashAlgoNameMap(Map<ASN1ObjectIdentifier, String> oidNameMap, Map<String, HashAlgo> nameOidMap, HashAlgo hashAlgo, String... names) { oidNameMap.put(hashAlgo.getOid(), names[0].toUpperCase()); nameOidMap.put(hashAlgo.getOid().getId(), hashAlgo); for (String name : names) { nameOidMap.put(name.toUpperCase(), hashAlgo); } }
public static ASN1ObjectIdentifier getHashAlg(String hashAlgName) throws NoSuchAlgorithmException { Args.notBlank(hashAlgName, "hashAlgName"); HashAlgo hashAlgo = HashAlgo.getInstance(hashAlgName.toUpperCase()); if (hashAlgo == null) { throw new NoSuchAlgorithmException("Unsupported hash algorithm " + hashAlgName); } return hashAlgo.getOid(); } // method getHashAlg
PbmMacCmpResponder(X500Name x500Name, List<String> owfs, List<String> macs) { super(x500Name); this.owfAlgos = new ArrayList<>(owfs.size()); for (int i = 0; i < owfs.size(); i++) { String algo = owfs.get(i); HashAlgo ha; try { ha = HashAlgo.getNonNullInstance(algo); } catch (Exception ex) { throw new IllegalArgumentException("invalid owf " + algo, ex); } owfAlgos.add(ha.getOid()); } this.macAlgos = new ArrayList<>(macs.size()); for (int i = 0; i < macs.size(); i++) { String algo = macs.get(i); AlgorithmIdentifier algId; try { algId = AlgorithmUtil.getMacAlgId(algo); } catch (NoSuchAlgorithmException ex) { throw new IllegalArgumentException("invalid mac" + algo, ex); } macAlgos.add(algId.getAlgorithm()); } }
requestPbmOwfs.add(ha.getOid());
requestPbmOwfs.add(ha.getOid());
public static AlgorithmIdentifier extractDigesetAlgFromSigAlg(AlgorithmIdentifier sigAlgId) throws NoSuchAlgorithmException { ASN1ObjectIdentifier algOid = sigAlgId.getAlgorithm(); ASN1ObjectIdentifier digestAlgOid; if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(algOid)) { ASN1Encodable asn1Encodable = sigAlgId.getParameters(); RSASSAPSSparams param = RSASSAPSSparams.getInstance(asn1Encodable); digestAlgOid = param.getHashAlgorithm().getAlgorithm(); } else { HashAlgo digestAlg = sigAlgOidToDigestMap.get(algOid); if (digestAlg == null) { throw new NoSuchAlgorithmException("unknown signature algorithm " + algOid.getId()); } digestAlgOid = digestAlg.getOid(); } return new AlgorithmIdentifier(digestAlgOid, DERNull.INSTANCE); } // method extractDigesetAlgorithmIdentifier
private static RSASSAPSSparams createPSSRSAParams(HashAlgo digestAlg) throws NoSuchAlgorithmException { int saltSize = Args.notNull(digestAlg, "digestAlg").getLength(); AlgorithmIdentifier digAlgId = new AlgorithmIdentifier(digestAlg.getOid(), DERNull.INSTANCE); return new RSASSAPSSparams(digAlgId, new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, digAlgId), new ASN1Integer(saltSize), RSASSAPSSparams.DEFAULT_TRAILER_FIELD); } // method createPSSRSAParams
buildAlgId(hashAlgo.getOid())); } else { throw new IllegalArgumentException("unknown type of key " + key.getClass().getName());
buildAlgId(hashAlgo.getOid())); } else { throw new IllegalArgumentException("unknown type of key " + key.getClass().getName());
AlgorithmIdentifier hashAlgorithm = AlgorithmIdentifier.getInstance(algId.getParameters()); if (!hashAlgorithm.getAlgorithm().equals(HashAlgo.SHA1.getOid())) { throw new XiSecurityException("unsupported KeyDerivationFunction.HashAlgorithm " + hashAlgorithm.getAlgorithm().getId()); AlgorithmIdentifier hashAlgorithm = AlgorithmIdentifier.getInstance(algId.getParameters()); if (!hashAlgorithm.getAlgorithm().equals(HashAlgo.SHA1.getOid())) { throw new XiSecurityException("unsupported MessageAuthenticationCode.HashAlgorithm " + hashAlgorithm.getAlgorithm().getId());