Skip to content

Commit

Permalink
[cryptotest] JSON schema for hash functions
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Torok <[email protected]>
  • Loading branch information
RyanTorok committed Feb 14, 2024
1 parent 2745a65 commit b14e78f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sw/host/cryptotest/testvectors/data/schemas/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ filegroup(
srcs = ["ecdsa_sig_ver_schema.json"],
)

exports_files(["hmac_schema.json"])
exports_files([
"hash_schema.json",
"hmac_schema.json",
])
49 changes: 49 additions & 0 deletions sw/host/cryptotest/testvectors/data/schemas/hash_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/lowRISC/opentitan/master/sw/host/cryptotest/testvectors/data/schemas/hash_schema.json",
"title": "Cryptotest Hash Function Test Vector",
"description": "A list of testvectors for SHA-2, SHA-3, SHAKE, and cSHAKE testing",
"$defs": {
"byte_array": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255
}
}
},
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"vendor": {
"description": "Test vector vendor name",
"type": "string"
},
"test_case_id": {
"description": "Test_case_id",
"type": "integer"
},
"algorithm": {
"description": "The hash algorithm being tested",
"type": "string",
"enum": ["sha-224", "sha-256", "sha-384", "sha-512", "sha3-256", "sha3-384", "sha3-512", "shake-128", "shake-256"]
},
"message": {
"description": "Message to be hashed",
"$ref": "#/$defs/byte_array"
},
"digest": {
"description": "Digest output by the hash function",
"$ref": "#/$defs/byte_array"
},
"result": {
"description": "Whether the hash of `message` should be equal to `digest`",
"type": "boolean"
}
}
}
}

0 comments on commit b14e78f

Please sign in to comment.