|
16 | 16 | // under the License.
|
17 | 17 |
|
18 | 18 | #include "parquet/encryption/encryption_internal.h"
|
| 19 | + |
19 | 20 | #include <openssl/aes.h>
|
20 | 21 | #include <openssl/evp.h>
|
21 | 22 | #include <openssl/rand.h>
|
|
27 | 28 | #include <string>
|
28 | 29 | #include <vector>
|
29 | 30 |
|
| 31 | +#include "parquet/encryption/openssl_internal.h" |
30 | 32 | #include "parquet/exception.h"
|
31 | 33 |
|
32 | 34 | using parquet::ParquetException;
|
@@ -92,6 +94,8 @@ class AesEncryptor::AesEncryptorImpl {
|
92 | 94 |
|
93 | 95 | AesEncryptor::AesEncryptorImpl::AesEncryptorImpl(ParquetCipher::type alg_id, int key_len,
|
94 | 96 | bool metadata, bool write_length) {
|
| 97 | + openssl::EnsureInitialized(); |
| 98 | + |
95 | 99 | ctx_ = nullptr;
|
96 | 100 |
|
97 | 101 | length_buffer_length_ = write_length ? kBufferSizeLength : 0;
|
@@ -358,6 +362,8 @@ AesDecryptor::~AesDecryptor() {}
|
358 | 362 |
|
359 | 363 | AesDecryptor::AesDecryptorImpl::AesDecryptorImpl(ParquetCipher::type alg_id, int key_len,
|
360 | 364 | bool metadata, bool contains_length) {
|
| 365 | + openssl::EnsureInitialized(); |
| 366 | + |
361 | 367 | ctx_ = nullptr;
|
362 | 368 | length_buffer_length_ = contains_length ? kBufferSizeLength : 0;
|
363 | 369 | ciphertext_size_delta_ = length_buffer_length_ + kNonceLength;
|
@@ -646,6 +652,11 @@ void QuickUpdatePageAad(int32_t new_page_ordinal, std::string* AAD) {
|
646 | 652 | std::memcpy(AAD->data() + AAD->length() - 2, page_ordinal_bytes.data(), 2);
|
647 | 653 | }
|
648 | 654 |
|
649 |
| -void RandBytes(unsigned char* buf, int num) { RAND_bytes(buf, num); } |
| 655 | +void RandBytes(unsigned char* buf, int num) { |
| 656 | + openssl::EnsureInitialized(); |
| 657 | + RAND_bytes(buf, num); |
| 658 | +} |
| 659 | + |
| 660 | +void EnsureBackendInitialized() { openssl::EnsureInitialized(); } |
650 | 661 |
|
651 | 662 | } // namespace parquet::encryption
|
0 commit comments