Lines Matching defs:key

48   // During key pair generation, it is possible not to specify a key encoding,
49 // which will lead to a key object being returned.
141 const char* key,
144 return ParsePublicKeyPEM(pkey, key, key_len);
148 const unsigned char* p = reinterpret_cast<const unsigned char*>(key);
216 const char* key,
221 BIOPointer bio(BIO_new_mem_buf(key, key_len));
233 const unsigned char* p = reinterpret_cast<const unsigned char*>(key);
236 BIOPointer bio(BIO_new_mem_buf(key, key_len));
241 reinterpret_cast<const unsigned char*>(key), key_len)) {
253 const unsigned char* p = reinterpret_cast<const unsigned char*>(key);
258 // OpenSSL can fail to parse the key but still return a non-null pointer.
388 ThrowCryptoError(env, ERR_get_error(), "Failed to encode private key");
429 ThrowCryptoError(env, ERR_get_error(), "Failed to encode public key");
437 std::shared_ptr<KeyObjectData> key,
439 CHECK_EQ(key->GetKeyType(), kKeyTypeSecret);
446 key->GetSymmetricKey(),
447 key->GetSymmetricKeySize(),
475 Local<Value> key;
476 if (!jwk->Get(env->context(), env->jwk_k_string()).ToLocal(&key) ||
477 !key->IsString()) {
478 THROW_ERR_CRYPTO_INVALID_JWK(env, "Invalid JWK secret key format");
483 ByteSource key_data = ByteSource::FromEncodedString(env, key.As<String>());
489 std::shared_ptr<KeyObjectData> key,
492 switch (EVP_PKEY_id(key->GetAsymmetricKey().get())) {
494 if (handleRsaPss) return ExportJWKRsaKey(env, key, target);
497 case EVP_PKEY_RSA: return ExportJWKRsaKey(env, key, target);
498 case EVP_PKEY_EC: return ExportJWKEcKey(env, key, target).IsJust() ?
506 case EVP_PKEY_X448: return ExportJWKEdKey(env, key, target);
524 THROW_ERR_CRYPTO_INVALID_JWK(env, "%s is not a supported JWK key type", kty);
530 std::shared_ptr<KeyObjectData> key,
532 // For the secret key detail, all we care about is the length,
535 size_t length = key->GetSymmetricKeySize() * CHAR_BIT;
543 std::shared_ptr<KeyObjectData> key,
545 switch (EVP_PKEY_id(key->GetAsymmetricKey().get())) {
548 case EVP_PKEY_RSA_PSS: return GetRsaKeyDetail(env, key, target);
549 case EVP_PKEY_DSA: return GetDsaKeyDetail(env, key, target);
550 case EVP_PKEY_EC: return GetEcKeyDetail(env, key, target);
551 case EVP_PKEY_DH: return GetDhKeyDetail(env, key, target);
615 std::shared_ptr<KeyObjectData> key,
618 switch (key->GetKeyType()) {
620 return ExportJWKSecretKey(env, key, result.As<Object>());
625 env, key, result.As<Object>(), handleRsaPss);
638 // private key.
735 ByteSource key = ByteSource::FromStringOrBuffer(env, args[(*offset)++]);
743 ParsePrivateKey(&pkey, config.Release(), key.data<char>(), key.size());
745 "Failed to read private key");
748 KeyObjectHandle* key;
749 ASSIGN_OR_RETURN_UNWRAP(&key, args[*offset].As<Object>(), ManagedEVPPKey());
750 CHECK_EQ(key->Data()->GetKeyType(), kKeyTypePrivate);
752 return key->Data()->GetAsymmetricKey();
775 // For PEM, we can easily determine whether it is a public or private key
783 // easy, but PKCS#1 can be a public key or a private key.
798 UNREACHABLE("Invalid key encoding type");
809 env, std::move(pkey), ret, "Failed to read asymmetric key");
812 KeyObjectHandle* key = Unwrap<KeyObjectHandle>(args[*offset].As<Object>());
813 CHECK_NOT_NULL(key);
814 CHECK_NE(key->Data()->GetKeyType(), kKeyTypeSecret);
816 return key->Data()->GetAsymmetricKey();
830 "Passphrase required for encrypted key");
855 tracker->TrackFieldWithSize("key", asymmetric_key_);
862 std::shared_ptr<KeyObjectData> KeyObjectData::CreateSecret(ByteSource key) {
863 return std::shared_ptr<KeyObjectData>(new KeyObjectData(std::move(key)));
951 KeyObjectHandle* key = Unwrap<KeyObjectHandle>(obj);
952 CHECK_NOT_NULL(key);
953 key->data_ = data;
974 KeyObjectHandle* key;
975 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
988 key->data_ = KeyObjectData::CreateSecret(buf.ToCopy());
998 key->data_ = KeyObjectData::CreateAsymmetric(type, pkey);
1008 key->data_ = KeyObjectData::CreateAsymmetric(type, pkey);
1018 KeyObjectHandle* key;
1019 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
1026 // Step one, Secret key or not?
1038 // Secret key
1039 key->data_ = ImportJWKSecretKey(env, input);
1040 if (!key->data_) {
1045 key->data_ = ImportJWKAsymmetricKey(env, input, *kty_string, args, 1);
1046 if (!key->data_) {
1052 args.GetReturnValue().Set(key->data_->GetKeyType());
1057 KeyObjectHandle* key;
1058 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
1083 eckey.release(); // Release ownership of the key
1085 key->data_ =
1095 KeyObjectHandle* key;
1096 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
1121 key->data_ =
1125 CHECK(key->data_);
1140 std::shared_ptr<KeyObjectData> key = self_handle->Data();
1143 KeyType key_type = key->GetKeyType();
1149 size_t size = key->GetSymmetricKeySize();
1152 key->GetSymmetricKey(),
1162 EVP_PKEY* pkey = key->GetAsymmetricKey().get();
1177 UNREACHABLE("unsupported key type");
1185 KeyObjectHandle* key;
1186 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
1190 std::shared_ptr<KeyObjectData> data = key->Data();
1211 const ManagedEVPPKey& key = data_->GetAsymmetricKey();
1212 switch (EVP_PKEY_id(key.get())) {
1238 KeyObjectHandle* key;
1239 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
1241 args.GetReturnValue().Set(key->GetAsymmetricKeyType());
1247 const ManagedEVPPKey& key = data_->GetAsymmetricKey();
1250 EVPKeyCtxPointer ctx(EVP_PKEY_CTX_new(key.get(), nullptr));
1252 CHECK_EQ(EVP_PKEY_id(key.get()), EVP_PKEY_EC);
1266 KeyObjectHandle* key;
1267 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
1269 args.GetReturnValue().Set(key->CheckEcKeyData());
1274 KeyObjectHandle* key;
1275 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
1277 static_cast<uint32_t>(key->Data()->GetSymmetricKeySize()));
1281 KeyObjectHandle* key;
1282 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
1284 KeyType type = key->Data()->GetKeyType();
1288 result = key->ExportSecretKey();
1295 result = key->ExportPublicKey(config);
1305 result = key->ExportPrivateKey(config.Release());
1331 KeyObjectHandle* key;
1332 ASSIGN_OR_RETURN_UNWRAP(&key, args.Holder());
1337 ExportJWKInner(env, key->Data(), args[0], args[1]->IsTrue());
1433 Local<Value> key;
1434 if (!key_ctor->NewInstance(context, 1, &handle).ToLocal(&key))
1437 return BaseObjectPtr<BaseObject>(Unwrap<KeyObjectHandle>(key.As<Object>()));