| 655 | } |
| 656 | |
| 657 | int FSCryptDenc::decrypt(const char *in_data, int in_len, |
| 658 | char *out_data, int out_len) |
| 659 | { |
| 660 | int total_len; |
| 661 | |
| 662 | if ((int)key.size() != key_size) { |
| 663 | ldout(cct, 0) << "ERROR: unexpected encryption key size: " << key.size() << " (expected: " << key_size << ")" << dendl; |
| 664 | return -EINVAL; |
| 665 | } |
| 666 | |
| 667 | if ((uint64_t)out_len < (fscrypt_align_ofs(in_len))) { |
| 668 | ldout(cct, 0) << __FILE__ << ":" << __LINE__ << dendl; |
| 669 | return -ERANGE; |
| 670 | } |
| 671 | |
| 672 | if (!EVP_CipherInit_ex2(cipher_ctx, cipher, (const uint8_t *)key.data(), iv.raw, |
| 673 | 0, cipher_params.data())) { |
| 674 | ldout(cct, 0) << __FILE__ << ":" << __LINE__ << dendl; |
| 675 | return -EINVAL; |
| 676 | } |
| 677 | |
| 678 | int len; |
| 679 | |
| 680 | if (EVP_DecryptUpdate(cipher_ctx, (uint8_t *)out_data, &len, (const uint8_t *)in_data, in_len) != 1) { |
| 681 | ldout(cct, 0) << __FILE__ << ":" << __LINE__ << dendl; |
| 682 | return -EINVAL; |
| 683 | } |
| 684 | |
| 685 | total_len = len; |
| 686 | |
| 687 | int ret = EVP_DecryptFinal_ex(cipher_ctx, (uint8_t *)out_data + len, &len); |
| 688 | if (ret != 1) { |
| 689 | return -EINVAL; |
| 690 | } |
| 691 | |
| 692 | total_len += len; |
| 693 | |
| 694 | return total_len; |
| 695 | } |
| 696 | |
| 697 | int FSCryptDenc::encrypt(const char *in_data, int in_len, |
| 698 | char *out_data, int out_len) |
nothing calls this directly
no test coverage detected