Software APIs
entropy_kat.h
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 #ifndef OPENTITAN_SW_DEVICE_LIB_CRYPTO_DRIVERS_ENTROPY_KAT_H_
5 #define OPENTITAN_SW_DEVICE_LIB_CRYPTO_DRIVERS_ENTROPY_KAT_H_
6 
7 #include <stdbool.h>
8 #include <stddef.h>
9 #include <stdint.h>
10 
12 #include "sw/device/lib/base/status.h"
13 #include "sw/device/lib/crypto/drivers/entropy.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /**
20  * Run CTR DRBG Known-Answer-Tests (KATs) on SW CSRNG instance.
21  *
22  * Test vector sourced from NIST's CAVP website:
23  * https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/random-number-generators
24  *
25  * The number format in this docstring follows the CAVP format to simplify
26  * auditing of the implementation.
27  *
28  * Test vector: CTR_DRBG AES-256 no DF.
29  *
30  * - EntropyInput =
31  * df5d73faa468649edda33b5cca79b0b05600419ccb7a879ddfec9db32ee494e5531b51de16a30f769262474c73bec010
32  * - Nonce = EMPTY
33  * - PersonalizationString = EMPTY
34  *
35  * Command: Instantiate
36  * - Key = 8c52f901632d522774c08fad0eb2c33b98a701a1861aecf3d8a25860941709fd
37  * - V = 217b52142105250243c0b2c206b8f59e
38  *
39  * Command: Generate (first call):
40  * - Key = 72f4af5c93258eb3eeec8c0cacea6c1d1978a4fad44312725f1ac43b167f2d52
41  * - V = e86f6d07dfb551cebad80e6bf6830ac4
42  *
43  * Command: Generate (second call):
44  * - Key = 1a1c6e5f1cccc6974436e5fd3f015bc8e9dc0f90053b73e3c19d4dfd66d1b85a
45  * - V = 53c78ac61a0bac9d7d2e92b1e73e3392
46  * - ReturnedBits =
47  * d1c07cd95af8a7f11012c84ce48bb8cb87189e99d40fccb1771c619bdf82ab2280b1dc2f2581f39164f7ac0c510494b3a43c41b7db17514c87b107ae793e01c5
48  *
49  * @return Operation status in `status_t` format.
50  */
51 status_t entropy_csrng_kat(void);
52 
53 #ifdef __cplusplus
54 }
55 #endif
56 
57 #endif // OPENTITAN_SW_DEVICE_LIB_CRYPTO_DRIVERS_ENTROPY_KAT_H_