| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 44b9d08 commit 3302025
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -331,23 +331,23 @@ function createSecretKey(key) { | |||
| 331 | 331 | key = prepareSecretKey(key, true); | |
| 332 | 332 | if (key.byteLength === 0) | |
| 333 | 333 | throw new ERR_OUT_OF_RANGE('key.byteLength', '> 0', key.byteLength); | |
| 334 | - const handle = new KeyObjectHandle(kKeyTypeSecret); | ||
| 335 | - handle.init(key); | ||
| 334 | + const handle = new KeyObjectHandle(); | ||
| 335 | + handle.init(kKeyTypeSecret, key); | ||
| 336 | 336 | return new SecretKeyObject(handle); | |
| 337 | 337 | } | |
| 338 | 338 | ||
| 339 | 339 | function createPublicKey(key) { | |
| 340 | 340 | const { format, type, data } = prepareAsymmetricKey(key, kCreatePublic); | |
| 341 | - const handle = new KeyObjectHandle(kKeyTypePublic); | ||
| 342 | - handle.init(data, format, type); | ||
| 341 | + const handle = new KeyObjectHandle(); | ||
| 342 | + handle.init(kKeyTypePublic, data, format, type); | ||
| 343 | 343 | return new PublicKeyObject(handle); | |
| 344 | 344 | } | |
| 345 | 345 | ||
| 346 | 346 | function createPrivateKey(key) { | |
| 347 | 347 | const { format, type, data, passphrase } = | |
| 348 | 348 | prepareAsymmetricKey(key, kCreatePrivate); | |
| 349 | - const handle = new KeyObjectHandle(kKeyTypePrivate); | ||
| 350 | - handle.init(data, format, type, passphrase); | ||
| 349 | + const handle = new KeyObjectHandle(); | ||
| 350 | + handle.init(kKeyTypePrivate, data, format, type, passphrase); | ||
| 351 | 351 | return new PrivateKeyObject(handle); | |
| 352 | 352 | } | |
| 353 | 353 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2929,7 +2929,8 @@ ByteSource ByteSource::FromSymmetricKeyObjectHandle(Local<Value> handle) { | |||
| 2929 | 2929 | CHECK(handle->IsObject()); | |
| 2930 | 2930 | KeyObjectHandle* key = Unwrap<KeyObjectHandle>(handle.As<Object>()); | |
| 2931 | 2931 | CHECK_NOT_NULL(key); | |
| 2932 | - return Foreign(key->GetSymmetricKey(), key->GetSymmetricKeySize()); | ||
| 2932 | + return Foreign(key->Data()->GetSymmetricKey(), | ||
| 2933 | + key->Data()->GetSymmetricKeySize()); | ||
| 2933 | 2934 | } | |
| 2934 | 2935 | ||
| 2935 | 2936 | ByteSource::ByteSource(const char* data, char* allocated_data, size_t size) | |
@@ -3075,9 +3076,9 @@ static ManagedEVPPKey GetPrivateKeyFromJs( | |||
| 3075 | 3076 | CHECK(args[*offset]->IsObject() && allow_key_object); | |
| 3076 | 3077 | KeyObjectHandle* key; | |
| 3077 | 3078 | ASSIGN_OR_RETURN_UNWRAP(&key, args[*offset].As<Object>(), ManagedEVPPKey()); | |
| 3078 | - CHECK_EQ(key->GetKeyType(), kKeyTypePrivate); | ||
| 3079 | + CHECK_EQ(key->Data()->GetKeyType(), kKeyTypePrivate); | ||
| 3079 | 3080 | (*offset) += 4; | |
| 3080 | - return key->GetAsymmetricKey(); | ||
| 3081 | + return key->Data()->GetAsymmetricKey(); | ||
| 3081 | 3082 | } | |
| 3082 | 3083 | } | |
| 3083 | 3084 | ||
@@ -3135,9 +3136,9 @@ static ManagedEVPPKey GetPublicOrPrivateKeyFromJs( | |||
| 3135 | 3136 | CHECK(args[*offset]->IsObject()); | |
| 3136 | 3137 | KeyObjectHandle* key = Unwrap<KeyObjectHandle>(args[*offset].As<Object>()); | |
| 3137 | 3138 | CHECK_NOT_NULL(key); | |
| 3138 | - CHECK_NE(key->GetKeyType(), kKeyTypeSecret); | ||
| 3139 | + CHECK_NE(key->Data()->GetKeyType(), kKeyTypeSecret); | ||
| 3139 | 3140 | (*offset) += 4; | |
| 3140 | - return key->GetAsymmetricKey(); | ||
| 3141 | + return key->Data()->GetAsymmetricKey(); | ||
| 3141 | 3142 | } | |
| 3142 | 3143 | } | |
| 3143 | 3144 | ||
@@ -3243,6 +3244,48 @@ EVP_PKEY* ManagedEVPPKey::get() const { | |||
| 3243 | 3244 | return pkey_.get(); | |
| 3244 | 3245 | } | |
| 3245 | 3246 | ||
| 3247 | + KeyObjectData* KeyObjectData::CreateSecret(v8::Local<v8::ArrayBufferView> abv) { | ||
| 3248 | + size_t key_len = abv->ByteLength(); | ||
| 3249 | + char* mem = MallocOpenSSL<char>(key_len); | ||
| 3250 | + abv->CopyContents(mem, key_len); | ||
| 3251 | + KeyObjectData* data = new KeyObjectData(); | ||
| 3252 | + data->key_type_ = kKeyTypeSecret; | ||
| 3253 | + data->symmetric_key_ = std::unique_ptr<char, std::function<void(char*)>>(mem, | ||
| 3254 | + [key_len](char* p) { | ||
| 3255 | + OPENSSL_clear_free(p, key_len); | ||
| 3256 | + }); | ||
| 3257 | + data->symmetric_key_len_ = key_len; | ||
| 3258 | + return data; | ||
| 3259 | + } | ||
| 3260 | + | ||
| 3261 | + KeyObjectData* KeyObjectData::CreateAsymmetric(KeyType key_type, | ||
| 3262 | + const ManagedEVPPKey& pkey) { | ||
| 3263 | + CHECK(pkey); | ||
| 3264 | + KeyObjectData* data = new KeyObjectData(); | ||
| 3265 | + data->key_type_ = key_type; | ||
| 3266 | + data->asymmetric_key_ = pkey; | ||
| 3267 | + return data; | ||
| 3268 | + } | ||
| 3269 | + | ||
| 3270 | + KeyType KeyObjectData::GetKeyType() const { | ||
| 3271 | + return key_type_; | ||
| 3272 | + } | ||
| 3273 | + | ||
| 3274 | + ManagedEVPPKey KeyObjectData::GetAsymmetricKey() const { | ||
| 3275 | + CHECK_NE(key_type_, kKeyTypeSecret); | ||
| 3276 | + return asymmetric_key_; | ||
| 3277 | + } | ||
| 3278 | + | ||
| 3279 | + const char* KeyObjectData::GetSymmetricKey() const { | ||
| 3280 | + CHECK_EQ(key_type_, kKeyTypeSecret); | ||
| 3281 | + return symmetric_key_.get(); | ||
| 3282 | + } | ||
| 3283 | + | ||
| 3284 | + size_t KeyObjectData::GetSymmetricKeySize() const { | ||
| 3285 | + CHECK_EQ(key_type_, kKeyTypeSecret); | ||
| 3286 | + return symmetric_key_len_; | ||
| 3287 | + } | ||
| 3288 | + | ||
| 3246 | 3289 | Local<Function> KeyObjectHandle::Initialize(Environment* env, | |
| 3247 | 3290 | Local<Object> target) { | |
| 3248 | 3291 | Local<FunctionTemplate> t = env->NewFunctionTemplate(New); | |
@@ -3279,46 +3322,23 @@ MaybeLocal<Object> KeyObjectHandle::Create(Environment* env, | |||
| 3279 | 3322 | ||
| 3280 | 3323 | KeyObjectHandle* key = Unwrap<KeyObjectHandle>(obj); | |
| 3281 | 3324 | CHECK_NOT_NULL(key); | |
| 3282 | - if (key_type == kKeyTypePublic) | ||
| 3283 | - key->InitPublic(pkey); | ||
| 3284 | - else | ||
| 3285 | - key->InitPrivate(pkey); | ||
| 3325 | + key->data_.reset(KeyObjectData::CreateAsymmetric(key_type, pkey)); | ||
| 3286 | 3326 | return obj; | |
| 3287 | 3327 | } | |
| 3288 | 3328 | ||
| 3289 | - ManagedEVPPKey KeyObjectHandle::GetAsymmetricKey() const { | ||
| 3290 | - CHECK_NE(key_type_, kKeyTypeSecret); | ||
| 3291 | - return this->asymmetric_key_; | ||
| 3292 | - } | ||
| 3293 | - | ||
| 3294 | - const char* KeyObjectHandle::GetSymmetricKey() const { | ||
| 3295 | - CHECK_EQ(key_type_, kKeyTypeSecret); | ||
| 3296 | - return this->symmetric_key_.get(); | ||
| 3297 | - } | ||
| 3298 | - | ||
| 3299 | - size_t KeyObjectHandle::GetSymmetricKeySize() const { | ||
| 3300 | - CHECK_EQ(key_type_, kKeyTypeSecret); | ||
| 3301 | - return this->symmetric_key_len_; | ||
| 3329 | + const KeyObjectData* KeyObjectHandle::Data() { | ||
| 3330 | + return data_.get(); | ||
| 3302 | 3331 | } | |
| 3303 | 3332 | ||
| 3304 | 3333 | void KeyObjectHandle::New(const FunctionCallbackInfo<Value>& args) { | |
| 3305 | 3334 | CHECK(args.IsConstructCall()); | |
| 3306 | - CHECK(args[0]->IsInt32()); | ||
| 3307 | - KeyType key_type = static_cast<KeyType>(args[0].As<Uint32>()->Value()); | ||
| 3308 | 3335 | Environment* env = Environment::GetCurrent(args); | |
| 3309 | - new KeyObjectHandle(env, args.This(), key_type); | ||
| 3310 | - } | ||
| 3311 | - | ||
| 3312 | - KeyType KeyObjectHandle::GetKeyType() const { | ||
| 3313 | - return this->key_type_; | ||
| 3336 | + new KeyObjectHandle(env, args.This()); | ||
| 3314 | 3337 | } | |
| 3315 | 3338 | ||
| 3316 | 3339 | KeyObjectHandle::KeyObjectHandle(Environment* env, | |
| 3317 | - Local<Object> wrap, | ||
| 3318 | - KeyType key_type) | ||
| 3319 | - : BaseObject(env, wrap), | ||
| 3320 | - key_type_(key_type), | ||
| 3321 | - symmetric_key_(nullptr, nullptr) { | ||
| 3340 | + Local<Object> wrap) | ||
| 3341 | + : BaseObject(env, wrap) { | ||
| 3322 | 3342 | MakeWeak(); | |
| 3323 | 3343 | } | |
| 3324 | 3344 | ||
@@ -3327,66 +3347,45 @@ void KeyObjectHandle::Init(const FunctionCallbackInfo<Value>& args) { | |||
| 3327 | 3347 | ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); | |
| 3328 | 3348 | MarkPopErrorOnReturn mark_pop_error_on_return; | |
| 3329 | 3349 | ||
| 3350 | + CHECK(args[0]->IsInt32()); | ||
| 3351 | + KeyType type = static_cast<KeyType>(args[0].As<Uint32>()->Value()); | ||
| 3352 | + | ||
| 3330 | 3353 | unsigned int offset; | |
| 3331 | 3354 | ManagedEVPPKey pkey; | |
| 3332 | 3355 | ||
| 3333 | - switch (key->key_type_) { | ||
| 3356 | + switch (type) { | ||
| 3334 | 3357 | case kKeyTypeSecret: | |
| 3335 | - CHECK_EQ(args.Length(), 1); | ||
| 3336 | - CHECK(args[0]->IsArrayBufferView()); | ||
| 3337 | - key->InitSecret(args[0].As<ArrayBufferView>()); | ||
| 3358 | + CHECK_EQ(args.Length(), 2); | ||
| 3359 | + CHECK(args[1]->IsArrayBufferView()); | ||
| 3360 | + key->data_.reset( | ||
| 3361 | + KeyObjectData::CreateSecret(args[1].As<ArrayBufferView>())); | ||
| 3338 | 3362 | break; | |
| 3339 | 3363 | case kKeyTypePublic: | |
| 3340 | - CHECK_EQ(args.Length(), 3); | ||
| 3364 | + CHECK_EQ(args.Length(), 4); | ||
| 3341 | 3365 | ||
| 3342 | - offset = 0; | ||
| 3366 | + offset = 1; | ||
| 3343 | 3367 | pkey = GetPublicOrPrivateKeyFromJs(args, &offset); | |
| 3344 | 3368 | if (!pkey) | |
| 3345 | 3369 | return; | |
| 3346 | - key->InitPublic(pkey); | ||
| 3370 | + key->data_.reset(KeyObjectData::CreateAsymmetric(type, pkey)); | ||
| 3347 | 3371 | break; | |
| 3348 | 3372 | case kKeyTypePrivate: | |
| 3349 | - CHECK_EQ(args.Length(), 4); | ||
| 3373 | + CHECK_EQ(args.Length(), 5); | ||
| 3350 | 3374 | ||
| 3351 | - offset = 0; | ||
| 3375 | + offset = 1; | ||
| 3352 | 3376 | pkey = GetPrivateKeyFromJs(args, &offset, false); | |
| 3353 | 3377 | if (!pkey) | |
| 3354 | 3378 | return; | |
| 3355 | - key->InitPrivate(pkey); | ||
| 3379 | + key->data_.reset(KeyObjectData::CreateAsymmetric(type, pkey)); | ||
| 3356 | 3380 | break; | |
| 3357 | 3381 | default: | |
| 3358 | 3382 | CHECK(false); | |
| 3359 | 3383 | } | |
| 3360 | 3384 | } | |
| 3361 | 3385 | ||
| 3362 | - void KeyObjectHandle::InitSecret(Local<ArrayBufferView> abv) { | ||
| 3363 | - CHECK_EQ(this->key_type_, kKeyTypeSecret); | ||
| 3364 | - | ||
| 3365 | - size_t key_len = abv->ByteLength(); | ||
| 3366 | - char* mem = MallocOpenSSL<char>(key_len); | ||
| 3367 | - abv->CopyContents(mem, key_len); | ||
| 3368 | - this->symmetric_key_ = std::unique_ptr<char, std::function<void(char*)>>(mem, | ||
| 3369 | - [key_len](char* p) { | ||
| 3370 | - OPENSSL_clear_free(p, key_len); | ||
| 3371 | - }); | ||
| 3372 | - this->symmetric_key_len_ = key_len; | ||
| 3373 | - } | ||
| 3374 | - | ||
| 3375 | - void KeyObjectHandle::InitPublic(const ManagedEVPPKey& pkey) { | ||
| 3376 | - CHECK_EQ(this->key_type_, kKeyTypePublic); | ||
| 3377 | - CHECK(pkey); | ||
| 3378 | - this->asymmetric_key_ = pkey; | ||
| 3379 | - } | ||
| 3380 | - | ||
| 3381 | - void KeyObjectHandle::InitPrivate(const ManagedEVPPKey& pkey) { | ||
| 3382 | - CHECK_EQ(this->key_type_, kKeyTypePrivate); | ||
| 3383 | - CHECK(pkey); | ||
| 3384 | - this->asymmetric_key_ = pkey; | ||
| 3385 | - } | ||
| 3386 | - | ||
| 3387 | 3386 | Local<Value> KeyObjectHandle::GetAsymmetricKeyType() const { | |
| 3388 | - CHECK_NE(this->key_type_, kKeyTypeSecret); | ||
| 3389 | - switch (EVP_PKEY_id(this->asymmetric_key_.get())) { | ||
| 3387 | + const ManagedEVPPKey& key = data_->GetAsymmetricKey(); | ||
| 3388 | + switch (EVP_PKEY_id(key.get())) { | ||
| 3390 | 3389 | case EVP_PKEY_RSA: | |
| 3391 | 3390 | return env()->crypto_rsa_string(); | |
| 3392 | 3391 | case EVP_PKEY_RSA_PSS: | |
@@ -3422,24 +3421,27 @@ void KeyObjectHandle::GetSymmetricKeySize( | |||
| 3422 | 3421 | const FunctionCallbackInfo<Value>& args) { | |
| 3423 | 3422 | KeyObjectHandle* key; | |
| 3424 | 3423 | ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); | |
| 3425 | - args.GetReturnValue().Set(static_cast<uint32_t>(key->GetSymmetricKeySize())); | ||
| 3424 | + args.GetReturnValue().Set( | ||
| 3425 | + static_cast<uint32_t>(key->Data()->GetSymmetricKeySize())); | ||
| 3426 | 3426 | } | |
| 3427 | 3427 | ||
| 3428 | 3428 | void KeyObjectHandle::Export(const FunctionCallbackInfo<Value>& args) { | |
| 3429 | 3429 | KeyObjectHandle* key; | |
| 3430 | 3430 | ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder()); | |
| 3431 | 3431 | ||
| 3432 | + KeyType type = key->Data()->GetKeyType(); | ||
| 3433 | + | ||
| 3432 | 3434 | MaybeLocal<Value> result; | |
| 3433 | - if (key->key_type_ == kKeyTypeSecret) { | ||
| 3435 | + if (type == kKeyTypeSecret) { | ||
| 3434 | 3436 | result = key->ExportSecretKey(); | |
| 3435 | - } else if (key->key_type_ == kKeyTypePublic) { | ||
| 3437 | + } else if (type == kKeyTypePublic) { | ||
| 3436 | 3438 | unsigned int offset = 0; | |
| 3437 | 3439 | PublicKeyEncodingConfig config = | |
| 3438 | 3440 | GetPublicKeyEncodingFromJs(args, &offset, kKeyContextExport); | |
| 3439 | 3441 | CHECK_EQ(offset, static_cast<unsigned int>(args.Length())); | |
| 3440 | 3442 | result = key->ExportPublicKey(config); | |
| 3441 | 3443 | } else { | |
| 3442 | - CHECK_EQ(key->key_type_, kKeyTypePrivate); | ||
| 3444 | + CHECK_EQ(type, kKeyTypePrivate); | ||
| 3443 | 3445 | unsigned int offset = 0; | |
| 3444 | 3446 | NonCopyableMaybe<PrivateKeyEncodingConfig> config = | |
| 3445 | 3447 | GetPrivateKeyEncodingFromJs(args, &offset, kKeyContextExport); | |
@@ -3454,18 +3456,19 @@ void KeyObjectHandle::Export(const FunctionCallbackInfo<Value>& args) { | |||
| 3454 | 3456 | } | |
| 3455 | 3457 | ||
| 3456 | 3458 | Local<Value> KeyObjectHandle::ExportSecretKey() const { | |
| 3457 | - return Buffer::Copy(env(), symmetric_key_.get(), symmetric_key_len_) | ||
| 3458 | - .ToLocalChecked(); | ||
| 3459 | + const char* buf = data_->GetSymmetricKey(); | ||
| 3460 | + unsigned int len = data_->GetSymmetricKeySize(); | ||
| 3461 | + return Buffer::Copy(env(), buf, len).ToLocalChecked(); | ||
| 3459 | 3462 | } | |
| 3460 | 3463 | ||
| 3461 | 3464 | MaybeLocal<Value> KeyObjectHandle::ExportPublicKey( | |
| 3462 | 3465 | const PublicKeyEncodingConfig& config) const { | |
| 3463 | - return WritePublicKey(env(), asymmetric_key_.get(), config); | ||
| 3466 | + return WritePublicKey(env(), data_->GetAsymmetricKey().get(), config); | ||
| 3464 | 3467 | } | |
| 3465 | 3468 | ||
| 3466 | 3469 | MaybeLocal<Value> KeyObjectHandle::ExportPrivateKey( | |
| 3467 | 3470 | const PrivateKeyEncodingConfig& config) const { | |
| 3468 | - return WritePrivateKey(env(), asymmetric_key_.get(), config); | ||
| 3471 | + return WritePrivateKey(env(), data_->GetAsymmetricKey().get(), config); | ||
| 3469 | 3472 | } | |
| 3470 | 3473 | ||
| 3471 | 3474 | void NativeKeyObject::New(const FunctionCallbackInfo<Value>& args) { | |
@@ -6762,13 +6765,13 @@ void StatelessDiffieHellman(const FunctionCallbackInfo<Value>& args) { | |||
| 6762 | 6765 | CHECK(args[0]->IsObject() && args[1]->IsObject()); | |
| 6763 | 6766 | KeyObjectHandle* our_key_object; | |
| 6764 | 6767 | ASSIGN_OR_RETURN_UNWRAP(&our_key_object, args[0].As<Object>()); | |
| 6765 | - CHECK_EQ(our_key_object->GetKeyType(), kKeyTypePrivate); | ||
| 6768 | + CHECK_EQ(our_key_object->Data()->GetKeyType(), kKeyTypePrivate); | ||
| 6766 | 6769 | KeyObjectHandle* their_key_object; | |
| 6767 | 6770 | ASSIGN_OR_RETURN_UNWRAP(&their_key_object, args[1].As<Object>()); | |
| 6768 | - CHECK_NE(their_key_object->GetKeyType(), kKeyTypeSecret); | ||
| 6771 | + CHECK_NE(their_key_object->Data()->GetKeyType(), kKeyTypeSecret); | ||
| 6769 | 6772 | ||
| 6770 | - ManagedEVPPKey our_key = our_key_object->GetAsymmetricKey(); | ||
| 6771 | - ManagedEVPPKey their_key = their_key_object->GetAsymmetricKey(); | ||
| 6773 | + ManagedEVPPKey our_key = our_key_object->Data()->GetAsymmetricKey(); | ||
| 6774 | + ManagedEVPPKey their_key = their_key_object->Data()->GetAsymmetricKey(); | ||
| 6772 | 6775 | ||
| 6773 | 6776 | AllocatedBuffer out = StatelessDiffieHellman(env, our_key, their_key); | |
| 6774 | 6777 | if (out.size() == 0) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -408,6 +408,27 @@ class ManagedEVPPKey { | |||
| 408 | 408 | EVPKeyPointer pkey_; | |
| 409 | 409 | }; | |
| 410 | 410 | ||
| 411 | + class KeyObjectData { | ||
| 412 | + public: | ||
| 413 | + static KeyObjectData* CreateSecret(v8::Local<v8::ArrayBufferView> abv); | ||
| 414 | + static KeyObjectData* CreateAsymmetric(KeyType type, | ||
| 415 | + const ManagedEVPPKey& pkey); | ||
| 416 | + | ||
| 417 | + KeyType GetKeyType() const; | ||
| 418 | + | ||
| 419 | + // These functions allow unprotected access to the raw key material and should | ||
| 420 | + // only be used to implement cryptograohic operations requiring the key. | ||
| 421 | + ManagedEVPPKey GetAsymmetricKey() const; | ||
| 422 | + const char* GetSymmetricKey() const; | ||
| 423 | + size_t GetSymmetricKeySize() const; | ||
| 424 | + | ||
| 425 | + private: | ||
| 426 | + KeyType key_type_; | ||
| 427 | + std::unique_ptr<char, std::function<void(char*)>> symmetric_key_; | ||
| 428 | + unsigned int symmetric_key_len_; | ||
| 429 | + ManagedEVPPKey asymmetric_key_; | ||
| 430 | + }; | ||
| 431 | + | ||
| 411 | 432 | class KeyObjectHandle : public BaseObject { | |
| 412 | 433 | public: | |
| 413 | 434 | static v8::Local<v8::Function> Initialize(Environment* env, | |
@@ -422,21 +443,12 @@ class KeyObjectHandle : public BaseObject { | |||
| 422 | 443 | SET_MEMORY_INFO_NAME(KeyObjectHandle) | |
| 423 | 444 | SET_SELF_SIZE(KeyObjectHandle) | |
| 424 | 445 | ||
| 425 | - KeyType GetKeyType() const; | ||
| 426 | - | ||
| 427 | - // These functions allow unprotected access to the raw key material and should | ||
| 428 | - // only be used to implement cryptograohic operations requiring the key. | ||
| 429 | - ManagedEVPPKey GetAsymmetricKey() const; | ||
| 430 | - const char* GetSymmetricKey() const; | ||
| 431 | - size_t GetSymmetricKeySize() const; | ||
| 446 | + const KeyObjectData* Data(); | ||
| 432 | 447 | ||
| 433 | 448 | protected: | |
| 434 | 449 | static void New(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 435 | 450 | ||
| 436 | 451 | static void Init(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 437 | - void InitSecret(v8::Local<v8::ArrayBufferView> abv); | ||
| 438 | - void InitPublic(const ManagedEVPPKey& pkey); | ||
| 439 | - void InitPrivate(const ManagedEVPPKey& pkey); | ||
| 440 | 452 | ||
| 441 | 453 | static void GetAsymmetricKeyType( | |
| 442 | 454 | const v8::FunctionCallbackInfo<v8::Value>& args); | |
@@ -453,14 +465,10 @@ class KeyObjectHandle : public BaseObject { | |||
| 453 | 465 | const PrivateKeyEncodingConfig& config) const; | |
| 454 | 466 | ||
| 455 | 467 | KeyObjectHandle(Environment* env, | |
| 456 | - v8::Local<v8::Object> wrap, | ||
| 457 | - KeyType key_type); | ||
| 468 | + v8::Local<v8::Object> wrap); | ||
| 458 | 469 | ||
| 459 | 470 | private: | |
| 460 | - const KeyType key_type_; | ||
| 461 | - std::unique_ptr<char, std::function<void(char*)>> symmetric_key_; | ||
| 462 | - unsigned int symmetric_key_len_; | ||
| 463 | - ManagedEVPPKey asymmetric_key_; | ||
| 471 | + std::unique_ptr<KeyObjectData> data_; | ||
| 464 | 472 | }; | |
| 465 | 473 | ||
| 466 | 474 | class NativeKeyObject : public BaseObject { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments