forked from veraison/swid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocesses.go
More file actions
31 lines (22 loc) · 713 Bytes
/
processes.go
File metadata and controls
31 lines (22 loc) · 713 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
// Copyright 2020 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package swid
import "reflect"
// Processes models CoSWID process-entry / [ 2* process-entry ]
type Processes []Process
// MarshalCBOR provides the custom CBOR marshaler for process entries
func (pa Processes) MarshalCBOR() ([]byte, error) {
return arrayToCBOR(reflect.ValueOf(pa))
}
// UnmarshalCBOR provides the custom CBOR unmarshaler for process entries
func (pa *Processes) UnmarshalCBOR(data []byte) error {
if (data[0] & 0xe0) == 0x80 {
return dm.Unmarshal(data, (*[]Process)(pa))
}
var p Process
if err := dm.Unmarshal(data, &p); err != nil {
return err
}
*pa = append(*pa, p)
return nil
}