Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cryptotest] add ECDSA Verify test uJSON API definitions #21114

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sw/device/tests/crypto/cryptotest/json/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ cc_library(
deps = ["//sw/device/lib/ujson"],
)

cc_library(
name = "ecdsa_commands",
srcs = ["ecdsa_commands.c"],
hdrs = ["ecdsa_commands.h"],
deps = ["//sw/device/lib/ujson"],
)

cc_library(
name = "hmac_commands",
srcs = ["hmac_commands.c"],
Expand Down
1 change: 1 addition & 0 deletions sw/device/tests/crypto/cryptotest/json/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extern "C" {

#define COMMAND(_, value) \
value(_, Aes) \
value(_, Ecdsa) \
value(_, Hmac) \
value(_, AesSca) \
value(_, IbexFi) \
Expand Down
6 changes: 6 additions & 0 deletions sw/device/tests/crypto/cryptotest/json/ecdsa_commands.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

#define UJSON_SERDE_IMPL 1
#include "ecdsa_commands.h"
63 changes: 63 additions & 0 deletions sw/device/tests/crypto/cryptotest/json/ecdsa_commands.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

#ifndef OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_ECDSA_COMMANDS_H_
#define OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_ECDSA_COMMANDS_H_
#include "sw/device/lib/ujson/ujson_derive.h"
#ifdef __cplusplus
extern "C" {
#endif

#define ECDSA_CMD_MAX_MESSAGE_BYTES 64
#define ECDSA_CMD_MAX_SIGNATURE_SCALAR_BYTES 64
#define ECDSA_CMD_MAX_COORDINATE_BYTES 64

// clang-format off

#define ECDSA_OPERATION(_, value) \
value(_, Verify)
UJSON_SERDE_ENUM(CryptotestEcdsaOperation, cryptotest_ecdsa_operation_t, ECDSA_OPERATION);

#define ECDSA_HASH_ALG(_, value) \
value(_, Sha256) \
value(_, Sha384) \
value(_, Sha512) \
value(_, Sha3_256) \
value(_, Sha3_384) \
value(_, Sha3_512)
UJSON_SERDE_ENUM(CryptotestEcdsaHashAlg, cryptotest_ecdsa_hash_alg_t, ECDSA_HASH_ALG);

#define ECDSA_CURVE(_, value) \
value(_, P256) \
value(_, P384)
UJSON_SERDE_ENUM(CryptotestEcdsaCurve, cryptotest_ecdsa_curve_t, ECDSA_CURVE);

#define ECDSA_MESSAGE(field, string) \
field(input, uint8_t, ECDSA_CMD_MAX_MESSAGE_BYTES) \
field(input_len, size_t)
UJSON_SERDE_STRUCT(CryptotestEcdsaMessage, cryptotest_ecdsa_message_t, ECDSA_MESSAGE);

#define ECDSA_SIGNATURE(field, string) \
field(r, uint8_t, ECDSA_CMD_MAX_SIGNATURE_SCALAR_BYTES) \
field(r_len, size_t) \
field(s, uint8_t, ECDSA_CMD_MAX_SIGNATURE_SCALAR_BYTES) \
field(s_len, size_t)
UJSON_SERDE_STRUCT(CryptotestEcdsaSignature, cryptotest_ecdsa_signature_t, ECDSA_SIGNATURE);

#define ECDSA_COORDINATE(field, string) \
field(coordinate, uint8_t, ECDSA_CMD_MAX_COORDINATE_BYTES) \
field(coordinate_len, size_t)
UJSON_SERDE_STRUCT(CryptotestEcdsaCoordinate, cryptotest_ecdsa_coordinate_t, ECDSA_COORDINATE);

#define ECDSA_VERIFY_OUTPUT(_, value) \
value(_, Success) \
value(_, Failure)
UJSON_SERDE_ENUM(CryptotestEcdsaVerifyOutput, cryptotest_ecdsa_verify_output_t, ECDSA_VERIFY_OUTPUT);

// clang-format on

#ifdef __cplusplus
}
#endif
#endif // OPENTITAN_SW_DEVICE_TESTS_CRYPTO_CRYPTOTEST_JSON_ECDSA_COMMANDS_H_
Loading