From bd7709d55ad83ec2186c24c927ccc3363180bb3f3a220f8300141fb704da28c0 Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Wed, 1 Mar 2017 08:14:24 +0000 Subject: [PATCH 1/3] Accepting request 459445 from home:gladiac:branches:Java:Factory Add a test to check that ECC is working OBS-URL: https://build.opensuse.org/request/show/459445 OBS-URL: https://build.opensuse.org/package/show/Java:Factory/java-1_8_0-openjdk?expand=0&rev=211 --- TestECDSA.java | 49 ++++++++++++++++++++++++++++++++++++++ java-1_8_0-openjdk.changes | 5 ++++ java-1_8_0-openjdk.spec | 11 +++++++++ 3 files changed, 65 insertions(+) create mode 100644 TestECDSA.java diff --git a/TestECDSA.java b/TestECDSA.java new file mode 100644 index 0000000..ca7fe59 --- /dev/null +++ b/TestECDSA.java @@ -0,0 +1,49 @@ +/* TestECDSA -- Ensure ECDSA signatures are working. + Copyright (C) 2016 Red Hat, Inc. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ + +import java.math.BigInteger; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.Signature; + +/** + * @test + */ +public class TestECDSA { + + public static void main(String[] args) throws Exception { + KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC"); + KeyPair key = keyGen.generateKeyPair(); + + byte[] data = "This is a string to sign".getBytes("UTF-8"); + + Signature dsa = Signature.getInstance("NONEwithECDSA"); + dsa.initSign(key.getPrivate()); + dsa.update(data); + byte[] sig = dsa.sign(); + System.out.println("Signature: " + new BigInteger(1, sig).toString(16)); + + Signature dsaCheck = Signature.getInstance("NONEwithECDSA"); + dsaCheck.initVerify(key.getPublic()); + dsaCheck.update(data); + boolean success = dsaCheck.verify(sig); + if (!success) { + throw new RuntimeException("Test failed. Signature verification error"); + } + System.out.println("Test passed."); + } +} diff --git a/java-1_8_0-openjdk.changes b/java-1_8_0-openjdk.changes index 3d390fd..9992c86 100644 --- a/java-1_8_0-openjdk.changes +++ b/java-1_8_0-openjdk.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Feb 21 07:18:27 UTC 2017 - asn@cryptomilk.org + +- Add a test to check that ECC is working + ------------------------------------------------------------------- Wed Feb 1 12:54:10 UTC 2017 - fstrba@suse.com diff --git a/java-1_8_0-openjdk.spec b/java-1_8_0-openjdk.spec index 4112fa6..bc141ce 100644 --- a/java-1_8_0-openjdk.spec +++ b/java-1_8_0-openjdk.spec @@ -187,6 +187,10 @@ Source6: http://icedtea.classpath.org/download/drops/icedtea8/%{icedtea_v Source7: http://icedtea.classpath.org/download/drops/icedtea8/%{icedtea_version}/langtools.tar.xz Source8: http://icedtea.classpath.org/download/drops/icedtea8/%{icedtea_version}/hotspot.tar.xz Source9: http://icedtea.classpath.org/download/drops/icedtea8/%{icedtea_version}/nashorn.tar.xz + +# Test +Source10: TestECDSA.java + # RPM/distribution specific patches # RHBZ 1015432 Patch2: 1015432.patch @@ -874,6 +878,13 @@ then update-alternatives --remove jre_%{javaver} %{_jvmdir}/%{jrelnk} fi +%check +export JAVA_HOME=$(pwd)/%{buildoutputdir}images/j2sdk-image + +# Check ECC is working +$JAVA_HOME/bin/javac -d . %{SOURCE10} +$JAVA_HOME/bin/java TestECDSA + %if 0%{?suse_version} >= 1130 %posttrans headless # bnc#781690#c11: don't trust user defined JAVA_HOME and use the current VM From 66b054abbd77ff587684cc94626809204634e050876b4a2545c90d3bb4ac671c Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Wed, 1 Mar 2017 08:23:45 +0000 Subject: [PATCH 2/3] OBS-URL: https://build.opensuse.org/package/show/Java:Factory/java-1_8_0-openjdk?expand=0&rev=212 --- java-1_8_0-openjdk.spec | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/java-1_8_0-openjdk.spec b/java-1_8_0-openjdk.spec index bc141ce..41b4efd 100644 --- a/java-1_8_0-openjdk.spec +++ b/java-1_8_0-openjdk.spec @@ -138,16 +138,12 @@ %if 0%{?__isa_bits} %global bits %{__isa_bits} %endif -%bcond_with zero %if 0%{?suse_version} >= 1330 || 0%{?suse_version} == 1315 -%if %{with bootstrap} -%global with_sunec 0 -%else %global with_sunec 1 -%endif %else %global with_sunec 0 %endif +%bcond_with zero # Turn on/off some features depending on openSUSE version %if 0%{?suse_version} >= 1130 %if ! %{with zero} @@ -187,10 +183,8 @@ Source6: http://icedtea.classpath.org/download/drops/icedtea8/%{icedtea_v Source7: http://icedtea.classpath.org/download/drops/icedtea8/%{icedtea_version}/langtools.tar.xz Source8: http://icedtea.classpath.org/download/drops/icedtea8/%{icedtea_version}/hotspot.tar.xz Source9: http://icedtea.classpath.org/download/drops/icedtea8/%{icedtea_version}/nashorn.tar.xz - # Test Source10: TestECDSA.java - # RPM/distribution specific patches # RHBZ 1015432 Patch2: 1015432.patch @@ -878,6 +872,7 @@ then update-alternatives --remove jre_%{javaver} %{_jvmdir}/%{jrelnk} fi +%if %{with_sunec} %check export JAVA_HOME=$(pwd)/%{buildoutputdir}images/j2sdk-image @@ -885,6 +880,8 @@ export JAVA_HOME=$(pwd)/%{buildoutputdir}images/j2sdk-image $JAVA_HOME/bin/javac -d . %{SOURCE10} $JAVA_HOME/bin/java TestECDSA +%endif + %if 0%{?suse_version} >= 1130 %posttrans headless # bnc#781690#c11: don't trust user defined JAVA_HOME and use the current VM From d4342f531d28f874ddf95e02e9cd6ccd08ef43b2c85d9e502fe58c116120728b Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Wed, 1 Mar 2017 08:44:32 +0000 Subject: [PATCH 3/3] OBS-URL: https://build.opensuse.org/package/show/Java:Factory/java-1_8_0-openjdk?expand=0&rev=213 --- java-1_8_0-openjdk.changes | 8 ++++++++ java-1_8_0-openjdk.spec | 20 +++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/java-1_8_0-openjdk.changes b/java-1_8_0-openjdk.changes index 9992c86..a040ec5 100644 --- a/java-1_8_0-openjdk.changes +++ b/java-1_8_0-openjdk.changes @@ -1,7 +1,15 @@ +------------------------------------------------------------------- +Wed Mar 1 08:41:19 UTC 2017 - fstrba@suse.com + +- Fix build of Sun Elliptical Curves Crypto provider on Tumbleweed. + Fixes bsc#1026102. +- Clean the mozilla-nss requires and move them into the headless + ------------------------------------------------------------------- Tue Feb 21 07:18:27 UTC 2017 - asn@cryptomilk.org - Add a test to check that ECC is working + * new file TestECDSA.java ------------------------------------------------------------------- Wed Feb 1 12:54:10 UTC 2017 - fstrba@suse.com diff --git a/java-1_8_0-openjdk.spec b/java-1_8_0-openjdk.spec index 41b4efd..0b90dbd 100644 --- a/java-1_8_0-openjdk.spec +++ b/java-1_8_0-openjdk.spec @@ -232,12 +232,6 @@ BuildRequires: zip # Requires rest of java Requires: %{name}-headless = %{version}-%{release} Requires: fontconfig -# mozilla-nss has to be installed to prevent -# java.security.ProviderException: Could not initialize NSS -# ... -# java.io.FileNotFoundException: /usr/lib64/libnss3.so -#was bnc#634793 -Requires: mozilla-nss # Standard JPackage base provides. Provides: java = %{javaver} Provides: java-%{javaver} = %{version}-%{release} @@ -319,7 +313,6 @@ Summary: OpenJDK 8 Runtime Environment # Require jpackage-utils for ownership of /usr/lib/jvm/ Group: Development/Languages/Java Requires: jpackage-utils -%requires_eq mozilla-nss # Post requires update-alternatives to install tool update-alternatives. Requires(post): update-alternatives # Postun requires update-alternatives to uninstall tool update-alternatives. @@ -343,6 +336,19 @@ Provides: jndi-dns = %{version} Provides: jndi-ldap = %{version} Provides: jndi-rmi = %{version} Provides: jsse = %{version} +# mozilla-nss has to be installed to prevent +# java.security.ProviderException: Could not initialize NSS +# ... +# java.io.FileNotFoundException: /usr/lib64/libnss3.so +#was bnc#634793 +%if %{with sunec} +# The SunEC built against system NSS uses private APIs that +# change from time to time. Require thus the version we built +# against. +%requires_eq mozilla-nss +%else +Requires: mozilla-nss +%endif %if 0%{?suse_version} > 1320 # Require zoneinfo data in java8+ format provided by tzdata-java8 subpackage. Requires(post): tzdata-java8