Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/nodejs/src/crypto/crypto_scrypt.h
1 #ifndef SRC_CRYPTO_CRYPTO_SCRYPT_H_ 2 #define SRC_CRYPTO_CRYPTO_SCRYPT_H_ 3 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 5 6 #include "crypto/crypto_util.h" 7 #include "env.h" 8 #include "memory_tracker.h" 9 #include "v8.h" 10 11 namespace node { 12 namespace crypto { 13 #ifndef OPENSSL_NO_SCRYPT 14 15 // Scrypt is a password-based key derivation algorithm 16 // defined in https://tools.ietf.org/html/rfc7914 17 18 // It takes as input a password, a salt value, and a 19 // handful of additional parameters that control the 20 // cost of the operation. In this case, the higher 21 // the cost, the better the result. The length parameter 22 // defines the number of bytes that are generated. 23 24 // The salt must be as random as possible and should be 25 // at least 16 bytes in length. 26 27 struct ScryptConfig final : public MemoryRetainer { 28 CryptoJobMode mode; 29 ByteSource pass; 30 ByteSource salt; 31 uint32_t N; 32 uint32_t r; 33 uint32_t p; 34 uint64_t maxmem; 35 int32_t length; 36 37 ScryptConfig() = default; 38 39 explicit ScryptConfig(ScryptConfig&& other) noexcept; 40 41 ScryptConfig& operator=(ScryptConfig&& other) noexcept; 42 43 void MemoryInfo(MemoryTracker* tracker) const override; 44 SET_MEMORY_INFO_NAME(ScryptConfig) 45 SET_SELF_SIZE(ScryptConfig) 46 }; 47 48 struct ScryptTraits final { 49 using AdditionalParameters = ScryptConfig; 50 static constexpr const char* JobName = "ScryptJob"; 51 static constexpr AsyncWrap::ProviderType Provider = 52 AsyncWrap::PROVIDER_SCRYPTREQUEST; 53 54 static v8::Maybe<void> AdditionalConfig( 55 CryptoJobMode mode, 56 const v8::FunctionCallbackInfo<v8::Value>& args, 57 unsigned int offset, 58 ScryptConfig* params); 59 60 static bool DeriveBits(Environment* env, 61 const ScryptConfig& params, 62 ByteSource* out, 63 CryptoJobMode mode); 64 65 static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env, 66 const ScryptConfig& params, 67 ByteSource* out); 68 }; 69 70 using ScryptJob = DeriveBitsJob<ScryptTraits>; 71 72 #else 73 // If there is no Scrypt support, ScryptJob becomes a non-op 74 struct ScryptJob { 75 static void Initialize( 76 Environment* env, 77 v8::Local<v8::Object> target) {} 78 }; 79 #endif // !OPENSSL_NO_SCRYPT 80 81 } // namespace crypto 82 } // namespace node 83 84 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 85 #endif // SRC_CRYPTO_CRYPTO_SCRYPT_H_