MCPcopy Create free account
hub / github.com/apache/impala / InitializeRandom

Method InitializeRandom

be/src/util/openssl-util.cc:427–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427Status EncryptionKey::InitializeRandom(int iv_len, AES_CIPHER_MODE m) {
428 mode_ = m;
429 if (!IsModeSupported(m, true)) {
430 mode_ = GetSupportedDefaultMode();
431 LOG(WARNING) << Substitute("$0 is not supported, fall back to $1.",
432 ModeToString(m), ModeToString(mode_));
433 }
434
435 if (m == AES_CIPHER_MODE::INVALID) {
436 return Status("Invalid AES mode specified.");
437 }
438
439 uint64_t next_key_num = keys_generated.Add(1);
440 if (next_key_num % RNG_RESEED_INTERVAL == 0) {
441 SeedOpenSSLRNG();
442 }
443 RAND_bytes(key_, sizeof(key_));
444 RAND_bytes(iv_, sizeof(iv_));
445 memset(gcm_tag_, 0, sizeof(gcm_tag_));
446 initialized_ = true;
447 key_length_ = GetKeyLenForMode(mode_);
448 iv_length_ = iv_len;
449 return Status::OK();
450}
451
452Status EncryptionKey::Encrypt(const uint8_t* data, int64_t len, uint8_t* out,
453 int64_t* out_len) {

Callers 3

EncryptAndHashMethod · 0.80
TEST_FFunction · 0.80

Calls 6

SubstituteFunction · 0.85
SeedOpenSSLRNGFunction · 0.85
GetKeyLenForModeFunction · 0.85
OKFunction · 0.85
StatusClass · 0.70
AddMethod · 0.45

Tested by 2

TEST_FFunction · 0.64