Lines Matching refs:s
508 struct ecryptfs_write_tag_70_packet_silly_stack *s; in ecryptfs_write_tag_70_packet() local
511 s = kmalloc(sizeof(*s), GFP_KERNEL); in ecryptfs_write_tag_70_packet()
512 if (!s) { in ecryptfs_write_tag_70_packet()
514 "[%zd] bytes of kernel memory\n", __func__, sizeof(*s)); in ecryptfs_write_tag_70_packet()
517 s->desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; in ecryptfs_write_tag_70_packet()
520 &s->desc.tfm, in ecryptfs_write_tag_70_packet()
521 &s->tfm_mutex, mount_crypt_stat->global_default_fn_cipher_name); in ecryptfs_write_tag_70_packet()
528 mutex_lock(s->tfm_mutex); in ecryptfs_write_tag_70_packet()
529 s->block_size = crypto_blkcipher_blocksize(s->desc.tfm); in ecryptfs_write_tag_70_packet()
532 s->num_rand_bytes = (ECRYPTFS_FILENAME_MIN_RANDOM_PREPEND_BYTES + 1); in ecryptfs_write_tag_70_packet()
533 s->block_aligned_filename_size = (s->num_rand_bytes + filename_size); in ecryptfs_write_tag_70_packet()
534 if ((s->block_aligned_filename_size % s->block_size) != 0) { in ecryptfs_write_tag_70_packet()
535 s->num_rand_bytes += (s->block_size in ecryptfs_write_tag_70_packet()
536 - (s->block_aligned_filename_size in ecryptfs_write_tag_70_packet()
537 % s->block_size)); in ecryptfs_write_tag_70_packet()
538 s->block_aligned_filename_size = (s->num_rand_bytes in ecryptfs_write_tag_70_packet()
549 s->max_packet_size = (1 /* Tag 70 identifier */ in ecryptfs_write_tag_70_packet()
553 + s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
555 (*packet_size) = s->max_packet_size; in ecryptfs_write_tag_70_packet()
558 if (s->max_packet_size > (*remaining_bytes)) { in ecryptfs_write_tag_70_packet()
560 "[%zd] available\n", __func__, s->max_packet_size, in ecryptfs_write_tag_70_packet()
565 s->block_aligned_filename = kzalloc(s->block_aligned_filename_size, in ecryptfs_write_tag_70_packet()
567 if (!s->block_aligned_filename) { in ecryptfs_write_tag_70_packet()
570 s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
574 s->i = 0; in ecryptfs_write_tag_70_packet()
575 dest[s->i++] = ECRYPTFS_TAG_70_PACKET_TYPE; in ecryptfs_write_tag_70_packet()
576 rc = ecryptfs_write_packet_length(&dest[s->i], in ecryptfs_write_tag_70_packet()
579 + s->block_aligned_filename_size), in ecryptfs_write_tag_70_packet()
580 &s->packet_size_len); in ecryptfs_write_tag_70_packet()
587 s->i += s->packet_size_len; in ecryptfs_write_tag_70_packet()
588 ecryptfs_from_hex(&dest[s->i], in ecryptfs_write_tag_70_packet()
591 s->i += ECRYPTFS_SIG_SIZE; in ecryptfs_write_tag_70_packet()
592 s->cipher_code = ecryptfs_code_for_cipher_string( in ecryptfs_write_tag_70_packet()
595 if (s->cipher_code == 0) { in ecryptfs_write_tag_70_packet()
603 dest[s->i++] = s->cipher_code; in ecryptfs_write_tag_70_packet()
605 &s->auth_tok, mount_crypt_stat, in ecryptfs_write_tag_70_packet()
615 BUG_ON(s->auth_tok->token_type != ECRYPTFS_PASSWORD); in ecryptfs_write_tag_70_packet()
617 &s->hash_sg, in ecryptfs_write_tag_70_packet()
618 (u8 *)s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_write_tag_70_packet()
619 s->auth_tok->token.password.session_key_encryption_key_bytes); in ecryptfs_write_tag_70_packet()
620 s->hash_desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; in ecryptfs_write_tag_70_packet()
621 s->hash_desc.tfm = crypto_alloc_hash(ECRYPTFS_TAG_70_DIGEST, 0, in ecryptfs_write_tag_70_packet()
623 if (IS_ERR(s->hash_desc.tfm)) { in ecryptfs_write_tag_70_packet()
624 rc = PTR_ERR(s->hash_desc.tfm); in ecryptfs_write_tag_70_packet()
630 rc = crypto_hash_init(&s->hash_desc); in ecryptfs_write_tag_70_packet()
638 &s->hash_desc, &s->hash_sg, in ecryptfs_write_tag_70_packet()
639 s->auth_tok->token.password.session_key_encryption_key_bytes); in ecryptfs_write_tag_70_packet()
646 rc = crypto_hash_final(&s->hash_desc, s->hash); in ecryptfs_write_tag_70_packet()
653 for (s->j = 0; s->j < (s->num_rand_bytes - 1); s->j++) { in ecryptfs_write_tag_70_packet()
654 s->block_aligned_filename[s->j] = in ecryptfs_write_tag_70_packet()
655 s->hash[(s->j % ECRYPTFS_TAG_70_DIGEST_SIZE)]; in ecryptfs_write_tag_70_packet()
656 if ((s->j % ECRYPTFS_TAG_70_DIGEST_SIZE) in ecryptfs_write_tag_70_packet()
658 sg_init_one(&s->hash_sg, (u8 *)s->hash, in ecryptfs_write_tag_70_packet()
660 rc = crypto_hash_init(&s->hash_desc); in ecryptfs_write_tag_70_packet()
667 rc = crypto_hash_update(&s->hash_desc, &s->hash_sg, in ecryptfs_write_tag_70_packet()
675 rc = crypto_hash_final(&s->hash_desc, s->tmp_hash); in ecryptfs_write_tag_70_packet()
682 memcpy(s->hash, s->tmp_hash, in ecryptfs_write_tag_70_packet()
685 if (s->block_aligned_filename[s->j] == '\0') in ecryptfs_write_tag_70_packet()
686 s->block_aligned_filename[s->j] = ECRYPTFS_NON_NULL; in ecryptfs_write_tag_70_packet()
688 memcpy(&s->block_aligned_filename[s->num_rand_bytes], filename, in ecryptfs_write_tag_70_packet()
690 rc = virt_to_scatterlist(s->block_aligned_filename, in ecryptfs_write_tag_70_packet()
691 s->block_aligned_filename_size, &s->src_sg, 1); in ecryptfs_write_tag_70_packet()
697 s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
700 rc = virt_to_scatterlist(&dest[s->i], s->block_aligned_filename_size, in ecryptfs_write_tag_70_packet()
701 &s->dst_sg, 1); in ecryptfs_write_tag_70_packet()
707 s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
714 memset(s->iv, 0, ECRYPTFS_MAX_IV_BYTES); in ecryptfs_write_tag_70_packet()
715 s->desc.info = s->iv; in ecryptfs_write_tag_70_packet()
717 s->desc.tfm, in ecryptfs_write_tag_70_packet()
718 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_write_tag_70_packet()
726 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_write_tag_70_packet()
730 rc = crypto_blkcipher_encrypt_iv(&s->desc, &s->dst_sg, &s->src_sg, in ecryptfs_write_tag_70_packet()
731 s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
737 s->i += s->block_aligned_filename_size; in ecryptfs_write_tag_70_packet()
738 (*packet_size) = s->i; in ecryptfs_write_tag_70_packet()
741 crypto_free_hash(s->hash_desc.tfm); in ecryptfs_write_tag_70_packet()
743 memset(s->block_aligned_filename, 0, s->block_aligned_filename_size); in ecryptfs_write_tag_70_packet()
744 kfree(s->block_aligned_filename); in ecryptfs_write_tag_70_packet()
746 mutex_unlock(s->tfm_mutex); in ecryptfs_write_tag_70_packet()
748 kfree(s); in ecryptfs_write_tag_70_packet()
792 struct ecryptfs_parse_tag_70_packet_silly_stack *s; in ecryptfs_parse_tag_70_packet() local
798 s = kmalloc(sizeof(*s), GFP_KERNEL); in ecryptfs_parse_tag_70_packet()
799 if (!s) { in ecryptfs_parse_tag_70_packet()
801 "[%zd] bytes of kernel memory\n", __func__, sizeof(*s)); in ecryptfs_parse_tag_70_packet()
804 s->desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; in ecryptfs_parse_tag_70_packet()
828 &s->parsed_tag_70_packet_size, in ecryptfs_parse_tag_70_packet()
829 &s->packet_size_len); in ecryptfs_parse_tag_70_packet()
835 s->block_aligned_filename_size = (s->parsed_tag_70_packet_size in ecryptfs_parse_tag_70_packet()
837 if ((1 + s->packet_size_len + s->parsed_tag_70_packet_size) in ecryptfs_parse_tag_70_packet()
841 (1 + s->packet_size_len + 1 in ecryptfs_parse_tag_70_packet()
842 + s->block_aligned_filename_size)); in ecryptfs_parse_tag_70_packet()
846 (*packet_size) += s->packet_size_len; in ecryptfs_parse_tag_70_packet()
847 ecryptfs_to_hex(s->fnek_sig_hex, &data[(*packet_size)], in ecryptfs_parse_tag_70_packet()
849 s->fnek_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0'; in ecryptfs_parse_tag_70_packet()
851 s->cipher_code = data[(*packet_size)++]; in ecryptfs_parse_tag_70_packet()
852 rc = ecryptfs_cipher_code_to_string(s->cipher_string, s->cipher_code); in ecryptfs_parse_tag_70_packet()
855 __func__, s->cipher_code); in ecryptfs_parse_tag_70_packet()
858 rc = ecryptfs_get_tfm_and_mutex_for_cipher_name(&s->desc.tfm, in ecryptfs_parse_tag_70_packet()
859 &s->tfm_mutex, in ecryptfs_parse_tag_70_packet()
860 s->cipher_string); in ecryptfs_parse_tag_70_packet()
864 s->cipher_string, rc); in ecryptfs_parse_tag_70_packet()
867 mutex_lock(s->tfm_mutex); in ecryptfs_parse_tag_70_packet()
869 s->block_aligned_filename_size, &s->src_sg, 1); in ecryptfs_parse_tag_70_packet()
875 s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
878 (*packet_size) += s->block_aligned_filename_size; in ecryptfs_parse_tag_70_packet()
879 s->decrypted_filename = kmalloc(s->block_aligned_filename_size, in ecryptfs_parse_tag_70_packet()
881 if (!s->decrypted_filename) { in ecryptfs_parse_tag_70_packet()
884 s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
888 rc = virt_to_scatterlist(s->decrypted_filename, in ecryptfs_parse_tag_70_packet()
889 s->block_aligned_filename_size, &s->dst_sg, 1); in ecryptfs_parse_tag_70_packet()
895 s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
902 memset(s->iv, 0, ECRYPTFS_MAX_IV_BYTES); in ecryptfs_parse_tag_70_packet()
903 s->desc.info = s->iv; in ecryptfs_parse_tag_70_packet()
904 rc = ecryptfs_find_auth_tok_for_sig(&s->auth_tok, mount_crypt_stat, in ecryptfs_parse_tag_70_packet()
905 s->fnek_sig_hex); in ecryptfs_parse_tag_70_packet()
908 "fnek sig [%s]; rc = [%d]\n", __func__, s->fnek_sig_hex, in ecryptfs_parse_tag_70_packet()
914 BUG_ON(s->auth_tok->token_type != ECRYPTFS_PASSWORD); in ecryptfs_parse_tag_70_packet()
916 s->desc.tfm, in ecryptfs_parse_tag_70_packet()
917 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_parse_tag_70_packet()
925 s->auth_tok->token.password.session_key_encryption_key, in ecryptfs_parse_tag_70_packet()
929 rc = crypto_blkcipher_decrypt_iv(&s->desc, &s->dst_sg, &s->src_sg, in ecryptfs_parse_tag_70_packet()
930 s->block_aligned_filename_size); in ecryptfs_parse_tag_70_packet()
936 s->i = 0; in ecryptfs_parse_tag_70_packet()
937 while (s->decrypted_filename[s->i] != '\0' in ecryptfs_parse_tag_70_packet()
938 && s->i < s->block_aligned_filename_size) in ecryptfs_parse_tag_70_packet()
939 s->i++; in ecryptfs_parse_tag_70_packet()
940 if (s->i == s->block_aligned_filename_size) { in ecryptfs_parse_tag_70_packet()
947 s->i++; in ecryptfs_parse_tag_70_packet()
948 (*filename_size) = (s->block_aligned_filename_size - s->i); in ecryptfs_parse_tag_70_packet()
963 memcpy((*filename), &s->decrypted_filename[s->i], (*filename_size)); in ecryptfs_parse_tag_70_packet()
966 kfree(s->decrypted_filename); in ecryptfs_parse_tag_70_packet()
968 mutex_unlock(s->tfm_mutex); in ecryptfs_parse_tag_70_packet()
975 kfree(s); in ecryptfs_parse_tag_70_packet()