https://wpack-wg.github.io/bundled-responses/draft-ietf-wpack-bundled-responses.html#signatures-section
(sectionContents []byte)
| 338 | |
| 339 | // https://wpack-wg.github.io/bundled-responses/draft-ietf-wpack-bundled-responses.html#signatures-section |
| 340 | func parseSignaturesSection(sectionContents []byte) (*Signatures, error) { |
| 341 | // signatures = [ |
| 342 | // authorities: [*authority], |
| 343 | // vouched-subsets: [*{ |
| 344 | // authority: index-in-authorities, |
| 345 | // sig: bstr, |
| 346 | // signed: bstr ; Expected to hold a signed-subset item. |
| 347 | // }], |
| 348 | // ] |
| 349 | dec := cbor.NewDecoder(bytes.NewBuffer(sectionContents)) |
| 350 | signaturesLength, err := dec.DecodeArrayHeader() |
| 351 | if err != nil { |
| 352 | return nil, fmt.Errorf("bundle.signatures: failed to decode array header: %v", err) |
| 353 | } |
| 354 | if signaturesLength != 2 { |
| 355 | return nil, fmt.Errorf("bundle.signatures: unexpected array length: %d", signaturesLength) |
| 356 | } |
| 357 | |
| 358 | authoritiesLength, err := dec.DecodeArrayHeader() |
| 359 | if err != nil { |
| 360 | return nil, fmt.Errorf("bundle.signatures: failed to decode array header: %v", err) |
| 361 | } |
| 362 | var authorities []*certurl.AugmentedCertificate |
| 363 | for i := uint64(0); i < authoritiesLength; i++ { |
| 364 | a, err := certurl.DecodeAugmentedCertificateFrom(dec) |
| 365 | if err != nil { |
| 366 | return nil, fmt.Errorf("bundle.signatures: cannot parse certificate: %v", err) |
| 367 | } |
| 368 | authorities = append(authorities, a) |
| 369 | } |
| 370 | |
| 371 | vouchedSubsetsLength, err := dec.DecodeArrayHeader() |
| 372 | if err != nil { |
| 373 | return nil, fmt.Errorf("bundle.signatures: failed to decode array header: %v", err) |
| 374 | } |
| 375 | var vouchedSubsets []*VouchedSubset |
| 376 | for i := uint64(0); i < vouchedSubsetsLength; i++ { |
| 377 | n, err := dec.DecodeMapHeader() |
| 378 | if err != nil { |
| 379 | return nil, fmt.Errorf("bundle.signatures: cannot decode map header: %v", err) |
| 380 | } |
| 381 | if n != 3 { |
| 382 | return nil, fmt.Errorf("bundle.signatures: unexpected map size: %d", n) |
| 383 | } |
| 384 | |
| 385 | vs := &VouchedSubset{} |
| 386 | for i := uint64(0); i < n; i++ { |
| 387 | label, err := dec.DecodeTextString() |
| 388 | if err != nil { |
| 389 | return nil, fmt.Errorf("bundle.signatures: cannot decode map key: %v", err) |
| 390 | } |
| 391 | switch label { |
| 392 | case "authority": |
| 393 | vs.Authority, err = dec.DecodeUint() |
| 394 | if err != nil { |
| 395 | return nil, fmt.Errorf("bundle.signatures: cannot decode authority: %v", err) |
| 396 | } |
| 397 | case "sig": |
no test coverage detected