Skip to content

Commit 8b1b067

Browse files
committed
upgrade fxamacker/cbor to v2.5.0
Signed-off-by: qmuntal <[email protected]>
1 parent 4451940 commit 8b1b067

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/veraison/go-cose
22

33
go 1.18
44

5-
require github.com/fxamacker/cbor/v2 v2.4.0
5+
require github.com/fxamacker/cbor/v2 v2.5.0
66

77
require github.com/x448/float16 v0.8.4 // indirect
88

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
2-
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
1+
github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE=
2+
github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
33
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
44
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=

sign_test.go

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -654,13 +654,13 @@ func TestSignature_Sign_Internal(t *testing.T) {
654654
},
655655
},
656656
},
657-
protected: []byte{0x40, 0xa1, 0x00, 0x00},
657+
protected: []byte{0x43, 0xa1, 0x00, 0x00},
658658
payload: []byte("hello world"),
659659
external: []byte{},
660660
toBeSigned: []byte{
661661
0x85, // array type
662662
0x69, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, // context
663-
0x40, 0xa1, 0x00, 0x00, // body_protected
663+
0x43, 0xa1, 0x00, 0x00, // body_protected
664664
0x47, 0xa1, 0x01, 0x3a, 0x6d, 0x6f, 0x63, 0x6a, // sign_protected
665665
0x40, // external
666666
0x4b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, // payload
@@ -2222,7 +2222,7 @@ func TestSignature_toBeSigned(t *testing.T) {
22222222
payload []byte
22232223
external []byte
22242224
want []byte
2225-
wantErr bool
2225+
wantErr string
22262226
}{
22272227
{
22282228
name: "valid signature",
@@ -2233,12 +2233,12 @@ func TestSignature_toBeSigned(t *testing.T) {
22332233
},
22342234
},
22352235
},
2236-
protected: []byte{0x40, 0xa1, 0x00, 0x00},
2236+
protected: []byte{0x43, 0xa1, 0x00, 0x00},
22372237
payload: []byte("hello world"),
22382238
want: []byte{
22392239
0x85, // array type
22402240
0x69, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, // context
2241-
0x40, 0xa1, 0x00, 0x00, // body_protected
2241+
0x43, 0xa1, 0x00, 0x00, // body_protected
22422242
0x47, 0xa1, 0x01, 0x3a, 0x6d, 0x6f, 0x63, 0x6a, // sign_protected
22432243
0x40, // external
22442244
0x4b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, // payload
@@ -2255,7 +2255,20 @@ func TestSignature_toBeSigned(t *testing.T) {
22552255
},
22562256
protected: []byte{0x00},
22572257
payload: []byte{},
2258-
wantErr: true,
2258+
wantErr: "cbor: require bstr type",
2259+
},
2260+
{
2261+
name: "extraneous protected data",
2262+
s: &Signature{
2263+
Headers: Headers{
2264+
Protected: ProtectedHeader{
2265+
HeaderLabelAlgorithm: algorithmMock,
2266+
},
2267+
},
2268+
},
2269+
protected: []byte{0x40, 0xa1, 0x00, 0x00},
2270+
payload: []byte("hello world"),
2271+
wantErr: "cbor: 3 bytes of extraneous data starting at index 1",
22592272
},
22602273
{
22612274
name: "invalid sign protected header",
@@ -2268,7 +2281,7 @@ func TestSignature_toBeSigned(t *testing.T) {
22682281
},
22692282
protected: []byte{0x40},
22702283
payload: []byte{},
2271-
wantErr: true,
2284+
wantErr: "protected header: header label: require int / tstr type",
22722285
},
22732286
{
22742287
name: "invalid raw sign protected header",
@@ -2279,15 +2292,17 @@ func TestSignature_toBeSigned(t *testing.T) {
22792292
},
22802293
protected: []byte{0x40},
22812294
payload: []byte{},
2282-
wantErr: true,
2295+
wantErr: "cbor: require bstr type",
22832296
},
22842297
}
22852298
for _, tt := range tests {
22862299
t.Run(tt.name, func(t *testing.T) {
22872300
got, err := tt.s.toBeSigned(tt.protected, tt.payload, tt.external)
2288-
if (err != nil) != tt.wantErr {
2289-
t.Errorf("Signature.toBeSigned() error = %v, wantErr %v", err, tt.wantErr)
2290-
return
2301+
if err != nil && (err.Error() != tt.wantErr) {
2302+
t.Fatalf("Signature.toBeSigned() error = %v, wantErr %v", err, tt.wantErr)
2303+
}
2304+
if err == nil && (tt.wantErr != "") {
2305+
t.Fatalf("Signature.toBeSigned() error = %v, wantErr %v", err, tt.wantErr)
22912306
}
22922307
if !reflect.DeepEqual(got, tt.want) {
22932308
t.Errorf("Signature.toBeSigned() = %v, want %v", got, tt.want)

0 commit comments

Comments
 (0)