• Home
  • Raw
  • Download

Lines Matching refs:fek

764 static unsigned ntfs_raw_fek_decrypt(u8 *fek, u32 fek_size,  in ntfs_raw_fek_decrypt()  argument
773 ntfs_buffer_reverse(fek, fek_size); in ntfs_raw_fek_decrypt()
775 err = gcry_mpi_scan(&fek_mpi, GCRYMPI_FMT_USG, fek, fek_size, NULL); in ntfs_raw_fek_decrypt()
818 err = gcry_mpi_print(GCRYMPI_FMT_USG, fek, fek_size, &size, fek_mpi); in ntfs_raw_fek_decrypt()
830 padding = strnlen((char *)fek, size) + 1; in ntfs_raw_fek_decrypt()
837 memmove(fek, fek + padding, size); in ntfs_raw_fek_decrypt()
890 static gcry_error_t ntfs_desx_decrypt(ntfs_fek *fek, u8 *outbuf, in ntfs_desx_decrypt() argument
895 ntfs_desx_ctx *ctx = &fek->desx_ctx; in ntfs_desx_decrypt()
899 err = gcry_cipher_encrypt(fek->gcry_cipher_hd, outbuf, 8, NULL, 0); in ntfs_desx_decrypt()
910 static gcry_error_t ntfs_desx_encrypt(ntfs_fek *fek, u8 *outbuf, in ntfs_desx_encrypt() argument
914 ntfs_desx_ctx *ctx = &fek->desx_ctx; in ntfs_desx_encrypt()
917 err = gcry_cipher_decrypt(fek->gcry_cipher_hd, outbuf, 8, NULL, 0); in ntfs_desx_encrypt()
1048 ntfs_fek *fek; in ntfs_fek_import_from_raw() local
1062 fek = malloc(((((sizeof(*fek) + 7) & ~7) + key_size + 7) & ~7) + in ntfs_fek_import_from_raw()
1064 if (!fek) { in ntfs_fek_import_from_raw()
1068 ctx = &fek->desx_ctx; in ntfs_fek_import_from_raw()
1069 fek->alg_id = *(le32*)(fek_buf + 8); in ntfs_fek_import_from_raw()
1071 fek->key_data = (u8*)fek + ((sizeof(*fek) + 7) & ~7); in ntfs_fek_import_from_raw()
1072 memcpy(fek->key_data, fek_buf + 16, key_size); in ntfs_fek_import_from_raw()
1073 fek->des_gcry_cipher_hd_ptr = NULL; in ntfs_fek_import_from_raw()
1074 *(gcry_cipher_hd_t***)(fek->key_data + ((key_size + 7) & ~7)) = in ntfs_fek_import_from_raw()
1075 &fek->des_gcry_cipher_hd_ptr; in ntfs_fek_import_from_raw()
1076 switch (fek->alg_id) { in ntfs_fek_import_from_raw()
1096 if (fek->alg_id == CALG_DES) in ntfs_fek_import_from_raw()
1100 le32_to_cpu(fek->alg_id)); in ntfs_fek_import_from_raw()
1116 err = gcry_cipher_open(&fek->gcry_cipher_hd, gcry_algo, in ntfs_fek_import_from_raw()
1125 if (fek->alg_id == CALG_DESX) { in ntfs_fek_import_from_raw()
1126 err = ntfs_desx_key_expand(fek->key_data, (u32*)ctx->des_key, in ntfs_fek_import_from_raw()
1129 err = gcry_cipher_setkey(fek->gcry_cipher_hd, in ntfs_fek_import_from_raw()
1132 err = gcry_cipher_setkey(fek->gcry_cipher_hd, fek->key_data, in ntfs_fek_import_from_raw()
1138 gcry_cipher_close(fek->gcry_cipher_hd); in ntfs_fek_import_from_raw()
1142 return fek; in ntfs_fek_import_from_raw()
1144 free(fek); in ntfs_fek_import_from_raw()
1152 static void ntfs_fek_release(ntfs_fek *fek) in ntfs_fek_release() argument
1154 if (fek->des_gcry_cipher_hd_ptr) in ntfs_fek_release()
1155 gcry_cipher_close(*fek->des_gcry_cipher_hd_ptr); in ntfs_fek_release()
1156 gcry_cipher_close(fek->gcry_cipher_hd); in ntfs_fek_release()
1157 free(fek); in ntfs_fek_release()
1171 ntfs_fek *fek; in ntfs_df_array_fek_get() local
1217 fek = ntfs_fek_import_from_raw(fek_buf, fek_size); in ntfs_df_array_fek_get()
1218 if (fek) in ntfs_df_array_fek_get()
1219 return fek; in ntfs_df_array_fek_get()
1238 ntfs_fek *fek = NULL; in ntfs_inode_fek_get() local
1267 fek = ntfs_df_array_fek_get(df_array, rsa_key, thumbprint, in ntfs_inode_fek_get()
1270 return fek; in ntfs_inode_fek_get()
1276 static int ntfs_fek_decrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset) in ntfs_fek_decrypt_sector() argument
1280 err = gcry_cipher_reset(fek->gcry_cipher_hd); in ntfs_fek_decrypt_sector()
1292 if (fek->alg_id == CALG_DESX) { in ntfs_fek_decrypt_sector()
1295 fek->desx_ctx.prev_blk = 0; in ntfs_fek_decrypt_sector()
1297 err = ntfs_desx_decrypt(fek, &data[k], &data[k]); in ntfs_fek_decrypt_sector()
1300 err = gcry_cipher_decrypt(fek->gcry_cipher_hd, data, 512, NULL, 0); in ntfs_fek_decrypt_sector()
1306 if (fek->alg_id == CALG_AES_256) { in ntfs_fek_decrypt_sector()
1319 static int ntfs_fek_encrypt_sector(ntfs_fek *fek, u8 *data, const u64 offset) in ntfs_fek_encrypt_sector() argument
1323 err = gcry_cipher_reset(fek->gcry_cipher_hd); in ntfs_fek_encrypt_sector()
1336 if (fek->alg_id == CALG_AES_256) { in ntfs_fek_encrypt_sector()
1343 if (fek->alg_id == CALG_DESX) { in ntfs_fek_encrypt_sector()
1346 fek->desx_ctx.prev_blk = 0; in ntfs_fek_encrypt_sector()
1348 err = ntfs_desx_encrypt(fek, &data[k], &data[k]); in ntfs_fek_encrypt_sector()
1351 err = gcry_cipher_encrypt(fek->gcry_cipher_hd, data, 512, NULL, 0); in ntfs_fek_encrypt_sector()
1365 static int ntfs_cat_decrypt(ntfs_inode *inode, ntfs_fek *fek) in ntfs_cat_decrypt() argument
1402 if ((i = ntfs_fek_decrypt_sector(fek, buffer, offset)) < in ntfs_cat_decrypt()
1434 static int ntfs_feed_encrypt(ntfs_inode *inode, ntfs_fek *fek) in ntfs_feed_encrypt() argument
1501 if ((i = ntfs_fek_encrypt_sector(fek, buffer, offset)) in ntfs_feed_encrypt()
1544 ntfs_fek *fek; in main() local
1612 fek = ntfs_inode_fek_get(inode, rsa_key, thumbprint, in main()
1615 if (fek) { in main()
1617 res = ntfs_feed_encrypt(inode, fek); in main()
1619 res = ntfs_cat_decrypt(inode, fek); in main()
1620 ntfs_fek_release(fek); in main()