OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "V8SubtleCrypto.h" | 6 #include "V8SubtleCrypto.h" |
7 | 7 |
8 #include "V8Key.h" | 8 #include "V8Key.h" |
9 #include "bindings/v8/Dictionary.h" | 9 #include "bindings/v8/Dictionary.h" |
10 #include "bindings/v8/custom/V8ArrayBufferCustom.h" | 10 #include "bindings/v8/custom/V8ArrayBufferCustom.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 TONATIVE_VOID(Key*, key, V8Key::toNativeWithTypeCheck(info.GetIsolate(), inf
o[1])); | 74 TONATIVE_VOID(Key*, key, V8Key::toNativeWithTypeCheck(info.GetIsolate(), inf
o[1])); |
75 TONATIVE_VOID(ArrayBufferView*, signature, info[2]->IsArrayBufferView() ? V8
ArrayBufferView::toNative(v8::Handle<v8::ArrayBufferView>::Cast(info[2])) : 0); | 75 TONATIVE_VOID(ArrayBufferView*, signature, info[2]->IsArrayBufferView() ? V8
ArrayBufferView::toNative(v8::Handle<v8::ArrayBufferView>::Cast(info[2])) : 0); |
76 TONATIVE_VOID(ArrayBufferView*, data, info[3]->IsArrayBufferView() ? V8Array
BufferView::toNative(v8::Handle<v8::ArrayBufferView>::Cast(info[3])) : 0); | 76 TONATIVE_VOID(ArrayBufferView*, data, info[3]->IsArrayBufferView() ? V8Array
BufferView::toNative(v8::Handle<v8::ArrayBufferView>::Cast(info[3])) : 0); |
77 v8SetReturnValue(info, impl->verifySignature(algorithm, key, signature, data
).v8Value()); | 77 v8SetReturnValue(info, impl->verifySignature(algorithm, key, signature, data
).v8Value()); |
78 } | 78 } |
79 | 79 |
80 void V8SubtleCrypto::verifyMethodCustom(const v8::FunctionCallbackInfo<v8::Value
>& info) | 80 void V8SubtleCrypto::verifyMethodCustom(const v8::FunctionCallbackInfo<v8::Value
>& info) |
81 { | 81 { |
82 v8::Isolate* isolate = info.GetIsolate(); | 82 v8::Isolate* isolate = info.GetIsolate(); |
| 83 ExceptionState exceptionState(ExceptionState::ExecutionContext, "verify", "S
ubtleCrypto", info.Holder(), isolate); |
83 // typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData; | 84 // typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData; |
84 // | 85 // |
85 // Promise verify(Dictionary algorithm, Key key, | 86 // Promise verify(Dictionary algorithm, Key key, |
86 // CryptoOperationData signature, | 87 // CryptoOperationData signature, |
87 // CryptoOperationData data); | 88 // CryptoOperationData data); |
88 switch (info.Length()) { | 89 switch (info.Length()) { |
89 case 4: | 90 case 4: |
90 // Promise verify(Dictionary algorithm, Key key, ArrayBuffer signature,
ArrayBuffer data); | 91 // Promise verify(Dictionary algorithm, Key key, ArrayBuffer signature,
ArrayBuffer data); |
91 if (V8ArrayBuffer::hasInstance(info[2], isolate) | 92 if (V8ArrayBuffer::hasInstance(info[2], isolate) |
92 && V8ArrayBuffer::hasInstance(info[3], isolate)) { | 93 && V8ArrayBuffer::hasInstance(info[3], isolate)) { |
(...skipping 12 matching lines...) Expand all Loading... |
105 verify3Method(info); | 106 verify3Method(info); |
106 return; | 107 return; |
107 } | 108 } |
108 // Promise verify(Dictionary algorithm, Key key, ArrayBufferView signatu
re, ArrayBufferView data); | 109 // Promise verify(Dictionary algorithm, Key key, ArrayBufferView signatu
re, ArrayBufferView data); |
109 if (V8ArrayBufferView::hasInstance(info[2], isolate) | 110 if (V8ArrayBufferView::hasInstance(info[2], isolate) |
110 && V8ArrayBufferView::hasInstance(info[3], isolate)) { | 111 && V8ArrayBufferView::hasInstance(info[3], isolate)) { |
111 verify4Method(info); | 112 verify4Method(info); |
112 return; | 113 return; |
113 } | 114 } |
114 break; | 115 break; |
115 } | 116 default: |
116 ExceptionState exceptionState(ExceptionState::ExecutionContext, "verify", "S
ubtleCrypto", info.Holder(), isolate); | 117 throwArityTypeError(exceptionState, "[4]", info.Length()); |
117 if (UNLIKELY(info.Length() < 4)) { | |
118 throwArityTypeError(exceptionState, 4, info.Length()); | |
119 return; | 118 return; |
| 119 break; |
120 } | 120 } |
121 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); | 121 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
122 exceptionState.throwIfNeeded(); | 122 exceptionState.throwIfNeeded(); |
123 } | 123 } |
124 | 124 |
125 } // namespace WebCore | 125 } // namespace WebCore |
OLD | NEW |