Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: Source/modules/crypto/SubtleCrypto.cpp

Issue 606653006: bindings: Adds DOMArrayBuffer, etc. as thin wrappers for ArrayBuffer, etc. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/crypto/SubtleCrypto.h ('k') | Source/modules/encoding/TextDecoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 String json = jsonObject->toJSONString(); 187 String json = jsonObject->toJSONString();
188 jsonUtf8 = json.utf8(); 188 jsonUtf8 = json.utf8();
189 return true; 189 return true;
190 } 190 }
191 191
192 SubtleCrypto::SubtleCrypto() 192 SubtleCrypto::SubtleCrypto()
193 { 193 {
194 } 194 }
195 195
196 ScriptPromise SubtleCrypto::encrypt(ScriptState* scriptState, const Dictionary& rawAlgorithm, CryptoKey* key, const ArrayPiece& data) 196 ScriptPromise SubtleCrypto::encrypt(ScriptState* scriptState, const Dictionary& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& data)
197 { 197 {
198 return startCryptoOperation(scriptState, rawAlgorithm, key, WebCryptoOperati onEncrypt, ArrayPiece(), data); 198 return startCryptoOperation(scriptState, rawAlgorithm, key, WebCryptoOperati onEncrypt, ArrayPiece(), data);
199 } 199 }
200 200
201 ScriptPromise SubtleCrypto::decrypt(ScriptState* scriptState, const Dictionary& rawAlgorithm, CryptoKey* key, const ArrayPiece& data) 201 ScriptPromise SubtleCrypto::decrypt(ScriptState* scriptState, const Dictionary& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& data)
202 { 202 {
203 return startCryptoOperation(scriptState, rawAlgorithm, key, WebCryptoOperati onDecrypt, ArrayPiece(), data); 203 return startCryptoOperation(scriptState, rawAlgorithm, key, WebCryptoOperati onDecrypt, ArrayPiece(), data);
204 } 204 }
205 205
206 ScriptPromise SubtleCrypto::sign(ScriptState* scriptState, const Dictionary& raw Algorithm, CryptoKey* key, const ArrayPiece& data) 206 ScriptPromise SubtleCrypto::sign(ScriptState* scriptState, const Dictionary& raw Algorithm, CryptoKey* key, const DOMArrayPiece& data)
207 { 207 {
208 return startCryptoOperation(scriptState, rawAlgorithm, key, WebCryptoOperati onSign, ArrayPiece(), data); 208 return startCryptoOperation(scriptState, rawAlgorithm, key, WebCryptoOperati onSign, ArrayPiece(), data);
209 } 209 }
210 210
211 ScriptPromise SubtleCrypto::verifySignature(ScriptState* scriptState, const Dict ionary& rawAlgorithm, CryptoKey* key, const ArrayPiece& signature, const ArrayPi ece& data) 211 ScriptPromise SubtleCrypto::verifySignature(ScriptState* scriptState, const Dict ionary& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& signature, const DOMA rrayPiece& data)
212 { 212 {
213 return startCryptoOperation(scriptState, rawAlgorithm, key, WebCryptoOperati onVerify, signature, data); 213 return startCryptoOperation(scriptState, rawAlgorithm, key, WebCryptoOperati onVerify, signature, data);
214 } 214 }
215 215
216 ScriptPromise SubtleCrypto::digest(ScriptState* scriptState, const Dictionary& r awAlgorithm, const ArrayPiece& data) 216 ScriptPromise SubtleCrypto::digest(ScriptState* scriptState, const Dictionary& r awAlgorithm, const DOMArrayPiece& data)
217 { 217 {
218 return startCryptoOperation(scriptState, rawAlgorithm, 0, WebCryptoOperation Digest, ArrayPiece(), data); 218 return startCryptoOperation(scriptState, rawAlgorithm, 0, WebCryptoOperation Digest, ArrayPiece(), data);
219 } 219 }
220 220
221 ScriptPromise SubtleCrypto::generateKey(ScriptState* scriptState, const Dictiona ry& rawAlgorithm, bool extractable, const Vector<String>& rawKeyUsages) 221 ScriptPromise SubtleCrypto::generateKey(ScriptState* scriptState, const Dictiona ry& rawAlgorithm, bool extractable, const Vector<String>& rawKeyUsages)
222 { 222 {
223 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); 223 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState);
224 ScriptPromise promise = result->promise(); 224 ScriptPromise promise = result->promise();
225 225
226 if (!canAccessWebCrypto(scriptState, result.get())) 226 if (!canAccessWebCrypto(scriptState, result.get()))
227 return promise; 227 return promise;
228 228
229 WebCryptoKeyUsageMask keyUsages; 229 WebCryptoKeyUsageMask keyUsages;
230 if (!CryptoKey::parseUsageMask(rawKeyUsages, keyUsages, result.get())) 230 if (!CryptoKey::parseUsageMask(rawKeyUsages, keyUsages, result.get()))
231 return promise; 231 return promise;
232 232
233 WebCryptoAlgorithm algorithm; 233 WebCryptoAlgorithm algorithm;
234 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationGenerateKey, algorithm, result.get())) 234 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationGenerateKey, algorithm, result.get()))
235 return promise; 235 return promise;
236 236
237 Platform::current()->crypto()->generateKey(algorithm, extractable, keyUsages , result->result()); 237 Platform::current()->crypto()->generateKey(algorithm, extractable, keyUsages , result->result());
238 return promise; 238 return promise;
239 } 239 }
240 240
241 ScriptPromise SubtleCrypto::importKey(ScriptState* scriptState, const String& ra wFormat, const ArrayPiece& keyData, const Dictionary& rawAlgorithm, bool extract able, const Vector<String>& rawKeyUsages) 241 ScriptPromise SubtleCrypto::importKey(ScriptState* scriptState, const String& ra wFormat, const DOMArrayPiece& keyData, const Dictionary& rawAlgorithm, bool extr actable, const Vector<String>& rawKeyUsages)
242 { 242 {
243 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); 243 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState);
244 ScriptPromise promise = result->promise(); 244 ScriptPromise promise = result->promise();
245 245
246 if (!canAccessWebCrypto(scriptState, result.get())) 246 if (!canAccessWebCrypto(scriptState, result.get()))
247 return promise; 247 return promise;
248 248
249 if (!ensureNotNull(keyData, "keyData", result.get())) 249 if (!ensureNotNull(keyData, "keyData", result.get()))
250 return promise; 250 return promise;
251 251
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 return promise; 354 return promise;
355 } 355 }
356 356
357 if (!wrappingKey->canBeUsedForAlgorithm(wrapAlgorithm, WebCryptoOperationWra pKey, result.get())) 357 if (!wrappingKey->canBeUsedForAlgorithm(wrapAlgorithm, WebCryptoOperationWra pKey, result.get()))
358 return promise; 358 return promise;
359 359
360 Platform::current()->crypto()->wrapKey(format, key->key(), wrappingKey->key( ), wrapAlgorithm, result->result()); 360 Platform::current()->crypto()->wrapKey(format, key->key(), wrappingKey->key( ), wrapAlgorithm, result->result());
361 return promise; 361 return promise;
362 } 362 }
363 363
364 ScriptPromise SubtleCrypto::unwrapKey(ScriptState* scriptState, const String& ra wFormat, const ArrayPiece& wrappedKey, CryptoKey* unwrappingKey, const Dictionar y& rawUnwrapAlgorithm, const Dictionary& rawUnwrappedKeyAlgorithm, bool extracta ble, const Vector<String>& rawKeyUsages) 364 ScriptPromise SubtleCrypto::unwrapKey(ScriptState* scriptState, const String& ra wFormat, const DOMArrayPiece& wrappedKey, CryptoKey* unwrappingKey, const Dictio nary& rawUnwrapAlgorithm, const Dictionary& rawUnwrappedKeyAlgorithm, bool extra ctable, const Vector<String>& rawKeyUsages)
365 { 365 {
366 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); 366 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState);
367 ScriptPromise promise = result->promise(); 367 ScriptPromise promise = result->promise();
368 368
369 if (!canAccessWebCrypto(scriptState, result.get())) 369 if (!canAccessWebCrypto(scriptState, result.get()))
370 return promise; 370 return promise;
371 371
372 if (!ensureNotNull(wrappedKey, "wrappedKey", result.get())) 372 if (!ensureNotNull(wrappedKey, "wrappedKey", result.get()))
373 return promise; 373 return promise;
374 if (!ensureNotNull(unwrappingKey, "unwrappingKey", result.get())) 374 if (!ensureNotNull(unwrappingKey, "unwrappingKey", result.get()))
(...skipping 16 matching lines...) Expand all
391 return promise; 391 return promise;
392 392
393 if (!unwrappingKey->canBeUsedForAlgorithm(unwrapAlgorithm, WebCryptoOperatio nUnwrapKey, result.get())) 393 if (!unwrappingKey->canBeUsedForAlgorithm(unwrapAlgorithm, WebCryptoOperatio nUnwrapKey, result.get()))
394 return promise; 394 return promise;
395 395
396 Platform::current()->crypto()->unwrapKey(format, wrappedKey.bytes(), wrapped Key.byteLength(), unwrappingKey->key(), unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages, result->result()); 396 Platform::current()->crypto()->unwrapKey(format, wrappedKey.bytes(), wrapped Key.byteLength(), unwrappingKey->key(), unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages, result->result());
397 return promise; 397 return promise;
398 } 398 }
399 399
400 } // namespace blink 400 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/crypto/SubtleCrypto.h ('k') | Source/modules/encoding/TextDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698