Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/nodejs/src/crypto/crypto_aes.h
1 #ifndef SRC_CRYPTO_CRYPTO_AES_H_ 2 #define SRC_CRYPTO_CRYPTO_AES_H_ 3 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 5 6 #include "crypto/crypto_cipher.h" 7 #include "crypto/crypto_keys.h" 8 #include "crypto/crypto_util.h" 9 #include "env.h" 10 #include "v8.h" 11 12 namespace node { 13 namespace crypto { 14 constexpr size_t kAesBlockSize = 16; 15 constexpr unsigned kNoAuthTagLength = static_cast<unsigned>(-1); 16 constexpr const char* kDefaultWrapIV = "\xa6\xa6\xa6\xa6\xa6\xa6\xa6\xa6"; 17 18 #define VARIANTS(V) \ 19 V(CTR_128, AES_CTR_Cipher, NID_aes_128_ctr) \ 20 V(CTR_192, AES_CTR_Cipher, NID_aes_192_ctr) \ 21 V(CTR_256, AES_CTR_Cipher, NID_aes_256_ctr) \ 22 V(CBC_128, AES_Cipher, NID_aes_128_cbc) \ 23 V(CBC_192, AES_Cipher, NID_aes_192_cbc) \ 24 V(CBC_256, AES_Cipher, NID_aes_256_cbc) \ 25 V(GCM_128, AES_Cipher, NID_aes_128_gcm) \ 26 V(GCM_192, AES_Cipher, NID_aes_192_gcm) \ 27 V(GCM_256, AES_Cipher, NID_aes_256_gcm) \ 28 V(KW_128, AES_Cipher, NID_id_aes128_wrap) \ 29 V(KW_192, AES_Cipher, NID_id_aes192_wrap) \ 30 V(KW_256, AES_Cipher, NID_id_aes256_wrap) 31 32 enum AESKeyVariant { 33 #define V(name, _, __) kKeyVariantAES_##name, 34 VARIANTS(V) 35 #undef V 36 }; 37 38 struct AESCipherConfig final : public MemoryRetainer { 39 CryptoJobMode mode; 40 AESKeyVariant variant; 41 ncrypto::Cipher cipher; 42 size_t length; 43 ByteSource iv; // Used for both iv or counter 44 ByteSource additional_data; 45 ByteSource tag; // Used only for authenticated modes (GCM) 46 47 AESCipherConfig() = default; 48 49 AESCipherConfig(AESCipherConfig&& other) noexcept; 50 51 AESCipherConfig& operator=(AESCipherConfig&& other) noexcept; 52 53 void MemoryInfo(MemoryTracker* tracker) const override; 54 SET_MEMORY_INFO_NAME(AESCipherConfig) 55 SET_SELF_SIZE(AESCipherConfig) 56 }; 57 58 struct AESCipherTraits final { 59 static constexpr const char* JobName = "AESCipherJob"; 60 61 using AdditionalParameters = AESCipherConfig; 62 63 static v8::Maybe<void> AdditionalConfig( 64 CryptoJobMode mode, 65 const v8::FunctionCallbackInfo<v8::Value>& args, 66 unsigned int offset, 67 WebCryptoCipherMode cipher_mode, 68 AESCipherConfig* config); 69 70 static WebCryptoCipherStatus DoCipher(Environment* env, 71 const KeyObjectData& key_data, 72 WebCryptoCipherMode cipher_mode, 73 const AESCipherConfig& params, 74 const ByteSource& in, 75 ByteSource* out); 76 }; 77 78 using AESCryptoJob = CipherJob<AESCipherTraits>; 79 80 namespace AES { 81 void Initialize(Environment* env, v8::Local<v8::Object> target); 82 void RegisterExternalReferences(ExternalReferenceRegistry* registry); 83 } // namespace AES 84 } // namespace crypto 85 } // namespace node 86 87 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 88 #endif // SRC_CRYPTO_CRYPTO_AES_H_