From 2b9bfecfa602083ba3123daae480bd902c40c3ef Mon Sep 17 00:00:00 2001 From: Ed Marshall Date: Jul 27 2018 01:08:09 +0000 Subject: Update to latest upstream, adjust patches, switch to forge-specific packaging. --- diff --git a/.gitignore b/.gitignore index 2a301f9..b16a36e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /go-crypto-433e2f3.tar.gz /go-crypto-8bab6ce.tar.gz +/go-crypto-670ebd3adf7a737d69ffe83a777a8e34eadc1b32.tar.gz diff --git a/go-crypto-670ebd3-bn256-ModInverse-fix.patch b/go-crypto-670ebd3-bn256-ModInverse-fix.patch new file mode 100644 index 0000000..f2aa855 --- /dev/null +++ b/go-crypto-670ebd3-bn256-ModInverse-fix.patch @@ -0,0 +1,98 @@ +diff --git a/bn256/bn256.go b/bn256/bn256.go +index bc96e3d..8fbf24b 100644 +--- a/bn256/bn256.go ++++ b/bn256/bn256.go +@@ -93,14 +93,18 @@ func (e *G1) Neg(a *G1) *G1 { + + // Marshal converts n to a byte slice. + func (n *G1) Marshal() []byte { ++ // Each value is a 256-bit number. ++ const numBytes = 256 / 8 ++ ++ if n.p.IsInfinity() { ++ return make([]byte, numBytes*2) ++ } ++ + n.p.MakeAffine(nil) + + xBytes := new(big.Int).Mod(n.p.x, p).Bytes() + yBytes := new(big.Int).Mod(n.p.y, p).Bytes() + +- // Each value is a 256-bit number. +- const numBytes = 256 / 8 +- + ret := make([]byte, numBytes*2) + copy(ret[1*numBytes-len(xBytes):], xBytes) + copy(ret[2*numBytes-len(yBytes):], yBytes) +@@ -201,6 +205,13 @@ func (e *G2) Add(a, b *G2) *G2 { + + // Marshal converts n into a byte slice. + func (n *G2) Marshal() []byte { ++ // Each value is a 256-bit number. ++ const numBytes = 256 / 8 ++ ++ if n.p.IsInfinity() { ++ return make([]byte, numBytes*4) ++ } ++ + n.p.MakeAffine(nil) + + xxBytes := new(big.Int).Mod(n.p.x.x, p).Bytes() +@@ -208,9 +219,6 @@ func (n *G2) Marshal() []byte { + yxBytes := new(big.Int).Mod(n.p.y.x, p).Bytes() + yyBytes := new(big.Int).Mod(n.p.y.y, p).Bytes() + +- // Each value is a 256-bit number. +- const numBytes = 256 / 8 +- + ret := make([]byte, numBytes*4) + copy(ret[1*numBytes-len(xxBytes):], xxBytes) + copy(ret[2*numBytes-len(xyBytes):], xyBytes) +diff --git a/bn256/curve.go b/bn256/curve.go +index 55b7063..63c052b 100644 +--- a/bn256/curve.go ++++ b/bn256/curve.go +@@ -245,10 +245,19 @@ func (c *curvePoint) Mul(a *curvePoint, scalar *big.Int, pool *bnPool) *curvePoi + return c + } + ++// MakeAffine converts c to affine form and returns c. If c is ∞, then it sets ++// c to 0 : 1 : 0. + func (c *curvePoint) MakeAffine(pool *bnPool) *curvePoint { + if words := c.z.Bits(); len(words) == 1 && words[0] == 1 { + return c + } ++ if c.IsInfinity() { ++ c.x.SetInt64(0) ++ c.y.SetInt64(1) ++ c.z.SetInt64(0) ++ c.t.SetInt64(0) ++ return c ++ } + + zInv := pool.Get().ModInverse(c.z, p) + t := pool.Get().Mul(c.y, zInv) +diff --git a/bn256/twist.go b/bn256/twist.go +index 4f8b3fe..056d80f 100644 +--- a/bn256/twist.go ++++ b/bn256/twist.go +@@ -219,10 +219,19 @@ func (c *twistPoint) Mul(a *twistPoint, scalar *big.Int, pool *bnPool) *twistPoi + return c + } + ++// MakeAffine converts c to affine form and returns c. If c is ∞, then it sets ++// c to 0 : 1 : 0. + func (c *twistPoint) MakeAffine(pool *bnPool) *twistPoint { + if c.z.IsOne() { + return c + } ++ if c.IsInfinity() { ++ c.x.SetZero() ++ c.y.SetOne() ++ c.z.SetZero() ++ c.t.SetZero() ++ return c ++ } + + zInv := newGFp2(pool).Invert(c.z, pool) + t := newGFp2(pool).Mul(c.y, zInv, pool) diff --git a/go-crypto-8bab6ce-go1.10-fixtests.patch b/go-crypto-8bab6ce-go1.10-fixtests.patch deleted file mode 100644 index e0e7151..0000000 --- a/go-crypto-8bab6ce-go1.10-fixtests.patch +++ /dev/null @@ -1,124 +0,0 @@ -From c9eb468035638d42332ed062597ed7bb90ac7125 Mon Sep 17 00:00:00 2001 -From: Ed Marshall -Date: Thu, 15 Mar 2018 00:07:45 -0700 -Subject: [PATCH] Fix test failures on Go 1.10. - ---- - ocsp/ocsp_test.go | 12 ++++++------ - openpgp/keys_test.go | 6 +++--- - openpgp/read_test.go | 2 +- - openpgp/write_test.go | 4 ++-- - 4 files changed, 12 insertions(+), 12 deletions(-) - -diff --git a/ocsp/ocsp_test.go b/ocsp/ocsp_test.go -index 338684973..c56269c62 100644 ---- a/ocsp/ocsp_test.go -+++ b/ocsp/ocsp_test.go -@@ -34,11 +34,11 @@ func TestOCSPDecode(t *testing.T) { - } - - if !reflect.DeepEqual(resp.ThisUpdate, expected.ThisUpdate) { -- t.Errorf("resp.ThisUpdate: got %d, want %d", resp.ThisUpdate, expected.ThisUpdate) -+ t.Errorf("resp.ThisUpdate: got %v, want %v", resp.ThisUpdate, expected.ThisUpdate) - } - - if !reflect.DeepEqual(resp.NextUpdate, expected.NextUpdate) { -- t.Errorf("resp.NextUpdate: got %d, want %d", resp.NextUpdate, expected.NextUpdate) -+ t.Errorf("resp.NextUpdate: got %v, want %v", resp.NextUpdate, expected.NextUpdate) - } - - if resp.Status != expected.Status { -@@ -220,15 +220,15 @@ func TestOCSPResponse(t *testing.T) { - } - - if !reflect.DeepEqual(resp.ThisUpdate, template.ThisUpdate) { -- t.Errorf("resp.ThisUpdate: got %d, want %d", resp.ThisUpdate, template.ThisUpdate) -+ t.Errorf("resp.ThisUpdate: got %v, want %v", resp.ThisUpdate, template.ThisUpdate) - } - - if !reflect.DeepEqual(resp.NextUpdate, template.NextUpdate) { -- t.Errorf("resp.NextUpdate: got %d, want %d", resp.NextUpdate, template.NextUpdate) -+ t.Errorf("resp.NextUpdate: got %v, want %v", resp.NextUpdate, template.NextUpdate) - } - - if !reflect.DeepEqual(resp.RevokedAt, template.RevokedAt) { -- t.Errorf("resp.RevokedAt: got %d, want %d", resp.RevokedAt, template.RevokedAt) -+ t.Errorf("resp.RevokedAt: got %v, want %v", resp.RevokedAt, template.RevokedAt) - } - - if !reflect.DeepEqual(resp.Extensions, template.ExtraExtensions) { -@@ -236,7 +236,7 @@ func TestOCSPResponse(t *testing.T) { - } - - if !resp.ProducedAt.Equal(producedAt) { -- t.Errorf("resp.ProducedAt: got %d, want %d", resp.ProducedAt, producedAt) -+ t.Errorf("resp.ProducedAt: got %v, want %v", resp.ProducedAt, producedAt) - } - - if resp.Status != template.Status { -diff --git a/openpgp/keys_test.go b/openpgp/keys_test.go -index f54df23c6..f193f5b5a 100644 ---- a/openpgp/keys_test.go -+++ b/openpgp/keys_test.go -@@ -55,7 +55,7 @@ func TestMissingCrossSignature(t *testing.T) { - t.Errorf("Should have gotten 1 key; got %d", len(keys)) - } - if err != nil { -- t.Errorf("Should not have failed, but got: %v\n") -+ t.Errorf("Should not have failed, but got: %v\n", err) - } - - key := keys[0] -@@ -88,7 +88,7 @@ func TestInvalidCrossSignature(t *testing.T) { - t.Errorf("Should have gotten 1 key; got %d", len(keys)) - } - if err != nil { -- t.Errorf("Should not have failed, but got: %v\n") -+ t.Errorf("Should not have failed, but got: %v\n", err) - } - - key := keys[0] -@@ -331,7 +331,7 @@ func TestKeyWithoutUID(t *testing.T) { - if se, ok := err.(pgpErrors.StructuralError); !ok { - t.Fatal("expected a structural error") - } else if strings.Index(se.Error(), "entity without any identities") < 0 { -- t.Fatal("Got wrong error: %s", se.Error()) -+ t.Fatalf("Got wrong error: %s", se.Error()) - } - } - -diff --git a/openpgp/read_test.go b/openpgp/read_test.go -index 4568637e4..d57f2e09c 100644 ---- a/openpgp/read_test.go -+++ b/openpgp/read_test.go -@@ -494,7 +494,7 @@ func TestGNUS2KDummySigningSubkey(t *testing.T) { - key := testSerializePrivate(t, gnuDummyS2KPrivateKeyWithSigningSubkey, gnuDummyS2KPrivateKeyWithSigningSubkeyPassphrase, 2) - _, err := trySigning(key) - if err != nil { -- t.Fatal("Got a signing failure: %s\n", err) -+ t.Fatalf("Got a signing failure: %v\n", err) - } - } - -diff --git a/openpgp/write_test.go b/openpgp/write_test.go -index fae436ceb..c661fcacb 100644 ---- a/openpgp/write_test.go -+++ b/openpgp/write_test.go -@@ -176,7 +176,7 @@ func TestNewEntity(t *testing.T) { - t.Errorf("failed to find bit length: %s", err) - } - if int(bl) != defaultRSAKeyBits { -- t.Errorf("BitLength %v, expected %v", defaultRSAKeyBits) -+ t.Errorf("BitLength %v, expected %v", bl, defaultRSAKeyBits) - } - - // Check bit-length with a config. -@@ -334,7 +334,7 @@ func TestEncryption(t *testing.T) { - signKey, _ := kring[0].signingKey(testTime) - expectedKeyId := signKey.PublicKey.KeyId - if md.SignedByKeyId != expectedKeyId { -- t.Errorf("#%d: message signed by wrong key id, got: %d, want: %d", i, *md.SignedBy, expectedKeyId) -+ t.Errorf("#%d: message signed by wrong key id, got: %d, want: %d", i, md.SignedByKeyId, expectedKeyId) - } - if md.SignedBy == nil { - t.Errorf("#%d: failed to find the signing Entity", i) diff --git a/golang-github-keybase-go-crypto.spec b/golang-github-keybase-go-crypto.spec index 8e00c79..bcb541f 100644 --- a/golang-github-keybase-go-crypto.spec +++ b/golang-github-keybase-go-crypto.spec @@ -1,268 +1,68 @@ -# If any of the following macros should be set otherwise, -# you can wrap any of them with the following conditions: -# - %%if 0%%{centos} == 7 -# - %%if 0%%{?rhel} == 7 -# - %%if 0%%{?fedora} == 23 -# Or just test for particular distribution: -# - %%if 0%%{centos} -# - %%if 0%%{?rhel} -# - %%if 0%%{?fedora} -# -# Be aware, on centos, both %%rhel and %%centos are set. If you want to test -# rhel specific macros, you can use %%if 0%%{?rhel} && 0%%{?centos} == 0 condition. -# (Don't forget to replace double percentage symbol with single one in order to apply a condition) - -# Generate devel rpm -%global with_devel 1 -# Build project from bundled dependencies -%global with_bundled 0 -# Build with debug info rpm -%global with_debug 0 -# Run tests in check section -%global with_check 1 -# Generate unit-test rpm -%global with_unit_test 1 +# https://github.com/keybase/go-crypto -%if 0%{?with_debug} -%global _dwz_low_mem_die_limit 0 -%else -%global debug_package %{nil} -%endif +%global goipath github.com/keybase/go-crypto +%global commit 670ebd3adf7a737d69ffe83a777a8e34eadc1b32 +%global common_description %{expand: +A fork of the Go supplementary cryptography libraries.} -%global provider github -%global provider_tld com -%global project keybase -%global repo go-crypto -# https://github.com/keybase/go-crypto -%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} -%global import_path %{provider_prefix} -%global commit 8bab6ce2ea76875dcf28c287110f9cdf17fee30c -%global commitdate 20180130 -%global shortcommit %(c=%{commit}; echo ${c:0:7}) +%gometa -Name: golang-%{provider}-%{project}-%{repo} +Name: %{goname} Version: 0 -Release: 0.2.%{commitdate}git%{shortcommit}%{?dist} +Release: 0.3%{?dist} Summary: Supplementary Go cryptography libraries (Keybase fork) -# Detected licences -# - BSD (3 clause) at 'LICENSE' License: BSD -URL: https://%{provider_prefix} -Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz - -# Fix tests for Go 1.10 -# https://github.com/keybase/go-crypto/pull/63 -Patch0: go-crypto-8bab6ce-go1.10-fixtests.patch - -# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required -ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm}} -# If go_compiler is not set to 1, there is no virtual provide. Use golang instead. -BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} - +URL: %{gourl} +Source0: %{gosource} +# Backported from upstream project to fix test failures with bn256: +# https://github.com/golang/crypto/commit/8b1d31080a7692e075c4681cb2458454a1fe0706 +Patch0: go-crypto-670ebd3-bn256-ModInverse-fix.patch %description -%{summary} +%{common_description} + -%if 0%{?with_devel} %package devel Summary: %{summary} -BuildArch: noarch - -%if 0%{?with_check} && ! 0%{?with_bundled} -%endif - - -Provides: golang(%{import_path}/bcrypt) = %{version}-%{release} -Provides: golang(%{import_path}/blowfish) = %{version}-%{release} -Provides: golang(%{import_path}/bn256) = %{version}-%{release} -Provides: golang(%{import_path}/brainpool) = %{version}-%{release} -Provides: golang(%{import_path}/cast5) = %{version}-%{release} -Provides: golang(%{import_path}/curve25519) = %{version}-%{release} -Provides: golang(%{import_path}/ed25519) = %{version}-%{release} -Provides: golang(%{import_path}/hkdf) = %{version}-%{release} -Provides: golang(%{import_path}/md4) = %{version}-%{release} -Provides: golang(%{import_path}/nacl/box) = %{version}-%{release} -Provides: golang(%{import_path}/nacl/secretbox) = %{version}-%{release} -Provides: golang(%{import_path}/ocsp) = %{version}-%{release} -Provides: golang(%{import_path}/openpgp) = %{version}-%{release} -Provides: golang(%{import_path}/openpgp/armor) = %{version}-%{release} -Provides: golang(%{import_path}/openpgp/clearsign) = %{version}-%{release} -Provides: golang(%{import_path}/openpgp/ecdh) = %{version}-%{release} -Provides: golang(%{import_path}/openpgp/elgamal) = %{version}-%{release} -Provides: golang(%{import_path}/openpgp/errors) = %{version}-%{release} -Provides: golang(%{import_path}/openpgp/packet) = %{version}-%{release} -Provides: golang(%{import_path}/openpgp/s2k) = %{version}-%{release} -Provides: golang(%{import_path}/otr) = %{version}-%{release} -Provides: golang(%{import_path}/pbkdf2) = %{version}-%{release} -Provides: golang(%{import_path}/pkcs12) = %{version}-%{release} -Provides: golang(%{import_path}/poly1305) = %{version}-%{release} -Provides: golang(%{import_path}/ripemd160) = %{version}-%{release} -Provides: golang(%{import_path}/rsa) = %{version}-%{release} -Provides: golang(%{import_path}/salsa20) = %{version}-%{release} -Provides: golang(%{import_path}/salsa20/salsa) = %{version}-%{release} -Provides: golang(%{import_path}/scrypt) = %{version}-%{release} -Provides: golang(%{import_path}/sha3) = %{version}-%{release} -Provides: golang(%{import_path}/ssh) = %{version}-%{release} -Provides: golang(%{import_path}/ssh/agent) = %{version}-%{release} -Provides: golang(%{import_path}/ssh/terminal) = %{version}-%{release} -Provides: golang(%{import_path}/ssh/test) = %{version}-%{release} -Provides: golang(%{import_path}/ssh/testdata) = %{version}-%{release} -Provides: golang(%{import_path}/tea) = %{version}-%{release} -Provides: golang(%{import_path}/twofish) = %{version}-%{release} -Provides: golang(%{import_path}/xtea) = %{version}-%{release} -Provides: golang(%{import_path}/xts) = %{version}-%{release} %description devel -%{summary} +%{common_description} This package contains library source intended for building other packages which use import path with -%{import_path} prefix. -%endif - -%if 0%{?with_unit_test} && 0%{?with_devel} -%package unit-test-devel -Summary: Unit tests for %{name} package -%if 0%{?with_check} -#Here comes all BuildRequires: PACKAGE the unit tests -#in %%check section need for running -%endif - -# test subpackage tests code from devel subpackage -Requires: %{name}-devel = %{version}-%{release} - -%if 0%{?with_check} && ! 0%{?with_bundled} -BuildRequires: golang(golang.org/x/crypto/openpgp/armor) -%endif +%{goipath} prefix. -Requires: golang(golang.org/x/crypto/openpgp/armor) - -%description unit-test-devel -%{summary} - -This package contains unit tests for project -providing packages with %{import_path} prefix. -%endif %prep -%setup -q -n %{repo}-%{commit} -%patch0 -p1 +%forgeautosetup -p1 -%build -%install -# source codes for building projects -%if 0%{?with_devel} -install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ -echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list -# find all *.go but no *_test.go files and generate devel.file-list -for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go") ; do - dirprefix=$(dirname $file) - install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix - cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file - echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list - while [ "$dirprefix" != "." ]; do - echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list - dirprefix=$(dirname $dirprefix) - done -done -%endif +%build -# testing files for this project -%if 0%{?with_unit_test} && 0%{?with_devel} -install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ -# find all *_test.go files and generate unit-test-devel.file-list -for file in $(find . -iname "*_test.go" -o -wholename "*/testdata/*") ; do - dirprefix=$(dirname $file) - install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix - cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file - echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list - while [ "$dirprefix" != "." ]; do - echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list - dirprefix=$(dirname $dirprefix) - done -done -%endif +%install +%goinstall -%if 0%{?with_devel} -sort -u -o devel.file-list devel.file-list -%endif %check -%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel} -%if ! 0%{?with_bundled} -export GOPATH=%{buildroot}/%{gopath}:%{gopath} -%else -# No dependency directories so far - -export GOPATH=%{buildroot}/%{gopath}:%{gopath} -%endif +# SSH agent tests fail in mock +%gochecks -d ssh/agent -%if ! 0%{?gotest:1} -%global gotest go test -%endif -%gotest %{import_path}/bcrypt -%gotest %{import_path}/blowfish -%gotest %{import_path}/bn256 -%gotest %{import_path}/brainpool -%gotest %{import_path}/cast5 -%gotest %{import_path}/curve25519 -%gotest %{import_path}/ed25519 -%gotest %{import_path}/hkdf -%gotest %{import_path}/md4 -%gotest %{import_path}/nacl/box -%gotest %{import_path}/nacl/secretbox -%gotest %{import_path}/ocsp -%gotest %{import_path}/openpgp -%gotest %{import_path}/openpgp/armor -%gotest %{import_path}/openpgp/clearsign -%gotest %{import_path}/openpgp/elgamal -%gotest %{import_path}/openpgp/packet -%gotest %{import_path}/openpgp/s2k -%gotest %{import_path}/otr -%gotest %{import_path}/pbkdf2 -%gotest %{import_path}/pkcs12 -%gotest %{import_path}/pkcs12/internal/rc2 -%gotest %{import_path}/poly1305 -%gotest %{import_path}/ripemd160 -%gotest %{import_path}/rsa -%gotest %{import_path}/salsa20 -%gotest %{import_path}/salsa20/salsa -%gotest %{import_path}/scrypt -%gotest %{import_path}/sha3 -%gotest %{import_path}/ssh -# The agent client test is unusable in mock. -%gotest '-short' %{import_path}/ssh/agent -%gotest %{import_path}/ssh/terminal -%gotest %{import_path}/ssh/test -%gotest %{import_path}/tea -%gotest %{import_path}/twofish -%gotest %{import_path}/xtea -%gotest %{import_path}/xts -%endif - -#define license tag if not already defined -%{!?_licensedir:%global license %doc} - - -%if 0%{?with_devel} %files devel -f devel.file-list %license LICENSE %doc README PATENTS AUTHORS CONTRIBUTING.md CONTRIBUTORS -%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project} -%endif -%if 0%{?with_unit_test} && 0%{?with_devel} -%files unit-test-devel -f unit-test-devel.file-list -%license LICENSE -%doc README PATENTS AUTHORS CONTRIBUTING.md CONTRIBUTORS -%endif %changelog +* Thu Jul 26 2018 Ed Marshall - 0-0.3.20180727git670ebd3 +- Switch to forge-specific packaging. +- Update to latest upstream commit. +- Upstream merged go-crypto-8bab6ce-go1.10-fixtests.patch. +- Backport bn256 ModInverse patch from upstream's upstream to fix test failure. + * Fri Jul 13 2018 Fedora Release Engineering - 0-0.2.20180130git8bab6ce - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild diff --git a/sources b/sources index 8567301..07a92e3 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (go-crypto-8bab6ce.tar.gz) = 502956e02bf49819ea0e057427e6932ec4581a32c85a948559f1911c4f1d3783e28863ae3445ab965d663ea395c915a8c526c9cfd86c2cbfa269f9e689e1e16b +SHA512 (go-crypto-670ebd3adf7a737d69ffe83a777a8e34eadc1b32.tar.gz) = 306f2027a15ec2e4a35258d91e0f415672324e68c2b0e5227ab7b44d29ea2d8848eece3571b6ee672901e8fc290d25f72a5590336809ed05860a876900f402ed