blob: fd93336081400e8d155d098215edd8d52ed4a6df (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package types
import (
"fmt"
"github.com/google/certificate-transparency-go/tls"
)
const (
HashSizeV1 = 32
)
// GetProofByHashV1 is a serializable get-proof-by-hash request
type GetProofByHashV1 struct {
Hash [HashSizeV1]byte
TreeSize uint64
}
// GetConsistencyProofV1 is a serializable get-consistency-proof request
type GetConsistencyProofV1 struct {
First uint64
Second uint64
}
// GetEntriesV1 is a serializable get-entries request
type GetEntriesV1 struct {
Start uint64
End uint64
}
// 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
}
|