< prev index next >

src/jdk.crypto.ec/share/classes/sun/security/ec/SunEC.java

Print this page
rev 48796 : code cleanup

*** 1,7 **** /* ! * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 28,38 **** import java.util.*; import java.security.*; import java.util.regex.Pattern; import sun.security.util.CurveDB; import sun.security.util.NamedCurve; ! import sun.security.util.ECParameters; import static sun.security.util.SecurityConstants.PROVIDER_VER; /** * Provider class for the Elliptic Curve provider. * Supports EC keypair and parameter generation, ECDSA signing and --- 28,38 ---- import java.util.*; import java.security.*; import java.util.regex.Pattern; import sun.security.util.CurveDB; import sun.security.util.NamedCurve; ! import static sun.security.util.SecurityConstants.PROVIDER_VER; /** * Provider class for the Elliptic Curve provider. * Supports EC keypair and parameter generation, ECDSA signing and
*** 117,138 **** --- 117,148 ---- new ECDSASignature.Raw()); } } else if (type.equals("KeyFactory")) { if (algo.equals("EC")) { return new ECKeyFactory(); + } else if (algo.equals("XDH")) { + return new XDHKeyFactory(); } } else if (type.equals("AlgorithmParameters")) { if (algo.equals("EC")) { return new sun.security.util.ECParameters(); } } else if (type.equals("KeyPairGenerator")) { if (algo.equals("EC")) { return new ECKeyPairGenerator(); + } else if (algo.equals("XDH")) { + return new XDHKeyPairGenerator(); + } else if (algo.equals("X25519")) { + return new XDHKeyPairGenerator.X25519(); + } else if (algo.equals("X448")) { + return new XDHKeyPairGenerator.X448(); } } else if (type.equals("KeyAgreement")) { if (algo.equals("ECDH")) { return new ECDHKeyAgreement(); + } else if (algo.equals("XDH")) { + return new XDHKeyAgreement(); } } } catch (Exception ex) { throw new NoSuchAlgorithmException("Error constructing " + type + " for " + algo + " using SunEC", ex);
*** 203,212 **** --- 213,224 ---- putService(new ProviderService(this, "AlgorithmParameters", "EC", "sun.security.util.ECParameters", new String[] { "EllipticCurve", "1.2.840.10045.2.1", "OID.1.2.840.10045.2.1" }, apAttrs)); + putXDHEntries(); + /* * Register the algorithms below only when the full ECC implementation * is available */ if (!useFullImplementation) {
*** 270,275 **** --- 282,314 ---- * Key Agreement engine */ putService(new ProviderService(this, "KeyAgreement", "ECDH", "sun.security.ec.ECDHKeyAgreement", null, ATTRS)); } + + private void putXDHEntries() { + + HashMap<String, String> ATTRS = new HashMap<>(1); + ATTRS.put("ImplementedIn", "Software"); + + putService(new ProviderService(this, "KeyFactory", + "XDH", "sun.security.ec.XDHKeyFactory", new String[]{ + "X25519", "1.3.101.110", "OID.1.3.101.110", + "X448", "1.3.101.111", "OID.1.3.101.111"}, ATTRS)); + + /* XDH does not require native implementation */ + putService(new ProviderService(this, "KeyPairGenerator", + "XDH", "sun.security.ec.XDHKeyPairGenerator", null, ATTRS)); + putService(new ProviderService(this, "KeyPairGenerator", + "X25519", "sun.security.ec.XDHKeyPairGenerator.X25519", + new String[]{"1.3.101.110", "OID.1.3.101.110"}, ATTRS)); + putService(new ProviderService(this, "KeyPairGenerator", + "X448", "sun.security.ec.XDHKeyPairGenerator.X448", + new String[]{"1.3.101.111", "OID.1.3.101.111"}, ATTRS)); + + putService(new ProviderService(this, "KeyAgreement", + "XDH", "sun.security.ec.XDHKeyAgreement", new String[]{ + "X25519", "1.3.101.110", "OID.1.3.101.110", + "X448", "1.3.101.111", "OID.1.3.101.111"}, ATTRS)); + + } }
< prev index next >