forked from veraison/swid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcbor.go
More file actions
35 lines (29 loc) · 673 Bytes
/
cbor.go
File metadata and controls
35 lines (29 loc) · 673 Bytes
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
// Copyright 2020 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package swid
import cbor "github.com/fxamacker/cbor/v2"
var (
em, emError = initCBOREncMode()
dm, dmError = initCBORDecMode()
)
func initCBOREncMode() (en cbor.EncMode, err error) {
encOpt := cbor.EncOptions{
IndefLength: cbor.IndefLengthForbidden,
TimeTag: cbor.EncTagRequired,
}
return encOpt.EncMode()
}
func initCBORDecMode() (dm cbor.DecMode, err error) {
decOpt := cbor.DecOptions{
IndefLength: cbor.IndefLengthForbidden,
}
return decOpt.DecMode()
}
func init() {
if emError != nil {
panic(emError)
}
if dmError != nil {
panic(dmError)
}
}