src/jdk.crypto.ec/share/classes/sun/security/ec/XECParameters.java
changeset 55353 946f7f2d321c
parent 50053 9bc1e6487cbb
equal deleted inserted replaced
55352:1357c4996b2e 55353:946f7f2d321c
     1 /*
     1 /*
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   154         ObjectIdentifier oid = new ObjectIdentifier(oidBytes);
   154         ObjectIdentifier oid = new ObjectIdentifier(oidBytes);
   155         XECParameters params =
   155         XECParameters params =
   156             new XECParameters(bits, p, a24, basePoint, logCofactor, oid, name);
   156             new XECParameters(bits, p, a24, basePoint, logCofactor, oid, name);
   157         bySize.put(bits, params);
   157         bySize.put(bits, params);
   158         byOid.put(oid, params);
   158         byOid.put(oid, params);
   159         byName.put(name, params);
   159         byName.put(name.toLowerCase(), params);
   160     }
   160     }
   161 
   161 
   162     public static Optional<XECParameters> getByOid(ObjectIdentifier id) {
   162     public static Optional<XECParameters> getByOid(ObjectIdentifier id) {
   163         return Optional.ofNullable(OID_MAP.get(id));
   163         return Optional.ofNullable(OID_MAP.get(id));
   164     }
   164     }
   165     public static Optional<XECParameters> getBySize(int size) {
   165     public static Optional<XECParameters> getBySize(int size) {
   166         return Optional.ofNullable(SIZE_MAP.get(size));
   166         return Optional.ofNullable(SIZE_MAP.get(size));
   167     }
   167     }
   168     public static Optional<XECParameters> getByName(String name) {
   168     public static Optional<XECParameters> getByName(String name) {
   169         return Optional.ofNullable(NAME_MAP.get(name));
   169         return Optional.ofNullable(NAME_MAP.get(name.toLowerCase()));
   170     }
   170     }
   171 
   171 
   172     boolean oidEquals(XECParameters other) {
   172     boolean oidEquals(XECParameters other) {
   173         return oid.equals(other.getOid());
   173         return oid.equals(other.getOid());
   174     }
   174     }