dep-libtomcrypt/tests/tomcrypt_test.h

72 lines
1.7 KiB
C
Raw Permalink Normal View History

2020-06-17 10:15:27 +02:00
/* LibTomCrypt, modular cryptographic library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
2005-04-17 11:37:13 +00:00
#ifndef TOMCRYPT_TEST_H_
#define TOMCRYPT_TEST_H_
2005-04-17 11:37:13 +00:00
2026-05-03 23:19:19 +02:00
#define _POSIX_C_SOURCE 200809L /* otherwise PATH_MAX + strdup are not defined for build with -std=c99 */
2018-05-31 14:44:47 +02:00
#include "tomcrypt_private.h"
2005-04-17 11:37:13 +00:00
#include "common.h"
2005-04-17 11:37:13 +00:00
typedef struct {
char *name, *prov, *req;
int (*entry)(void);
} test_entry;
/* TESTS */
int cipher_hash_test(void);
int modes_test(void);
int mac_test(void);
Add Project Wycheproof testvectors for SIV. Gemini proposed this to convert ``` import json import requests def to_c_hex(hex_str): if not hex_str: return "NULL" bytes_list = [f"0x{hex_str[i:i+2]}" for i in range(0, len(hex_str), 2)] return "{" + ",".join(bytes_list) + "}" url = "https://raw.githubusercontent.com/C2SP/wycheproof/main/testvectors_v1/aes_siv_cmac_test.json" data = requests.get(url).json() print("#include <stdint.h>\n#include <stddef.h>\n") print("typedef struct { int tcId; const char* comment; uint8_t key[64]; size_t keyLen; const uint8_t* aad; size_t aadLen; const uint8_t* msg; size_t msgLen; const uint8_t* ct; size_t ctLen; const char* result; } aes_siv_test_case;\n") for group in data['testGroups']: for test in group['tests']: tid = test['tcId'] if test['aad']: print(f"static const uint8_t aad_{tid}[] = {to_c_hex(test['aad'])};") if test['msg']: print(f"static const uint8_t msg_{tid}[] = {to_c_hex(test['msg'])};") if test['ct']: print(f"static const uint8_t ct_{tid}[] = {to_c_hex(test['ct'])};") print("\nstatic const aes_siv_test_case aes_siv_tests[] = {") for group in data['testGroups']: for test in group['tests']: tid = test['tcId'] key_hex = to_c_hex(test['key']) aad_ptr = f"aad_{tid}" if test['aad'] else "NULL" msg_ptr = f"msg_{tid}" if test['msg'] else "NULL" ct_ptr = f"ct_{tid}" if test['ct'] else "NULL" print(f" {{ {tid}, \"{test['comment']}\", {key_hex}, {len(test['key'])//2}, {aad_ptr}, {len(test['aad'])//2}, {msg_ptr}, {len(test['msg'])//2}, {ct_ptr}, {len(test['ct'])//2}, \"{test['result']}\" }},") print("};") ``` I manually modified the result type to be an enum. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
2026-04-23 09:23:11 +02:00
int siv_wycheproof_test(void);
2005-04-17 11:37:13 +00:00
int pkcs_1_test(void);
2014-08-05 17:21:02 +02:00
int pkcs_1_pss_test(void);
2014-08-05 19:15:14 +02:00
int pkcs_1_oaep_test(void);
2014-08-05 23:48:35 +02:00
int pkcs_1_emsa_test(void);
2014-08-06 00:58:45 +02:00
int pkcs_1_eme_test(void);
2005-04-17 11:37:13 +00:00
int store_test(void);
2017-03-27 19:32:05 +02:00
int rotate_test(void);
2005-04-17 11:37:13 +00:00
int rsa_test(void);
int dh_test(void);
2018-11-07 09:25:08 +01:00
int ecc_test(void);
2005-04-17 11:37:13 +00:00
int dsa_test(void);
2017-06-08 13:25:40 +02:00
int der_test(void);
2014-01-03 15:16:59 +01:00
int misc_test(void);
2014-05-01 18:01:13 +02:00
int base64_test(void);
2017-10-19 17:27:08 +02:00
int base32_test(void);
2018-03-22 15:44:01 +01:00
int base16_test(void);
2017-04-21 16:12:18 +02:00
int file_test(void);
2017-04-23 22:04:39 +02:00
int multi_test(void);
int pem_test(void);
2017-06-08 11:51:36 +02:00
int prng_test(void);
2017-06-28 14:02:25 +02:00
int mpi_test(void);
2018-01-23 12:48:57 +01:00
int padding_test(void);
2018-02-20 16:50:55 +01:00
int x25519_test(void);
int x25519_mpi_test(void);
2026-04-12 23:47:40 +02:00
int x448_test(void);
int x448_mpi_test(void);
2018-02-20 16:50:55 +01:00
int ed25519_test(void);
int ed25519_mpi_test(void);
2026-04-12 23:47:40 +02:00
int ed448_test(void);
int ed448_mpi_test(void);
int ssh_test(void);
int argon2_test(void);
2019-09-23 10:23:26 +02:00
int bcrypt_test(void);
int scrypt_test(void);
int no_null_termination_check_test(void);
int pk_oid_test(void);
int deprecated_test(void);
int nop_test(void);
2005-04-17 11:37:13 +00:00
extern const char ltc_der_tests_cacert_root_cert[];
extern const unsigned long ltc_der_tests_cacert_root_cert_size;
extern const unsigned char ltc_openssl_public_rsa[];
extern const unsigned long ltc_openssl_public_rsa_sz;
#ifdef LTC_PKCS_1
struct ltc_prng_descriptor* no_prng_desc_get(void);
void no_prng_desc_free(struct ltc_prng_descriptor*);
#endif
2005-04-17 11:37:13 +00:00
#endif