| 576 | } |
| 577 | |
| 578 | Status EncryptionKey::InitializeFields(const uint8_t* key, int key_len, const uint8_t* iv, |
| 579 | int iv_len, AES_CIPHER_MODE m) { |
| 580 | RETURN_IF_ERROR(ValidateModeAndKeyLength(m, key_len)); |
| 581 | if (!IsModeSupported(m, true)) { |
| 582 | return Status(Substitute("AES mode $0 is not supported by OpenSSL version ($1) " |
| 583 | "that Impala was built against.", ModeToString(m), OPENSSL_VERSION_TEXT)); |
| 584 | } |
| 585 | |
| 586 | mode_ = m; |
| 587 | |
| 588 | key_length_ = key_len; |
| 589 | iv_length_ = iv_len; |
| 590 | memcpy(key_, key, key_length_); |
| 591 | if (iv_length_ != 0) { |
| 592 | memcpy(iv_, iv, iv_length_); |
| 593 | } |
| 594 | initialized_ = true; |
| 595 | return Status::OK(); |
| 596 | } |
| 597 | |
| 598 | void EncryptionKey::SetGcmTag(const uint8_t* tag) { |
| 599 | memcpy(gcm_tag_, tag, AES_BLOCK_SIZE); |