Browse Source

Support Wycheproof vectors with the curve given in the group.

Future versions of the Wycheproof vectors will specify the curve for a
group of tests, rather than for each test. This change works with both
the old and new style.

Change-Id: I0d9a503c8357eb4c617544e727d8f4a703c2c2b0
Reviewed-on: https://boringssl-review.googlesource.com/30084
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
Adam Langley 6 years ago
parent
commit
23e9aec99b
1 changed files with 12 additions and 2 deletions
  1. +12
    -2
      util/convert_wycheproof.go

+ 12
- 2
util/convert_wycheproof.go View File

@@ -157,7 +157,8 @@ func convertWycheproof(f io.Writer, jsonPath string) error {
// Skip tests with unsupported curves. We filter these out at
// conversion time to avoid unnecessarily inflating
// crypto_test_data.cc.
if curve, ok := group["curve"]; ok && !isSupportedCurve(curve.(string)) {
groupCurve := group["curve"]
if groupCurve != nil && !isSupportedCurve(groupCurve.(string)) {
continue
}
if keyI, ok := group["key"]; ok {
@@ -183,8 +184,10 @@ func convertWycheproof(f io.Writer, jsonPath string) error {
tests := group["tests"].([]interface{})
for _, testI := range tests {
test := testI.(map[string]interface{})

curve := test["curve"]
// Skip tests with unsupported curves.
if curve, ok := test["curve"]; ok && !isSupportedCurve(curve.(string)) {
if curve != nil && !isSupportedCurve(curve.(string)) {
continue
}
if _, err := fmt.Fprintf(f, "# tcId = %d\n", int(test["tcId"].(float64))); err != nil {
@@ -203,6 +206,13 @@ func convertWycheproof(f io.Writer, jsonPath string) error {
return err
}
}
// If the curve was only specified at the group level then copy it into
// each test.
if curve == nil && groupCurve != nil {
if err := printAttribute(f, "curve", groupCurve, false); err != nil {
return err
}
}
if flags, ok := test["flags"]; ok {
for _, flag := range flags.([]interface{}) {
if note, ok := w.Notes[flag.(string)]; ok {


Loading…
Cancel
Save