xref: /freebsd/crypto/openssl/include/openssl/self_test.h (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1 /*
2  * Copyright 2019-2022 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_KAT_CIPHER         "KAT_Cipher"
34 # define OSSL_SELF_TEST_TYPE_KAT_ASYM_CIPHER    "KAT_AsymmetricCipher"
35 # define OSSL_SELF_TEST_TYPE_KAT_DIGEST         "KAT_Digest"
36 # define OSSL_SELF_TEST_TYPE_KAT_SIGNATURE      "KAT_Signature"
37 # define OSSL_SELF_TEST_TYPE_PCT_SIGNATURE      "PCT_Signature"
38 # define OSSL_SELF_TEST_TYPE_KAT_KDF            "KAT_KDF"
39 # define OSSL_SELF_TEST_TYPE_KAT_KA             "KAT_KA"
40 # define OSSL_SELF_TEST_TYPE_DRBG               "DRBG"
41 
42 /* Test event sub categories */
43 # define OSSL_SELF_TEST_DESC_NONE           "None"
44 # define OSSL_SELF_TEST_DESC_INTEGRITY_HMAC "HMAC"
45 # define OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1  "RSA"
46 # define OSSL_SELF_TEST_DESC_PCT_ECDSA      "ECDSA"
47 # define OSSL_SELF_TEST_DESC_PCT_DSA        "DSA"
48 # define OSSL_SELF_TEST_DESC_CIPHER_AES_GCM "AES_GCM"
49 # define OSSL_SELF_TEST_DESC_CIPHER_AES_ECB "AES_ECB_Decrypt"
50 # define OSSL_SELF_TEST_DESC_CIPHER_TDES    "TDES"
51 # define OSSL_SELF_TEST_DESC_ASYM_RSA_ENC   "RSA_Encrypt"
52 # define OSSL_SELF_TEST_DESC_ASYM_RSA_DEC   "RSA_Decrypt"
53 # define OSSL_SELF_TEST_DESC_MD_SHA1        "SHA1"
54 # define OSSL_SELF_TEST_DESC_MD_SHA2        "SHA2"
55 # define OSSL_SELF_TEST_DESC_MD_SHA3        "SHA3"
56 # define OSSL_SELF_TEST_DESC_SIGN_DSA       "DSA"
57 # define OSSL_SELF_TEST_DESC_SIGN_RSA       "RSA"
58 # define OSSL_SELF_TEST_DESC_SIGN_ECDSA     "ECDSA"
59 # define OSSL_SELF_TEST_DESC_DRBG_CTR       "CTR"
60 # define OSSL_SELF_TEST_DESC_DRBG_HASH      "HASH"
61 # define OSSL_SELF_TEST_DESC_DRBG_HMAC      "HMAC"
62 # define OSSL_SELF_TEST_DESC_KA_DH          "DH"
63 # define OSSL_SELF_TEST_DESC_KA_ECDH        "ECDH"
64 # define OSSL_SELF_TEST_DESC_KDF_HKDF       "HKDF"
65 # define OSSL_SELF_TEST_DESC_KDF_SSKDF      "SSKDF"
66 # define OSSL_SELF_TEST_DESC_KDF_X963KDF    "X963KDF"
67 # define OSSL_SELF_TEST_DESC_KDF_X942KDF    "X942KDF"
68 # define OSSL_SELF_TEST_DESC_KDF_PBKDF2     "PBKDF2"
69 # define OSSL_SELF_TEST_DESC_KDF_SSHKDF     "SSHKDF"
70 # define OSSL_SELF_TEST_DESC_KDF_TLS12_PRF  "TLS12_PRF"
71 # define OSSL_SELF_TEST_DESC_KDF_KBKDF      "KBKDF"
72 # define OSSL_SELF_TEST_DESC_KDF_TLS13_EXTRACT  "TLS13_KDF_EXTRACT"
73 # define OSSL_SELF_TEST_DESC_KDF_TLS13_EXPAND   "TLS13_KDF_EXPAND"
74 # define OSSL_SELF_TEST_DESC_RNG            "RNG"
75 
76 void OSSL_SELF_TEST_set_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK *cb,
77                                  void *cbarg);
78 void OSSL_SELF_TEST_get_callback(OSSL_LIB_CTX *libctx, OSSL_CALLBACK **cb,
79                                  void **cbarg);
80 
81 OSSL_SELF_TEST *OSSL_SELF_TEST_new(OSSL_CALLBACK *cb, void *cbarg);
82 void OSSL_SELF_TEST_free(OSSL_SELF_TEST *st);
83 
84 void OSSL_SELF_TEST_onbegin(OSSL_SELF_TEST *st, const char *type,
85                             const char *desc);
86 int OSSL_SELF_TEST_oncorrupt_byte(OSSL_SELF_TEST *st, unsigned char *bytes);
87 void OSSL_SELF_TEST_onend(OSSL_SELF_TEST *st, int ret);
88 
89 # ifdef __cplusplus
90 }
91 # endif
92 #endif /* OPENSSL_SELF_TEST_H */
93