2 * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 /* We need to use some deprecated APIs */
11 #define OPENSSL_SUPPRESS_DEPRECATED
13 /* Required for vmsplice */
21 #include <openssl/engine.h>
22 #include <openssl/async.h>
23 #include <openssl/err.h>
24 #include "internal/nelem.h"
26 #include <sys/socket.h>
27 #include <linux/version.h>
31 #if LINUX_VERSION_CODE < KERNEL_VERSION(K_MAJ, K_MIN1, K_MIN2) || \
34 # warning "AFALG ENGINE requires Kernel Headers >= 4.1.0"
35 # warning "Skipping Compilation of AFALG engine"
37 void engine_load_afalg_int(void);
38 void engine_load_afalg_int(void)
43 # include <linux/if_alg.h>
45 # include <sys/utsname.h>
47 # include <linux/aio_abi.h>
48 # include <sys/syscall.h>
52 # include "e_afalg_err.c"
59 # ifndef SPLICE_F_GIFT
60 # define SPLICE_F_GIFT (0x08)
64 # define ALG_AES_IV_LEN 16
65 # define ALG_IV_LEN(len) (sizeof(struct af_alg_iv) + (len))
66 # define ALG_OP_TYPE unsigned int
67 # define ALG_OP_LEN (sizeof(ALG_OP_TYPE))
69 # ifdef OPENSSL_NO_DYNAMIC_ENGINE
70 void engine_load_afalg_int(void);
73 /* Local Linkage Functions */
74 static int afalg_init_aio(afalg_aio *aio);
75 static int afalg_fin_cipher_aio(afalg_aio *ptr, int sfd,
76 unsigned char *buf, size_t len);
77 static int afalg_create_sk(afalg_ctx *actx, const char *ciphertype,
78 const char *ciphername);
79 static int afalg_destroy(ENGINE *e);
80 static int afalg_init(ENGINE *e);
81 static int afalg_finish(ENGINE *e);
82 static const EVP_CIPHER *afalg_aes_cbc(int nid);
83 static cbc_handles *get_cipher_handle(int nid);
84 static int afalg_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
85 const int **nids, int nid);
86 static int afalg_cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
87 const unsigned char *iv, int enc);
88 static int afalg_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
89 const unsigned char *in, size_t inl);
90 static int afalg_cipher_cleanup(EVP_CIPHER_CTX *ctx);
91 static int afalg_chk_platform(void);
93 /* Engine Id and Name */
94 static const char *engine_afalg_id = "afalg";
95 static const char *engine_afalg_name = "AFALG engine support";
97 static int afalg_cipher_nids[] = {
103 static cbc_handles cbc_handle[] = {{AES_KEY_SIZE_128, NULL},
104 {AES_KEY_SIZE_192, NULL},
105 {AES_KEY_SIZE_256, NULL}};
107 static ossl_inline int io_setup(unsigned n, aio_context_t *ctx)
109 return syscall(__NR_io_setup, n, ctx);
112 static ossl_inline int eventfd(int n)
114 return syscall(__NR_eventfd2, n, 0);
117 static ossl_inline int io_destroy(aio_context_t ctx)
119 return syscall(__NR_io_destroy, ctx);
122 static ossl_inline int io_read(aio_context_t ctx, long n, struct iocb **iocb)
124 return syscall(__NR_io_submit, ctx, n, iocb);
127 static ossl_inline int io_getevents(aio_context_t ctx, long min, long max,
128 struct io_event *events,
129 struct timespec *timeout)
131 #if defined(__NR_io_getevents)
132 return syscall(__NR_io_getevents, ctx, min, max, events, timeout);
133 #elif defined(__NR_io_pgetevents_time64)
134 /* Let's only support the 64 suffix syscalls for 64-bit time_t.
135 * This simplifies the code for us as we don't need to use a 64-bit
136 * version of timespec with a 32-bit time_t and handle converting
137 * between 64-bit and 32-bit times and check for overflows.
139 if (sizeof(timeout->tv_sec) == 8)
140 return syscall(__NR_io_pgetevents_time64, ctx, min, max, events, timeout, NULL);
146 # error "We require either the io_getevents syscall or __NR_io_pgetevents_time64."
150 static void afalg_waitfd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key,
151 OSSL_ASYNC_FD waitfd, void *custom)
156 static int afalg_setup_async_event_notification(afalg_aio *aio)
159 ASYNC_WAIT_CTX *waitctx;
163 if ((job = ASYNC_get_current_job()) != NULL) {
165 waitctx = ASYNC_get_wait_ctx(job);
166 if (waitctx == NULL) {
167 ALG_WARN("%s(%d): ASYNC_get_wait_ctx error", __FILE__, __LINE__);
170 /* Get waitfd from ASYNC_WAIT_CTX if it is already set */
171 ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_afalg_id,
175 * waitfd is not set in ASYNC_WAIT_CTX, create a new one
176 * and set it. efd will be signaled when AIO operation completes
178 aio->efd = eventfd(0);
179 if (aio->efd == -1) {
180 ALG_PERR("%s(%d): Failed to get eventfd : ", __FILE__,
182 AFALGerr(AFALG_F_AFALG_SETUP_ASYNC_EVENT_NOTIFICATION,
183 AFALG_R_EVENTFD_FAILED);
186 ret = ASYNC_WAIT_CTX_set_wait_fd(waitctx, engine_afalg_id,
188 afalg_waitfd_cleanup);
190 ALG_WARN("%s(%d): Failed to set wait fd", __FILE__, __LINE__);
194 /* make fd non-blocking in async mode */
195 if (fcntl(aio->efd, F_SETFL, O_NONBLOCK) != 0) {
196 ALG_WARN("%s(%d): Failed to set event fd as NONBLOCKING",
200 aio->mode = MODE_ASYNC;
203 aio->efd = eventfd(0);
204 if (aio->efd == -1) {
205 ALG_PERR("%s(%d): Failed to get eventfd : ", __FILE__, __LINE__);
206 AFALGerr(AFALG_F_AFALG_SETUP_ASYNC_EVENT_NOTIFICATION,
207 AFALG_R_EVENTFD_FAILED);
210 aio->mode = MODE_SYNC;
215 static int afalg_init_aio(afalg_aio *aio)
219 /* Initialise for AIO */
221 r = io_setup(MAX_INFLIGHTS, &aio->aio_ctx);
223 ALG_PERR("%s(%d): io_setup error : ", __FILE__, __LINE__);
224 AFALGerr(AFALG_F_AFALG_INIT_AIO, AFALG_R_IO_SETUP_FAILED);
228 memset(aio->cbt, 0, sizeof(aio->cbt));
230 aio->mode = MODE_UNINIT;
235 static int afalg_fin_cipher_aio(afalg_aio *aio, int sfd, unsigned char *buf,
240 unsigned int done = 0;
242 struct timespec timeout;
243 struct io_event events[MAX_INFLIGHTS];
249 /* if efd has not been initialised yet do it here */
250 if (aio->mode == MODE_UNINIT) {
251 r = afalg_setup_async_event_notification(aio);
256 cb = &(aio->cbt[0 % MAX_INFLIGHTS]);
257 memset(cb, '\0', sizeof(*cb));
258 cb->aio_fildes = sfd;
259 cb->aio_lio_opcode = IOCB_CMD_PREAD;
261 * The pointer has to be converted to unsigned value first to avoid
262 * sign extension on cast to 64 bit value in 32-bit builds
264 cb->aio_buf = (size_t)buf;
267 cb->aio_nbytes = len;
268 cb->aio_flags = IOCB_FLAG_RESFD;
269 cb->aio_resfd = aio->efd;
272 * Perform AIO read on AFALG socket, this in turn performs an async
273 * crypto operation in kernel space
275 r = io_read(aio->aio_ctx, 1, &cb);
277 ALG_PWARN("%s(%d): io_read failed : ", __FILE__, __LINE__);
282 /* While AIO read is being performed pause job */
285 /* Check for completion of AIO read */
286 r = read(aio->efd, &eval, sizeof(eval));
288 if (errno == EAGAIN || errno == EWOULDBLOCK)
290 ALG_PERR("%s(%d): read failed for event fd : ", __FILE__, __LINE__);
292 } else if (r == 0 || eval <= 0) {
293 ALG_WARN("%s(%d): eventfd read %d bytes, eval = %lu\n", __FILE__,
298 /* Get results of AIO read */
299 r = io_getevents(aio->aio_ctx, 1, MAX_INFLIGHTS,
303 * events.res indicates the actual status of the operation.
304 * Handle the error condition first.
306 if (events[0].res < 0) {
308 * Underlying operation cannot be completed at the time
309 * of previous submission. Resubmit for the operation.
311 if (events[0].res == -EBUSY && retry++ < 3) {
312 r = io_read(aio->aio_ctx, 1, &cb);
314 ALG_PERR("%s(%d): retry %d for io_read failed : ",
315 __FILE__, __LINE__, retry);
321 * Retries exceed for -EBUSY or unrecoverable error
322 * condition for this instance of operation.
325 ("%s(%d): Crypto Operation failed with code %lld\n",
326 __FILE__, __LINE__, events[0].res);
330 /* Operation successful. */
333 ALG_PERR("%s(%d): io_getevents failed : ", __FILE__, __LINE__);
336 ALG_WARN("%s(%d): io_geteventd read 0 bytes\n", __FILE__,
345 static ossl_inline void afalg_set_op_sk(struct cmsghdr *cmsg,
346 const ALG_OP_TYPE op)
348 cmsg->cmsg_level = SOL_ALG;
349 cmsg->cmsg_type = ALG_SET_OP;
350 cmsg->cmsg_len = CMSG_LEN(ALG_OP_LEN);
351 memcpy(CMSG_DATA(cmsg), &op, ALG_OP_LEN);
354 static void afalg_set_iv_sk(struct cmsghdr *cmsg, const unsigned char *iv,
355 const unsigned int len)
357 struct af_alg_iv *aiv;
359 cmsg->cmsg_level = SOL_ALG;
360 cmsg->cmsg_type = ALG_SET_IV;
361 cmsg->cmsg_len = CMSG_LEN(ALG_IV_LEN(len));
362 aiv = (struct af_alg_iv *)CMSG_DATA(cmsg);
364 memcpy(aiv->iv, iv, len);
367 static ossl_inline int afalg_set_key(afalg_ctx *actx, const unsigned char *key,
371 ret = setsockopt(actx->bfd, SOL_ALG, ALG_SET_KEY, key, klen);
373 ALG_PERR("%s(%d): Failed to set socket option : ", __FILE__, __LINE__);
374 AFALGerr(AFALG_F_AFALG_SET_KEY, AFALG_R_SOCKET_SET_KEY_FAILED);
380 static int afalg_create_sk(afalg_ctx *actx, const char *ciphertype,
381 const char *ciphername)
383 struct sockaddr_alg sa;
386 actx->bfd = actx->sfd = -1;
388 memset(&sa, 0, sizeof(sa));
389 sa.salg_family = AF_ALG;
390 OPENSSL_strlcpy((char *) sa.salg_type, ciphertype, sizeof(sa.salg_type));
391 OPENSSL_strlcpy((char *) sa.salg_name, ciphername, sizeof(sa.salg_name));
393 actx->bfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
394 if (actx->bfd == -1) {
395 ALG_PERR("%s(%d): Failed to open socket : ", __FILE__, __LINE__);
396 AFALGerr(AFALG_F_AFALG_CREATE_SK, AFALG_R_SOCKET_CREATE_FAILED);
400 r = bind(actx->bfd, (struct sockaddr *)&sa, sizeof(sa));
402 ALG_PERR("%s(%d): Failed to bind socket : ", __FILE__, __LINE__);
403 AFALGerr(AFALG_F_AFALG_CREATE_SK, AFALG_R_SOCKET_BIND_FAILED);
407 actx->sfd = accept(actx->bfd, NULL, 0);
409 ALG_PERR("%s(%d): Socket Accept Failed : ", __FILE__, __LINE__);
410 AFALGerr(AFALG_F_AFALG_CREATE_SK, AFALG_R_SOCKET_ACCEPT_FAILED);
421 actx->bfd = actx->sfd = -1;
425 static int afalg_start_cipher_sk(afalg_ctx *actx, const unsigned char *in,
426 size_t inl, const unsigned char *iv,
430 struct cmsghdr *cmsg;
433 # ifdef ALG_ZERO_COPY
436 char cbuf[CMSG_SPACE(ALG_IV_LEN(ALG_AES_IV_LEN)) + CMSG_SPACE(ALG_OP_LEN)];
438 memset(&msg, 0, sizeof(msg));
439 memset(cbuf, 0, sizeof(cbuf));
440 msg.msg_control = cbuf;
441 msg.msg_controllen = sizeof(cbuf);
444 * cipher direction (i.e. encrypt or decrypt) and iv are sent to the
445 * kernel as part of sendmsg()'s ancillary data
447 cmsg = CMSG_FIRSTHDR(&msg);
448 afalg_set_op_sk(cmsg, enc);
449 cmsg = CMSG_NXTHDR(&msg, cmsg);
450 afalg_set_iv_sk(cmsg, iv, ALG_AES_IV_LEN);
452 /* iov that describes input data */
453 iov.iov_base = (unsigned char *)in;
456 msg.msg_flags = MSG_MORE;
458 # ifdef ALG_ZERO_COPY
461 * Works best when buffer is 4k aligned
462 * OPENS: out of place processing (i.e. out != in)
465 /* Input data is not sent as part of call to sendmsg() */
469 /* Sendmsg() sends iv and cipher direction to the kernel */
470 sbytes = sendmsg(actx->sfd, &msg, 0);
472 ALG_PERR("%s(%d): sendmsg failed for zero copy cipher operation : ",
478 * vmsplice and splice are used to pin the user space input buffer for
479 * kernel space processing avoiding copies from user to kernel space
481 ret = vmsplice(actx->zc_pipe[1], &iov, 1, SPLICE_F_GIFT);
483 ALG_PERR("%s(%d): vmsplice failed : ", __FILE__, __LINE__);
487 ret = splice(actx->zc_pipe[0], NULL, actx->sfd, NULL, inl, 0);
489 ALG_PERR("%s(%d): splice failed : ", __FILE__, __LINE__);
496 /* Sendmsg() sends iv, cipher direction and input data to the kernel */
497 sbytes = sendmsg(actx->sfd, &msg, 0);
499 ALG_PERR("%s(%d): sendmsg failed for cipher operation : ", __FILE__,
504 if (sbytes != (ssize_t) inl) {
505 ALG_WARN("Cipher operation send bytes %zd != inlen %zd\n", sbytes,
514 static int afalg_cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
515 const unsigned char *iv, int enc)
520 const char *ciphername;
522 if (ctx == NULL || key == NULL) {
523 ALG_WARN("%s(%d): Null Parameter\n", __FILE__, __LINE__);
527 if (EVP_CIPHER_CTX_cipher(ctx) == NULL) {
528 ALG_WARN("%s(%d): Cipher object NULL\n", __FILE__, __LINE__);
532 actx = EVP_CIPHER_CTX_get_cipher_data(ctx);
534 ALG_WARN("%s(%d): Cipher data NULL\n", __FILE__, __LINE__);
538 ciphertype = EVP_CIPHER_CTX_nid(ctx);
539 switch (ciphertype) {
540 case NID_aes_128_cbc:
541 case NID_aes_192_cbc:
542 case NID_aes_256_cbc:
543 ciphername = "cbc(aes)";
546 ALG_WARN("%s(%d): Unsupported Cipher type %d\n", __FILE__, __LINE__,
551 if (ALG_AES_IV_LEN != EVP_CIPHER_CTX_iv_length(ctx)) {
552 ALG_WARN("%s(%d): Unsupported IV length :%d\n", __FILE__, __LINE__,
553 EVP_CIPHER_CTX_iv_length(ctx));
557 /* Setup AFALG socket for crypto processing */
558 ret = afalg_create_sk(actx, "skcipher", ciphername);
563 ret = afalg_set_key(actx, key, EVP_CIPHER_CTX_key_length(ctx));
567 /* Setup AIO ctx to allow async AFALG crypto processing */
568 if (afalg_init_aio(&actx->aio) == 0)
571 # ifdef ALG_ZERO_COPY
575 actx->init_done = MAGIC_INIT_NUM;
585 static int afalg_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
586 const unsigned char *in, size_t inl)
590 char nxtiv[ALG_AES_IV_LEN] = { 0 };
592 if (ctx == NULL || out == NULL || in == NULL) {
593 ALG_WARN("NULL parameter passed to function %s(%d)\n", __FILE__,
598 actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx);
599 if (actx == NULL || actx->init_done != MAGIC_INIT_NUM) {
600 ALG_WARN("%s afalg ctx passed\n",
601 ctx == NULL ? "NULL" : "Uninitialised");
606 * set iv now for decrypt operation as the input buffer can be
607 * overwritten for inplace operation where in = out.
609 if (EVP_CIPHER_CTX_encrypting(ctx) == 0) {
610 memcpy(nxtiv, in + (inl - ALG_AES_IV_LEN), ALG_AES_IV_LEN);
613 /* Send input data to kernel space */
614 ret = afalg_start_cipher_sk(actx, (unsigned char *)in, inl,
615 EVP_CIPHER_CTX_iv(ctx),
616 EVP_CIPHER_CTX_encrypting(ctx));
621 /* Perform async crypto operation in kernel space */
622 ret = afalg_fin_cipher_aio(&actx->aio, actx->sfd, out, inl);
626 if (EVP_CIPHER_CTX_encrypting(ctx)) {
627 memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), out + (inl - ALG_AES_IV_LEN),
630 memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), nxtiv, ALG_AES_IV_LEN);
636 static int afalg_cipher_cleanup(EVP_CIPHER_CTX *ctx)
641 ALG_WARN("NULL parameter passed to function %s(%d)\n", __FILE__,
646 actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx);
647 if (actx == NULL || actx->init_done != MAGIC_INIT_NUM) {
648 ALG_WARN("%s afalg ctx passed\n",
649 ctx == NULL ? "NULL" : "Uninitialised");
655 # ifdef ALG_ZERO_COPY
656 close(actx->zc_pipe[0]);
657 close(actx->zc_pipe[1]);
659 /* close efd in sync mode, async mode is closed in afalg_waitfd_cleanup() */
660 if (actx->aio.mode == MODE_SYNC)
661 close(actx->aio.efd);
662 io_destroy(actx->aio.aio_ctx);
667 static cbc_handles *get_cipher_handle(int nid)
670 case NID_aes_128_cbc:
671 return &cbc_handle[AES_CBC_128];
672 case NID_aes_192_cbc:
673 return &cbc_handle[AES_CBC_192];
674 case NID_aes_256_cbc:
675 return &cbc_handle[AES_CBC_256];
681 static const EVP_CIPHER *afalg_aes_cbc(int nid)
683 cbc_handles *cipher_handle = get_cipher_handle(nid);
685 if (cipher_handle == NULL)
687 if (cipher_handle->_hidden == NULL
688 && ((cipher_handle->_hidden =
689 EVP_CIPHER_meth_new(nid,
691 cipher_handle->key_size)) == NULL
692 || !EVP_CIPHER_meth_set_iv_length(cipher_handle->_hidden,
694 || !EVP_CIPHER_meth_set_flags(cipher_handle->_hidden,
696 EVP_CIPH_FLAG_DEFAULT_ASN1)
697 || !EVP_CIPHER_meth_set_init(cipher_handle->_hidden,
699 || !EVP_CIPHER_meth_set_do_cipher(cipher_handle->_hidden,
701 || !EVP_CIPHER_meth_set_cleanup(cipher_handle->_hidden,
702 afalg_cipher_cleanup)
703 || !EVP_CIPHER_meth_set_impl_ctx_size(cipher_handle->_hidden,
704 sizeof(afalg_ctx)))) {
705 EVP_CIPHER_meth_free(cipher_handle->_hidden);
706 cipher_handle->_hidden= NULL;
708 return cipher_handle->_hidden;
711 static int afalg_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
712 const int **nids, int nid)
716 if (cipher == NULL) {
717 *nids = afalg_cipher_nids;
718 return (sizeof(afalg_cipher_nids) / sizeof(afalg_cipher_nids[0]));
722 case NID_aes_128_cbc:
723 case NID_aes_192_cbc:
724 case NID_aes_256_cbc:
725 *cipher = afalg_aes_cbc(nid);
734 static int bind_afalg(ENGINE *e)
736 /* Ensure the afalg error handling is set up */
738 ERR_load_AFALG_strings();
740 if (!ENGINE_set_id(e, engine_afalg_id)
741 || !ENGINE_set_name(e, engine_afalg_name)
742 || !ENGINE_set_destroy_function(e, afalg_destroy)
743 || !ENGINE_set_init_function(e, afalg_init)
744 || !ENGINE_set_finish_function(e, afalg_finish)) {
745 AFALGerr(AFALG_F_BIND_AFALG, AFALG_R_INIT_FAILED);
750 * Create _hidden_aes_xxx_cbc by calling afalg_aes_xxx_cbc
751 * now, as bind_aflag can only be called by one thread at a
754 for(i = 0; i < OSSL_NELEM(afalg_cipher_nids); i++) {
755 if (afalg_aes_cbc(afalg_cipher_nids[i]) == NULL) {
756 AFALGerr(AFALG_F_BIND_AFALG, AFALG_R_INIT_FAILED);
761 if (!ENGINE_set_ciphers(e, afalg_ciphers)) {
762 AFALGerr(AFALG_F_BIND_AFALG, AFALG_R_INIT_FAILED);
769 # ifndef OPENSSL_NO_DYNAMIC_ENGINE
770 static int bind_helper(ENGINE *e, const char *id)
772 if (id && (strcmp(id, engine_afalg_id) != 0))
775 if (!afalg_chk_platform())
783 IMPLEMENT_DYNAMIC_CHECK_FN()
784 IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)
787 static int afalg_chk_platform(void)
791 int kver[3] = { -1, -1, -1 };
798 AFALGerr(AFALG_F_AFALG_CHK_PLATFORM,
799 AFALG_R_FAILED_TO_GET_PLATFORM_INFO);
803 str = strtok(ut.release, ".");
804 for (i = 0; i < 3 && str != NULL; i++) {
806 str = strtok(NULL, ".");
809 if (KERNEL_VERSION(kver[0], kver[1], kver[2])
810 < KERNEL_VERSION(K_MAJ, K_MIN1, K_MIN2)) {
811 ALG_ERR("ASYNC AFALG not supported this kernel(%d.%d.%d)\n",
812 kver[0], kver[1], kver[2]);
813 ALG_ERR("ASYNC AFALG requires kernel version %d.%d.%d or later\n",
814 K_MAJ, K_MIN1, K_MIN2);
815 AFALGerr(AFALG_F_AFALG_CHK_PLATFORM,
816 AFALG_R_KERNEL_DOES_NOT_SUPPORT_ASYNC_AFALG);
820 /* Test if we can actually create an AF_ALG socket */
821 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
823 AFALGerr(AFALG_F_AFALG_CHK_PLATFORM, AFALG_R_SOCKET_CREATE_FAILED);
831 # ifdef OPENSSL_NO_DYNAMIC_ENGINE
832 static ENGINE *engine_afalg(void)
834 ENGINE *ret = ENGINE_new();
837 if (!bind_afalg(ret)) {
844 void engine_load_afalg_int(void)
848 if (!afalg_chk_platform())
851 toadd = engine_afalg();
860 static int afalg_init(ENGINE *e)
865 static int afalg_finish(ENGINE *e)
870 static int free_cbc(void)
872 short unsigned int i;
873 for(i = 0; i < OSSL_NELEM(afalg_cipher_nids); i++) {
874 EVP_CIPHER_meth_free(cbc_handle[i]._hidden);
875 cbc_handle[i]._hidden = NULL;
880 static int afalg_destroy(ENGINE *e)
882 ERR_unload_AFALG_strings();
887 #endif /* KERNEL VERSION */