| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e78ccd8 commit 74509b1
32 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -124,7 +124,8 @@ Maybe<void> Argon2Traits::AdditionalConfig( | |||
| 124 | 124 | bool Argon2Traits::DeriveBits(Environment* env, | |
| 125 | 125 | const Argon2Config& config, | |
| 126 | 126 | ByteSource* out, | |
| 127 | - CryptoJobMode mode) { | ||
| 127 | + CryptoJobMode mode, | ||
| 128 | + CryptoErrorStore* errors) { | ||
| 128 | 129 | // If the config.length is zero-length, just return an empty buffer. | |
| 129 | 130 | // It's useless, yes, but allowed via the API. | |
| 130 | 131 | if (config.keylen == 0) { | |
@@ -144,7 +145,10 @@ bool Argon2Traits::DeriveBits(Environment* env, | |||
| 144 | 145 | config.ad, | |
| 145 | 146 | config.type); | |
| 146 | 147 | ||
| 147 | - if (!dp) return false; | ||
| 148 | + if (!dp) { | ||
| 149 | + errors->Insert(NodeCryptoError::ARGON2_FAILED); | ||
| 150 | + return false; | ||
| 151 | + } | ||
| 148 | 152 | DCHECK(!dp.isSecure()); | |
| 149 | 153 | *out = ByteSource::Allocated(dp.release()); | |
| 150 | 154 | return true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,7 +59,8 @@ struct Argon2Traits final { | |||
| 59 | 59 | static bool DeriveBits(Environment* env, | |
| 60 | 60 | const Argon2Config& config, | |
| 61 | 61 | ByteSource* out, | |
| 62 | - CryptoJobMode mode); | ||
| 62 | + CryptoJobMode mode, | ||
| 63 | + CryptoErrorStore* errors); | ||
| 63 | 64 | ||
| 64 | 65 | static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env, | |
| 65 | 66 | const Argon2Config& config, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -504,16 +504,11 @@ MaybeLocal<Value> DHBitsTraits::EncodeOutput(Environment* env, | |||
| 504 | 504 | bool DHBitsTraits::DeriveBits(Environment* env, | |
| 505 | 505 | const DHBitsConfig& params, | |
| 506 | 506 | ByteSource* out, | |
| 507 | - CryptoJobMode mode) { | ||
| 507 | + CryptoJobMode mode, | ||
| 508 | + CryptoErrorStore* errors) { | ||
| 508 | 509 | auto dp = DHPointer::stateless(params.private_key.GetAsymmetricKey(), | |
| 509 | 510 | params.public_key.GetAsymmetricKey()); | |
| 510 | 511 | if (!dp) { | |
| 511 | - bool can_throw = mode == CryptoJobMode::kCryptoJobSync; | ||
| 512 | - | ||
| 513 | - if (can_throw) { | ||
| 514 | - unsigned long err = ERR_get_error(); // NOLINT(runtime/int) | ||
| 515 | - if (err) ThrowCryptoError(env, err, "diffieHellman failed"); | ||
| 516 | - } | ||
| 517 | 512 | return false; | |
| 518 | 513 | } | |
| 519 | 514 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,7 +83,8 @@ struct DHBitsTraits final { | |||
| 83 | 83 | static bool DeriveBits(Environment* env, | |
| 84 | 84 | const DHBitsConfig& params, | |
| 85 | 85 | ByteSource* out_, | |
| 86 | - CryptoJobMode mode); | ||
| 86 | + CryptoJobMode mode, | ||
| 87 | + CryptoErrorStore* errors); | ||
| 87 | 88 | ||
| 88 | 89 | static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env, | |
| 89 | 90 | const DHBitsConfig& params, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -433,7 +433,8 @@ Maybe<void> ECDHBitsTraits::AdditionalConfig( | |||
| 433 | 433 | bool ECDHBitsTraits::DeriveBits(Environment* env, | |
| 434 | 434 | const ECDHBitsConfig& params, | |
| 435 | 435 | ByteSource* out, | |
| 436 | - CryptoJobMode mode) { | ||
| 436 | + CryptoJobMode mode, | ||
| 437 | + CryptoErrorStore* errors) { | ||
| 437 | 438 | size_t len = 0; | |
| 438 | 439 | const auto& m_privkey = params.private_.GetAsymmetricKey(); | |
| 439 | 440 | const auto& m_pubkey = params.public_.GetAsymmetricKey(); | |
@@ -464,8 +465,10 @@ bool ECDHBitsTraits::DeriveBits(Environment* env, | |||
| 464 | 465 | const EC_KEY* public_key = m_pubkey; | |
| 465 | 466 | ||
| 466 | 467 | const auto group = ECKeyPointer::GetGroup(private_key); | |
| 467 | - if (group == nullptr) | ||
| 468 | + if (group == nullptr) { | ||
| 469 | + errors->Insert(NodeCryptoError::ECDH_FAILED); | ||
| 468 | 470 | return false; | |
| 471 | + } | ||
| 469 | 472 | ||
| 470 | 473 | CHECK(ECKeyPointer::Check(private_key)); | |
| 471 | 474 | CHECK(ECKeyPointer::Check(public_key)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -80,7 +80,8 @@ struct ECDHBitsTraits final { | |||
| 80 | 80 | static bool DeriveBits(Environment* env, | |
| 81 | 81 | const ECDHBitsConfig& params, | |
| 82 | 82 | ByteSource* out_, | |
| 83 | - CryptoJobMode mode); | ||
| 83 | + CryptoJobMode mode, | ||
| 84 | + CryptoErrorStore* errors); | ||
| 84 | 85 | ||
| 85 | 86 | static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env, | |
| 86 | 87 | const ECDHBitsConfig& params, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -540,7 +540,8 @@ Maybe<void> HashTraits::AdditionalConfig( | |||
| 540 | 540 | bool HashTraits::DeriveBits(Environment* env, | |
| 541 | 541 | const HashConfig& params, | |
| 542 | 542 | ByteSource* out, | |
| 543 | - CryptoJobMode mode) { | ||
| 543 | + CryptoJobMode mode, | ||
| 544 | + CryptoErrorStore* errors) { | ||
| 544 | 545 | auto ctx = EVPMDCtxPointer::New(); | |
| 545 | 546 | ||
| 546 | 547 | if (!ctx.digestInit(params.digest) || !ctx.digestUpdate(params.in)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,7 +73,8 @@ struct HashTraits final { | |||
| 73 | 73 | static bool DeriveBits(Environment* env, | |
| 74 | 74 | const HashConfig& params, | |
| 75 | 75 | ByteSource* out, | |
| 76 | - CryptoJobMode mode); | ||
| 76 | + CryptoJobMode mode, | ||
| 77 | + CryptoErrorStore* errors); | ||
| 77 | 78 | ||
| 78 | 79 | static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env, | |
| 79 | 80 | const HashConfig& params, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,7 +100,8 @@ Maybe<void> HKDFTraits::AdditionalConfig( | |||
| 100 | 100 | bool HKDFTraits::DeriveBits(Environment* env, | |
| 101 | 101 | const HKDFConfig& params, | |
| 102 | 102 | ByteSource* out, | |
| 103 | - CryptoJobMode mode) { | ||
| 103 | + CryptoJobMode mode, | ||
| 104 | + CryptoErrorStore* errors) { | ||
| 104 | 105 | auto dp = ncrypto::hkdf(params.digest, | |
| 105 | 106 | ncrypto::Buffer<const unsigned char>{ | |
| 106 | 107 | .data = reinterpret_cast<const unsigned char*>( | |
@@ -116,7 +117,10 @@ bool HKDFTraits::DeriveBits(Environment* env, | |||
| 116 | 117 | .len = params.salt.size(), | |
| 117 | 118 | }, | |
| 118 | 119 | params.length); | |
| 119 | - if (!dp) return false; | ||
| 120 | + if (!dp) { | ||
| 121 | + errors->Insert(NodeCryptoError::HKDF_FAILED); | ||
| 122 | + return false; | ||
| 123 | + } | ||
| 120 | 124 | ||
| 121 | 125 | DCHECK(!dp.isSecure()); | |
| 122 | 126 | *out = ByteSource::Allocated(dp.release()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,7 +45,8 @@ struct HKDFTraits final { | |||
| 45 | 45 | static bool DeriveBits(Environment* env, | |
| 46 | 46 | const HKDFConfig& params, | |
| 47 | 47 | ByteSource* out, | |
| 48 | - CryptoJobMode mode); | ||
| 48 | + CryptoJobMode mode, | ||
| 49 | + CryptoErrorStore* errors); | ||
| 49 | 50 | ||
| 50 | 51 | static v8::MaybeLocal<v8::Value> EncodeOutput(Environment* env, | |
| 51 | 52 | const HKDFConfig& params, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments