mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-01 10:06:53 +03:00
test_suite_psa_crypto_util: split ECDSA test function in two
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
@ -1,15 +1,10 @@
|
||||
/* BEGIN_HEADER */
|
||||
#include <test/helpers.h>
|
||||
#include <mbedtls/psa_util.h>
|
||||
|
||||
enum {
|
||||
ECDSA_RAW_TO_DER = 0,
|
||||
ECDSA_DER_TO_RAW,
|
||||
};
|
||||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_ASN1_WRITE_C:MBEDTLS_ASN1_PARSE_C */
|
||||
void ecdsa_raw_to_der(int direction, int key_bits, data_t *input, data_t *exp_result, int exp_ret)
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_ASN1_WRITE_C */
|
||||
void ecdsa_raw_to_der(int key_bits, data_t *input, data_t *exp_result, int exp_ret)
|
||||
{
|
||||
unsigned char *tmp_buf = NULL;
|
||||
size_t tmp_buf_len = exp_result->len;
|
||||
@ -17,15 +12,31 @@ void ecdsa_raw_to_der(int direction, int key_bits, data_t *input, data_t *exp_re
|
||||
|
||||
TEST_CALLOC(tmp_buf, tmp_buf_len);
|
||||
|
||||
if (direction == ECDSA_RAW_TO_DER) {
|
||||
TEST_EQUAL(mbedtls_ecdsa_raw_to_der(input->x, input->len,
|
||||
tmp_buf, tmp_buf_len, &ret_len,
|
||||
key_bits), exp_ret);
|
||||
} else {
|
||||
TEST_EQUAL(mbedtls_ecdsa_der_to_raw(input->x, input->len,
|
||||
tmp_buf, tmp_buf_len, &ret_len,
|
||||
key_bits), exp_ret);
|
||||
}
|
||||
TEST_EQUAL(mbedtls_ecdsa_raw_to_der(input->x, input->len,
|
||||
tmp_buf, tmp_buf_len, &ret_len,
|
||||
key_bits), exp_ret);
|
||||
|
||||
if (exp_ret == 0) {
|
||||
ASSERT_COMPARE(exp_result->x, exp_result->len, tmp_buf, ret_len);
|
||||
}
|
||||
|
||||
exit:
|
||||
mbedtls_free(tmp_buf);
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_ASN1_PARSE_C */
|
||||
void ecdsa_der_to_raw(int key_bits, data_t *input, data_t *exp_result, int exp_ret)
|
||||
{
|
||||
unsigned char *tmp_buf = NULL;
|
||||
size_t tmp_buf_len = exp_result->len;
|
||||
size_t ret_len;
|
||||
|
||||
TEST_CALLOC(tmp_buf, tmp_buf_len);
|
||||
|
||||
TEST_EQUAL(mbedtls_ecdsa_der_to_raw(input->x, input->len,
|
||||
tmp_buf, tmp_buf_len, &ret_len,
|
||||
key_bits), exp_ret);
|
||||
|
||||
if (exp_ret == 0) {
|
||||
ASSERT_COMPARE(exp_result->x, exp_result->len, tmp_buf, ret_len);
|
||||
|
Reference in New Issue
Block a user