/*
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
/* Macros to build Self test data */
#define ITM(x) x, sizeof(x)
#define ITM_STR(x) x, (sizeof(x) - 1)
#define ST_KAT_PARAM_END() { "", 0, NULL, 0 }
#define ST_KAT_PARAM_BIGNUM(name, data) \
{ name, OSSL_PARAM_UNSIGNED_INTEGER, ITM(data) }
#define ST_KAT_PARAM_OCTET(name, data) \
{ name, OSSL_PARAM_OCTET_STRING, ITM(data) }
#define ST_KAT_PARAM_UTF8STRING(name, data) \
{ name, OSSL_PARAM_UTF8_STRING, ITM_STR(data) }
/* used to store raw parameters for keys and algorithms */
typedef struct st_kat_param_st {
const char *name; /* an OSSL_PARAM name */
size_t type; /* the type associated with the data */
const void *data; /* unsigned char [], or char [] depending on the type */
size_t data_len; /* the length of the data */
} ST_KAT_PARAM;
typedef struct st_kat_st {
const char *desc;
const char *algorithm;
const unsigned char *pt;
size_t pt_len;
const unsigned char *expected;
size_t expected_len;
} ST_KAT;
typedef ST_KAT ST_KAT_DIGEST;
typedef struct st_kat_cipher_st {
ST_KAT base;
const unsigned char *key;
size_t key_len;
const unsigned char *iv;
size_t iv_len;
const unsigned char *aad;
size_t aad_len;
const unsigned char *tag;
size_t tag_len;
} ST_KAT_CIPHER;
typedef struct st_kat_kdf_st {
const char *desc;
const char *algorithm;
const ST_KAT_PARAM *params;
const unsigned char *expected;
size_t expected_len;
} ST_KAT_KDF;
typedef struct st_kat_drbg_st {
const char *desc;
const char *algorithm;
const char *param_name;
char *param_value;
const unsigned char *entropyin;
size_t entropyinlen;
const unsigned char *nonce;
size_t noncelen;
const unsigned char *persstr;
size_t persstrlen;
const unsigned char *entropyinpr1;
size_t entropyinpr1len;
const unsigned char *entropyinpr2;
size_t entropyinpr2len;
const unsigned char *entropyaddin1;
size_t entropyaddin1len;
const