diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-27 11:55:53 +0100 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-10-27 11:55:53 +0100 |
commit | 09ae216893aa1e82df288a91f2f298d642ede57e (patch) | |
tree | 22e9067a25a81bf0fd2b2bc6d87365555c62b80c /type.go | |
parent | 96a5021d586a20cbf00eb7f74ca08084bbaf048a (diff) |
added leaf appendix
Diffstat (limited to 'type.go')
-rw-r--r-- | type.go | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -6,6 +6,7 @@ import ( "encoding/base64" "github.com/google/certificate-transparency-go/tls" + "github.com/google/certificate-transparency-go/x509" "github.com/google/trillian" ) @@ -136,3 +137,23 @@ func StItemFromB64(s string) (StItem, error) { } return item, nil } + +// Appendix is extra data that Trillian can store about a leaf +type Appendix struct { + Signature []byte `tls:"minlen:0,maxlen:16383"` + Chain []RawCertificate `tls:"minlen:0,maxlen:65535"` +} + +// RawCertificate is a serialized X.509 certificate +type RawCertificate struct { + Data []byte `tls:"minlen:0,maxlen:65535"` +} + +// NewAppendix creates a new leaf Appendix for an X.509 chain and signature +func NewAppendix(x509Chain []*x509.Certificate, signature []byte) Appendix { + chain := make([]RawCertificate, 0, 2) // TODO: base length on config param + for _, c := range x509Chain { + chain = append(chain, RawCertificate{ c.Raw }) + } + return Appendix{ Signature: signature, Chain: chain } +} |