Lines Matching +full:mac +full:- +full:s
29 int s; in linux_af_alg_socket() local
32 return -1; in linux_af_alg_socket()
34 s = socket(AF_ALG, SOCK_SEQPACKET, 0); in linux_af_alg_socket()
35 if (s < 0) { in linux_af_alg_socket()
36 wpa_printf(MSG_ERROR, "%s: Failed to open AF_ALG socket: %s", in linux_af_alg_socket()
38 return -1; in linux_af_alg_socket()
45 if (bind(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { in linux_af_alg_socket()
47 "%s: Failed to bind AF_ALG socket(%s,%s): %s", in linux_af_alg_socket()
49 close(s); in linux_af_alg_socket()
50 return -1; in linux_af_alg_socket()
53 return s; in linux_af_alg_socket()
60 u8 *mac, size_t mac_len) in linux_af_alg_hash_vector() argument
62 int s, t; in linux_af_alg_hash_vector() local
65 int ret = -1; in linux_af_alg_hash_vector()
67 s = linux_af_alg_socket("hash", alg); in linux_af_alg_hash_vector()
68 if (s < 0) in linux_af_alg_hash_vector()
69 return -1; in linux_af_alg_hash_vector()
71 if (key && setsockopt(s, SOL_ALG, ALG_SET_KEY, key, key_len) < 0) { in linux_af_alg_hash_vector()
72 wpa_printf(MSG_ERROR, "%s: setsockopt(ALG_SET_KEY) failed: %s", in linux_af_alg_hash_vector()
74 close(s); in linux_af_alg_hash_vector()
75 return -1; in linux_af_alg_hash_vector()
78 t = accept(s, NULL, NULL); in linux_af_alg_hash_vector()
80 wpa_printf(MSG_ERROR, "%s: accept on AF_ALG socket failed: %s", in linux_af_alg_hash_vector()
82 close(s); in linux_af_alg_hash_vector()
83 return -1; in linux_af_alg_hash_vector()
90 "%s: send on AF_ALG socket failed: %s", in linux_af_alg_hash_vector()
96 "%s: send on AF_ALG socket did not accept full buffer (%d/%d)", in linux_af_alg_hash_vector()
102 res = recv(t, mac, mac_len, 0); in linux_af_alg_hash_vector()
105 "%s: recv on AF_ALG socket failed: %s", in linux_af_alg_hash_vector()
111 "%s: recv on AF_ALG socket did not return full buffer (%d/%d)", in linux_af_alg_hash_vector()
119 close(s); in linux_af_alg_hash_vector()
125 int md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac) in md4_vector() argument
128 mac, 16); in md4_vector()
132 int md5_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac) in md5_vector() argument
135 mac, MD5_MAC_LEN); in md5_vector()
140 u8 *mac) in sha1_vector() argument
143 mac, SHA1_MAC_LEN); in sha1_vector()
148 u8 *mac) in sha256_vector() argument
151 mac, SHA256_MAC_LEN); in sha256_vector()
156 u8 *mac) in sha384_vector() argument
159 mac, SHA384_MAC_LEN); in sha384_vector()
164 u8 *mac) in sha512_vector() argument
167 mac, 64); in sha512_vector()
172 const u8 *addr[], const size_t *len, u8 *mac) in hmac_md5_vector() argument
175 addr, len, mac, 16); in hmac_md5_vector()
180 u8 *mac) in hmac_md5() argument
182 return hmac_md5_vector(key, key_len, 1, &data, &data_len, mac); in hmac_md5()
187 const u8 *addr[], const size_t *len, u8 *mac) in hmac_sha1_vector() argument
190 addr, len, mac, SHA1_MAC_LEN); in hmac_sha1_vector()
195 u8 *mac) in hmac_sha1() argument
197 return hmac_sha1_vector(key, key_len, 1, &data, &data_len, mac); in hmac_sha1()
202 const u8 *addr[], const size_t *len, u8 *mac) in hmac_sha256_vector() argument
205 addr, len, mac, SHA256_MAC_LEN); in hmac_sha256_vector()
210 size_t data_len, u8 *mac) in hmac_sha256() argument
212 return hmac_sha256_vector(key, key_len, 1, &data, &data_len, mac); in hmac_sha256()
217 const u8 *addr[], const size_t *len, u8 *mac) in hmac_sha384_vector() argument
220 addr, len, mac, SHA384_MAC_LEN); in hmac_sha384_vector()
225 size_t data_len, u8 *mac) in hmac_sha384() argument
227 return hmac_sha384_vector(key, key_len, 1, &data, &data_len, mac); in hmac_sha384()
232 int s; member
252 ctx->mac_len = MD5_MAC_LEN; in crypto_hash_init()
256 ctx->mac_len = SHA1_MAC_LEN; in crypto_hash_init()
260 ctx->mac_len = MD5_MAC_LEN; in crypto_hash_init()
264 ctx->mac_len = SHA1_MAC_LEN; in crypto_hash_init()
268 ctx->mac_len = SHA256_MAC_LEN; in crypto_hash_init()
272 ctx->mac_len = SHA256_MAC_LEN; in crypto_hash_init()
276 ctx->mac_len = SHA384_MAC_LEN; in crypto_hash_init()
280 ctx->mac_len = 64; in crypto_hash_init()
287 ctx->s = linux_af_alg_socket("hash", name); in crypto_hash_init()
288 if (ctx->s < 0) { in crypto_hash_init()
294 setsockopt(ctx->s, SOL_ALG, ALG_SET_KEY, key, key_len) < 0) { in crypto_hash_init()
295 wpa_printf(MSG_ERROR, "%s: setsockopt(ALG_SET_KEY) failed: %s", in crypto_hash_init()
297 close(ctx->s); in crypto_hash_init()
302 ctx->t = accept(ctx->s, NULL, NULL); in crypto_hash_init()
303 if (ctx->t < 0) { in crypto_hash_init()
304 wpa_printf(MSG_ERROR, "%s: accept on AF_ALG socket failed: %s", in crypto_hash_init()
306 close(ctx->s); in crypto_hash_init()
322 res = send(ctx->t, data, len, MSG_MORE); in crypto_hash_update()
325 "%s: send on AF_ALG socket failed: %s", in crypto_hash_update()
327 ctx->failed = 1; in crypto_hash_update()
332 "%s: send on AF_ALG socket did not accept full buffer (%d/%d)", in crypto_hash_update()
334 ctx->failed = 1; in crypto_hash_update()
342 close(ctx->s); in crypto_hash_deinit()
343 close(ctx->t); in crypto_hash_deinit()
348 int crypto_hash_finish(struct crypto_hash *ctx, u8 *mac, size_t *len) in crypto_hash_finish() argument
353 return -2; in crypto_hash_finish()
355 if (!mac || !len) { in crypto_hash_finish()
360 if (ctx->failed) { in crypto_hash_finish()
362 return -2; in crypto_hash_finish()
365 if (*len < ctx->mac_len) { in crypto_hash_finish()
367 *len = ctx->mac_len; in crypto_hash_finish()
368 return -1; in crypto_hash_finish()
370 *len = ctx->mac_len; in crypto_hash_finish()
372 res = recv(ctx->t, mac, ctx->mac_len, 0); in crypto_hash_finish()
375 "%s: recv on AF_ALG socket failed: %s", in crypto_hash_finish()
378 return -2; in crypto_hash_finish()
380 if ((size_t) res < ctx->mac_len) { in crypto_hash_finish()
382 "%s: recv on AF_ALG socket did not return full buffer (%d/%d)", in crypto_hash_finish()
383 __func__, (int) res, (int) ctx->mac_len); in crypto_hash_finish()
385 return -2; in crypto_hash_finish()
391 return -1; in crypto_hash_finish()
397 int s; member
406 if (skcipher->s >= 0) in linux_af_alg_skcipher_deinit()
407 close(skcipher->s); in linux_af_alg_skcipher_deinit()
408 if (skcipher->t >= 0) in linux_af_alg_skcipher_deinit()
409 close(skcipher->t); in linux_af_alg_skcipher_deinit()
422 skcipher->t = -1; in linux_af_alg_skcipher()
424 skcipher->s = linux_af_alg_socket("skcipher", alg); in linux_af_alg_skcipher()
425 if (skcipher->s < 0) in linux_af_alg_skcipher()
428 if (setsockopt(skcipher->s, SOL_ALG, ALG_SET_KEY, key, key_len) < 0) { in linux_af_alg_skcipher()
429 wpa_printf(MSG_ERROR, "%s: setsockopt(ALG_SET_KEY) failed: %s", in linux_af_alg_skcipher()
434 skcipher->t = accept(skcipher->s, NULL, NULL); in linux_af_alg_skcipher()
435 if (skcipher->t < 0) { in linux_af_alg_skcipher()
436 wpa_printf(MSG_ERROR, "%s: accept on AF_ALG socket failed: %s", in linux_af_alg_skcipher()
467 hdr->cmsg_level = SOL_ALG; in linux_af_alg_skcipher_oper()
468 hdr->cmsg_type = ALG_SET_OP; in linux_af_alg_skcipher_oper()
469 hdr->cmsg_len = CMSG_LEN(sizeof(u32)); in linux_af_alg_skcipher_oper()
473 ret = sendmsg(skcipher->t, &msg, 0); in linux_af_alg_skcipher_oper()
475 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s", in linux_af_alg_skcipher_oper()
477 return -1; in linux_af_alg_skcipher_oper()
480 ret = read(skcipher->t, out, AES_BLOCK_SIZE); in linux_af_alg_skcipher_oper()
482 wpa_printf(MSG_ERROR, "%s: read failed: %s", in linux_af_alg_skcipher_oper()
484 return -1; in linux_af_alg_skcipher_oper()
488 "%s: read did not return full data (%d/%d)", in linux_af_alg_skcipher_oper()
490 return -1; in linux_af_alg_skcipher_oper()
551 return -1; in rc4_skip()
555 return -1; in rc4_skip()
569 hdr->cmsg_level = SOL_ALG; in rc4_skip()
570 hdr->cmsg_type = ALG_SET_OP; in rc4_skip()
571 hdr->cmsg_len = CMSG_LEN(sizeof(u32)); in rc4_skip()
575 ret = sendmsg(skcipher->t, &msg, 0); in rc4_skip()
577 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s", in rc4_skip()
581 return -1; in rc4_skip()
587 ret = recvmsg(skcipher->t, &msg, 0); in rc4_skip()
589 wpa_printf(MSG_ERROR, "%s: recvmsg failed: %s", in rc4_skip()
592 return -1; in rc4_skip()
598 "%s: recvmsg did not return full data (%d/%d)", in rc4_skip()
600 return -1; in rc4_skip()
618 int res = -1; in des_encrypt()
625 next = tmp << (7 - i); in des_encrypt()
642 hdr->cmsg_level = SOL_ALG; in des_encrypt()
643 hdr->cmsg_type = ALG_SET_OP; in des_encrypt()
644 hdr->cmsg_len = CMSG_LEN(sizeof(u32)); in des_encrypt()
648 ret = sendmsg(skcipher->t, &msg, 0); in des_encrypt()
650 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s", in des_encrypt()
655 ret = read(skcipher->t, cypher, 8); in des_encrypt()
657 wpa_printf(MSG_ERROR, "%s: read failed: %s", in des_encrypt()
663 "%s: read did not return full data (%d/8)", in des_encrypt()
690 return -1; in aes_128_cbc_oper()
703 hdr->cmsg_level = SOL_ALG; in aes_128_cbc_oper()
704 hdr->cmsg_type = ALG_SET_OP; in aes_128_cbc_oper()
705 hdr->cmsg_len = CMSG_LEN(sizeof(u32)); in aes_128_cbc_oper()
710 hdr->cmsg_level = SOL_ALG; in aes_128_cbc_oper()
711 hdr->cmsg_type = ALG_SET_IV; in aes_128_cbc_oper()
712 hdr->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv_len); in aes_128_cbc_oper()
714 alg_iv->ivlen = iv_len; in aes_128_cbc_oper()
715 os_memcpy(alg_iv->iv, iv, iv_len); in aes_128_cbc_oper()
717 ret = sendmsg(skcipher->t, &msg, 0); in aes_128_cbc_oper()
719 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s", in aes_128_cbc_oper()
722 return -1; in aes_128_cbc_oper()
725 ret = recvmsg(skcipher->t, &msg, 0); in aes_128_cbc_oper()
727 wpa_printf(MSG_ERROR, "%s: recvmsg failed: %s", in aes_128_cbc_oper()
730 return -1; in aes_128_cbc_oper()
734 "%s: recvmsg not return full data (%d/%d)", in aes_128_cbc_oper()
737 return -1; in aes_128_cbc_oper()
758 const u8 *addr[], const size_t *len, u8 *mac) in omac1_aes_vector() argument
761 addr, len, mac, AES_BLOCK_SIZE); in omac1_aes_vector()
766 const u8 *addr[], const size_t *len, u8 *mac) in omac1_aes_128_vector() argument
768 return omac1_aes_vector(key, 16, num_elem, addr, len, mac); in omac1_aes_128_vector()
772 int omac1_aes_128(const u8 *key, const u8 *data, size_t data_len, u8 *mac) in omac1_aes_128() argument
774 return omac1_aes_128_vector(key, 1, &data, &data_len, mac); in omac1_aes_128()
778 int omac1_aes_256(const u8 *key, const u8 *data, size_t data_len, u8 *mac) in omac1_aes_256() argument
780 return omac1_aes_vector(key, 32, 1, &data, &data_len, mac); in omac1_aes_256()
799 return -1; in aes_unwrap()
812 hdr->cmsg_level = SOL_ALG; in aes_unwrap()
813 hdr->cmsg_type = ALG_SET_OP; in aes_unwrap()
814 hdr->cmsg_len = CMSG_LEN(sizeof(u32)); in aes_unwrap()
819 hdr->cmsg_level = SOL_ALG; in aes_unwrap()
820 hdr->cmsg_type = ALG_SET_IV; in aes_unwrap()
821 hdr->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv_len); in aes_unwrap()
823 alg_iv->ivlen = iv_len; in aes_unwrap()
824 os_memcpy(alg_iv->iv, cipher, iv_len); in aes_unwrap()
826 ret = sendmsg(skcipher->t, &msg, 0); in aes_unwrap()
828 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s", in aes_unwrap()
830 return -1; in aes_unwrap()
833 ret = read(skcipher->t, plain, n * 8); in aes_unwrap()
835 wpa_printf(MSG_ERROR, "%s: read failed: %s", in aes_unwrap()
838 return -1; in aes_unwrap()
842 "%s: read not return full data (%d/%d)", in aes_unwrap()
845 return -1; in aes_unwrap()
896 ctx->skcipher = linux_af_alg_skcipher(name, key, key_len); in crypto_cipher_init()
897 if (!ctx->skcipher) { in crypto_cipher_init()
908 hdr->cmsg_level = SOL_ALG; in crypto_cipher_init()
909 hdr->cmsg_type = ALG_SET_IV; in crypto_cipher_init()
910 hdr->cmsg_len = CMSG_SPACE(sizeof(*alg_iv) + iv_len); in crypto_cipher_init()
912 alg_iv->ivlen = iv_len; in crypto_cipher_init()
913 os_memcpy(alg_iv->iv, iv, iv_len); in crypto_cipher_init()
915 ret = sendmsg(ctx->skcipher->t, &msg, 0); in crypto_cipher_init()
917 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s", in crypto_cipher_init()
919 linux_af_alg_skcipher_deinit(ctx->skcipher); in crypto_cipher_init()
948 hdr->cmsg_level = SOL_ALG; in crypto_cipher_oper()
949 hdr->cmsg_type = ALG_SET_OP; in crypto_cipher_oper()
950 hdr->cmsg_len = CMSG_LEN(sizeof(u32)); in crypto_cipher_oper()
954 ret = sendmsg(ctx->skcipher->t, &msg, 0); in crypto_cipher_oper()
956 wpa_printf(MSG_ERROR, "%s: sendmsg failed: %s", in crypto_cipher_oper()
958 return -1; in crypto_cipher_oper()
961 ret = read(ctx->skcipher->t, out, len); in crypto_cipher_oper()
963 wpa_printf(MSG_ERROR, "%s: read failed: %s", in crypto_cipher_oper()
965 return -1; in crypto_cipher_oper()
969 "%s: read did not return full data (%d/%d)", in crypto_cipher_oper()
971 return -1; in crypto_cipher_oper()
995 linux_af_alg_skcipher_deinit(ctx->skcipher); in crypto_cipher_deinit()