private HashAlgo(int length, AlgorithmCode algorithmCode, String oid, String name) { this.length = length; this.algorithmCode = algorithmCode; this.oid = new ASN1ObjectIdentifier(oid).intern(); this.algId = new AlgorithmIdentifier(this.oid, DERNull.INSTANCE); this.name = name; try { this.encoded = new ASN1ObjectIdentifier(oid).getEncoded(); } catch (IOException ex) { throw new IllegalArgumentException("invalid oid: " + oid); } }
@Override public void addSymbol(String oid, String... names) { ASN1ObjectIdentifier asn1ObjectIdentifier = new ASN1ObjectIdentifier(oid).intern(); if(defaultSymbols.contains(asn1ObjectIdentifier)) { throw new IllegalArgumentException("OID '" + oid + "' already registered"); } for(String name : names){ ASN1ObjectIdentifier exist = (ASN1ObjectIdentifier) defaultLookUp.get(Strings.toLowerCase(name)); if(exist!=null) { throw new IllegalArgumentException("Name '" + name + "' already registered"); } } boolean first = true; for(String name:names) { if(first) { defaultSymbols.put(asn1ObjectIdentifier, name); first = false; } defaultLookUp.put(name, asn1ObjectIdentifier); } updateKeyWordsMap(); }
private HashAlgoType(final int length, final AlgorithmCode algorithmCode, final String oid, final String name, final String shortName) { this.length = length; this.algorithmCode = algorithmCode; this.oid = new ASN1ObjectIdentifier(oid).intern(); this.algId = new AlgorithmIdentifier(this.oid, DERNull.INSTANCE); this.name = name; this.shortName = shortName; try { this.encoded = new ASN1ObjectIdentifier(oid).getEncoded(); } catch (IOException ex) { throw new IllegalArgumentException("invalid oid: " + oid); } }
public static DigestCalculator sha256() { Digest digest = new SHA256Digest(); // The OID for SHA-256: http://www.oid-info.com/get/2.16.840.1.101.3.4.2.1 ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier( "2.16.840.1.101.3.4.2.1").intern(); AlgorithmIdentifier algId = new AlgorithmIdentifier(oid); return new Digester(digest, algId); }