--- old/src/jdk.crypto.ec/share/classes/sun/security/ec/SunEC.java 2018-03-09 11:19:21.810014000 -0500 +++ new/src/jdk.crypto.ec/share/classes/sun/security/ec/SunEC.java 2018-03-09 11:19:21.406014000 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -30,7 +30,7 @@ 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; /** @@ -119,6 +119,8 @@ } 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")) { @@ -127,10 +129,18 @@ } 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) { @@ -205,6 +215,8 @@ 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 @@ -272,4 +284,31 @@ putService(new ProviderService(this, "KeyAgreement", "ECDH", "sun.security.ec.ECDHKeyAgreement", null, ATTRS)); } + + private void putXDHEntries() { + + HashMap 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)); + + } }