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>
diff --git a/util/fipstools/acvp/acvptool/acvp.go b/util/fipstools/acvp/acvptool/acvp.go index f497532..f477d65 100644 --- a/util/fipstools/acvp/acvptool/acvp.go +++ b/util/fipstools/acvp/acvptool/acvp.go
@@ -178,18 +178,20 @@ 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
diff --git a/util/fipstools/acvp/acvptool/test/expected/ACVP-AES-GCM.bz2 b/util/fipstools/acvp/acvptool/test/expected/ACVP-AES-GCM.bz2 index df90c77..d50948d 100644 --- a/util/fipstools/acvp/acvptool/test/expected/ACVP-AES-GCM.bz2 +++ b/util/fipstools/acvp/acvptool/test/expected/ACVP-AES-GCM.bz2 Binary files differ
diff --git a/util/fipstools/acvp/acvptool/test/vectors/ACVP-AES-GCM.bz2 b/util/fipstools/acvp/acvptool/test/vectors/ACVP-AES-GCM.bz2 index 1d49d05..719bcc0 100644 --- a/util/fipstools/acvp/acvptool/test/vectors/ACVP-AES-GCM.bz2 +++ b/util/fipstools/acvp/acvptool/test/vectors/ACVP-AES-GCM.bz2 Binary files differ