static RefPtr<CryptoAlgorithmParameters> createRsaKeyGenParams(ExecState& state, JSValue value) { if (!value.isObject()) { throwTypeError(&state); return nullptr; } JSDictionary jsDictionary(&state, value.getObject()); auto result = adoptRef(*new CryptoAlgorithmRsaKeyGenParams); JSValue modulusLengthValue = getProperty(&state, value.getObject(), "modulusLength"); if (state.hadException()) return nullptr; // FIXME: Why no EnforceRange? Filed as <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23779>. result->modulusLength = convert<uint32_t>(state, modulusLengthValue, NormalConversion); if (state.hadException()) return nullptr; JSValue publicExponentValue = getProperty(&state, value.getObject(), "publicExponent"); if (state.hadException()) return nullptr; RefPtr<Uint8Array> publicExponentArray = toUint8Array(publicExponentValue); if (!publicExponentArray) { throwTypeError(&state, "Expected a Uint8Array in publicExponent"); return nullptr; } result->publicExponent.append(publicExponentArray->data(), publicExponentArray->byteLength()); result->hasHash = getHashAlgorithm(jsDictionary, result->hash, HashRequirement::Optional); return WTFMove(result); }
static std::unique_ptr<CryptoAlgorithmParameters> createRsaKeyGenParams(ExecState* exec, JSValue value) { if (!value.isObject()) { throwTypeError(exec); return nullptr; } auto result = std::make_unique<CryptoAlgorithmRsaKeyGenParams>(); JSValue modulusLengthValue = getProperty(exec, value.getObject(), "modulusLength"); if (exec->hadException()) return nullptr; // FIXME: Why no EnforceRange? Filed as <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23779>. result->modulusLength = toUInt32(exec, modulusLengthValue, NormalConversion); if (exec->hadException()) return nullptr; JSValue publicExponentValue = getProperty(exec, value.getObject(), "publicExponent"); if (exec->hadException()) return nullptr; RefPtr<Uint8Array> publicExponentArray = toUint8Array(publicExponentValue); if (!publicExponentArray) { throwTypeError(exec, "Expected a Uint8Array in publicExponent"); return nullptr; } result->publicExponent.append(publicExponentArray->data(), publicExponentArray->byteLength()); return WTF::move(result); }
void JSDictionary::convertValue(JSC::ExecState*, JSC::JSValue value, RefPtr<Uint8Array>& result) { result = toUint8Array(value); }