1/*
2 * ccaes.h
3 * corecrypto
4 *
5 * Created on 12/10/2010
6 *
7 * Copyright (c) 2010,2011,2012,2013,2015 Apple Inc. All rights reserved.
8 *
9 */
10
11#ifndef _CORECRYPTO_CCAES_H_
12#define _CORECRYPTO_CCAES_H_
13
14#include <corecrypto/cc_config.h>
15#include <corecrypto/ccmode.h>
16
17#define CCAES_BLOCK_SIZE 16
18#define CCAES_KEY_SIZE_128 16
19#define CCAES_KEY_SIZE_192 24
20#define CCAES_KEY_SIZE_256 32
21
22#define CCAES_CTR_MAX_PARALLEL_NBLOCKS 8
23
24extern const struct ccmode_ecb ccaes_ltc_ecb_decrypt_mode;
25extern const struct ccmode_ecb ccaes_ltc_ecb_encrypt_mode;
26
27extern const struct ccmode_cbc ccaes_gladman_cbc_encrypt_mode;
28extern const struct ccmode_cbc ccaes_gladman_cbc_decrypt_mode;
29
30#if CCAES_ARM_ASM
31extern const struct ccmode_ecb ccaes_arm_ecb_encrypt_mode;
32extern const struct ccmode_ecb ccaes_arm_ecb_decrypt_mode;
33
34extern const struct ccmode_cbc ccaes_arm_cbc_encrypt_mode;
35extern const struct ccmode_cbc ccaes_arm_cbc_decrypt_mode;
36
37extern const struct ccmode_xts ccaes_arm_xts_encrypt_mode;
38extern const struct ccmode_xts ccaes_arm_xts_decrypt_mode;
39
40extern const struct ccmode_cfb ccaes_arm_cfb_encrypt_mode;
41extern const struct ccmode_cfb ccaes_arm_cfb_decrypt_mode;
42
43extern const struct ccmode_ofb ccaes_arm_ofb_crypt_mode;
44
45#endif
46
47#if CCAES_MUX
48/* Runtime check to see if hardware should be used */
49int ccaes_ios_hardware_enabled(int operation);
50
51extern const struct ccmode_cbc ccaes_ios_hardware_cbc_encrypt_mode;
52extern const struct ccmode_cbc ccaes_ios_hardware_cbc_decrypt_mode;
53
54extern const struct ccmode_ctr ccaes_ios_hardware_ctr_crypt_mode;
55
56extern const struct ccmode_cbc *ccaes_ios_mux_cbc_encrypt_mode(void);
57extern const struct ccmode_cbc *ccaes_ios_mux_cbc_decrypt_mode(void);
58
59extern const struct ccmode_ctr *ccaes_ios_mux_ctr_crypt_mode(void);
60
61#endif
62
63#if CCAES_INTEL_ASM
64//extern const struct ccmode_ecb ccaes_intel_ecb_encrypt_mode;
65//extern const struct ccmode_ecb ccaes_intel_ecb_decrypt_mode;
66
67extern const struct ccmode_ecb ccaes_intel_ecb_encrypt_opt_mode;
68extern const struct ccmode_ecb ccaes_intel_ecb_encrypt_aesni_mode;
69
70extern const struct ccmode_ecb ccaes_intel_ecb_decrypt_opt_mode;
71extern const struct ccmode_ecb ccaes_intel_ecb_decrypt_aesni_mode;
72
73//extern const struct ccmode_cbc ccaes_intel_cbc_encrypt_mode;
74//extern const struct ccmode_cbc ccaes_intel_cbc_decrypt_mode;
75
76extern const struct ccmode_cbc ccaes_intel_cbc_encrypt_opt_mode;
77extern const struct ccmode_cbc ccaes_intel_cbc_encrypt_aesni_mode;
78
79extern const struct ccmode_cbc ccaes_intel_cbc_decrypt_opt_mode;
80extern const struct ccmode_cbc ccaes_intel_cbc_decrypt_aesni_mode;
81
82//extern const struct ccmode_xts ccaes_intel_xts_encrypt_mode;
83//extern const struct ccmode_xts ccaes_intel_xts_decrypt_mode;
84
85extern const struct ccmode_xts ccaes_intel_xts_encrypt_opt_mode;
86extern const struct ccmode_xts ccaes_intel_xts_encrypt_aesni_mode;
87
88extern const struct ccmode_xts ccaes_intel_xts_decrypt_opt_mode;
89extern const struct ccmode_xts ccaes_intel_xts_decrypt_aesni_mode;
90#endif
91
92#if CC_USE_L4
93extern const struct ccmode_cbc ccaes_skg_cbc_encrypt_mode;
94extern const struct ccmode_cbc ccaes_skg_cbc_decrypt_mode;
95
96extern const struct ccmode_ecb ccaes_skg_ecb_encrypt_mode;
97extern const struct ccmode_ecb ccaes_skg_ecb_decrypt_mode;
98
99extern const struct ccmode_ecb ccaes_trng_ecb_encrypt_mode;
100#endif
101
102/* Implementation Selectors: */
103const struct ccmode_ecb *ccaes_ecb_encrypt_mode(void);
104const struct ccmode_cbc *ccaes_cbc_encrypt_mode(void);
105const struct ccmode_cfb *ccaes_cfb_encrypt_mode(void);
106const struct ccmode_cfb8 *ccaes_cfb8_encrypt_mode(void);
107const struct ccmode_xts *ccaes_xts_encrypt_mode(void);
108const struct ccmode_gcm *ccaes_gcm_encrypt_mode(void);
109const struct ccmode_ccm *ccaes_ccm_encrypt_mode(void);
110
111const struct ccmode_ecb *ccaes_ecb_decrypt_mode(void);
112const struct ccmode_cbc *ccaes_cbc_decrypt_mode(void);
113const struct ccmode_cfb *ccaes_cfb_decrypt_mode(void);
114const struct ccmode_cfb8 *ccaes_cfb8_decrypt_mode(void);
115const struct ccmode_xts *ccaes_xts_decrypt_mode(void);
116const struct ccmode_gcm *ccaes_gcm_decrypt_mode(void);
117const struct ccmode_ccm *ccaes_ccm_decrypt_mode(void);
118
119const struct ccmode_ctr *ccaes_ctr_crypt_mode(void);
120const struct ccmode_ofb *ccaes_ofb_crypt_mode(void);
121
122const struct ccmode_siv *ccaes_siv_encrypt_mode(void);
123const struct ccmode_siv *ccaes_siv_decrypt_mode(void);
124
125#endif /* _CORECRYPTO_CCAES_H_ */
126