Lines Matching refs:s
626 struct ecryptfs_write_tag_70_packet_silly_stack *s; in ecryptfs_write_tag_70_packet() local
630 s = kzalloc(sizeof(*s), GFP_KERNEL); in ecryptfs_write_tag_70_packet()
631 if (!s) in ecryptfs_write_tag_70_packet()
637 &s->auth_tok, mount_crypt_stat, in ecryptfs_write_tag_70_packet()
646 &s->skcipher_tfm, in ecryptfs_write_tag_70_packet()
647 &s->tfm_mutex, mount_crypt_stat->global_default_fn_cipher_name); in ecryptfs_write_tag_70_packet()
654 mutex_lock(s->tfm_mutex); in ecryptfs_write_tag_70_packet()
655 s->block_size = crypto_skcipher_blocksize(s->skcipher_tfm); in ecryptfs_write_tag_70_packet()
658 s->num_rand_bytes = (ECRYPTFS_FILENAME_MIN_RANDOM_PREPEND_BYTES + 1); in ecryptfs_write_tag_70_packet()
659 s->block_aligned_filename_size = (s->num_rand_bytes + filename_size); in ecryptfs_write_tag_70_packet()
660 if ((s->block_aligned_filename_size % s->block_size) != 0) { in ecryptfs_write_tag_70_packet()
661 s->num_rand_bytes += (s->block_size in ecryptfs_write_tag_70_packet()
662 - (s->block_aligned_filename_size in ecryptfs_write_tag_70_packet()
663 % s->block_size)); in ecryptfs_write_tag_70_packet()
664 s->block_aligned_filename_size = (s->num_rand_bytes in ecryptfs_write_tag_70_packet()
675 s->max_packet_size = (ECRYPTFS_TAG_70_MAX_METADATA_SIZE in ecryptfs_write_tag_70_packet()
676 + s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
678 (*packet_size) = s->max_packet_size; in ecryptfs_write_tag_70_packet()
681 if (s->max_packet_size > (*remaining_bytes)) { in ecryptfs_write_tag_70_packet()
683 "[%zd] available\n", __func__, s->max_packet_size, in ecryptfs_write_tag_70_packet()
689 s->skcipher_req = skcipher_request_alloc(s->skcipher_tfm, GFP_KERNEL); in ecryptfs_write_tag_70_packet()
690 if (!s->skcipher_req) { in ecryptfs_write_tag_70_packet()
693 crypto_skcipher_driver_name(s->skcipher_tfm)); in ecryptfs_write_tag_70_packet()
698 skcipher_request_set_callback(s->skcipher_req, in ecryptfs_write_tag_70_packet()
701 s->block_aligned_filename = kzalloc(s->block_aligned_filename_size, in ecryptfs_write_tag_70_packet()
703 if (!s->block_aligned_filename) { in ecryptfs_write_tag_70_packet()
707 dest[s->i++] = ECRYPTFS_TAG_70_PACKET_TYPE; in ecryptfs_write_tag_70_packet()
708 rc = ecryptfs_write_packet_length(&dest[s->i], in ecryptfs_write_tag_70_packet()
711 + s->block_aligned_filename_size), in ecryptfs_write_tag_70_packet()
712 &s->packet_size_len); in ecryptfs_write_tag_70_packet()
719 s->i += s->packet_size_len; in ecryptfs_write_tag_70_packet()
720 ecryptfs_from_hex(&dest[s->i], in ecryptfs_write_tag_70_packet()
723 s->i += ECRYPTFS_SIG_SIZE; in ecryptfs_write_tag_70_packet()
724 s->cipher_code = ecryptfs_code_for_cipher_string( in ecryptfs_write_tag_70_packet()
727 if (s->cipher_code == 0) { in ecryptfs_write_tag_70_packet()
735 dest[s->i++] = s->cipher_code; in ecryptfs_write_tag_70_packet()
738 if (s->auth_tok->token_type != ECRYPTFS_PASSWORD) { in ecryptfs_write_tag_70_packet()
744 s->hash_tfm = crypto_alloc_shash(ECRYPTFS_TAG_70_DIGEST, 0, 0); in ecryptfs_write_tag_70_packet()
745 if (IS_ERR(s->hash_tfm)) { in ecryptfs_write_tag_70_packet()
746 rc = PTR_ERR(s->hash_tfm); in ecryptfs_write_tag_70_packet()
753 s->hash_desc = kmalloc(sizeof(*s->hash_desc) + in ecryptfs_write_tag_70_packet()
754 crypto_shash_descsize(s->hash_tfm), GFP_KERNEL); in ecryptfs_write_tag_70_packet()
755 if (!s->hash_desc) { in ecryptfs_write_tag_70_packet()
760 s->hash_desc->tfm = s->hash_tfm; in ecryptfs_write_tag_70_packet()
762 rc = crypto_shash_digest(s->hash_desc, in ecryptfs_write_tag_70_packet()
763 (u8 *)s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_write_tag_70_packet()
764 s->auth_tok->token.password.session_key_encryption_key_bytes, in ecryptfs_write_tag_70_packet()
765 s->hash); in ecryptfs_write_tag_70_packet()
772 for (s->j = 0; s->j < (s->num_rand_bytes - 1); s->j++) { in ecryptfs_write_tag_70_packet()
773 s->block_aligned_filename[s->j] = in ecryptfs_write_tag_70_packet()
774 s->hash[(s->j % ECRYPTFS_TAG_70_DIGEST_SIZE)]; in ecryptfs_write_tag_70_packet()
775 if ((s->j % ECRYPTFS_TAG_70_DIGEST_SIZE) in ecryptfs_write_tag_70_packet()
777 rc = crypto_shash_digest(s->hash_desc, (u8 *)s->hash, in ecryptfs_write_tag_70_packet()
779 s->tmp_hash); in ecryptfs_write_tag_70_packet()
786 memcpy(s->hash, s->tmp_hash, in ecryptfs_write_tag_70_packet()
789 if (s->block_aligned_filename[s->j] == '\0') in ecryptfs_write_tag_70_packet()
790 s->block_aligned_filename[s->j] = ECRYPTFS_NON_NULL; in ecryptfs_write_tag_70_packet()
792 memcpy(&s->block_aligned_filename[s->num_rand_bytes], filename, in ecryptfs_write_tag_70_packet()
794 rc = virt_to_scatterlist(s->block_aligned_filename, in ecryptfs_write_tag_70_packet()
795 s->block_aligned_filename_size, s->src_sg, 2); in ecryptfs_write_tag_70_packet()
800 s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
803 rc = virt_to_scatterlist(&dest[s->i], s->block_aligned_filename_size, in ecryptfs_write_tag_70_packet()
804 s->dst_sg, 2); in ecryptfs_write_tag_70_packet()
809 __func__, rc, s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
817 s->skcipher_tfm, in ecryptfs_write_tag_70_packet()
818 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_write_tag_70_packet()
826 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_write_tag_70_packet()
830 skcipher_request_set_crypt(s->skcipher_req, s->src_sg, s->dst_sg, in ecryptfs_write_tag_70_packet()
831 s->block_aligned_filename_size, s->iv); in ecryptfs_write_tag_70_packet()
832 rc = crypto_skcipher_encrypt(s->skcipher_req); in ecryptfs_write_tag_70_packet()
838 s->i += s->block_aligned_filename_size; in ecryptfs_write_tag_70_packet()
839 (*packet_size) = s->i; in ecryptfs_write_tag_70_packet()
842 crypto_free_shash(s->hash_tfm); in ecryptfs_write_tag_70_packet()
844 kfree_sensitive(s->block_aligned_filename); in ecryptfs_write_tag_70_packet()
846 mutex_unlock(s->tfm_mutex); in ecryptfs_write_tag_70_packet()
852 skcipher_request_free(s->skcipher_req); in ecryptfs_write_tag_70_packet()
853 kfree_sensitive(s->hash_desc); in ecryptfs_write_tag_70_packet()
854 kfree(s); in ecryptfs_write_tag_70_packet()
899 struct ecryptfs_parse_tag_70_packet_silly_stack *s; in ecryptfs_parse_tag_70_packet() local
906 s = kzalloc(sizeof(*s), GFP_KERNEL); in ecryptfs_parse_tag_70_packet()
907 if (!s) in ecryptfs_parse_tag_70_packet()
933 &s->parsed_tag_70_packet_size, in ecryptfs_parse_tag_70_packet()
934 &s->packet_size_len); in ecryptfs_parse_tag_70_packet()
940 s->block_aligned_filename_size = (s->parsed_tag_70_packet_size in ecryptfs_parse_tag_70_packet()
942 if ((1 + s->packet_size_len + s->parsed_tag_70_packet_size) in ecryptfs_parse_tag_70_packet()
946 (1 + s->packet_size_len + 1 in ecryptfs_parse_tag_70_packet()
947 + s->block_aligned_filename_size)); in ecryptfs_parse_tag_70_packet()
951 (*packet_size) += s->packet_size_len; in ecryptfs_parse_tag_70_packet()
952 ecryptfs_to_hex(s->fnek_sig_hex, &data[(*packet_size)], in ecryptfs_parse_tag_70_packet()
954 s->fnek_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0'; in ecryptfs_parse_tag_70_packet()
956 s->cipher_code = data[(*packet_size)++]; in ecryptfs_parse_tag_70_packet()
957 rc = ecryptfs_cipher_code_to_string(s->cipher_string, s->cipher_code); in ecryptfs_parse_tag_70_packet()
960 __func__, s->cipher_code); in ecryptfs_parse_tag_70_packet()
964 &s->auth_tok, mount_crypt_stat, in ecryptfs_parse_tag_70_packet()
965 s->fnek_sig_hex); in ecryptfs_parse_tag_70_packet()
968 "fnek sig [%s]; rc = [%d]\n", __func__, s->fnek_sig_hex, in ecryptfs_parse_tag_70_packet()
972 rc = ecryptfs_get_tfm_and_mutex_for_cipher_name(&s->skcipher_tfm, in ecryptfs_parse_tag_70_packet()
973 &s->tfm_mutex, in ecryptfs_parse_tag_70_packet()
974 s->cipher_string); in ecryptfs_parse_tag_70_packet()
978 s->cipher_string, rc); in ecryptfs_parse_tag_70_packet()
981 mutex_lock(s->tfm_mutex); in ecryptfs_parse_tag_70_packet()
983 s->block_aligned_filename_size, s->src_sg, 2); in ecryptfs_parse_tag_70_packet()
988 __func__, rc, s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
991 (*packet_size) += s->block_aligned_filename_size; in ecryptfs_parse_tag_70_packet()
992 s->decrypted_filename = kmalloc(s->block_aligned_filename_size, in ecryptfs_parse_tag_70_packet()
994 if (!s->decrypted_filename) { in ecryptfs_parse_tag_70_packet()
998 rc = virt_to_scatterlist(s->decrypted_filename, in ecryptfs_parse_tag_70_packet()
999 s->block_aligned_filename_size, s->dst_sg, 2); in ecryptfs_parse_tag_70_packet()
1004 __func__, rc, s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
1008 s->skcipher_req = skcipher_request_alloc(s->skcipher_tfm, GFP_KERNEL); in ecryptfs_parse_tag_70_packet()
1009 if (!s->skcipher_req) { in ecryptfs_parse_tag_70_packet()
1012 crypto_skcipher_driver_name(s->skcipher_tfm)); in ecryptfs_parse_tag_70_packet()
1017 skcipher_request_set_callback(s->skcipher_req, in ecryptfs_parse_tag_70_packet()
1026 if (s->auth_tok->token_type != ECRYPTFS_PASSWORD) { in ecryptfs_parse_tag_70_packet()
1033 s->skcipher_tfm, in ecryptfs_parse_tag_70_packet()
1034 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_parse_tag_70_packet()
1042 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_parse_tag_70_packet()
1046 skcipher_request_set_crypt(s->skcipher_req, s->src_sg, s->dst_sg, in ecryptfs_parse_tag_70_packet()
1047 s->block_aligned_filename_size, s->iv); in ecryptfs_parse_tag_70_packet()
1048 rc = crypto_skcipher_decrypt(s->skcipher_req); in ecryptfs_parse_tag_70_packet()
1055 while (s->i < s->block_aligned_filename_size && in ecryptfs_parse_tag_70_packet()
1056 s->decrypted_filename[s->i] != '\0') in ecryptfs_parse_tag_70_packet()
1057 s->i++; in ecryptfs_parse_tag_70_packet()
1058 if (s->i == s->block_aligned_filename_size) { in ecryptfs_parse_tag_70_packet()
1065 s->i++; in ecryptfs_parse_tag_70_packet()
1066 (*filename_size) = (s->block_aligned_filename_size - s->i); in ecryptfs_parse_tag_70_packet()
1078 memcpy((*filename), &s->decrypted_filename[s->i], (*filename_size)); in ecryptfs_parse_tag_70_packet()
1081 kfree(s->decrypted_filename); in ecryptfs_parse_tag_70_packet()
1083 mutex_unlock(s->tfm_mutex); in ecryptfs_parse_tag_70_packet()
1094 skcipher_request_free(s->skcipher_req); in ecryptfs_parse_tag_70_packet()
1095 kfree(s); in ecryptfs_parse_tag_70_packet()