MCPcopy Create free account
hub / github.com/ceph/ceph / encrypt

Method encrypt

src/client/FSCrypt.cc:697–731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695}
696
697int FSCryptDenc::encrypt(const char *in_data, int in_len,
698 char *out_data, int out_len)
699{
700 int total_len;
701
702 if ((int)key.size() != key_size) {
703 ldout(cct, 0) << "ERROR: unexpected encryption key size: " << key.size() << " (expected: " << key_size << ")" << dendl;
704 return -EINVAL;
705 }
706
707 if ((uint64_t)out_len < (fscrypt_align_ofs(in_len))) {
708 return -ERANGE;
709 }
710
711 if (!EVP_CipherInit_ex2(cipher_ctx, cipher, (const uint8_t *)key.data(), iv.raw,
712 1, cipher_params.data())) {
713 return -EINVAL;
714 }
715
716 int len;
717
718 if (EVP_EncryptUpdate(cipher_ctx, (uint8_t *)out_data, &len, (const uint8_t *)in_data, in_len) != 1) {
719 return -EINVAL;
720 }
721
722 total_len = len;
723
724 if (EVP_EncryptFinal_ex(cipher_ctx, (uint8_t *)out_data + len, &len) != 1) {
725 return -EINVAL;
726 }
727
728 total_len += len;
729
730 return total_len;
731}
732
733FSCryptDenc::~FSCryptDenc()
734{

Callers

nothing calls this directly

Calls 3

fscrypt_align_ofsFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected