github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/c-deps/libroach/ccl/crypto_utils.h (about)

     1  // Copyright 2017 The Cockroach Authors.
     2  //
     3  // Licensed as a CockroachDB Enterprise file under the Cockroach Community
     4  // License (the "License"); you may not use this file except in compliance with
     5  // the License. You may obtain a copy of the License at
     6  //
     7  //     https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt
     8  
     9  #pragma once
    10  
    11  #include <rocksdb/status.h>
    12  #include <string>
    13  #include "../rocksdbutils/env_encryption.h"
    14  #include "ccl/storageccl/engineccl/enginepbccl/key_registry.pb.h"
    15  
    16  namespace enginepbccl = cockroach::ccl::storageccl::engineccl::enginepbccl;
    17  
    18  /*
    19   * These provide various crypto primitives. They currently use CryptoPP.
    20   */
    21  
    22  // HexString returns the lowercase hexadecimal representation of the data contained 's'.
    23  // eg: HexString("1") -> "31" (hex(character value)), not "1" -> "1".
    24  std::string HexString(const std::string& s);
    25  
    26  // RandomBytes returns `length` bytes of data from a pseudo-random number generator.
    27  // This is non-blocking.
    28  std::string RandomBytes(size_t length);
    29  
    30  // Create a new AES cipher using the passed-in key.
    31  // Suitable for encryption only, Decrypt is not implemented.
    32  rocksdb_utils::BlockCipher* NewAESEncryptCipher(const enginepbccl::SecretKey* key);
    33  
    34  // Returns true if CryptoPP is using AES-NI.
    35  bool UsesAESNI();
    36  
    37  // DisableCoreFile sets the maximum size of a core file to 0. Returns success
    38  // if successfully called.
    39  rocksdb::Status DisableCoreFile();