Skip to content

Commit 5722833

Browse files
committed
eddsa: add vectors for x = 0 with the sign bit set
RFC 8032 point decoding rejects an encoding whose x is zero when the sign bit of x is set (Section 5.1.3 and Section 5.2.3, step 4). Neither file exercised this check. Add one vector per curve where R encodes y = 1 with the sign bit of x set.
1 parent ec6af72 commit 5722833

2 files changed

Lines changed: 68 additions & 2 deletions

File tree

testvectors_v1/ed25519_test.json

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"algorithm": "EDDSA",
33
"schema": "eddsa_verify_schema_v1.json",
4-
"numberOfTests": 150,
4+
"numberOfTests": 151,
55
"header": [
66
"Test vectors of type EddsaVerify are intended for testing"
77
],
@@ -3322,6 +3322,39 @@
33223322
"result": "valid"
33233323
}
33243324
]
3325+
},
3326+
{
3327+
"type": "EddsaVerify",
3328+
"source": {
3329+
"name": "github/cpu/eddsazerosigngen",
3330+
"version": "1.0"
3331+
},
3332+
"publicKey": {
3333+
"type": "EDDSAPublicKey",
3334+
"curve": "edwards25519",
3335+
"keySize": 255,
3336+
"pk": "d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a"
3337+
},
3338+
"publicKeyDer": "302a300506032b6570032100d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a",
3339+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=\n-----END PUBLIC KEY-----\n",
3340+
"publicKeyJwk": {
3341+
"kty": "OKP",
3342+
"crv": "Ed25519",
3343+
"kid": "none",
3344+
"x": "11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo"
3345+
},
3346+
"tests": [
3347+
{
3348+
"tcId": 151,
3349+
"comment": "R encodes y = 1 with the sign bit of x set. The only point with y = 1 has x = 0, so decoding must fail (RFC 8032, Section 5.1.3). Accepted only by verifiers that ignore the sign of x.",
3350+
"flags": [
3351+
"InvalidEncoding"
3352+
],
3353+
"msg": "313233343030",
3354+
"sig": "0100000000000000000000000000000000000000000000000000000000000080c803ee1f2342aa96ff698a393d1ab5e66f3eda101d6d120b394c3fd32c117d0a",
3355+
"result": "invalid"
3356+
}
3357+
]
33253358
}
33263359
]
33273360
}

testvectors_v1/ed448_test.json

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"algorithm": "EDDSA",
33
"schema": "eddsa_verify_schema_v1.json",
4-
"numberOfTests": 86,
4+
"numberOfTests": 87,
55
"header": [
66
"Test vectors of type EddsaVerify are intended for testing"
77
],
@@ -1229,6 +1229,39 @@
12291229
"result": "valid"
12301230
}
12311231
]
1232+
},
1233+
{
1234+
"type": "EddsaVerify",
1235+
"source": {
1236+
"name": "github/cpu/eddsazerosigngen",
1237+
"version": "1.0"
1238+
},
1239+
"publicKey": {
1240+
"type": "EDDSAPublicKey",
1241+
"curve": "edwards448",
1242+
"keySize": 448,
1243+
"pk": "5fd7449b59b461fd2ce787ec616ad46a1da1342485a70e1f8a0ea75d80e96778edf124769b46c7061bd6783df1e50f6cd1fa1abeafe8256180"
1244+
},
1245+
"publicKeyDer": "3043300506032b6571033a005fd7449b59b461fd2ce787ec616ad46a1da1342485a70e1f8a0ea75d80e96778edf124769b46c7061bd6783df1e50f6cd1fa1abeafe8256180",
1246+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMEMwBQYDK2VxAzoAX9dEm1m0Yf0s54fsYWrUah2hNCSFpw4fig6nXYDpZ3jt8SR2\nm0bHBhvWeD3x5Q9s0foavq/oJWGA\n-----END PUBLIC KEY-----\n",
1247+
"publicKeyJwk": {
1248+
"kty": "OKP",
1249+
"crv": "Ed448",
1250+
"kid": "none",
1251+
"x": "X9dEm1m0Yf0s54fsYWrUah2hNCSFpw4fig6nXYDpZ3jt8SR2m0bHBhvWeD3x5Q9s0foavq_oJWGA"
1252+
},
1253+
"tests": [
1254+
{
1255+
"tcId": 87,
1256+
"comment": "R encodes y = 1 with the sign bit of x set. The only point with y = 1 has x = 0, so decoding must fail (RFC 8032, Section 5.2.3). Accepted only by verifiers that ignore the sign of x.",
1257+
"flags": [
1258+
"InvalidEncoding"
1259+
],
1260+
"msg": "313233343030",
1261+
"sig": "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008091f5b9d3cd6099f02315ceb7c46200fd14cc3a15d40ab348932f9b7765a96c2f0833cc81f90c8c48a13d7df4298301067e5f5f850467f81600",
1262+
"result": "invalid"
1263+
}
1264+
]
12321265
}
12331266
]
12341267
}

0 commit comments

Comments
 (0)