1 /* 2 * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved. 3 * 4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 * this file except in compliance with the License. You can obtain a copy 6 * in the file LICENSE in the source distribution or at 7 * https://www.openssl.org/source/license.html 8 */ 9 10 #ifndef OPENSSL_SELF_TEST_H 11 # define OPENSSL_SELF_TEST_H 12 # pragma once 13 14 # include <openssl/core.h> /* OSSL_CALLBACK */ 15 16 # ifdef __cplusplus 17 extern "C" { 18 # endif 19 20 /* The test event phases */ 21 # define OSSL_SELF_TEST_PHASE_NONE "None" 22 # define OSSL_SELF_TEST_PHASE_START "Start" 23 # define OSSL_SELF_TEST_PHASE_CORRUPT "Corrupt" 24 # define OSSL_SELF_TEST_PHASE_PASS "Pass" 25 # define OSSL_SELF_TEST_PHASE_FAIL "Fail" 26 27 /* Test event categories */ 28 # define OSSL_SELF_TEST_TYPE_NONE "None" 29 # define OSSL_SELF_TEST_TYPE_MODULE_INTEGRITY "Module_Integrity" 30 # define OSSL_SELF_TEST_TYPE_INSTALL_INTEGRITY "Install_Integrity" 31 # define OSSL_SELF_TEST_TYPE_CRNG "Continuous_RNG_Test" 32 # define OSSL_SELF_TEST_TYPE_PCT "Conditional_PCT" 33 # define OSSL_SELF_TEST_TYPE_PCT_KAT "Conditional_KAT" 34 # define OSSL_SELF_TEST_TYPE_KAT_INTEGRITY "KAT_Integrity" 35 # define OSSL_SELF_TEST_TYPE_KAT_CIPHER "KAT_Cipher" 36 # define OSSL_SELF_TEST_TYPE_KAT_ASYM_CIPHER "KAT_AsymmetricCipher" 37 # define OSSL_SELF_TEST_TYPE_KAT_DIGEST "KAT_Digest" 38 # define OSSL_SELF_TEST_TYPE_KAT_SIGNATURE "KAT_Signature" 39 # define OSSL_SELF_TEST_TYPE_PCT_SIGNATURE "PCT_Signature" 40 # define OSSL_SELF_TEST_TYPE_KAT_KDF "KAT_KDF" 41 # define OSSL_SELF_TEST_TYPE_KAT_KA "KAT_KA" 42 # define OSSL_SELF_TEST_TYPE_DRBG "DRBG" 43 44 /* Test event sub categories */ 45 # define OSSL_SELF_TEST_DESC_NONE "None" 46 # define OSSL_SELF_TEST_DESC_INTEGRITY_HMAC "HMAC" 47 # define OSSL_SELF_TEST_DESC_PCT_RSA "RSA" 48 # define OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1 "RSA" 49 # define OSSL_SELF_TEST_DESC_PCT_ECDSA "ECDSA" 50 # define OSSL_SELF_TEST_DESC_PCT_EDDSA "EDDSA" 51 # define OSSL_SELF_TEST_DESC_PCT_DSA "DSA" 52 # define OSSL_SELF_TEST_DESC_CIPHER_AES_GCM "AES_GCM" 53 # define OSSL_SELF_TEST_DESC_CIPHER_AES_ECB "AES_ECB_Decrypt" 54 # define OSSL_SELF_TEST_DESC_CIPHER_TDES "TDES" 55 # define OSSL_SELF_TEST_DESC_ASYM_RSA_ENC "RSA_Encrypt" 56 # define OSSL_SELF_TEST_DESC_ASYM_RSA_DEC "RSA_Decrypt" 57 # define OSSL_SELF_TEST_DESC_MD_SHA1 "SHA1" 58 # define OSSL_SELF_TEST_DESC_MD_SHA2 "SHA2" 59 # define OSSL_SELF_TEST_DESC_MD_SHA3 "SHA3" 60 # define OSSL_SELF_TEST_DESC_SIGN_DSA "DSA" 61 # define OSSL_SELF_TEST_DESC_SIGN_RSA "RSA" 62 # define OSSL_SELF_TEST_DESC_SIGN_ECDSA "ECDSA" 63 # define OSSL_SELF_TEST_DESC_SIGN_EDDSA "EDDSA" 64 # define OSSL_SELF_TEST_DESC_DRBG_CTR "CTR" 65 # define OSSL_SELF_TEST_DESC_DRBG_HASH "HASH" 66 # define OSSL_SELF_TEST_DESC_DRBG_HMAC "HMAC" 67 # define OSSL_SELF_TEST_DESC_KA_DH "DH" 68 # define OSSL_SELF_TEST_DESC_KA_ECDH "ECDH" 69 # define OSSL_SELF_TEST_DESC_KDF_HKDF "HKDF" 70 # define OSSL_SELF_TEST_DESC_KDF_SSKDF "SSKDF" 71 # define OSSL_SELF_TEST_DESC_KDF_X963KDF "X963KDF" 72 # define OSSL_SELF_TEST_DESC_KDF_X942KDF "X942KDF" 73 # define OSSL_SELF_TEST_DESC_KDF_PBKDF2 "PBKDF2" 74 # define OSSL_SELF_TEST_DESC_KDF_SSHKDF "SSHKDF" 75 # define OSSL_SELF_TEST_DESC_KDF_TLS12_PRF "TLS12_PRF" 76 # define OSSL_SELF_TEST_DESC_KDF_KBKDF "KBKDF" 77 # define OSSL_SELF_TEST_DESC_KDF_KBKDF_KMAC "KBKDF_KMAC" 78 # define OSSL_SELF_TEST_DESC_KDF_TLS13_EXTRACT "TLS13_KDF_EXTRACT" 79 # define OSSL_SELF_TEST_DESC_KDF_TLS13_EXPAND "TLS13_KDF_EXPAND" 80 # define OSSL_SELF_TEST_DESC_RNG "RNG" 81 82 void OSSL_SELF_TEST_set_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK *cb, 83 void *cbarg); 84 void OSSL_SELF_TEST_get_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK **cb, 85 void **cbarg); 86 87 OSSL_SELF_TEST *OSSL_SELF_TEST_new(OSSL_CALLBACK *cb, void *cbarg); 88 void OSSL_SELF_TEST_free(OSSL_SELF_TEST *st); 89 90 void OSSL_SELF_TEST_onbegin(OSSL_SELF_TEST *st, const char *type, 91 const char *desc); 92 int OSSL_SELF_TEST_oncorrupt_byte(OSSL_SELF_TEST *st, unsigned char *bytes); 93 void OSSL_SELF_TEST_onend(OSSL_SELF_TEST *st, int ret); 94 95 # ifdef __cplusplus 96 } 97 # endif 98 #endif /* OPENSSL_SELF_TEST_H */ 99