1 /*
2  * Copyright (c) 2022 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include "mocks/hmac_prng.h"
9 #include "mocks/hmac_prng_expects.h"
10 
expect_single_call_tc_hmac_prng_init(TCHmacPrng_t prng,unsigned int plen)11 void expect_single_call_tc_hmac_prng_init(TCHmacPrng_t prng, unsigned int plen)
12 {
13 	const char *func_name = "tc_hmac_prng_init";
14 
15 	zassert_equal(tc_hmac_prng_init_fake.call_count, 1, "'%s()' was called more than once",
16 		      func_name);
17 
18 	zassert_equal_ptr(tc_hmac_prng_init_fake.arg0_val, prng,
19 		      "'%s()' was called with incorrect '%s' value", func_name, "prng");
20 	zassert_not_null(tc_hmac_prng_init_fake.arg1_val,
21 			 "'%s()' was called with incorrect '%s' value", func_name, "buffer");
22 	zassert_equal(tc_hmac_prng_init_fake.arg2_val, plen,
23 		      "'%s()' was called with incorrect '%s' value", func_name, "plen");
24 }
25 
expect_single_call_tc_hmac_prng_reseed(TCHmacPrng_t prng,unsigned int seedlen,unsigned int additionallen)26 void expect_single_call_tc_hmac_prng_reseed(TCHmacPrng_t prng, unsigned int seedlen,
27 					    unsigned int additionallen)
28 {
29 	const char *func_name = "tc_hmac_prng_reseed";
30 
31 	zassert_equal(tc_hmac_prng_reseed_fake.call_count, 1, "'%s()' was called more than once",
32 		      func_name);
33 
34 	zassert_equal_ptr(tc_hmac_prng_reseed_fake.arg0_val, prng,
35 			  "'%s()' was called with incorrect '%s' value", func_name, "prng");
36 	zassert_not_null(tc_hmac_prng_reseed_fake.arg1_val,
37 			 "'%s()' was called with incorrect '%s' value", func_name, "seed");
38 	zassert_equal(tc_hmac_prng_reseed_fake.arg2_val, seedlen,
39 		      "'%s()' was called with incorrect '%s' value", func_name, "seedlen");
40 	zassert_not_null(tc_hmac_prng_reseed_fake.arg3_val,
41 			 "'%s()' was called with incorrect '%s' value", func_name,
42 			 "additional_input");
43 	zassert_equal(tc_hmac_prng_reseed_fake.arg4_val, additionallen,
44 		      "'%s()' was called with incorrect '%s' value", func_name, "additionallen");
45 }
46 
expect_call_count_tc_hmac_prng_generate(int call_count,uint8_t * out,unsigned int outlen,TCHmacPrng_t prng)47 void expect_call_count_tc_hmac_prng_generate(int call_count, uint8_t *out, unsigned int outlen,
48 					      TCHmacPrng_t prng)
49 {
50 	const char *func_name = "tc_hmac_prng_generate";
51 
52 	zassert_equal(tc_hmac_prng_generate_fake.call_count, call_count,
53 		      "'%s()' was called more than once", func_name);
54 
55 	zassert_equal_ptr(tc_hmac_prng_generate_fake.arg0_val, out,
56 			  "'%s()' was called with incorrect '%s' value", func_name, "out");
57 	zassert_equal(tc_hmac_prng_generate_fake.arg1_val, outlen,
58 		      "'%s()' was called with incorrect '%s' value", func_name, "outlen");
59 	zassert_equal_ptr(tc_hmac_prng_generate_fake.arg2_val, prng,
60 			  "'%s()' was called with incorrect '%s' value", func_name, "prng");
61 }
62