| 150 | : AesCryptoContext(alg_id, key_len, metadata, write_length) {} |
| 151 | |
| 152 | AesCryptoContext::CipherContext AesEncryptor::AesEncryptorImpl::MakeCipherContext() |
| 153 | const { |
| 154 | auto ctx = NewCipherContext(); |
| 155 | if (kGcmMode == aes_mode_) { |
| 156 | // Init AES-GCM with specified key length |
| 157 | if (16 == key_length_) { |
| 158 | ENCRYPT_INIT(ctx.get(), EVP_aes_128_gcm()); |
| 159 | } else if (24 == key_length_) { |
| 160 | ENCRYPT_INIT(ctx.get(), EVP_aes_192_gcm()); |
| 161 | } else if (32 == key_length_) { |
| 162 | ENCRYPT_INIT(ctx.get(), EVP_aes_256_gcm()); |
| 163 | } |
| 164 | } else { |
| 165 | // Init AES-CTR with specified key length |
| 166 | if (16 == key_length_) { |
| 167 | ENCRYPT_INIT(ctx.get(), EVP_aes_128_ctr()); |
| 168 | } else if (24 == key_length_) { |
| 169 | ENCRYPT_INIT(ctx.get(), EVP_aes_192_ctr()); |
| 170 | } else if (32 == key_length_) { |
| 171 | ENCRYPT_INIT(ctx.get(), EVP_aes_256_ctr()); |
| 172 | } |
| 173 | } |
| 174 | return ctx; |
| 175 | } |
| 176 | |
| 177 | int32_t AesEncryptor::AesEncryptorImpl::SignedFooterEncrypt( |
| 178 | std::span<const uint8_t> footer, std::span<const uint8_t> key, |