} else {
var sd yacpki.SignedData
sd.Load.T = *typ
- sdHashes := []string{*hashAlgo}
+ sdHashes := map[string]*struct{}{*hashAlgo: nil}
sd.Hashes = &sdHashes
sigHashes := map[string][]byte{*hashAlgo: hasher.Sum(nil)}
when := time.Now().UTC().Truncate(1000 * time.Microsecond)
}
type SignedData struct {
- Hashes *[]string `yac:"hash,omitempty"`
- Cers *[]*SignedData `yac:"certs,omitempty"`
- Load SignedDataLoad `yac:"load"`
- Sigs []*Sig `yac:"sigs"`
+ Hashes *map[string]*struct{} `yac:"hash,omitempty"`
+ Cers *[]*SignedData `yac:"certs,omitempty"`
+ Load SignedDataLoad `yac:"load"`
+ Sigs []*Sig `yac:"sigs"`
}
func SignedDataParse(data []byte) (sd *SignedData, tail []byte, err error) {
return
}
var exists bool
- for _, ai := range *sd.Hashes {
+ for ai := range *sd.Hashes {
if _, ok := (*sig.TBS.Hashes)[ai]; ok {
exists = true
break
? ku: {+ ku => nil},
pub: [+ {av, id: uuid}],
sub: {text => text}, ; subject
- ? crit: [+ {t: text, * text => any}],
+ ? crit: {+ crit-text-type => any},
* text => any
}
ku = "ca" / "sig" / "app-name" / text
+crit-ext-type = text
list. It @strong{must} be absent if empty.
@item crit
-Optional list of critical (in terms of X.509) extensions. Non-critical
-ones may be placed outside that map, directly in @code{cer-load}. It
-@strong{must} be absent if empty.
-
-Each extension has required "t" field with specified extension type. All
-other values are extension-specific.
+Optional critical (in terms of X.509) extensions. Non-critical
+ones may be placed outside that map, directly in @code{cer-load}.
+It @strong{must} be absent if empty. Values are extension specific.
@end table
av = {a: ai, v: bytes}
signed-data = {
- ? hash: [+ ai], ; when using prehashing
+ ? hash: {+ ai => nil}, ; when using prehashing
load: {
t: text,
? v: bytes / text / blob / map / list,
Lacking it, or lacking its actual state, you probably won't be able even
guessing the context of the data inside.
+Sets can be emulated by using MAPs with NIL values. That gives only
+1-byte overhead for each element, but reuses already existing code.
+
If you really desire more compact encoding, even agree to use schema
definitions, then think about replacing MAPs with LISTs. Non-present
values can be indicated by NIL tag.