Sync from SUSE:SLFO:Main ed25519-java revision 9027ad5770ef8acd03465f323d02b4fe

This commit is contained in:
Adrian Schröter 2024-05-31 15:24:49 +02:00
commit 44c34878a1
6 changed files with 221 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

View File

@ -0,0 +1,37 @@
From c5629faa3e1880cc71da506263f224bc818fe827 Mon Sep 17 00:00:00 2001
From: Jack Grigg <thestr4d@gmail.com>
Date: Sun, 27 Jan 2019 23:27:00 +0000
Subject: [PATCH 1/2] EdDSAEngine.initVerify(): Handle any non-EdDSAPublicKey
X.509-encoded pubkey
sun.security.x509.X509Key is a JDK-internal API, and should not be used
directly. Instead of looking for an instance of that class, we check the
primary encoding format of the PublicKey, and proceed if it is "X.509".
---
src/net/i2p/crypto/eddsa/EdDSAEngine.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/net/i2p/crypto/eddsa/EdDSAEngine.java b/src/net/i2p/crypto/eddsa/EdDSAEngine.java
index 1f0ba6d..6b25410 100644
--- a/src/net/i2p/crypto/eddsa/EdDSAEngine.java
+++ b/src/net/i2p/crypto/eddsa/EdDSAEngine.java
@@ -29,7 +29,6 @@ import java.util.Arrays;
import net.i2p.crypto.eddsa.math.Curve;
import net.i2p.crypto.eddsa.math.GroupElement;
import net.i2p.crypto.eddsa.math.ScalarOps;
-import sun.security.x509.X509Key;
/**
* Signing and verification for EdDSA.
@@ -157,7 +156,7 @@ public final class EdDSAEngine extends Signature {
}
} else if (!key.getParams().getHashAlgorithm().equals(digest.getAlgorithm()))
throw new InvalidKeyException("Key hash algorithm does not match chosen digest");
- } else if (publicKey instanceof X509Key) {
+ } else if (publicKey.getFormat().equals("X.509")) {
// X509Certificate will sometimes contain an X509Key rather than the EdDSAPublicKey itself; the contained
// key is valid but needs to be instanced as an EdDSAPublicKey before it can be used.
EdDSAPublicKey parsedPublicKey;
--
2.33.1

View File

@ -0,0 +1,46 @@
From 1ea7fb5ed949d8a458fda40b186868b7cffbb271 Mon Sep 17 00:00:00 2001
From: Mat Booth <mat.booth@gmail.com>
Date: Wed, 1 Dec 2021 09:35:10 +0000
Subject: [PATCH 2/2] Disable test that relies on internal sun JDK classes
---
test/net/i2p/crypto/eddsa/EdDSAEngineTest.java | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/test/net/i2p/crypto/eddsa/EdDSAEngineTest.java b/test/net/i2p/crypto/eddsa/EdDSAEngineTest.java
index 2ed793b..adc46fd 100644
--- a/test/net/i2p/crypto/eddsa/EdDSAEngineTest.java
+++ b/test/net/i2p/crypto/eddsa/EdDSAEngineTest.java
@@ -31,8 +31,6 @@ import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import sun.security.util.DerValue;
-import sun.security.x509.X509Key;
/**
* @author str4d
@@ -217,20 +215,4 @@ public class EdDSAEngineTest {
assertThat("verifyOneShot() failed", sgr.verifyOneShot(TEST_MSG, TEST_MSG_SIG), is(true));
}
- @Test
- public void testVerifyX509PublicKeyInfo() throws Exception {
- EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName("Ed25519");
- Signature sgr = new EdDSAEngine(MessageDigest.getInstance(spec.getHashAlgorithm()));
- for (Ed25519TestVectors.TestTuple testCase : Ed25519TestVectors.testCases) {
- EdDSAPublicKeySpec pubKey = new EdDSAPublicKeySpec(testCase.pk, spec);
- PublicKey vKey = new EdDSAPublicKey(pubKey);
- PublicKey x509Key = X509Key.parse(new DerValue(vKey.getEncoded()));
- sgr.initVerify(x509Key);
-
- sgr.update(testCase.message);
-
- assertThat("Test case " + testCase.caseNum + " failed",
- sgr.verify(testCase.sig), is(true));
- }
- }
}
--
2.33.1

BIN
ed25519-java-0.3.0.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

23
ed25519-java.changes Normal file
View File

@ -0,0 +1,23 @@
-------------------------------------------------------------------
Wed Feb 21 10:42:44 UTC 2024 - Gus Kenion <gus.kenion@suse.com>
- Use %patch -P N instead of deprecated %patchN.
-------------------------------------------------------------------
Mon Sep 11 10:01:59 UTC 2023 - Fridrich Strba <fstrba@suse.com>
- Reproducible builds: use SOURCE_DATE_EPOCH for timestamp
-------------------------------------------------------------------
Tue Mar 22 08:08:13 UTC 2022 - Fridrich Strba <fstrba@suse.com>
- Build with source and target levels 8
- Added patches:
* 0001-EdDSAEngine.initVerify-Handle-any-non-EdDSAPublicKey.patch
* 0002-Disable-test-that-relies-on-internal-sun-JDK-classes.patch
+ Remove use of internal sun JDK classes
-------------------------------------------------------------------
Mon Jun 29 11:08:23 UTC 2020 - Fridrich Strba <fstrba@suse.com>
- Initial packaging of ed25519 0.3.0

89
ed25519-java.spec Normal file
View File

@ -0,0 +1,89 @@
#
# spec file for package ed25519-java
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: ed25519-java
Version: 0.3.0
Release: 0
Summary: Implementation of EdDSA (Ed25519) in Java
License: CC0-1.0
URL: https://github.com/str4d/ed25519-java
Source0: https://github.com/str4d/ed25519-java/archive/v%{version}/%{name}-%{version}.tar.gz
Patch0: 0001-EdDSAEngine.initVerify-Handle-any-non-EdDSAPublicKey.patch
Patch1: 0002-Disable-test-that-relies-on-internal-sun-JDK-classes.patch
BuildRequires: fdupes
BuildRequires: java-devel >= 1.8
BuildRequires: maven-local
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildArch: noarch
%description
This is an implementation of EdDSA in Java. Structurally, it
is based on the ref10 implementation in SUPERCOP (see
http://ed25519.cr.yp.to/software.html).
There are two internal implementations:
* A port of the radix-2^51 operations in ref10
- fast and constant-time, but only useful for Ed25519.
* A generic version using BigIntegers for calculation
- a bit slower and not constant-time, but compatible
with any EdDSA parameter specification.
%package javadoc
Summary: Javadoc for %{name}
%description javadoc
This package contains javadoc for %{name}.
%prep
%setup -q
%patch -P 0 -p1
%patch -P 1 -p1
# Unwanted tasks
%pom_remove_plugin :maven-gpg-plugin
%pom_remove_plugin :maven-javadoc-plugin
%pom_remove_plugin :maven-source-plugin
# Unavailable plugin
%pom_remove_plugin :nexus-staging-maven-plugin
# Make dep on sun.security.x509 optional, inject an Import-Package directive
%pom_xpath_inject "pom:configuration/pom:instructions" \
"<Import-Package>sun.security.x509;resolution:=optional,*</Import-Package>"
%{mvn_file} net.i2p.crypto:eddsa %{name} eddsa
%build
%{mvn_build} -f -- \
%if %{?pkg_vcmp:%pkg_vcmp java-devel >= 9}%{!?pkg_vcmp:0}
-Dmaven.compiler.release=8 \
%endif
-Dproject.build.outputTimestamp=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ) \
-Dsource=8
%install
%mvn_install
%fdupes -s %{buildroot}%{_javadocdir}
%files -f .mfiles
%doc README.md
%license LICENSE.txt
%files javadoc -f .mfiles-javadoc
%license LICENSE.txt
%changelog