File: rsa-verification-error.patch

package info (click to toggle)
golang-github-mendersoftware-mender-artifact 4.1.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,820 kB
  • sloc: sh: 140; makefile: 130
file content (57 lines) | stat: -rw-r--r-- 3,120 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Index: golang-github-mendersoftware-mender-artifact/artifact/signer_test.go
===================================================================
--- golang-github-mendersoftware-mender-artifact.orig/artifact/signer_test.go
+++ golang-github-mendersoftware-mender-artifact/artifact/signer_test.go
@@ -17,6 +17,7 @@ package artifact
 import (
 	"crypto/ecdsa"
 	"crypto/rsa"
+	"strings"
 	"testing"
 
 	"github.com/pkg/errors"
@@ -187,7 +188,9 @@ func TestRSA(t *testing.T) {
 	v = mustCreateVerifier(t, []byte(PublicRSAKeyError))
 	err = v.Verify(msg, sig)
 	assert.Error(t, err)
-	assert.Contains(t, errors.Cause(err).Error(), "verification error")
+	//assert.Contains(t, errors.Cause(err).Error(), "verification error")
+	emsg := errors.Cause(err).Error()
+	assert.True(t, strings.Contains(emsg, "verification error") || strings.Contains(emsg, "public exponent is even"), "should contain 'verification error' or 'public exponent is even'")
 }
 
 func TestRSARaw(t *testing.T) {
Index: golang-github-mendersoftware-mender-artifact/areader/reader_test.go
===================================================================
--- golang-github-mendersoftware-mender-artifact.orig/areader/reader_test.go
+++ golang-github-mendersoftware-mender-artifact/areader/reader_test.go
@@ -277,14 +277,14 @@ func TestReadArtifact(t *testing.T) {
 		"version 2 pass":   {2, false, rfh(), nil, nil},
 		"version 2 signed": {2, true, rfh(), mustCreateVerifier(t, []byte(PublicKey)), nil},
 		"version 2 - public key error": {2, true, rfh(), mustCreateVerifier(t, []byte(PublicKeyError)),
-			errors.New("reader: invalid signature: crypto/rsa: verification error")},
+			errors.New("reader: invalid signature: crypto/rsa: public exponent is even")}, // verification error
 		// test that we do not need a verifier for signed artifact
 		"version 2 - no verifier needed for a signed artifact": {2, true, rfh(), nil, nil},
 		// Version 3 tests.
 		"version 3 - base case": {3, false, rfh(), nil, nil},
 		"version 3 - signed":    {3, true, rfh(), mustCreateVerifier(t, []byte(PublicKey)), nil},
 		"version 3 - public key error": {3, true, rfh(), mustCreateVerifier(t, []byte(PublicKeyError)),
-			errors.New("readHeaderV3: reader: invalid signature: crypto/rsa: verification error")},
+			errors.New("readHeaderV3: reader: invalid signature: crypto/rsa: public exponent is even")}, // verification error
 	}
 
 	// first create archive, that we will be able to read
Index: golang-github-mendersoftware-mender-artifact/cli/validate_test.go
===================================================================
--- golang-github-mendersoftware-mender-artifact.orig/cli/validate_test.go
+++ golang-github-mendersoftware-mender-artifact/cli/validate_test.go
@@ -76,7 +76,7 @@ var validateTests = map[string]struct {
 		version:               2,
 		writeKey:              []byte(PrivateValidateRSAKey),
 		validateKey:           []byte(PublicValidateRSAKeyError),
-		expectedValidateError: "verification error",
+		expectedValidateError: "public exponent is even", // "verification error"
 	},
 	"invalid public key": {
 		version:             2,