Debian Codegraph @

lib/kcapi-sym.c

raw symbols SCIP
1 /* Kernel crypto API AF_ALG Symmetric Cipher API
2 *
3 * Copyright (C) 2016 - 2022, Stephan Mueller <[email protected]>
4 *
5 * License: see COPYING file in root directory
6 *
7 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
8 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
9 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
10 * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
11 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
12 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
13 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
14 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
15 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
16 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
17 * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
18 * DAMAGE.
19 */
20
21 #include "internal.h"cxx . . $ `<file>/lib/internal.h`/
22 #include "kcapi.h"cxx . . $ `<file>/lib/kcapi.h`/
23
24 int kcapi_cipher_initcxx . . $ kcapi_cipher_init(b54728dab28c239a).(struct kcapi_handlecxx . . $ kcapi_handle# **handle, const char *ciphername,
25 uint32_tcxx . . $ uint32_t# flags)
26 {
27 return _kcapi_handle_initcxx . . $ _kcapi_handle_init(db986b7fadb21840).(handle, "skcipher", ciphername, flags);
28 }
29
30 void kcapi_cipher_destroycxx . . $ kcapi_cipher_destroy(aba29416d24fdd59).(struct kcapi_handlecxx . . $ kcapi_handle# *handle)
31 {
32 _kcapi_handle_destroycxx . . $ _kcapi_handle_destroy(aba29416d24fdd59).(handle);
33 }
34
35 int kcapi_cipher_setkeycxx . . $ kcapi_cipher_setkey(4d0e261613a805ee).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
36 const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen)
37 {
38 return _kcapi_common_setkeycxx . . $ _kcapi_common_setkey(4d0e261613a805ee).(handle, key, keylen);
39 }
40
41 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_encrypt, "1.3.1")
42 ssize_tcxx . . $ ssize_t# impl_cipher_encryptcxx . . $ impl_cipher_encrypt(c011db556473c11f).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
43 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
44 const uint8_tcxx . . $ uint8_t# *iv,
45 uint8_tcxx . . $ uint8_t# *out, size_t outlen, int access)
46 {
47 struct kcapi_handle_tfmcxx . . $ kcapi_handle_tfm# *tfm = handle->tfmcxx . . $ kcapi_handle#tfm.;
48 uint32_tcxx . . $ uint32_t# bs = tfm->infocxx . . $ kcapi_handle_tfm#info..blocksizecxx . . $ kcapi_cipher_info#blocksize.;
49
50 /* require properly sized output data size */
51 if (outlen < ((inlen + bs - 1) / bs * bs))
52 kcapi_dologcxx . . $ kcapi_dolog(5f46d8f16dd28dce).(KCAPI_LOG_WARNcxx . . $ KCAPI_LOG_WARN.,
53 "Symmetric Encryption: Ciphertext buffer (%lu) is not plaintext buffer (%lu) rounded up to multiple of block size %u",
54 (unsigned long) outlen, (unsigned long)inlen, bs);
55
56 handle->ciphercxx . . $ kcapi_handle#cipher..ivcxx . . $ kcapi_cipher_data#iv. = iv;
57 return _kcapi_cipher_crypt_chunkcxx . . $ _kcapi_cipher_crypt_chunk(8a744cecfacfebd9).(handle, in, inlen, out, outlen, access,
58 ALG_OP_ENCRYPTcxx . . $ `<external>/7256700519741588701/if_alg.h:59:9`!);
59 }
60
61 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_encrypt, "0.12.0")
62 int32_tcxx . . $ int32_t# orig_cipher_encryptcxx . . $ orig_cipher_encrypt(2bb63b96ebaef8c9).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
63 const uint8_tcxx . . $ uint8_t# *in, uint32_tcxx . . $ uint32_t# inlen,
64 const uint8_tcxx . . $ uint8_t# *iv,
65 uint8_tcxx . . $ uint8_t# *out, uint32_tcxx . . $ uint32_t# outlen, int access)
66 {
67 return (int32_tcxx . . $ int32_t#)impl_cipher_encryptcxx . . $ impl_cipher_encrypt(c011db556473c11f).(handle, in, inlen, iv, out, outlen,
68 access);
69 }
70
71 /*
72 * Fallback function if AIO is not present, but caller requested AIO operation.
73 */
74 static ssize_tcxx . . $ ssize_t#
75 _kcapi_cipher_encrypt_aio_fallbackcxx . . $ _kcapi_cipher_encrypt_aio_fallback(555cd3245f36046).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
76 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
77 size_t iovlen, const uint8_tcxx . . $ uint8_t# *iv)
78 {
79 ssize_tcxx . . $ ssize_t# rc = kcapi_cipher_stream_init_enccxx . . $ kcapi_cipher_stream_init_enc(71df3816f1c2c97b).(handle, iv, iniov, iovlen);
80
81 if (rc < 0)
82 return rc;
83
84 return kcapi_cipher_stream_opcxx . . $ kcapi_cipher_stream_op(8a8f5b62e036cb66).(handle, outiov, iovlen);
85 }
86
87 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_encrypt_aio, "1.3.1")
88 ssize_tcxx . . $ ssize_t# impl_cipher_encrypt_aiocxx . . $ impl_cipher_encrypt_aio(642fe7813a90216d).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
89 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
90 size_t iovlen, const uint8_tcxx . . $ uint8_t# *iv, int access)
91 {
92 ssize_tcxx . . $ ssize_t# ret;
93
94 handle->ciphercxx . . $ kcapi_handle#cipher..ivcxx . . $ kcapi_cipher_data#iv. = iv;
95
96 ret = _kcapi_cipher_crypt_aiocxx . . $ _kcapi_cipher_crypt_aio(2eaa747523f18d63).(handle, iniov, outiov, iovlen,
97 access, ALG_OP_ENCRYPTcxx . . $ `<external>/7256700519741588701/if_alg.h:59:9`!);
98 if (ret != -EOPNOTSUPPcxx . . $ `<external>/17922322188510340118/errno.h:79:9`!)
99 return ret;
100
101 return _kcapi_cipher_encrypt_aio_fallbackcxx . . $ _kcapi_cipher_encrypt_aio_fallback(555cd3245f36046).(handle, iniov, outiov,
102 iovlen, iv);
103 }
104
105 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_encrypt_aio, "0.12.0")
106 int32_tcxx . . $ int32_t# orig_cipher_encrypt_aiocxx . . $ orig_cipher_encrypt_aio(9c7ca60b62de7fac).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
107 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
108 uint32_tcxx . . $ uint32_t# iovlen, const uint8_tcxx . . $ uint8_t# *iv,
109 int access)
110 {
111 return (int32_tcxx . . $ int32_t#)impl_cipher_encrypt_aiocxx . . $ impl_cipher_encrypt_aio(642fe7813a90216d).(handle, iniov, outiov, iovlen,
112 iv, access);
113 }
114
115 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_decrypt, "1.3.1")
116 ssize_tcxx . . $ ssize_t# impl_cipher_decryptcxx . . $ impl_cipher_decrypt(c011db556473c11f).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
117 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
118 const uint8_tcxx . . $ uint8_t# *iv,
119 uint8_tcxx . . $ uint8_t# *out, size_t outlen, int access)
120 {
121 struct kcapi_handle_tfmcxx . . $ kcapi_handle_tfm# *tfm = handle->tfmcxx . . $ kcapi_handle#tfm.;
122
123 /* require properly sized output data size */
124 if (inlen % tfm->infocxx . . $ kcapi_handle_tfm#info..blocksizecxx . . $ kcapi_cipher_info#blocksize.)
125 kcapi_dologcxx . . $ kcapi_dolog(5f46d8f16dd28dce).(KCAPI_LOG_WARNcxx . . $ KCAPI_LOG_WARN.,
126 "Symmetric Decryption: Ciphertext buffer is not multiple of block size %u",
127 tfm->infocxx . . $ kcapi_handle_tfm#info..blocksizecxx . . $ kcapi_cipher_info#blocksize.);
128
129 if (outlen < inlen)
130 kcapi_dologcxx . . $ kcapi_dolog(5f46d8f16dd28dce).(KCAPI_LOG_WARNcxx . . $ KCAPI_LOG_WARN.,
131 "Symmetric Decryption: Plaintext buffer (%lu) is smaller as ciphertext buffer (%lu)",
132 (unsigned long)outlen, (unsigned long)inlen);
133
134 handle->ciphercxx . . $ kcapi_handle#cipher..ivcxx . . $ kcapi_cipher_data#iv. = iv;
135 return _kcapi_cipher_crypt_chunkcxx . . $ _kcapi_cipher_crypt_chunk(8a744cecfacfebd9).(handle, in, inlen, out, outlen, access,
136 ALG_OP_DECRYPTcxx . . $ `<external>/7256700519741588701/if_alg.h:58:9`!);
137 }
138
139 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_decrypt, "0.12.0")
140 int32_tcxx . . $ int32_t# orig_cipher_decryptcxx . . $ orig_cipher_decrypt(2bb63b96ebaef8c9).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
141 const uint8_tcxx . . $ uint8_t# *in, uint32_tcxx . . $ uint32_t# inlen,
142 const uint8_tcxx . . $ uint8_t# *iv,
143 uint8_tcxx . . $ uint8_t# *out, uint32_tcxx . . $ uint32_t# outlen, int access)
144 {
145 return (int32_tcxx . . $ int32_t#)impl_cipher_decryptcxx . . $ impl_cipher_decrypt(c011db556473c11f).(handle, in, inlen, iv, out, outlen,
146 access);
147 }
148
149 /*
150 * Fallback function if AIO is not present, but caller requested AIO operation.
151 */
152 static ssize_tcxx . . $ ssize_t#
153 _kcapi_cipher_decrypt_aio_fallbackcxx . . $ _kcapi_cipher_decrypt_aio_fallback(555cd3245f36046).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
154 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
155 size_t iovlen, const uint8_tcxx . . $ uint8_t# *iv)
156 {
157 ssize_tcxx . . $ ssize_t# rc = kcapi_cipher_stream_init_deccxx . . $ kcapi_cipher_stream_init_dec(71df3816f1c2c97b).(handle, iv, iniov, iovlen);
158
159 if (rc < 0)
160 return rc;
161
162 return kcapi_cipher_stream_opcxx . . $ kcapi_cipher_stream_op(8a8f5b62e036cb66).(handle, outiov, iovlen);
163 }
164
165 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_decrypt_aio, "1.3.1")
166 ssize_tcxx . . $ ssize_t# impl_cipher_decrypt_aiocxx . . $ impl_cipher_decrypt_aio(642fe7813a90216d).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
167 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
168 size_t iovlen, const uint8_tcxx . . $ uint8_t# *iv, int access)
169 {
170 ssize_tcxx . . $ ssize_t# ret;
171
172 handle->ciphercxx . . $ kcapi_handle#cipher..ivcxx . . $ kcapi_cipher_data#iv. = iv;
173
174 ret = _kcapi_cipher_crypt_aiocxx . . $ _kcapi_cipher_crypt_aio(2eaa747523f18d63).(handle, iniov, outiov, iovlen,
175 access, ALG_OP_DECRYPTcxx . . $ `<external>/7256700519741588701/if_alg.h:58:9`!);
176 if (ret != -EOPNOTSUPPcxx . . $ `<external>/17922322188510340118/errno.h:79:9`!)
177 return ret;
178
179 return _kcapi_cipher_decrypt_aio_fallbackcxx . . $ _kcapi_cipher_decrypt_aio_fallback(555cd3245f36046).(handle, iniov, outiov,
180 iovlen, iv);
181 }
182
183 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_decrypt_aio, "0.12.0")
184 int32_tcxx . . $ int32_t# orig_cipher_decrypt_aiocxx . . $ orig_cipher_decrypt_aio(9c7ca60b62de7fac).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
185 struct ioveccxx . . $ iovec# *iniov, struct ioveccxx . . $ iovec# *outiov,
186 uint32_tcxx . . $ uint32_t# iovlen, const uint8_tcxx . . $ uint8_t# *iv, int access)
187 {
188 return (int32_tcxx . . $ int32_t#)impl_cipher_decrypt_aiocxx . . $ impl_cipher_decrypt_aio(642fe7813a90216d).(handle, iniov, outiov, iovlen,
189 iv, access);
190 }
191
192 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_stream_init_enc, "1.3.1")
193 ssize_tcxx . . $ ssize_t# impl_cipher_stream_init_enccxx . . $ impl_cipher_stream_init_enc(71df3816f1c2c97b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
194 const uint8_tcxx . . $ uint8_t# *iv,
195 struct ioveccxx . . $ iovec# *iov, size_t iovlen)
196 {
197 handle->ciphercxx . . $ kcapi_handle#cipher..ivcxx . . $ kcapi_cipher_data#iv. = iv;
198 return _kcapi_common_send_metacxx . . $ _kcapi_common_send_meta(f4e40828a4f4c91f).(handle, iov, iovlen, ALG_OP_ENCRYPTcxx . . $ `<external>/7256700519741588701/if_alg.h:59:9`!,
199 MSG_MOREcxx . . $ `<external>/8962547315054503424/socket.h:244:9`!);
200 }
201
202 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_stream_init_enc, "0.12.0")
203 int32_tcxx . . $ int32_t# orig_cipher_stream_init_enccxx . . $ orig_cipher_stream_init_enc(9733c0cb68428d4b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
204 const uint8_tcxx . . $ uint8_t# *iv,
205 struct ioveccxx . . $ iovec# *iov, uint32_tcxx . . $ uint32_t# iovlen)
206 {
207 return (int32_tcxx . . $ int32_t#)impl_cipher_stream_init_enccxx . . $ impl_cipher_stream_init_enc(71df3816f1c2c97b).(handle, iv, iov, iovlen);
208 }
209
210 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_stream_init_dec, "1.3.1")
211 ssize_tcxx . . $ ssize_t# impl_cipher_stream_init_deccxx . . $ impl_cipher_stream_init_dec(71df3816f1c2c97b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
212 const uint8_tcxx . . $ uint8_t# *iv,
213 struct ioveccxx . . $ iovec# *iov, size_t iovlen)
214 {
215 handle->ciphercxx . . $ kcapi_handle#cipher..ivcxx . . $ kcapi_cipher_data#iv. = iv;
216 return _kcapi_common_send_metacxx . . $ _kcapi_common_send_meta(f4e40828a4f4c91f).(handle, iov, iovlen, ALG_OP_DECRYPTcxx . . $ `<external>/7256700519741588701/if_alg.h:58:9`!,
217 MSG_MOREcxx . . $ `<external>/8962547315054503424/socket.h:244:9`!);
218 }
219
220 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_stream_init_dec, "0.12.0")
221 int32_tcxx . . $ int32_t# orig_cipher_stream_init_deccxx . . $ orig_cipher_stream_init_dec(9733c0cb68428d4b).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
222 const uint8_tcxx . . $ uint8_t# *iv,
223 struct ioveccxx . . $ iovec# *iov, uint32_tcxx . . $ uint32_t# iovlen)
224 {
225 return (int32_tcxx . . $ int32_t#)impl_cipher_stream_init_deccxx . . $ impl_cipher_stream_init_dec(71df3816f1c2c97b).(handle, iv, iov, iovlen);
226 }
227
228 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_stream_update, "1.3.1")
229 ssize_tcxx . . $ ssize_t# impl_cipher_stream_updatecxx . . $ impl_cipher_stream_update(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
230 struct ioveccxx . . $ iovec# *iov, size_t iovlen)
231 {
232 if (handle->processed_sgcxx . . $ kcapi_handle#processed_sg. <= handle->flagscxx . . $ kcapi_handle#flags..alg_max_pagescxx . . $ kcapi_flags#alg_max_pages.)
233 return _kcapi_common_vmsplice_iovcxx . . $ _kcapi_common_vmsplice_iov(367dd066ce527de7).(handle, iov, iovlen,
234 SPLICE_F_MOREcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:350:10`!);
235 else
236 return _kcapi_common_send_datacxx . . $ _kcapi_common_send_data(367dd066ce527de7).(handle, iov, iovlen, MSG_MOREcxx . . $ `<external>/8962547315054503424/socket.h:244:9`!);
237 }
238
239 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_stream_update, "0.12.0")
240 int32_tcxx . . $ int32_t# orig_cipher_stream_updatecxx . . $ orig_cipher_stream_update(c4d2c5412bbf44d9).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
241 struct ioveccxx . . $ iovec# *iov, uint32_tcxx . . $ uint32_t# iovlen)
242 {
243 return (int32_tcxx . . $ int32_t#)impl_cipher_stream_updatecxx . . $ impl_cipher_stream_update(8a8f5b62e036cb66).(handle, iov, iovlen);
244 }
245
246 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_stream_update_last, "1.3.1")
247 ssize_tcxx . . $ ssize_t# impl_cipher_stream_update_lastcxx . . $ impl_cipher_stream_update_last(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
248 struct ioveccxx . . $ iovec# *iov, size_t iovlen)
249 {
250 if (handle->processed_sgcxx . . $ kcapi_handle#processed_sg. <= handle->flagscxx . . $ kcapi_handle#flags..alg_max_pagescxx . . $ kcapi_flags#alg_max_pages.)
251 return _kcapi_common_vmsplice_iovcxx . . $ _kcapi_common_vmsplice_iov(367dd066ce527de7).(handle, iov, iovlen, 0);
252 else
253 return _kcapi_common_send_datacxx . . $ _kcapi_common_send_data(367dd066ce527de7).(handle, iov, iovlen, 0);
254 }
255
256 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_stream_update_last, "1.2.0")
257 int32_tcxx . . $ int32_t# orig_cipher_stream_update_lastcxx . . $ orig_cipher_stream_update_last(c4d2c5412bbf44d9).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
258 struct ioveccxx . . $ iovec# *iov, uint32_tcxx . . $ uint32_t# iovlen)
259 {
260 return (int32_tcxx . . $ int32_t#)impl_cipher_stream_update_lastcxx . . $ impl_cipher_stream_update_last(8a8f5b62e036cb66).(handle, iov, iovlen);
261 }
262
263 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_stream_op, "1.3.1")
264 ssize_tcxx . . $ ssize_t# impl_cipher_stream_opcxx . . $ impl_cipher_stream_op(8a8f5b62e036cb66).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
265 struct ioveccxx . . $ iovec# *iov, size_t iovlen)
266 {
267 if (!iov || !iovlen) {
268 kcapi_dologcxx . . $ kcapi_dolog(5f46d8f16dd28dce).(KCAPI_LOG_ERRcxx . . $ KCAPI_LOG_ERR.,
269 "Symmetric operation: No buffer for output data provided");
270 return -EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
271 }
272 return _kcapi_common_recv_datacxx . . $ _kcapi_common_recv_data(8a8f5b62e036cb66).(handle, iov, iovlen);
273 }
274
275 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_stream_op, "0.12.0")
276 int32_tcxx . . $ int32_t# orig_cipher_stream_opcxx . . $ orig_cipher_stream_op(c4d2c5412bbf44d9).(struct kcapi_handlecxx . . $ kcapi_handle# *handle,
277 struct ioveccxx . . $ iovec# *iov, uint32_tcxx . . $ uint32_t# iovlen)
278 {
279 return (int32_tcxx . . $ int32_t#)impl_cipher_stream_opcxx . . $ impl_cipher_stream_op(8a8f5b62e036cb66).(handle, iov, iovlen);
280 }
281
282 uint32_tcxx . . $ uint32_t# kcapi_cipher_ivsizecxx . . $ kcapi_cipher_ivsize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle)
283 {
284 struct kcapi_handle_tfmcxx . . $ kcapi_handle_tfm# *tfm = handle->tfmcxx . . $ kcapi_handle#tfm.;
285
286 return tfm->infocxx . . $ kcapi_handle_tfm#info..ivsizecxx . . $ kcapi_cipher_info#ivsize.;
287 }
288
289 uint32_tcxx . . $ uint32_t# kcapi_cipher_blocksizecxx . . $ kcapi_cipher_blocksize(994c7fcc3809be77).(struct kcapi_handlecxx . . $ kcapi_handle# *handle)
290 {
291 struct kcapi_handle_tfmcxx . . $ kcapi_handle_tfm# *tfm = handle->tfmcxx . . $ kcapi_handle#tfm.;
292
293 return tfm->infocxx . . $ kcapi_handle_tfm#info..blocksizecxx . . $ kcapi_cipher_info#blocksize.;
294 }
295
296 static inline ssize_tcxx . . $ ssize_t# kcapi_cipher_conv_enc_commoncxx . . $ kcapi_cipher_conv_enc_common(d2aa283dd4db830c).(const char *name,
297 const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
298 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
299 const uint8_tcxx . . $ uint8_t# *iv,
300 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
301 {
302 struct kcapi_handlecxx . . $ kcapi_handle# *handle;
303 ssize_tcxx . . $ ssize_t# ret = _kcapi_handle_initcxx . . $ _kcapi_handle_init(db986b7fadb21840).(&handle, "skcipher", name, 0);
304 if (ret)
305 return ret;
306
307 ret = kcapi_cipher_setkeycxx . . $ kcapi_cipher_setkey(4d0e261613a805ee).(handle, key, keylen);
308 if (ret)
309 goto out;
310
311 ret = kcapi_cipher_encryptcxx . . $ kcapi_cipher_encrypt(c011db556473c11f).(handle, in, inlen, iv, out, outlen, 0);
312
313 out:
314 _kcapi_handle_destroycxx . . $ _kcapi_handle_destroy(aba29416d24fdd59).(handle);
315 return ret;
316 }
317
318 static inline ssize_tcxx . . $ ssize_t# kcapi_cipher_conv_dec_commoncxx . . $ kcapi_cipher_conv_dec_common(d2aa283dd4db830c).(const char *name,
319 const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
320 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
321 const uint8_tcxx . . $ uint8_t# *iv,
322 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
323 {
324 struct kcapi_handlecxx . . $ kcapi_handle# *handle;
325 ssize_tcxx . . $ ssize_t# ret = _kcapi_handle_initcxx . . $ _kcapi_handle_init(db986b7fadb21840).(&handle, "skcipher", name, 0);
326
327 if (ret)
328 return ret;
329
330 ret = kcapi_cipher_setkeycxx . . $ kcapi_cipher_setkey(4d0e261613a805ee).(handle, key, keylen);
331 if (ret)
332 goto out;
333
334 ret = kcapi_cipher_decryptcxx . . $ kcapi_cipher_decrypt(c011db556473c11f).(handle, in, inlen, iv, out, outlen, 0);
335
336 out:
337 _kcapi_handle_destroycxx . . $ _kcapi_handle_destroy(aba29416d24fdd59).(handle);
338 return ret;
339 }
340
341 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_enc_aes_cbc, "1.3.1")
342 ssize_tcxx . . $ ssize_t# impl_cipher_enc_aes_cbccxx . . $ impl_cipher_enc_aes_cbc(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
343 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
344 const uint8_tcxx . . $ uint8_t# *iv,
345 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
346 {
347 return kcapi_cipher_conv_enc_commoncxx . . $ kcapi_cipher_conv_enc_common(d2aa283dd4db830c).("cbc(aes)", key, keylen, in, inlen,
348 iv, out, outlen);
349 }
350
351 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_enc_aes_cbc, "1.0.0")
352 int32_tcxx . . $ int32_t# orig_cipher_enc_aes_cbccxx . . $ orig_cipher_enc_aes_cbc(d85e1e905111582c).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
353 const uint8_tcxx . . $ uint8_t# *in, uint32_tcxx . . $ uint32_t# inlen,
354 const uint8_tcxx . . $ uint8_t# *iv,
355 uint8_tcxx . . $ uint8_t# *out, uint32_tcxx . . $ uint32_t# outlen)
356 {
357 return (int32_tcxx . . $ int32_t#)kcapi_cipher_conv_enc_commoncxx . . $ kcapi_cipher_conv_enc_common(d2aa283dd4db830c).("cbc(aes)", key, keylen,
358 in, inlen, iv,
359 out, outlen);
360 }
361
362 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_enc_aes_ctr, "1.3.1")
363 ssize_tcxx . . $ ssize_t# impl_cipher_enc_aes_ctrcxx . . $ impl_cipher_enc_aes_ctr(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
364 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
365 const uint8_tcxx . . $ uint8_t# *ctr,
366 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
367 {
368 return kcapi_cipher_conv_enc_commoncxx . . $ kcapi_cipher_conv_enc_common(d2aa283dd4db830c).("ctr(aes)", key, keylen, in, inlen,
369 ctr, out, outlen);
370 }
371
372 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_enc_aes_ctr, "1.0.0")
373 int32_tcxx . . $ int32_t# orig_cipher_enc_aes_ctrcxx . . $ orig_cipher_enc_aes_ctr(d85e1e905111582c).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
374 const uint8_tcxx . . $ uint8_t# *in, uint32_tcxx . . $ uint32_t# inlen,
375 const uint8_tcxx . . $ uint8_t# *ctr,
376 uint8_tcxx . . $ uint8_t# *out, uint32_tcxx . . $ uint32_t# outlen)
377 {
378 return (int32_tcxx . . $ int32_t#)kcapi_cipher_conv_enc_commoncxx . . $ kcapi_cipher_conv_enc_common(d2aa283dd4db830c).("ctr(aes)", key, keylen,
379 in, inlen, ctr,
380 out, outlen);
381 }
382
383 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_dec_aes_cbc, "1.3.1")
384 ssize_tcxx . . $ ssize_t# impl_cipher_dec_aes_cbccxx . . $ impl_cipher_dec_aes_cbc(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
385 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
386 const uint8_tcxx . . $ uint8_t# *iv,
387 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
388 {
389 return kcapi_cipher_conv_dec_commoncxx . . $ kcapi_cipher_conv_dec_common(d2aa283dd4db830c).("cbc(aes)", key, keylen, in, inlen,
390 iv, out, outlen);
391 }
392
393 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_dec_aes_cbc, "1.0.0")
394 int32_tcxx . . $ int32_t# orig_cipher_dec_aes_cbccxx . . $ orig_cipher_dec_aes_cbc(d85e1e905111582c).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
395 const uint8_tcxx . . $ uint8_t# *in, uint32_tcxx . . $ uint32_t# inlen,
396 const uint8_tcxx . . $ uint8_t# *iv,
397 uint8_tcxx . . $ uint8_t# *out, uint32_tcxx . . $ uint32_t# outlen)
398 {
399 return (int32_tcxx . . $ int32_t#)kcapi_cipher_conv_dec_commoncxx . . $ kcapi_cipher_conv_dec_common(d2aa283dd4db830c).("cbc(aes)", key, keylen,
400 in, inlen, iv,
401 out, outlen);
402 }
403
404 IMPL_SYMVERcxx . . $ `lib/internal.h:363:10`!(cipher_dec_aes_ctr, "1.3.1")
405 ssize_tcxx . . $ ssize_t# impl_cipher_dec_aes_ctrcxx . . $ impl_cipher_dec_aes_ctr(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
406 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
407 const uint8_tcxx . . $ uint8_t# *ctr,
408 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
409 {
410 return kcapi_cipher_conv_dec_commoncxx . . $ kcapi_cipher_conv_dec_common(d2aa283dd4db830c).("ctr(aes)", key, keylen, in, inlen,
411 ctr, out, outlen);
412 }
413
414 ORIG_SYMVERcxx . . $ `lib/internal.h:366:10`!(cipher_dec_aes_ctr, "1.0.0")
415 int32_tcxx . . $ int32_t# orig_cipher_dec_aes_ctrcxx . . $ orig_cipher_dec_aes_ctr(d85e1e905111582c).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
416 const uint8_tcxx . . $ uint8_t# *in, uint32_tcxx . . $ uint32_t# inlen,
417 const uint8_tcxx . . $ uint8_t# *ctr,
418 uint8_tcxx . . $ uint8_t# *out, uint32_tcxx . . $ uint32_t# outlen)
419 {
420 return (int32_tcxx . . $ int32_t#)kcapi_cipher_conv_dec_commoncxx . . $ kcapi_cipher_conv_dec_common(d2aa283dd4db830c).("ctr(aes)", key, keylen,
421 in, inlen, ctr,
422 out, outlen);
423 }
424
425 ssize_tcxx . . $ ssize_t# kcapi_cipher_enc_sm4_cbccxx . . $ kcapi_cipher_enc_sm4_cbc(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
426 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
427 const uint8_tcxx . . $ uint8_t# *iv,
428 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
429 {
430 return kcapi_cipher_conv_enc_commoncxx . . $ kcapi_cipher_conv_enc_common(d2aa283dd4db830c).("cbc(sm4)", key, keylen, in, inlen,
431 iv, out, outlen);
432 }
433
434 ssize_tcxx . . $ ssize_t# kcapi_cipher_enc_sm4_ctrcxx . . $ kcapi_cipher_enc_sm4_ctr(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
435 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
436 const uint8_tcxx . . $ uint8_t# *ctr,
437 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
438 {
439 return kcapi_cipher_conv_enc_commoncxx . . $ kcapi_cipher_conv_enc_common(d2aa283dd4db830c).("ctr(sm4)", key, keylen, in, inlen,
440 ctr, out, outlen);
441 }
442
443 ssize_tcxx . . $ ssize_t# kcapi_cipher_dec_sm4_cbccxx . . $ kcapi_cipher_dec_sm4_cbc(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
444 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
445 const uint8_tcxx . . $ uint8_t# *iv,
446 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
447 {
448 return kcapi_cipher_conv_dec_commoncxx . . $ kcapi_cipher_conv_dec_common(d2aa283dd4db830c).("cbc(sm4)", key, keylen, in, inlen,
449 iv, out, outlen);
450 }
451
452 ssize_tcxx . . $ ssize_t# kcapi_cipher_dec_sm4_ctrcxx . . $ kcapi_cipher_dec_sm4_ctr(e75b73ea416312ba).(const uint8_tcxx . . $ uint8_t# *key, uint32_tcxx . . $ uint32_t# keylen,
453 const uint8_tcxx . . $ uint8_t# *in, size_t inlen,
454 const uint8_tcxx . . $ uint8_t# *ctr,
455 uint8_tcxx . . $ uint8_t# *out, size_t outlen)
456 {
457 return kcapi_cipher_conv_dec_commoncxx . . $ kcapi_cipher_conv_dec_common(d2aa283dd4db830c).("ctr(sm4)", key, keylen, in, inlen,
458 ctr, out, outlen);
459 }