blob: da4bd9fa474097838e12f1e4d4e643c0851c5c8b (
plain)
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
|
package types
import (
"fmt"
"github.com/google/certificate-transparency-go/tls"
)
// Marshal marshals a TLS-encodable structure
func Marshal(item interface{}) ([]byte, error) {
serialized, err := tls.Marshal(item)
if err != nil {
return nil, fmt.Errorf("tls.Marshal: %v", err)
}
return serialized, nil
}
// Unmarshal unmarshals a TLS-encoded structure
func Unmarshal(serialized []byte, out interface{}) error {
extra, err := tls.Unmarshal(serialized, out)
if err != nil {
return fmt.Errorf("tls.Unmarshal: %v", err)
}
if len(extra) > 0 {
return fmt.Errorf("tls.Unmarshal: extra data: %X", extra)
}
return nil
}
|