forked from pool/java-1_8_0-openjdk
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
This commit is contained in:
parent
74c6946a69
commit
bd7709d55a
49
TestECDSA.java
Normal file
49
TestECDSA.java
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
Wed Feb 1 12:54:10 UTC 2017 - fstrba@suse.com
|
||||||
|
|
||||||
|
@ -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
|
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
|
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
|
Source9: http://icedtea.classpath.org/download/drops/icedtea8/%{icedtea_version}/nashorn.tar.xz
|
||||||
|
|
||||||
|
# Test
|
||||||
|
Source10: TestECDSA.java
|
||||||
|
|
||||||
# RPM/distribution specific patches
|
# RPM/distribution specific patches
|
||||||
# RHBZ 1015432
|
# RHBZ 1015432
|
||||||
Patch2: 1015432.patch
|
Patch2: 1015432.patch
|
||||||
@ -874,6 +878,13 @@ then
|
|||||||
update-alternatives --remove jre_%{javaver} %{_jvmdir}/%{jrelnk}
|
update-alternatives --remove jre_%{javaver} %{_jvmdir}/%{jrelnk}
|
||||||
fi
|
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
|
%if 0%{?suse_version} >= 1130
|
||||||
%posttrans headless
|
%posttrans headless
|
||||||
# bnc#781690#c11: don't trust user defined JAVA_HOME and use the current VM
|
# bnc#781690#c11: don't trust user defined JAVA_HOME and use the current VM
|
||||||
|
Loading…
x
Reference in New Issue
Block a user