| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -491,8 +491,7 @@ void UseDefaultIV(AESCipherConfig* params) { | |||
| 491 | 491 | } // namespace | |
| 492 | 492 | ||
| 493 | 493 | AESCipherConfig::AESCipherConfig(AESCipherConfig&& other) noexcept | |
| 494 | - : mode(other.mode), | ||
| 495 | - variant(other.variant), | ||
| 494 | + : variant(other.variant), | ||
| 496 | 495 | cipher(other.cipher), | |
| 497 | 496 | length(other.length), | |
| 498 | 497 | iv(std::move(other.iv)), | |
@@ -505,12 +504,8 @@ AESCipherConfig& AESCipherConfig::operator=(AESCipherConfig&& other) noexcept { | |||
| 505 | 504 | } | |
| 506 | 505 | ||
| 507 | 506 | void AESCipherConfig::MemoryInfo(MemoryTracker* tracker) const { | |
| 508 | - // If mode is sync, then the data in each of these properties | ||
| 509 | - // is not owned by the AESCipherConfig, so we ignore it. | ||
| 510 | - if (IsCryptoJobAsync(mode)) { | ||
| 511 | - tracker->TrackFieldWithSize("iv", iv.size()); | ||
| 512 | - tracker->TrackFieldWithSize("additional_data", additional_data.size()); | ||
| 513 | - } | ||
| 507 | + tracker->TraitTrackInline(iv, "iv"); | ||
| 508 | + tracker->TraitTrackInline(additional_data, "additional_data"); | ||
| 514 | 509 | } | |
| 515 | 510 | ||
| 516 | 511 | Maybe<void> AESCipherTraits::AdditionalConfig( | |
@@ -521,8 +516,6 @@ Maybe<void> AESCipherTraits::AdditionalConfig( | |||
| 521 | 516 | AESCipherConfig* params) { | |
| 522 | 517 | Environment* env = Environment::GetCurrent(args); | |
| 523 | 518 | ||
| 524 | - params->mode = mode; | ||
| 525 | - | ||
| 526 | 519 | CHECK(args[offset]->IsUint32()); // Key Variant | |
| 527 | 520 | params->variant = | |
| 528 | 521 | static_cast<AESKeyVariant>(args[offset].As<Uint32>()->Value()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,7 +58,6 @@ enum class AESKeyVariant { | |||
| 58 | 58 | }; | |
| 59 | 59 | ||
| 60 | 60 | struct AESCipherConfig final : public MemoryRetainer { | |
| 61 | - CryptoJobMode mode; | ||
| 62 | 61 | AESKeyVariant variant; | |
| 63 | 62 | ncrypto::Cipher cipher; | |
| 64 | 63 | size_t length; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,8 +21,7 @@ using v8::Uint32; | |||
| 21 | 21 | using v8::Value; | |
| 22 | 22 | ||
| 23 | 23 | Argon2Config::Argon2Config(Argon2Config&& other) noexcept | |
| 24 | - : mode{other.mode}, | ||
| 25 | - key{std::move(other.key)}, | ||
| 24 | + : key{std::move(other.key)}, | ||
| 26 | 25 | pass{std::move(other.pass)}, | |
| 27 | 26 | salt{std::move(other.salt)}, | |
| 28 | 27 | secret{std::move(other.secret)}, | |
@@ -40,13 +39,13 @@ Argon2Config& Argon2Config::operator=(Argon2Config&& other) noexcept { | |||
| 40 | 39 | } | |
| 41 | 40 | ||
| 42 | 41 | void Argon2Config::MemoryInfo(MemoryTracker* tracker) const { | |
| 43 | - if (key) tracker->TrackField("key", key); | ||
| 44 | - if (IsCryptoJobAsync(mode)) { | ||
| 45 | - if (!key) tracker->TrackFieldWithSize("pass", pass.size()); | ||
| 46 | - tracker->TrackFieldWithSize("salt", salt.size()); | ||
| 47 | - tracker->TrackFieldWithSize("secret", secret.size()); | ||
| 48 | - tracker->TrackFieldWithSize("ad", ad.size()); | ||
| 49 | - } | ||
| 42 | + if (key) | ||
| 43 | + tracker->TrackField("key", key); | ||
| 44 | + else | ||
| 45 | + tracker->TraitTrackInline(pass, "pass"); | ||
| 46 | + tracker->TraitTrackInline(salt, "salt"); | ||
| 47 | + tracker->TraitTrackInline(secret, "secret"); | ||
| 48 | + tracker->TraitTrackInline(ad, "ad"); | ||
| 50 | 49 | } | |
| 51 | 50 | ||
| 52 | 51 | MaybeLocal<Value> Argon2Traits::EncodeOutput(Environment* env, | |
@@ -62,8 +61,6 @@ Maybe<void> Argon2Traits::AdditionalConfig( | |||
| 62 | 61 | Argon2Config* config) { | |
| 63 | 62 | Environment* env = Environment::GetCurrent(args); | |
| 64 | 63 | ||
| 65 | - config->mode = mode; | ||
| 66 | - | ||
| 67 | 64 | CHECK(KeyObjectHandle::HasInstance(env, args[offset]) || | |
| 68 | 65 | IsAnyBufferSource(args[offset])); // pass | |
| 69 | 66 | ArrayBufferOrViewContents<char> salt(args[offset + 1]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,6 @@ namespace node::crypto { | |||
| 22 | 22 | // at least 16 bytes in length. | |
| 23 | 23 | ||
| 24 | 24 | struct Argon2Config final : public MemoryRetainer { | |
| 25 | - CryptoJobMode mode; | ||
| 26 | 25 | KeyObjectData key; | |
| 27 | 26 | ByteSource pass; | |
| 28 | 27 | ByteSource salt; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,8 +81,7 @@ bool ValidateAdditionalData(Environment* env, | |||
| 81 | 81 | ||
| 82 | 82 | ChaCha20Poly1305CipherConfig::ChaCha20Poly1305CipherConfig( | |
| 83 | 83 | ChaCha20Poly1305CipherConfig&& other) noexcept | |
| 84 | - : mode(other.mode), | ||
| 85 | - cipher(other.cipher), | ||
| 84 | + : cipher(other.cipher), | ||
| 86 | 85 | iv(std::move(other.iv)), | |
| 87 | 86 | additional_data(std::move(other.additional_data)) {} | |
| 88 | 87 | ||
@@ -94,12 +93,8 @@ ChaCha20Poly1305CipherConfig& ChaCha20Poly1305CipherConfig::operator=( | |||
| 94 | 93 | } | |
| 95 | 94 | ||
| 96 | 95 | void ChaCha20Poly1305CipherConfig::MemoryInfo(MemoryTracker* tracker) const { | |
| 97 | - // If mode is sync, then the data in each of these properties | ||
| 98 | - // is not owned by the ChaCha20Poly1305CipherConfig, so we ignore it. | ||
| 99 | - if (IsCryptoJobAsync(mode)) { | ||
| 100 | - tracker->TrackFieldWithSize("iv", iv.size()); | ||
| 101 | - tracker->TrackFieldWithSize("additional_data", additional_data.size()); | ||
| 102 | - } | ||
| 96 | + tracker->TraitTrackInline(iv, "iv"); | ||
| 97 | + tracker->TraitTrackInline(additional_data, "additional_data"); | ||
| 103 | 98 | } | |
| 104 | 99 | ||
| 105 | 100 | Maybe<void> ChaCha20Poly1305CipherTraits::AdditionalConfig( | |
@@ -110,7 +105,6 @@ Maybe<void> ChaCha20Poly1305CipherTraits::AdditionalConfig( | |||
| 110 | 105 | ChaCha20Poly1305CipherConfig* params) { | |
| 111 | 106 | Environment* env = Environment::GetCurrent(args); | |
| 112 | 107 | ||
| 113 | - params->mode = mode; | ||
| 114 | 108 | params->cipher = ncrypto::Cipher::CHACHA20_POLY1305; | |
| 115 | 109 | ||
| 116 | 110 | #ifndef OPENSSL_IS_BORINGSSL | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,6 @@ namespace node::crypto { | |||
| 13 | 13 | constexpr unsigned kChaCha20Poly1305AuthTagLength = 16; | |
| 14 | 14 | ||
| 15 | 15 | struct ChaCha20Poly1305CipherConfig final : public MemoryRetainer { | |
| 16 | - CryptoJobMode mode; | ||
| 17 | 16 | ncrypto::Cipher cipher; | |
| 18 | 17 | ByteSource iv; | |
| 19 | 18 | ByteSource additional_data; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -268,9 +268,8 @@ class CipherJob final : public CryptoJob<CipherTraits> { | |||
| 268 | 268 | ||
| 269 | 269 | SET_SELF_SIZE(CipherJob) | |
| 270 | 270 | void MemoryInfo(MemoryTracker* tracker) const override { | |
| 271 | - if (IsCryptoJobAsync(CryptoJob<CipherTraits>::mode())) | ||
| 272 | - tracker->TrackFieldWithSize("in", in_.size()); | ||
| 273 | - tracker->TrackFieldWithSize("out", out_.size()); | ||
| 271 | + tracker->TraitTrackInline(in_, "in"); | ||
| 272 | + tracker->TraitTrackInline(out_, "out"); | ||
| 274 | 273 | CryptoJob<CipherTraits>::MemoryInfo(tracker); | |
| 275 | 274 | } | |
| 276 | 275 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,7 +58,7 @@ Hash::Hash(Environment* env, Local<Object> wrap) : BaseObject(env, wrap) { | |||
| 58 | 58 | ||
| 59 | 59 | void Hash::MemoryInfo(MemoryTracker* tracker) const { | |
| 60 | 60 | tracker->TrackFieldWithSize("mdctx", mdctx_ ? kSizeOf_EVP_MD_CTX : 0); | |
| 61 | - tracker->TrackFieldWithSize("md", digest_ ? md_len_ : 0); | ||
| 61 | + tracker->TraitTrackInline(digest_, "md"); | ||
| 62 | 62 | } | |
| 63 | 63 | ||
| 64 | 64 | #if NCRYPTO_USE_BORINGSSL_EVP_DO_ALL_FALLBACK | |
@@ -528,10 +528,7 @@ void Hash::HashDigest(const FunctionCallbackInfo<Value>& args) { | |||
| 528 | 528 | } | |
| 529 | 529 | ||
| 530 | 530 | HashConfig::HashConfig(HashConfig&& other) noexcept | |
| 531 | - : mode(other.mode), | ||
| 532 | - in(std::move(other.in)), | ||
| 533 | - digest(other.digest), | ||
| 534 | - length(other.length) {} | ||
| 531 | + : in(std::move(other.in)), digest(other.digest), length(other.length) {} | ||
| 535 | 532 | ||
| 536 | 533 | HashConfig& HashConfig::operator=(HashConfig&& other) noexcept { | |
| 537 | 534 | if (&other == this) return *this; | |
@@ -540,8 +537,7 @@ HashConfig& HashConfig::operator=(HashConfig&& other) noexcept { | |||
| 540 | 537 | } | |
| 541 | 538 | ||
| 542 | 539 | void HashConfig::MemoryInfo(MemoryTracker* tracker) const { | |
| 543 | - // If the Job is sync, then the HashConfig does not own the data. | ||
| 544 | - if (IsCryptoJobAsync(mode)) tracker->TrackFieldWithSize("in", in.size()); | ||
| 540 | + tracker->TraitTrackInline(in, "in"); | ||
| 545 | 541 | } | |
| 546 | 542 | ||
| 547 | 543 | MaybeLocal<Value> HashTraits::EncodeOutput(Environment* env, | |
@@ -557,8 +553,6 @@ Maybe<void> HashTraits::AdditionalConfig( | |||
| 557 | 553 | HashConfig* params) { | |
| 558 | 554 | Environment* env = Environment::GetCurrent(args); | |
| 559 | 555 | ||
| 560 | - params->mode = mode; | ||
| 561 | - | ||
| 562 | 556 | CHECK(args[offset]->IsString()); // Hash algorithm | |
| 563 | 557 | Utf8Value digest(env->isolate(), args[offset]); | |
| 564 | 558 | params->digest = ncrypto::getDigestByName(*digest); | |
@@ -787,8 +781,7 @@ bool DigestUpdateBytepad(ncrypto::EVPMDCtxPointer* ctx, | |||
| 787 | 781 | } // namespace | |
| 788 | 782 | ||
| 789 | 783 | CShakeConfig::CShakeConfig(CShakeConfig&& other) noexcept | |
| 790 | - : mode(other.mode), | ||
| 791 | - in(std::move(other.in)), | ||
| 784 | + : in(std::move(other.in)), | ||
| 792 | 785 | function_name(std::move(other.function_name)), | |
| 793 | 786 | customization(std::move(other.customization)), | |
| 794 | 787 | variant(other.variant), | |
@@ -801,12 +794,9 @@ CShakeConfig& CShakeConfig::operator=(CShakeConfig&& other) noexcept { | |||
| 801 | 794 | } | |
| 802 | 795 | ||
| 803 | 796 | void CShakeConfig::MemoryInfo(MemoryTracker* tracker) const { | |
| 804 | - // If the Job is sync, then the CShakeConfig does not own the data. | ||
| 805 | - if (IsCryptoJobAsync(mode)) { | ||
| 806 | - tracker->TrackFieldWithSize("in", in.size()); | ||
| 807 | - tracker->TrackFieldWithSize("function_name", function_name.size()); | ||
| 808 | - tracker->TrackFieldWithSize("customization", customization.size()); | ||
| 809 | - } | ||
| 797 | + tracker->TraitTrackInline(in, "in"); | ||
| 798 | + tracker->TraitTrackInline(function_name, "function_name"); | ||
| 799 | + tracker->TraitTrackInline(customization, "customization"); | ||
| 810 | 800 | } | |
| 811 | 801 | ||
| 812 | 802 | MaybeLocal<Value> CShakeTraits::EncodeOutput(Environment* env, | |
@@ -822,8 +812,6 @@ Maybe<void> CShakeTraits::AdditionalConfig( | |||
| 822 | 812 | CShakeConfig* params) { | |
| 823 | 813 | Environment* env = Environment::GetCurrent(args); | |
| 824 | 814 | ||
| 825 | - params->mode = mode; | ||
| 826 | - | ||
| 827 | 815 | CHECK(args[offset]->IsString()); // Algorithm name | |
| 828 | 816 | Utf8Value algorithm_name(env->isolate(), args[offset]); | |
| 829 | 817 | std::string_view algorithm_str = algorithm_name.ToStringView(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,6 @@ class Hash final : public BaseObject { | |||
| 42 | 42 | }; | |
| 43 | 43 | ||
| 44 | 44 | struct HashConfig final : public MemoryRetainer { | |
| 45 | - CryptoJobMode mode; | ||
| 46 | 45 | ByteSource in; | |
| 47 | 46 | const EVP_MD* digest; | |
| 48 | 47 | unsigned int length; | |
@@ -108,7 +107,6 @@ struct CShakeParams final { | |||
| 108 | 107 | bool DeriveCShakeBits(const CShakeParams& params, ByteSource* out); | |
| 109 | 108 | ||
| 110 | 109 | struct CShakeConfig final : public MemoryRetainer { | |
| 111 | - CryptoJobMode mode; | ||
| 112 | 110 | ByteSource in; | |
| 113 | 111 | ByteSource function_name; | |
| 114 | 112 | ByteSource customization; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,8 +20,7 @@ using v8::Value; | |||
| 20 | 20 | ||
| 21 | 21 | namespace crypto { | |
| 22 | 22 | HKDFConfig::HKDFConfig(HKDFConfig&& other) noexcept | |
| 23 | - : mode(other.mode), | ||
| 24 | - length(other.length), | ||
| 23 | + : length(other.length), | ||
| 25 | 24 | digest(other.digest), | |
| 26 | 25 | key(std::move(other.key)), | |
| 27 | 26 | key_data(std::move(other.key_data)), | |
@@ -47,8 +46,6 @@ Maybe<void> HKDFTraits::AdditionalConfig( | |||
| 47 | 46 | HKDFConfig* params) { | |
| 48 | 47 | Environment* env = Environment::GetCurrent(args); | |
| 49 | 48 | ||
| 50 | - params->mode = mode; | ||
| 51 | - | ||
| 52 | 49 | CHECK(args[offset]->IsString()); // Hash | |
| 53 | 50 | CHECK(KeyObjectHandle::HasInstance(env, args[offset + 1]) || | |
| 54 | 51 | IsAnyBufferSource(args[offset + 1])); // Key | |
@@ -140,13 +137,12 @@ bool HKDFTraits::DeriveBits(Environment* env, | |||
| 140 | 137 | } | |
| 141 | 138 | ||
| 142 | 139 | void HKDFConfig::MemoryInfo(MemoryTracker* tracker) const { | |
| 143 | - if (key) tracker->TrackField("key", key); | ||
| 144 | - // If the job is sync, then the HKDFConfig does not own the data | ||
| 145 | - if (IsCryptoJobAsync(mode)) { | ||
| 146 | - if (!key) tracker->TrackFieldWithSize("key", key_data.size()); | ||
| 147 | - tracker->TrackFieldWithSize("salt", salt.size()); | ||
| 148 | - tracker->TrackFieldWithSize("info", info.size()); | ||
| 149 | - } | ||
| 140 | + if (key) | ||
| 141 | + tracker->TrackField("key", key); | ||
| 142 | + else | ||
| 143 | + tracker->TraitTrackInline(key_data, "key"); | ||
| 144 | + tracker->TraitTrackInline(salt, "salt"); | ||
| 145 | + tracker->TraitTrackInline(info, "info"); | ||
| 150 | 146 | } | |
| 151 | 147 | ||
| 152 | 148 | } // namespace crypto | |
| Back | FazBrowse Home | New Git URL |
0 commit comments