| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 73cd9dd commit ac2edbc
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -183,16 +183,12 @@ struct KeyPairGenTraits final { | |||
| 183 | 183 | AdditionalParameters* params, | |
| 184 | 184 | v8::Local<v8::Value>* result) { | |
| 185 | 185 | v8::Local<v8::Value> keys[2]; | |
| 186 | - if (ManagedEVPPKey::ToEncodedPublicKey( | ||
| 187 | - env, | ||
| 188 | - std::move(params->key), | ||
| 189 | - params->public_key_encoding, | ||
| 190 | - &keys[0]).IsNothing() || | ||
| 191 | - ManagedEVPPKey::ToEncodedPrivateKey( | ||
| 192 | - env, | ||
| 193 | - std::move(params->key), | ||
| 194 | - params->private_key_encoding, | ||
| 195 | - &keys[1]).IsNothing()) { | ||
| 186 | + if (params->key | ||
| 187 | + .ToEncodedPublicKey(env, params->public_key_encoding, &keys[0]) | ||
| 188 | + .IsNothing() || | ||
| 189 | + params->key | ||
| 190 | + .ToEncodedPrivateKey(env, params->private_key_encoding, &keys[1]) | ||
| 191 | + .IsNothing()) { | ||
| 196 | 192 | return v8::Nothing<bool>(); | |
| 197 | 193 | } | |
| 198 | 194 | *result = v8::Array::New(env->isolate(), keys, arraysize(keys)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -632,44 +632,42 @@ Maybe<bool> ExportJWKInner(Environment* env, | |||
| 632 | 632 | ||
| 633 | 633 | Maybe<bool> ManagedEVPPKey::ToEncodedPublicKey( | |
| 634 | 634 | Environment* env, | |
| 635 | - ManagedEVPPKey key, | ||
| 636 | 635 | const PublicKeyEncodingConfig& config, | |
| 637 | 636 | Local<Value>* out) { | |
| 638 | - if (!key) return Nothing<bool>(); | ||
| 637 | + if (!*this) return Nothing<bool>(); | ||
| 639 | 638 | if (config.output_key_object_) { | |
| 640 | 639 | // Note that this has the downside of containing sensitive data of the | |
| 641 | 640 | // private key. | |
| 642 | 641 | std::shared_ptr<KeyObjectData> data = | |
| 643 | - KeyObjectData::CreateAsymmetric(kKeyTypePublic, std::move(key)); | ||
| 642 | + KeyObjectData::CreateAsymmetric(kKeyTypePublic, *this); | ||
| 644 | 643 | return Tristate(KeyObjectHandle::Create(env, data).ToLocal(out)); | |
| 645 | 644 | } else if (config.format_ == kKeyFormatJWK) { | |
| 646 | 645 | std::shared_ptr<KeyObjectData> data = | |
| 647 | - KeyObjectData::CreateAsymmetric(kKeyTypePublic, std::move(key)); | ||
| 646 | + KeyObjectData::CreateAsymmetric(kKeyTypePublic, *this); | ||
| 648 | 647 | *out = Object::New(env->isolate()); | |
| 649 | 648 | return ExportJWKInner(env, data, *out, false); | |
| 650 | 649 | } | |
| 651 | 650 | ||
| 652 | - return Tristate(WritePublicKey(env, key.get(), config).ToLocal(out)); | ||
| 651 | + return Tristate(WritePublicKey(env, get(), config).ToLocal(out)); | ||
| 653 | 652 | } | |
| 654 | 653 | ||
| 655 | 654 | Maybe<bool> ManagedEVPPKey::ToEncodedPrivateKey( | |
| 656 | 655 | Environment* env, | |
| 657 | - ManagedEVPPKey key, | ||
| 658 | 656 | const PrivateKeyEncodingConfig& config, | |
| 659 | 657 | Local<Value>* out) { | |
| 660 | - if (!key) return Nothing<bool>(); | ||
| 658 | + if (!*this) return Nothing<bool>(); | ||
| 661 | 659 | if (config.output_key_object_) { | |
| 662 | 660 | std::shared_ptr<KeyObjectData> data = | |
| 663 | - KeyObjectData::CreateAsymmetric(kKeyTypePrivate, std::move(key)); | ||
| 661 | + KeyObjectData::CreateAsymmetric(kKeyTypePrivate, *this); | ||
| 664 | 662 | return Tristate(KeyObjectHandle::Create(env, data).ToLocal(out)); | |
| 665 | 663 | } else if (config.format_ == kKeyFormatJWK) { | |
| 666 | 664 | std::shared_ptr<KeyObjectData> data = | |
| 667 | - KeyObjectData::CreateAsymmetric(kKeyTypePrivate, std::move(key)); | ||
| 665 | + KeyObjectData::CreateAsymmetric(kKeyTypePrivate, *this); | ||
| 668 | 666 | *out = Object::New(env->isolate()); | |
| 669 | 667 | return ExportJWKInner(env, data, *out, false); | |
| 670 | 668 | } | |
| 671 | 669 | ||
| 672 | - return Tristate(WritePrivateKey(env, key.get(), config).ToLocal(out)); | ||
| 670 | + return Tristate(WritePrivateKey(env, get(), config).ToLocal(out)); | ||
| 673 | 671 | } | |
| 674 | 672 | ||
| 675 | 673 | NonCopyableMaybe<PrivateKeyEncodingConfig> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -112,17 +112,13 @@ class ManagedEVPPKey : public MemoryRetainer { | |||
| 112 | 112 | unsigned int* offset, | |
| 113 | 113 | bool allow_key_object); | |
| 114 | 114 | ||
| 115 | - static v8::Maybe<bool> ToEncodedPublicKey( | ||
| 116 | - Environment* env, | ||
| 117 | - ManagedEVPPKey key, | ||
| 118 | - const PublicKeyEncodingConfig& config, | ||
| 119 | - v8::Local<v8::Value>* out); | ||
| 115 | + v8::Maybe<bool> ToEncodedPublicKey(Environment* env, | ||
| 116 | + const PublicKeyEncodingConfig& config, | ||
| 117 | + v8::Local<v8::Value>* out); | ||
| 120 | 118 | ||
| 121 | - static v8::Maybe<bool> ToEncodedPrivateKey( | ||
| 122 | - Environment* env, | ||
| 123 | - ManagedEVPPKey key, | ||
| 124 | - const PrivateKeyEncodingConfig& config, | ||
| 125 | - v8::Local<v8::Value>* out); | ||
| 119 | + v8::Maybe<bool> ToEncodedPrivateKey(Environment* env, | ||
| 120 | + const PrivateKeyEncodingConfig& config, | ||
| 121 | + v8::Local<v8::Value>* out); | ||
| 126 | 122 | ||
| 127 | 123 | private: | |
| 128 | 124 | size_t size_of_private_key() const; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments