| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | |
| 23 | #if ENABLE(WEB_CRYPTO) |
| 24 | |
| 25 | #include "JSRsaHashedKeyGenParams.h" |
| 26 | |
| 27 | #include "JSDOMConvertBufferSource.h" |
| 28 | #include "JSDOMConvertNumbers.h" |
| 29 | #include "JSDOMConvertObject.h" |
| 30 | #include "JSDOMConvertStrings.h" |
| 31 | #include "JSDOMConvertUnion.h" |
| 32 | #include <JavaScriptCore/JSCInlines.h> |
| 33 | #include <wtf/Variant.h> |
| 34 | |
| 35 | |
| 36 | namespace WebCore { |
| 37 | using namespace JSC; |
| 38 | |
| 39 | #if ENABLE(WEB_CRYPTO) |
| 40 | |
| 41 | template<> CryptoAlgorithmRsaHashedKeyGenParams convertDictionary<CryptoAlgorithmRsaHashedKeyGenParams>(ExecState& state, JSValue value) |
| 42 | { |
| 43 | VM& vm = state.vm(); |
| 44 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 45 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 46 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 47 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 48 | throwTypeError(&state, throwScope); |
| 49 | return { }; |
| 50 | } |
| 51 | CryptoAlgorithmRsaHashedKeyGenParams result; |
| 52 | JSValue nameValue; |
| 53 | if (isNullOrUndefined) |
| 54 | nameValue = jsUndefined(); |
| 55 | else { |
| 56 | nameValue = object->get(&state, Identifier::fromString(&state, "name" )); |
| 57 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 58 | } |
| 59 | if (!nameValue.isUndefined()) { |
| 60 | result.name = convert<IDLDOMString>(state, nameValue); |
| 61 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 62 | } else { |
| 63 | throwRequiredMemberTypeError(state, throwScope, "name" , "RsaHashedKeyGenParams" , "DOMString" ); |
| 64 | return { }; |
| 65 | } |
| 66 | JSValue modulusLengthValue; |
| 67 | if (isNullOrUndefined) |
| 68 | modulusLengthValue = jsUndefined(); |
| 69 | else { |
| 70 | modulusLengthValue = object->get(&state, Identifier::fromString(&state, "modulusLength" )); |
| 71 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 72 | } |
| 73 | if (!modulusLengthValue.isUndefined()) { |
| 74 | result.modulusLength = convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(state, modulusLengthValue); |
| 75 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 76 | } else { |
| 77 | throwRequiredMemberTypeError(state, throwScope, "modulusLength" , "RsaHashedKeyGenParams" , "unsigned long" ); |
| 78 | return { }; |
| 79 | } |
| 80 | JSValue publicExponentValue; |
| 81 | if (isNullOrUndefined) |
| 82 | publicExponentValue = jsUndefined(); |
| 83 | else { |
| 84 | publicExponentValue = object->get(&state, Identifier::fromString(&state, "publicExponent" )); |
| 85 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 86 | } |
| 87 | if (!publicExponentValue.isUndefined()) { |
| 88 | result.publicExponent = convert<IDLUint8Array>(state, publicExponentValue); |
| 89 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 90 | } else { |
| 91 | throwRequiredMemberTypeError(state, throwScope, "publicExponent" , "RsaHashedKeyGenParams" , "Uint8Array" ); |
| 92 | return { }; |
| 93 | } |
| 94 | JSValue hashValue; |
| 95 | if (isNullOrUndefined) |
| 96 | hashValue = jsUndefined(); |
| 97 | else { |
| 98 | hashValue = object->get(&state, Identifier::fromString(&state, "hash" )); |
| 99 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 100 | } |
| 101 | if (!hashValue.isUndefined()) { |
| 102 | result.hash = convert<IDLUnion<IDLObject, IDLDOMString>>(state, hashValue); |
| 103 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 104 | } else { |
| 105 | throwRequiredMemberTypeError(state, throwScope, "hash" , "RsaHashedKeyGenParams" , "(object or DOMString)" ); |
| 106 | return { }; |
| 107 | } |
| 108 | return result; |
| 109 | } |
| 110 | |
| 111 | #endif |
| 112 | |
| 113 | } // namespace WebCore |
| 114 | |
| 115 | #endif // ENABLE(WEB_CRYPTO) |
| 116 | |