2 * Crypto wrapper for Linux kernel AF_ALG
3 * Copyright (c) 2017, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
10 #include <linux/if_alg.h>
26 static int linux_af_alg_socket(const char *type, const char *name)
28 struct sockaddr_alg sa;
34 s = socket(AF_ALG, SOCK_SEQPACKET, 0);
36 wpa_printf(MSG_ERROR, "%s: Failed to open AF_ALG socket: %s",
37 __func__, strerror(errno));
41 os_memset(&sa, 0, sizeof(sa));
42 sa.salg_family = AF_ALG;
43 os_strlcpy((char *) sa.salg_type, type, sizeof(sa.salg_type));
44 os_strlcpy((char *) sa.salg_name, name, sizeof(sa.salg_type));
45 if (bind(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
47 "%s: Failed to bind AF_ALG socket(%s,%s): %s",
48 __func__, type, name, strerror(errno));
57 static int linux_af_alg_hash_vector(const char *alg, const u8 *key,
58 size_t key_len, size_t num_elem,
59 const u8 *addr[], const size_t *len,
60 u8 *mac, size_t mac_len)
67 s = linux_af_alg_socket("hash", alg);
71 if (key && setsockopt(s, SOL_ALG, ALG_SET_KEY, key, key_len) < 0) {
72 wpa_printf(MSG_ERROR, "%s: setsockopt(ALG_SET_KEY) failed: %s",
73 __func__, strerror(errno));
78 t = accept(s, NULL, NULL);
80 wpa_printf(MSG_ERROR, "%s: accept on AF_ALG socket failed: %s",
81 __func__, strerror(errno));
86 for (i = 0; i < num_elem; i++) {
87 res = send(t, addr[i], len[i], i + 1 < num_elem ? MSG_MORE : 0);
90 "%s: send on AF_ALG socket failed: %s",
91 __func__, strerror(errno));
94 if ((size_t) res < len[i]) {
96 "%s: send on AF_ALG socket did not accept full buffer (%d/%d)",
97 __func__, (int) res, (int) len[i]);
102 res = recv(t, mac, mac_len, 0);
104 wpa_printf(MSG_ERROR,
105 "%s: recv on AF_ALG socket failed: %s",
106 __func__, strerror(errno));
109 if ((size_t) res < mac_len) {
110 wpa_printf(MSG_ERROR,
111 "%s: recv on AF_ALG socket did not return full buffer (%d/%d)",
112 __func__, (int) res, (int) mac_len);
125 int md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac)
127 return linux_af_alg_hash_vector("md4", NULL, 0, num_elem, addr, len,
132 int md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac)
134 return linux_af_alg_hash_vector("md5", NULL, 0, num_elem, addr, len,
139 int sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len,
142 return linux_af_alg_hash_vector("sha1", NULL, 0, num_elem, addr, len,
147 int sha256_vector(size_t num_elem, const u8 *addr[], const size_t *len,
150 return linux_af_alg_hash_vector("sha256", NULL, 0, num_elem, addr, len,
151 mac, SHA256_MAC_LEN);
155 int sha384_vector(size_t num_elem, const u8 *addr[], const size_t *len,
158 return linux_af_alg_hash_vector("sha384", NULL, 0, num_elem, addr, len,
159 mac, SHA384_MAC_LEN);
163 int sha512_vector(size_t num_elem, const u8 *addr[], const size_t *len,
166 return linux_af_alg_hash_vector("sha512", NULL, 0, num_elem, addr, len,
171 int hmac_md5_vector(const u8 *key, size_t key_len, size_t num_elem,
172 const u8 *addr[], const size_t *len, u8 *mac)
174 return linux_af_alg_hash_vector("hmac(md5)", key, key_len, num_elem,
179 int hmac_md5(const u8 *key, size_t key_len, const u8 *data, size_t data_len,
182 return hmac_md5_vector(key, key_len, 1, &data, &data_len, mac);
186 int hmac_sha1_vector(const u8 *key, size_t key_len, size_t num_elem,
187 const u8 *addr[], const size_t *len, u8 *mac)
189 return linux_af_alg_hash_vector("hmac(sha1)", key, key_len, num_elem,
190 addr, len, mac, SHA1_MAC_LEN);
194 int hmac_sha1(const u8 *key, size_t key_len, const u8 *data, size_t data_len,
197 return hmac_sha1_vector(key, key_len, 1, &data, &data_len, mac);
201 int hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem,
202 const u8 *addr[], const size_t *len, u8 *mac)
204 return linux_af_alg_hash_vector("hmac(sha256)", key, key_len, num_elem,
205 addr, len, mac, SHA256_MAC_LEN);
209 int hmac_sha256(const u8 *key, size_t key_len, const u8 *data,
210 size_t data_len, u8 *mac)
212 return hmac_sha256_vector(key, key_len, 1, &data, &data_len, mac);
216 int hmac_sha384_vector(const u8 *key, size_t key_len, size_t num_elem,
217 const u8 *addr[], const size_t *len, u8 *mac)
219 return linux_af_alg_hash_vector("hmac(sha384)", key, key_len, num_elem,
220 addr, len, mac, SHA384_MAC_LEN);
224 int hmac_sha384(const u8 *key, size_t key_len, const u8 *data,
225 size_t data_len, u8 *mac)
227 return hmac_sha384_vector(key, key_len, 1, &data, &data_len, mac);
239 struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
242 struct crypto_hash *ctx;
245 ctx = os_zalloc(sizeof(*ctx));
250 case CRYPTO_HASH_ALG_MD5:
252 ctx->mac_len = MD5_MAC_LEN;
254 case CRYPTO_HASH_ALG_SHA1:
256 ctx->mac_len = SHA1_MAC_LEN;
258 case CRYPTO_HASH_ALG_HMAC_MD5:
260 ctx->mac_len = MD5_MAC_LEN;
262 case CRYPTO_HASH_ALG_HMAC_SHA1:
264 ctx->mac_len = SHA1_MAC_LEN;
266 case CRYPTO_HASH_ALG_SHA256:
268 ctx->mac_len = SHA256_MAC_LEN;
270 case CRYPTO_HASH_ALG_HMAC_SHA256:
271 name = "hmac(sha256)";
272 ctx->mac_len = SHA256_MAC_LEN;
274 case CRYPTO_HASH_ALG_SHA384:
276 ctx->mac_len = SHA384_MAC_LEN;
278 case CRYPTO_HASH_ALG_SHA512:
287 ctx->s = linux_af_alg_socket("hash", name);
293 if (key && key_len &&
294 setsockopt(ctx->s, SOL_ALG, ALG_SET_KEY, key, key_len) < 0) {
295 wpa_printf(MSG_ERROR, "%s: setsockopt(ALG_SET_KEY) failed: %s",
296 __func__, strerror(errno));
302 ctx->t = accept(ctx->s, NULL, NULL);
304 wpa_printf(MSG_ERROR, "%s: accept on AF_ALG socket failed: %s",
305 __func__, strerror(errno));
315 void crypto_hash_update(struct crypto_hash *ctx, const u8 *data, size_t len)
322 res = send(ctx->t, data, len, MSG_MORE);
324 wpa_printf(MSG_ERROR,
325 "%s: send on AF_ALG socket failed: %s",
326 __func__, strerror(errno));
330 if ((size_t) res < len) {
331 wpa_printf(MSG_ERROR,
332 "%s: send on AF_ALG socket did not accept full buffer (%d/%d)",
333 __func__, (int) res, (int) len);
340 static void crypto_hash_deinit(struct crypto_hash *ctx)
348 int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len)
356 crypto_hash_deinit(ctx);
361 crypto_hash_deinit(ctx);
365 if (*len < ctx->mac_len) {
366 crypto_hash_deinit(ctx);
372 res = recv(ctx->t, mac, ctx->mac_len, 0);
374 wpa_printf(MSG_ERROR,
375 "%s: recv on AF_ALG socket failed: %s",
376 __func__, strerror(errno));
377 crypto_hash_deinit(ctx);
380 if ((size_t) res < ctx->mac_len) {
381 wpa_printf(MSG_ERROR,
382 "%s: recv on AF_ALG socket did not return full buffer (%d/%d)",
383 __func__, (int) res, (int) ctx->mac_len);
384 crypto_hash_deinit(ctx);
388 crypto_hash_deinit(ctx);
396 struct linux_af_alg_skcipher {
402 static void linux_af_alg_skcipher_deinit(struct linux_af_alg_skcipher *skcipher)
406 if (skcipher->s >= 0)
408 if (skcipher->t >= 0)
414 static struct linux_af_alg_skcipher *
415 linux_af_alg_skcipher(const char *alg, const u8 *key, size_t key_len)
417 struct linux_af_alg_skcipher *skcipher;
419 skcipher = os_zalloc(sizeof(*skcipher));
424 skcipher->s = linux_af_alg_socket("skcipher", alg);
428 if (setsockopt(skcipher->s, SOL_ALG, ALG_SET_KEY, key, key_len) < 0) {
429 wpa_printf(MSG_ERROR, "%s: setsockopt(ALG_SET_KEY) failed: %s",
430 __func__, strerror(errno));
434 skcipher->t = accept(skcipher->s, NULL, NULL);
435 if (skcipher->t < 0) {
436 wpa_printf(MSG_ERROR, "%s: accept on AF_ALG socket failed: %s",
437 __func__, strerror(errno));
443 linux_af_alg_skcipher_deinit(skcipher);
448 static int linux_af_alg_skcipher_oper(struct linux_af_alg_skcipher *skcipher,
449 int enc, const u8 *in, u8 *out)
451 char buf[CMSG_SPACE(sizeof(u32))];
458 io[0].iov_base = (void *) in;
459 io[0].iov_len = AES_BLOCK_SIZE;
460 os_memset(&msg, 0, sizeof(msg));
461 os_memset(buf, 0, sizeof(buf));
462 msg.msg_control = buf;
463 msg.msg_controllen = CMSG_SPACE(sizeof(u32));
466 hdr = CMSG_FIRSTHDR(&msg);
467 hdr->cmsg_level = SOL_ALG;
468 hdr->cmsg_type = ALG_SET_OP;
469 hdr->cmsg_len = CMSG_LEN(sizeof(u32));
470 op = (u32 *) CMSG_DATA(hdr);
471 *op = enc ? ALG_OP_ENCRYPT : ALG_OP_DECRYPT;
473 ret = sendmsg(skcipher->t, &msg, 0);
475 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s",
476 __func__, strerror(errno));
480 ret = read(skcipher->t, out, AES_BLOCK_SIZE);
482 wpa_printf(MSG_ERROR, "%s: read failed: %s",
483 __func__, strerror(errno));
486 if (ret < AES_BLOCK_SIZE) {
487 wpa_printf(MSG_ERROR,
488 "%s: read did not return full data (%d/%d)",
489 __func__, (int) ret, AES_BLOCK_SIZE);
497 void * aes_encrypt_init(const u8 *key, size_t len)
499 return linux_af_alg_skcipher("ecb(aes)", key, len);
503 int aes_encrypt(void *ctx, const u8 *plain, u8 *crypt)
505 struct linux_af_alg_skcipher *skcipher = ctx;
507 return linux_af_alg_skcipher_oper(skcipher, 1, plain, crypt);
511 void aes_encrypt_deinit(void *ctx)
513 linux_af_alg_skcipher_deinit(ctx);
517 void * aes_decrypt_init(const u8 *key, size_t len)
519 return linux_af_alg_skcipher("ecb(aes)", key, len);
523 int aes_decrypt(void *ctx, const u8 *crypt, u8 *plain)
525 struct linux_af_alg_skcipher *skcipher = ctx;
527 return linux_af_alg_skcipher_oper(skcipher, 0, crypt, plain);
531 void aes_decrypt_deinit(void *ctx)
533 linux_af_alg_skcipher_deinit(ctx);
537 int rc4_skip(const u8 *key, size_t keylen, size_t skip,
538 u8 *data, size_t data_len)
540 struct linux_af_alg_skcipher *skcipher;
542 char buf[CMSG_SPACE(sizeof(u32))];
549 skip_buf = os_zalloc(skip + 1);
552 skcipher = linux_af_alg_skcipher("ecb(arc4)", key, keylen);
558 io[0].iov_base = skip_buf;
559 io[0].iov_len = skip;
560 io[1].iov_base = data;
561 io[1].iov_len = data_len;
562 os_memset(&msg, 0, sizeof(msg));
563 os_memset(buf, 0, sizeof(buf));
564 msg.msg_control = buf;
565 msg.msg_controllen = CMSG_SPACE(sizeof(u32));
568 hdr = CMSG_FIRSTHDR(&msg);
569 hdr->cmsg_level = SOL_ALG;
570 hdr->cmsg_type = ALG_SET_OP;
571 hdr->cmsg_len = CMSG_LEN(sizeof(u32));
572 op = (u32 *) CMSG_DATA(hdr);
573 *op = ALG_OP_ENCRYPT;
575 ret = sendmsg(skcipher->t, &msg, 0);
577 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s",
578 __func__, strerror(errno));
580 linux_af_alg_skcipher_deinit(skcipher);
585 msg.msg_control = NULL;
586 msg.msg_controllen = 0;
587 ret = recvmsg(skcipher->t, &msg, 0);
589 wpa_printf(MSG_ERROR, "%s: recvmsg failed: %s",
590 __func__, strerror(errno));
591 linux_af_alg_skcipher_deinit(skcipher);
594 linux_af_alg_skcipher_deinit(skcipher);
596 if ((size_t) ret < skip + data_len) {
597 wpa_printf(MSG_ERROR,
598 "%s: recvmsg did not return full data (%d/%d)",
599 __func__, (int) ret, (int) (skip + data_len));
607 int des_encrypt(const u8 *clear, const u8 *key, u8 *cypher)
609 u8 pkey[8], next, tmp;
611 struct linux_af_alg_skcipher *skcipher;
612 char buf[CMSG_SPACE(sizeof(u32))];
620 /* Add parity bits to the key */
622 for (i = 0; i < 7; i++) {
624 pkey[i] = (tmp >> i) | next | 1;
625 next = tmp << (7 - i);
629 skcipher = linux_af_alg_skcipher("ecb(des)", pkey, sizeof(pkey));
633 io[0].iov_base = (void *) clear;
635 os_memset(&msg, 0, sizeof(msg));
636 os_memset(buf, 0, sizeof(buf));
637 msg.msg_control = buf;
638 msg.msg_controllen = CMSG_SPACE(sizeof(u32));
641 hdr = CMSG_FIRSTHDR(&msg);
642 hdr->cmsg_level = SOL_ALG;
643 hdr->cmsg_type = ALG_SET_OP;
644 hdr->cmsg_len = CMSG_LEN(sizeof(u32));
645 op = (u32 *) CMSG_DATA(hdr);
646 *op = ALG_OP_ENCRYPT;
648 ret = sendmsg(skcipher->t, &msg, 0);
650 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s",
651 __func__, strerror(errno));
655 ret = read(skcipher->t, cypher, 8);
657 wpa_printf(MSG_ERROR, "%s: read failed: %s",
658 __func__, strerror(errno));
662 wpa_printf(MSG_ERROR,
663 "%s: read did not return full data (%d/8)",
664 __func__, (int) ret);
670 linux_af_alg_skcipher_deinit(skcipher);
675 static int aes_128_cbc_oper(const u8 *key, int enc, const u8 *iv,
676 u8 *data, size_t data_len)
678 struct linux_af_alg_skcipher *skcipher;
685 struct af_alg_iv *alg_iv;
686 size_t iv_len = AES_BLOCK_SIZE;
688 skcipher = linux_af_alg_skcipher("cbc(aes)", key, 16);
692 io[0].iov_base = (void *) data;
693 io[0].iov_len = data_len;
694 os_memset(&msg, 0, sizeof(msg));
695 os_memset(buf, 0, sizeof(buf));
696 msg.msg_control = buf;
697 msg.msg_controllen = CMSG_SPACE(sizeof(u32)) +
698 CMSG_SPACE(sizeof(*alg_iv) + iv_len);
702 hdr = CMSG_FIRSTHDR(&msg);
703 hdr->cmsg_level = SOL_ALG;
704 hdr->cmsg_type = ALG_SET_OP;
705 hdr->cmsg_len = CMSG_LEN(sizeof(u32));
706 op = (u32 *) CMSG_DATA(hdr);
707 *op = enc ? ALG_OP_ENCRYPT : ALG_OP_DECRYPT;
709 hdr = CMSG_NXTHDR(&msg, hdr);
710 hdr->cmsg_level = SOL_ALG;
711 hdr->cmsg_type = ALG_SET_IV;
712 hdr->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv_len);
713 alg_iv = (struct af_alg_iv *) CMSG_DATA(hdr);
714 alg_iv->ivlen = iv_len;
715 os_memcpy(alg_iv->iv, iv, iv_len);
717 ret = sendmsg(skcipher->t, &msg, 0);
719 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s",
720 __func__, strerror(errno));
721 linux_af_alg_skcipher_deinit(skcipher);
725 ret = recvmsg(skcipher->t, &msg, 0);
727 wpa_printf(MSG_ERROR, "%s: recvmsg failed: %s",
728 __func__, strerror(errno));
729 linux_af_alg_skcipher_deinit(skcipher);
732 if ((size_t) ret < data_len) {
733 wpa_printf(MSG_ERROR,
734 "%s: recvmsg not return full data (%d/%d)",
735 __func__, (int) ret, (int) data_len);
736 linux_af_alg_skcipher_deinit(skcipher);
740 linux_af_alg_skcipher_deinit(skcipher);
745 int aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len)
747 return aes_128_cbc_oper(key, 1, iv, data, data_len);
751 int aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len)
753 return aes_128_cbc_oper(key, 0, iv, data, data_len);
757 int omac1_aes_vector(const u8 *key, size_t key_len, size_t num_elem,
758 const u8 *addr[], const size_t *len, u8 *mac)
760 return linux_af_alg_hash_vector("cmac(aes)", key, key_len, num_elem,
761 addr, len, mac, AES_BLOCK_SIZE);
765 int omac1_aes_128_vector(const u8 *key, size_t num_elem,
766 const u8 *addr[], const size_t *len, u8 *mac)
768 return omac1_aes_vector(key, 16, num_elem, addr, len, mac);
772 int omac1_aes_128(const u8 *key, const u8 *data, size_t data_len, u8 *mac)
774 return omac1_aes_128_vector(key, 1, &data, &data_len, mac);
778 int omac1_aes_256(const u8 *key, const u8 *data, size_t data_len, u8 *mac)
780 return omac1_aes_vector(key, 32, 1, &data, &data_len, mac);
784 int aes_unwrap(const u8 *kek, size_t kek_len, int n, const u8 *cipher,
787 struct linux_af_alg_skcipher *skcipher;
794 struct af_alg_iv *alg_iv;
797 skcipher = linux_af_alg_skcipher("kw(aes)", kek, kek_len);
801 io[0].iov_base = (void *) (cipher + iv_len);
802 io[0].iov_len = n * 8;
803 os_memset(&msg, 0, sizeof(msg));
804 os_memset(buf, 0, sizeof(buf));
805 msg.msg_control = buf;
806 msg.msg_controllen = CMSG_SPACE(sizeof(u32)) +
807 CMSG_SPACE(sizeof(*alg_iv) + iv_len);
811 hdr = CMSG_FIRSTHDR(&msg);
812 hdr->cmsg_level = SOL_ALG;
813 hdr->cmsg_type = ALG_SET_OP;
814 hdr->cmsg_len = CMSG_LEN(sizeof(u32));
815 op = (u32 *) CMSG_DATA(hdr);
816 *op = ALG_OP_DECRYPT;
818 hdr = CMSG_NXTHDR(&msg, hdr);
819 hdr->cmsg_level = SOL_ALG;
820 hdr->cmsg_type = ALG_SET_IV;
821 hdr->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv_len);
822 alg_iv = (struct af_alg_iv *) CMSG_DATA(hdr);
823 alg_iv->ivlen = iv_len;
824 os_memcpy(alg_iv->iv, cipher, iv_len);
826 ret = sendmsg(skcipher->t, &msg, 0);
828 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s",
829 __func__, strerror(errno));
833 ret = read(skcipher->t, plain, n * 8);
835 wpa_printf(MSG_ERROR, "%s: read failed: %s",
836 __func__, strerror(errno));
837 linux_af_alg_skcipher_deinit(skcipher);
841 wpa_printf(MSG_ERROR,
842 "%s: read not return full data (%d/%d)",
843 __func__, (int) ret, n * 8);
844 linux_af_alg_skcipher_deinit(skcipher);
848 linux_af_alg_skcipher_deinit(skcipher);
853 struct crypto_cipher {
854 struct linux_af_alg_skcipher *skcipher;
858 struct crypto_cipher * crypto_cipher_init(enum crypto_cipher_alg alg,
859 const u8 *iv, const u8 *key,
862 struct crypto_cipher *ctx;
864 struct af_alg_iv *alg_iv;
871 ctx = os_zalloc(sizeof(*ctx));
876 case CRYPTO_CIPHER_ALG_RC4:
879 case CRYPTO_CIPHER_ALG_AES:
881 iv_len = AES_BLOCK_SIZE;
883 case CRYPTO_CIPHER_ALG_3DES:
884 name = "cbc(des3_ede)";
887 case CRYPTO_CIPHER_ALG_DES:
896 ctx->skcipher = linux_af_alg_skcipher(name, key, key_len);
897 if (!ctx->skcipher) {
903 os_memset(&msg, 0, sizeof(msg));
904 os_memset(buf, 0, sizeof(buf));
905 msg.msg_control = buf;
906 msg.msg_controllen = CMSG_SPACE(sizeof(*alg_iv) + iv_len);
907 hdr = CMSG_FIRSTHDR(&msg);
908 hdr->cmsg_level = SOL_ALG;
909 hdr->cmsg_type = ALG_SET_IV;
910 hdr->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv_len);
911 alg_iv = (struct af_alg_iv *) CMSG_DATA(hdr);
912 alg_iv->ivlen = iv_len;
913 os_memcpy(alg_iv->iv, iv, iv_len);
915 ret = sendmsg(ctx->skcipher->t, &msg, 0);
917 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s",
918 __func__, strerror(errno));
919 linux_af_alg_skcipher_deinit(ctx->skcipher);
929 static int crypto_cipher_oper(struct crypto_cipher *ctx, u32 type, const u8 *in,
932 char buf[CMSG_SPACE(sizeof(u32))];
939 io[0].iov_base = (void *) in;
941 os_memset(&msg, 0, sizeof(msg));
942 os_memset(buf, 0, sizeof(buf));
943 msg.msg_control = buf;
944 msg.msg_controllen = CMSG_SPACE(sizeof(u32));
947 hdr = CMSG_FIRSTHDR(&msg);
948 hdr->cmsg_level = SOL_ALG;
949 hdr->cmsg_type = ALG_SET_OP;
950 hdr->cmsg_len = CMSG_LEN(sizeof(u32));
951 op = (u32 *) CMSG_DATA(hdr);
954 ret = sendmsg(ctx->skcipher->t, &msg, 0);
956 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s",
957 __func__, strerror(errno));
961 ret = read(ctx->skcipher->t, out, len);
963 wpa_printf(MSG_ERROR, "%s: read failed: %s",
964 __func__, strerror(errno));
967 if (ret < (ssize_t) len) {
968 wpa_printf(MSG_ERROR,
969 "%s: read did not return full data (%d/%d)",
970 __func__, (int) ret, (int) len);
978 int crypto_cipher_encrypt(struct crypto_cipher *ctx, const u8 *plain,
979 u8 *crypt, size_t len)
981 return crypto_cipher_oper(ctx, ALG_OP_ENCRYPT, plain, crypt, len);
985 int crypto_cipher_decrypt(struct crypto_cipher *ctx, const u8 *crypt,
986 u8 *plain, size_t len)
988 return crypto_cipher_oper(ctx, ALG_OP_DECRYPT, crypt, plain, len);
992 void crypto_cipher_deinit(struct crypto_cipher *ctx)
995 linux_af_alg_skcipher_deinit(ctx->skcipher);
1001 int crypto_global_init(void)
1007 void crypto_global_deinit(void)