2 * Copyright (c) 2019 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #ifndef included_unittest_crypto_crypto_h
18 #define included_unittest_crypto_crypto_h
20 #define CRYPTO_TEST_MAX_OP_CHUNKS 8
26 } unittest_crypto_test_data_t;
28 typedef struct unittest_crypto_test_registration
31 vnet_crypto_alg_t alg;
32 unittest_crypto_test_data_t iv, key, digest, plaintext, ciphertext, aad,
34 u32 plaintext_incremental;
37 /* plaintext and cipher text data used for testing chained buffers */
38 unittest_crypto_test_data_t pt_chunks[CRYPTO_TEST_MAX_OP_CHUNKS + 1];
39 unittest_crypto_test_data_t ct_chunks[CRYPTO_TEST_MAX_OP_CHUNKS + 1];
42 struct unittest_crypto_test_registration *next;
43 } unittest_crypto_test_registration_t;
52 vnet_crypto_alg_t alg;
58 unittest_crypto_test_registration_t *test_registrations;
61 extern crypto_test_main_t crypto_test_main;
63 #define TEST_DATA(n) { .data = (u8 *) n, .length = sizeof (n)}
64 #define TEST_DATA_CHUNK(s,off,n) { .data = (u8 *) s + off, .length = n}
66 #define UNITTEST_REGISTER_CRYPTO_TEST(x) \
67 unittest_crypto_test_registration_t __unittest_crypto_test_##x; \
68 static void __clib_constructor \
69 __unittest_crypto_test_registration_##x (void) \
71 crypto_test_main_t * cm = &crypto_test_main; \
72 __unittest_crypto_test_##x.next = cm->test_registrations; \
73 cm->test_registrations = & __unittest_crypto_test_##x; \
75 unittest_crypto_test_registration_t __unittest_crypto_test_##x
80 * fd.io coding-style-patch-verification: ON
83 * eval: (c-set-style "gnu")