1/* Copyright (c) (2010-2022) Apple Inc. All rights reserved.
2 *
3 * corecrypto is licensed under Apple Inc.’s Internal Use License Agreement (which
4 * is contained in the License.txt file distributed with corecrypto) and only to
5 * people who accept that license. IMPORTANT: Any license rights granted to you by
6 * Apple Inc. (if any) are limited to internal use within your organization only on
7 * devices and computers you own or control, for the sole purpose of verifying the
8 * security characteristics and correct functioning of the Apple Software. You may
9 * not, directly or indirectly, redistribute the Apple Software or any portions thereof.
10 */
11
12#ifndef _CORECRYPTO_CCZP_H_
13#define _CORECRYPTO_CCZP_H_
14
15#include <corecrypto/ccn.h>
16
17CC_PTRCHECK_CAPABLE_HEADER()
18
19struct cczp;
20
21typedef struct cczp *cczp_t;
22typedef const struct cczp *cczp_const_t;
23
24struct cczp_funcs;
25typedef const struct cczp_funcs *cczp_funcs_t;
26
27// keep cczp_hd and cczp structures consistent
28// cczp_hd is typecasted to cczp to read EC curve params
29// make sure n is the first element see ccrsa_ctx_n macro
30#define __CCZP_HEADER_ELEMENTS_DEFINITIONS(pre) \
31 cc_size pre##n; \
32 cc_unit pre##bitlen; \
33 cczp_funcs_t pre##funcs;
34
35#define __CCZP_ELEMENTS_DEFINITIONS(pre) \
36 __CCZP_HEADER_ELEMENTS_DEFINITIONS(pre) \
37 cc_unit pre##ccn[];
38
39struct cczp {
40 __CCZP_ELEMENTS_DEFINITIONS()
41} CC_ALIGNED(CCN_UNIT_SIZE);
42
43#define CCZP_N(ZP) ((ZP)->n)
44#define CCZP_PRIME(ZP) ((ZP)->ccn)
45#define CCZP_BITLEN(ZP) ((ZP)->bitlen)
46
47CC_NONNULL((1))
48cc_size cczp_n(cczp_const_t zp);
49
50CC_NONNULL((1))
51const cc_unit * cc_indexable cczp_prime(cczp_const_t zp);
52
53CC_NONNULL((1))
54size_t cczp_bitlen(cczp_const_t zp);
55
56#endif /* _CORECRYPTO_CCZP_H_ */
57