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>
This commit is contained in:
parent
f3bfab0035
commit
23e9aec99b
@ -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…
Reference in New Issue
Block a user