acvp: recognise another style of JSON.

Some JSON files have a header, but without a URL. Thus consider a block
that doesn't contain an algorithm to also be a header.

Change-Id: Ic35a827843e9d0169ba8398df69c46a5baeffb44
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/48605
Reviewed-by: David Benjamin <davidben@google.com>
grpc-202302
Adam Langley 4 years ago committed by Adam Langley
parent d422d2c4aa
commit 5799ebfe5f
  1. 12
      util/fipstools/acvp/acvptool/acvp.go
  2. BIN
      util/fipstools/acvp/acvptool/test/expected/ACVP-AES-GCM.bz2
  3. BIN
      util/fipstools/acvp/acvptool/test/vectors/ACVP-AES-GCM.bz2

@ -178,18 +178,20 @@ func trimLeadingSlash(s string) string {
return s
}
// looksLikeHeaderElement returns true iff element looks like it's a header,
// not a test. Some ACVP files contain a header as the first element that
// should be duplicated into the response, and some don't. If the element
// contains a "url" field then we guess that it's a header.
// looksLikeHeaderElement returns true iff element looks like it's a header, not
// a test. Some ACVP files contain a header as the first element that should be
// duplicated into the response, and some don't. If the element contains
// a "url" field, or if it's missing an "algorithm" field, then we guess that
// it's a header.
func looksLikeHeaderElement(element json.RawMessage) bool {
var headerFields struct {
URL string `json:"url"`
Algorithm string `json:"algorithm"`
}
if err := json.Unmarshal(element, &headerFields); err != nil {
return false
}
return len(headerFields.URL) > 0
return len(headerFields.URL) > 0 || len(headerFields.Algorithm) == 0
}
// processFile reads a file containing vector sets, at least in the format

Loading…
Cancel
Save