Lines Matching refs:s

628 	struct ecryptfs_write_tag_70_packet_silly_stack *s;  in ecryptfs_write_tag_70_packet()  local
632 s = kmalloc(sizeof(*s), GFP_KERNEL); in ecryptfs_write_tag_70_packet()
633 if (!s) { in ecryptfs_write_tag_70_packet()
635 "[%zd] bytes of kernel memory\n", __func__, sizeof(*s)); in ecryptfs_write_tag_70_packet()
639 s->desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; in ecryptfs_write_tag_70_packet()
643 &s->auth_tok, mount_crypt_stat, in ecryptfs_write_tag_70_packet()
652 &s->desc.tfm, in ecryptfs_write_tag_70_packet()
653 &s->tfm_mutex, mount_crypt_stat->global_default_fn_cipher_name); in ecryptfs_write_tag_70_packet()
660 mutex_lock(s->tfm_mutex); in ecryptfs_write_tag_70_packet()
661 s->block_size = crypto_blkcipher_blocksize(s->desc.tfm); in ecryptfs_write_tag_70_packet()
664 s->num_rand_bytes = (ECRYPTFS_FILENAME_MIN_RANDOM_PREPEND_BYTES + 1); in ecryptfs_write_tag_70_packet()
665 s->block_aligned_filename_size = (s->num_rand_bytes + filename_size); in ecryptfs_write_tag_70_packet()
666 if ((s->block_aligned_filename_size % s->block_size) != 0) { in ecryptfs_write_tag_70_packet()
667 s->num_rand_bytes += (s->block_size in ecryptfs_write_tag_70_packet()
668 - (s->block_aligned_filename_size in ecryptfs_write_tag_70_packet()
669 % s->block_size)); in ecryptfs_write_tag_70_packet()
670 s->block_aligned_filename_size = (s->num_rand_bytes in ecryptfs_write_tag_70_packet()
681 s->max_packet_size = (ECRYPTFS_TAG_70_MAX_METADATA_SIZE in ecryptfs_write_tag_70_packet()
682 + s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
684 (*packet_size) = s->max_packet_size; in ecryptfs_write_tag_70_packet()
687 if (s->max_packet_size > (*remaining_bytes)) { in ecryptfs_write_tag_70_packet()
689 "[%zd] available\n", __func__, s->max_packet_size, in ecryptfs_write_tag_70_packet()
694 s->block_aligned_filename = kzalloc(s->block_aligned_filename_size, in ecryptfs_write_tag_70_packet()
696 if (!s->block_aligned_filename) { in ecryptfs_write_tag_70_packet()
699 s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
703 s->i = 0; in ecryptfs_write_tag_70_packet()
704 dest[s->i++] = ECRYPTFS_TAG_70_PACKET_TYPE; in ecryptfs_write_tag_70_packet()
705 rc = ecryptfs_write_packet_length(&dest[s->i], in ecryptfs_write_tag_70_packet()
708 + s->block_aligned_filename_size), in ecryptfs_write_tag_70_packet()
709 &s->packet_size_len); in ecryptfs_write_tag_70_packet()
716 s->i += s->packet_size_len; in ecryptfs_write_tag_70_packet()
717 ecryptfs_from_hex(&dest[s->i], in ecryptfs_write_tag_70_packet()
720 s->i += ECRYPTFS_SIG_SIZE; in ecryptfs_write_tag_70_packet()
721 s->cipher_code = ecryptfs_code_for_cipher_string( in ecryptfs_write_tag_70_packet()
724 if (s->cipher_code == 0) { in ecryptfs_write_tag_70_packet()
732 dest[s->i++] = s->cipher_code; in ecryptfs_write_tag_70_packet()
735 if (s->auth_tok->token_type != ECRYPTFS_PASSWORD) { in ecryptfs_write_tag_70_packet()
742 &s->hash_sg, in ecryptfs_write_tag_70_packet()
743 (u8 *)s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_write_tag_70_packet()
744 s->auth_tok->token.password.session_key_encryption_key_bytes); in ecryptfs_write_tag_70_packet()
745 s->hash_desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; in ecryptfs_write_tag_70_packet()
746 s->hash_desc.tfm = crypto_alloc_hash(ECRYPTFS_TAG_70_DIGEST, 0, in ecryptfs_write_tag_70_packet()
748 if (IS_ERR(s->hash_desc.tfm)) { in ecryptfs_write_tag_70_packet()
749 rc = PTR_ERR(s->hash_desc.tfm); in ecryptfs_write_tag_70_packet()
755 rc = crypto_hash_init(&s->hash_desc); in ecryptfs_write_tag_70_packet()
763 &s->hash_desc, &s->hash_sg, in ecryptfs_write_tag_70_packet()
764 s->auth_tok->token.password.session_key_encryption_key_bytes); in ecryptfs_write_tag_70_packet()
771 rc = crypto_hash_final(&s->hash_desc, s->hash); in ecryptfs_write_tag_70_packet()
778 for (s->j = 0; s->j < (s->num_rand_bytes - 1); s->j++) { in ecryptfs_write_tag_70_packet()
779 s->block_aligned_filename[s->j] = in ecryptfs_write_tag_70_packet()
780 s->hash[(s->j % ECRYPTFS_TAG_70_DIGEST_SIZE)]; in ecryptfs_write_tag_70_packet()
781 if ((s->j % ECRYPTFS_TAG_70_DIGEST_SIZE) in ecryptfs_write_tag_70_packet()
783 sg_init_one(&s->hash_sg, (u8 *)s->hash, in ecryptfs_write_tag_70_packet()
785 rc = crypto_hash_init(&s->hash_desc); in ecryptfs_write_tag_70_packet()
792 rc = crypto_hash_update(&s->hash_desc, &s->hash_sg, in ecryptfs_write_tag_70_packet()
800 rc = crypto_hash_final(&s->hash_desc, s->tmp_hash); in ecryptfs_write_tag_70_packet()
807 memcpy(s->hash, s->tmp_hash, in ecryptfs_write_tag_70_packet()
810 if (s->block_aligned_filename[s->j] == '\0') in ecryptfs_write_tag_70_packet()
811 s->block_aligned_filename[s->j] = ECRYPTFS_NON_NULL; in ecryptfs_write_tag_70_packet()
813 memcpy(&s->block_aligned_filename[s->num_rand_bytes], filename, in ecryptfs_write_tag_70_packet()
815 rc = virt_to_scatterlist(s->block_aligned_filename, in ecryptfs_write_tag_70_packet()
816 s->block_aligned_filename_size, s->src_sg, 2); in ecryptfs_write_tag_70_packet()
821 s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
824 rc = virt_to_scatterlist(&dest[s->i], s->block_aligned_filename_size, in ecryptfs_write_tag_70_packet()
825 s->dst_sg, 2); in ecryptfs_write_tag_70_packet()
830 __func__, rc, s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
837 memset(s->iv, 0, ECRYPTFS_MAX_IV_BYTES); in ecryptfs_write_tag_70_packet()
838 s->desc.info = s->iv; in ecryptfs_write_tag_70_packet()
840 s->desc.tfm, in ecryptfs_write_tag_70_packet()
841 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_write_tag_70_packet()
849 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_write_tag_70_packet()
853 rc = crypto_blkcipher_encrypt_iv(&s->desc, s->dst_sg, s->src_sg, in ecryptfs_write_tag_70_packet()
854 s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
860 s->i += s->block_aligned_filename_size; in ecryptfs_write_tag_70_packet()
861 (*packet_size) = s->i; in ecryptfs_write_tag_70_packet()
864 crypto_free_hash(s->hash_desc.tfm); in ecryptfs_write_tag_70_packet()
866 kzfree(s->block_aligned_filename); in ecryptfs_write_tag_70_packet()
868 mutex_unlock(s->tfm_mutex); in ecryptfs_write_tag_70_packet()
874 kfree(s); in ecryptfs_write_tag_70_packet()
918 struct ecryptfs_parse_tag_70_packet_silly_stack *s; in ecryptfs_parse_tag_70_packet() local
925 s = kmalloc(sizeof(*s), GFP_KERNEL); in ecryptfs_parse_tag_70_packet()
926 if (!s) { in ecryptfs_parse_tag_70_packet()
928 "[%zd] bytes of kernel memory\n", __func__, sizeof(*s)); in ecryptfs_parse_tag_70_packet()
932 s->desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; in ecryptfs_parse_tag_70_packet()
956 &s->parsed_tag_70_packet_size, in ecryptfs_parse_tag_70_packet()
957 &s->packet_size_len); in ecryptfs_parse_tag_70_packet()
963 s->block_aligned_filename_size = (s->parsed_tag_70_packet_size in ecryptfs_parse_tag_70_packet()
965 if ((1 + s->packet_size_len + s->parsed_tag_70_packet_size) in ecryptfs_parse_tag_70_packet()
969 (1 + s->packet_size_len + 1 in ecryptfs_parse_tag_70_packet()
970 + s->block_aligned_filename_size)); in ecryptfs_parse_tag_70_packet()
974 (*packet_size) += s->packet_size_len; in ecryptfs_parse_tag_70_packet()
975 ecryptfs_to_hex(s->fnek_sig_hex, &data[(*packet_size)], in ecryptfs_parse_tag_70_packet()
977 s->fnek_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0'; in ecryptfs_parse_tag_70_packet()
979 s->cipher_code = data[(*packet_size)++]; in ecryptfs_parse_tag_70_packet()
980 rc = ecryptfs_cipher_code_to_string(s->cipher_string, s->cipher_code); in ecryptfs_parse_tag_70_packet()
983 __func__, s->cipher_code); in ecryptfs_parse_tag_70_packet()
987 &s->auth_tok, mount_crypt_stat, in ecryptfs_parse_tag_70_packet()
988 s->fnek_sig_hex); in ecryptfs_parse_tag_70_packet()
991 "fnek sig [%s]; rc = [%d]\n", __func__, s->fnek_sig_hex, in ecryptfs_parse_tag_70_packet()
995 rc = ecryptfs_get_tfm_and_mutex_for_cipher_name(&s->desc.tfm, in ecryptfs_parse_tag_70_packet()
996 &s->tfm_mutex, in ecryptfs_parse_tag_70_packet()
997 s->cipher_string); in ecryptfs_parse_tag_70_packet()
1001 s->cipher_string, rc); in ecryptfs_parse_tag_70_packet()
1004 mutex_lock(s->tfm_mutex); in ecryptfs_parse_tag_70_packet()
1006 s->block_aligned_filename_size, s->src_sg, 2); in ecryptfs_parse_tag_70_packet()
1011 __func__, rc, s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
1014 (*packet_size) += s->block_aligned_filename_size; in ecryptfs_parse_tag_70_packet()
1015 s->decrypted_filename = kmalloc(s->block_aligned_filename_size, in ecryptfs_parse_tag_70_packet()
1017 if (!s->decrypted_filename) { in ecryptfs_parse_tag_70_packet()
1020 s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
1024 rc = virt_to_scatterlist(s->decrypted_filename, in ecryptfs_parse_tag_70_packet()
1025 s->block_aligned_filename_size, s->dst_sg, 2); in ecryptfs_parse_tag_70_packet()
1030 __func__, rc, s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
1037 memset(s->iv, 0, ECRYPTFS_MAX_IV_BYTES); in ecryptfs_parse_tag_70_packet()
1038 s->desc.info = s->iv; in ecryptfs_parse_tag_70_packet()
1041 if (s->auth_tok->token_type != ECRYPTFS_PASSWORD) { in ecryptfs_parse_tag_70_packet()
1048 s->desc.tfm, in ecryptfs_parse_tag_70_packet()
1049 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_parse_tag_70_packet()
1057 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_parse_tag_70_packet()
1061 rc = crypto_blkcipher_decrypt_iv(&s->desc, s->dst_sg, s->src_sg, in ecryptfs_parse_tag_70_packet()
1062 s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
1068 s->i = 0; in ecryptfs_parse_tag_70_packet()
1069 while (s->decrypted_filename[s->i] != '\0' in ecryptfs_parse_tag_70_packet()
1070 && s->i < s->block_aligned_filename_size) in ecryptfs_parse_tag_70_packet()
1071 s->i++; in ecryptfs_parse_tag_70_packet()
1072 if (s->i == s->block_aligned_filename_size) { in ecryptfs_parse_tag_70_packet()
1079 s->i++; in ecryptfs_parse_tag_70_packet()
1080 (*filename_size) = (s->block_aligned_filename_size - s->i); in ecryptfs_parse_tag_70_packet()
1095 memcpy((*filename), &s->decrypted_filename[s->i], (*filename_size)); in ecryptfs_parse_tag_70_packet()
1098 kfree(s->decrypted_filename); in ecryptfs_parse_tag_70_packet()
1100 mutex_unlock(s->tfm_mutex); in ecryptfs_parse_tag_70_packet()
1111 kfree(s); in ecryptfs_parse_tag_70_packet()