Skip to content

Commit 72506cd

Browse files
committed
vectorlint: validate EcCurve name values
1 parent 796a2dd commit 72506cd

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tools/vectorlint/main.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ var (
172172
},
173173
{
174174
Name: "EcCurve",
175-
// TODO(XXX): validate "EcCurve" format.
176-
Validate: noValidateFormat,
175+
// TODO(XXX): Seems like the EcCurve format should be defined as an enum?
176+
Validate: validateCurve,
177177
},
178178
{
179179
Name: "HexBytes",
@@ -223,3 +223,17 @@ func validatePem(value any) error {
223223

224224
return nil
225225
}
226+
227+
func validateCurve(value any) error {
228+
strVal, ok := value.(string)
229+
if !ok {
230+
return fmt.Errorf("invalid non-string EcCurve value: %v", value)
231+
}
232+
233+
switch strVal {
234+
case "curve25519", "curve448":
235+
return nil
236+
default:
237+
return fmt.Errorf("invalid EcCurve: unknown curve name: %v", value)
238+
}
239+
}

0 commit comments

Comments
 (0)