| OLD | NEW |
| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 jsonUtf8 = json.utf8(); | 162 jsonUtf8 = json.utf8(); |
| 163 return true; | 163 return true; |
| 164 } | 164 } |
| 165 | 165 |
| 166 SubtleCrypto::SubtleCrypto() | 166 SubtleCrypto::SubtleCrypto() |
| 167 { | 167 { |
| 168 } | 168 } |
| 169 | 169 |
| 170 ScriptPromise SubtleCrypto::encrypt(ScriptState* scriptState, const AlgorithmIde
ntifier& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& data) | 170 ScriptPromise SubtleCrypto::encrypt(ScriptState* scriptState, const AlgorithmIde
ntifier& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& data) |
| 171 { | 171 { |
| 172 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 172 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 173 ScriptPromise promise = result->promise(); | 173 ScriptPromise promise = result->promise(); |
| 174 | 174 |
| 175 if (!canAccessWebCrypto(scriptState, result.get())) | 175 if (!canAccessWebCrypto(scriptState, result.get())) |
| 176 return promise; | 176 return promise; |
| 177 | 177 |
| 178 if (!ensureNotNull(key, "key", result.get())) | 178 if (!ensureNotNull(key, "key", result.get())) |
| 179 return promise; | 179 return promise; |
| 180 if (!ensureNotNull(data, "dataBuffer", result.get())) | 180 if (!ensureNotNull(data, "dataBuffer", result.get())) |
| 181 return promise; | 181 return promise; |
| 182 | 182 |
| 183 WebCryptoAlgorithm algorithm; | 183 WebCryptoAlgorithm algorithm; |
| 184 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationEncrypt, algorithm, resu
lt.get())) | 184 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationEncrypt, algorithm, resu
lt.get())) |
| 185 return promise; | 185 return promise; |
| 186 | 186 |
| 187 if (!key->canBeUsedForAlgorithm(algorithm, WebCryptoKeyUsageEncrypt, result.
get())) | 187 if (!key->canBeUsedForAlgorithm(algorithm, WebCryptoKeyUsageEncrypt, result.
get())) |
| 188 return promise; | 188 return promise; |
| 189 | 189 |
| 190 Platform::current()->crypto()->encrypt(algorithm, key->key(), data.bytes(),
data.byteLength(), result->result()); | 190 Platform::current()->crypto()->encrypt(algorithm, key->key(), data.bytes(),
data.byteLength(), result->result()); |
| 191 return promise; | 191 return promise; |
| 192 } | 192 } |
| 193 | 193 |
| 194 ScriptPromise SubtleCrypto::decrypt(ScriptState* scriptState, const AlgorithmIde
ntifier& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& data) | 194 ScriptPromise SubtleCrypto::decrypt(ScriptState* scriptState, const AlgorithmIde
ntifier& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& data) |
| 195 { | 195 { |
| 196 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 196 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 197 ScriptPromise promise = result->promise(); | 197 ScriptPromise promise = result->promise(); |
| 198 | 198 |
| 199 if (!canAccessWebCrypto(scriptState, result.get())) | 199 if (!canAccessWebCrypto(scriptState, result.get())) |
| 200 return promise; | 200 return promise; |
| 201 | 201 |
| 202 if (!ensureNotNull(key, "key", result.get())) | 202 if (!ensureNotNull(key, "key", result.get())) |
| 203 return promise; | 203 return promise; |
| 204 if (!ensureNotNull(data, "dataBuffer", result.get())) | 204 if (!ensureNotNull(data, "dataBuffer", result.get())) |
| 205 return promise; | 205 return promise; |
| 206 | 206 |
| 207 WebCryptoAlgorithm algorithm; | 207 WebCryptoAlgorithm algorithm; |
| 208 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationDecrypt, algorithm, resu
lt.get())) | 208 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationDecrypt, algorithm, resu
lt.get())) |
| 209 return promise; | 209 return promise; |
| 210 | 210 |
| 211 if (!key->canBeUsedForAlgorithm(algorithm, WebCryptoKeyUsageDecrypt, result.
get())) | 211 if (!key->canBeUsedForAlgorithm(algorithm, WebCryptoKeyUsageDecrypt, result.
get())) |
| 212 return promise; | 212 return promise; |
| 213 | 213 |
| 214 Platform::current()->crypto()->decrypt(algorithm, key->key(), data.bytes(),
data.byteLength(), result->result()); | 214 Platform::current()->crypto()->decrypt(algorithm, key->key(), data.bytes(),
data.byteLength(), result->result()); |
| 215 return promise; | 215 return promise; |
| 216 } | 216 } |
| 217 | 217 |
| 218 ScriptPromise SubtleCrypto::sign(ScriptState* scriptState, const AlgorithmIdenti
fier& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& data) | 218 ScriptPromise SubtleCrypto::sign(ScriptState* scriptState, const AlgorithmIdenti
fier& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& data) |
| 219 { | 219 { |
| 220 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 220 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 221 ScriptPromise promise = result->promise(); | 221 ScriptPromise promise = result->promise(); |
| 222 | 222 |
| 223 if (!canAccessWebCrypto(scriptState, result.get())) | 223 if (!canAccessWebCrypto(scriptState, result.get())) |
| 224 return promise; | 224 return promise; |
| 225 | 225 |
| 226 if (!ensureNotNull(key, "key", result.get())) | 226 if (!ensureNotNull(key, "key", result.get())) |
| 227 return promise; | 227 return promise; |
| 228 if (!ensureNotNull(data, "dataBuffer", result.get())) | 228 if (!ensureNotNull(data, "dataBuffer", result.get())) |
| 229 return promise; | 229 return promise; |
| 230 | 230 |
| 231 WebCryptoAlgorithm algorithm; | 231 WebCryptoAlgorithm algorithm; |
| 232 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationSign, algorithm, result.
get())) | 232 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationSign, algorithm, result.
get())) |
| 233 return promise; | 233 return promise; |
| 234 | 234 |
| 235 if (!key->canBeUsedForAlgorithm(algorithm, WebCryptoKeyUsageSign, result.get
())) | 235 if (!key->canBeUsedForAlgorithm(algorithm, WebCryptoKeyUsageSign, result.get
())) |
| 236 return promise; | 236 return promise; |
| 237 | 237 |
| 238 Platform::current()->crypto()->sign(algorithm, key->key(), data.bytes(), dat
a.byteLength(), result->result()); | 238 Platform::current()->crypto()->sign(algorithm, key->key(), data.bytes(), dat
a.byteLength(), result->result()); |
| 239 return promise; | 239 return promise; |
| 240 } | 240 } |
| 241 | 241 |
| 242 ScriptPromise SubtleCrypto::verifySignature(ScriptState* scriptState, const Algo
rithmIdentifier& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& signature, c
onst DOMArrayPiece& data) | 242 ScriptPromise SubtleCrypto::verifySignature(ScriptState* scriptState, const Algo
rithmIdentifier& rawAlgorithm, CryptoKey* key, const DOMArrayPiece& signature, c
onst DOMArrayPiece& data) |
| 243 { | 243 { |
| 244 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 244 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 245 ScriptPromise promise = result->promise(); | 245 ScriptPromise promise = result->promise(); |
| 246 | 246 |
| 247 if (!canAccessWebCrypto(scriptState, result.get())) | 247 if (!canAccessWebCrypto(scriptState, result.get())) |
| 248 return promise; | 248 return promise; |
| 249 | 249 |
| 250 if (!ensureNotNull(key, "key", result.get())) | 250 if (!ensureNotNull(key, "key", result.get())) |
| 251 return promise; | 251 return promise; |
| 252 if (!ensureNotNull(data, "dataBuffer", result.get())) | 252 if (!ensureNotNull(data, "dataBuffer", result.get())) |
| 253 return promise; | 253 return promise; |
| 254 if (!ensureNotNull(signature, "signature", result.get())) | 254 if (!ensureNotNull(signature, "signature", result.get())) |
| 255 return promise; | 255 return promise; |
| 256 | 256 |
| 257 WebCryptoAlgorithm algorithm; | 257 WebCryptoAlgorithm algorithm; |
| 258 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationVerify, algorithm, resul
t.get())) | 258 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationVerify, algorithm, resul
t.get())) |
| 259 return promise; | 259 return promise; |
| 260 | 260 |
| 261 if (!key->canBeUsedForAlgorithm(algorithm, WebCryptoKeyUsageVerify, result.g
et())) | 261 if (!key->canBeUsedForAlgorithm(algorithm, WebCryptoKeyUsageVerify, result.g
et())) |
| 262 return promise; | 262 return promise; |
| 263 | 263 |
| 264 Platform::current()->crypto()->verifySignature(algorithm, key->key(), signat
ure.bytes(), signature.byteLength(), data.bytes(), data.byteLength(), result->re
sult()); | 264 Platform::current()->crypto()->verifySignature(algorithm, key->key(), signat
ure.bytes(), signature.byteLength(), data.bytes(), data.byteLength(), result->re
sult()); |
| 265 return promise; | 265 return promise; |
| 266 } | 266 } |
| 267 | 267 |
| 268 ScriptPromise SubtleCrypto::digest(ScriptState* scriptState, const AlgorithmIden
tifier& rawAlgorithm, const DOMArrayPiece& data) | 268 ScriptPromise SubtleCrypto::digest(ScriptState* scriptState, const AlgorithmIden
tifier& rawAlgorithm, const DOMArrayPiece& data) |
| 269 { | 269 { |
| 270 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 270 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 271 ScriptPromise promise = result->promise(); | 271 ScriptPromise promise = result->promise(); |
| 272 | 272 |
| 273 if (!canAccessWebCrypto(scriptState, result.get())) | 273 if (!canAccessWebCrypto(scriptState, result.get())) |
| 274 return promise; | 274 return promise; |
| 275 | 275 |
| 276 if (!ensureNotNull(data, "dataBuffer", result.get())) | 276 if (!ensureNotNull(data, "dataBuffer", result.get())) |
| 277 return promise; | 277 return promise; |
| 278 | 278 |
| 279 WebCryptoAlgorithm algorithm; | 279 WebCryptoAlgorithm algorithm; |
| 280 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationDigest, algorithm, resul
t.get())) | 280 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationDigest, algorithm, resul
t.get())) |
| 281 return promise; | 281 return promise; |
| 282 | 282 |
| 283 Platform::current()->crypto()->digest(algorithm, data.bytes(), data.byteLeng
th(), result->result()); | 283 Platform::current()->crypto()->digest(algorithm, data.bytes(), data.byteLeng
th(), result->result()); |
| 284 return promise; | 284 return promise; |
| 285 } | 285 } |
| 286 | 286 |
| 287 ScriptPromise SubtleCrypto::generateKey(ScriptState* scriptState, const Algorith
mIdentifier& rawAlgorithm, bool extractable, const Vector<String>& rawKeyUsages) | 287 ScriptPromise SubtleCrypto::generateKey(ScriptState* scriptState, const Algorith
mIdentifier& rawAlgorithm, bool extractable, const Vector<String>& rawKeyUsages) |
| 288 { | 288 { |
| 289 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 289 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 290 ScriptPromise promise = result->promise(); | 290 ScriptPromise promise = result->promise(); |
| 291 | 291 |
| 292 if (!canAccessWebCrypto(scriptState, result.get())) | 292 if (!canAccessWebCrypto(scriptState, result.get())) |
| 293 return promise; | 293 return promise; |
| 294 | 294 |
| 295 WebCryptoKeyUsageMask keyUsages; | 295 WebCryptoKeyUsageMask keyUsages; |
| 296 if (!CryptoKey::parseUsageMask(rawKeyUsages, keyUsages, result.get())) | 296 if (!CryptoKey::parseUsageMask(rawKeyUsages, keyUsages, result.get())) |
| 297 return promise; | 297 return promise; |
| 298 | 298 |
| 299 WebCryptoAlgorithm algorithm; | 299 WebCryptoAlgorithm algorithm; |
| 300 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationGenerateKey, algorithm,
result.get())) | 300 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationGenerateKey, algorithm,
result.get())) |
| 301 return promise; | 301 return promise; |
| 302 | 302 |
| 303 Platform::current()->crypto()->generateKey(algorithm, extractable, keyUsages
, result->result()); | 303 Platform::current()->crypto()->generateKey(algorithm, extractable, keyUsages
, result->result()); |
| 304 return promise; | 304 return promise; |
| 305 } | 305 } |
| 306 | 306 |
| 307 ScriptPromise SubtleCrypto::importKey(ScriptState* scriptState, const String& ra
wFormat, const ArrayBufferOrArrayBufferViewOrDictionary& keyData, const Algorith
mIdentifier& rawAlgorithm, bool extractable, const Vector<String>& rawKeyUsages) | 307 ScriptPromise SubtleCrypto::importKey(ScriptState* scriptState, const String& ra
wFormat, const ArrayBufferOrArrayBufferViewOrDictionary& keyData, const Algorith
mIdentifier& rawAlgorithm, bool extractable, const Vector<String>& rawKeyUsages) |
| 308 { | 308 { |
| 309 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 309 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 310 ScriptPromise promise = result->promise(); | 310 ScriptPromise promise = result->promise(); |
| 311 | 311 |
| 312 if (!canAccessWebCrypto(scriptState, result.get())) | 312 if (!canAccessWebCrypto(scriptState, result.get())) |
| 313 return promise; | 313 return promise; |
| 314 | 314 |
| 315 if (!ensureNotNull(keyData, "keyData", result.get())) | 315 if (!ensureNotNull(keyData, "keyData", result.get())) |
| 316 return promise; | 316 return promise; |
| 317 | 317 |
| 318 WebCryptoKeyFormat format; | 318 WebCryptoKeyFormat format; |
| 319 if (!CryptoKey::parseFormat(rawFormat, format, result.get())) | 319 if (!CryptoKey::parseFormat(rawFormat, format, result.get())) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 return promise; | 352 return promise; |
| 353 ptr = reinterpret_cast<const unsigned char*>(jsonUtf8.data()); | 353 ptr = reinterpret_cast<const unsigned char*>(jsonUtf8.data()); |
| 354 len = jsonUtf8.length(); | 354 len = jsonUtf8.length(); |
| 355 } | 355 } |
| 356 Platform::current()->crypto()->importKey(format, ptr, len, algorithm, extrac
table, keyUsages, result->result()); | 356 Platform::current()->crypto()->importKey(format, ptr, len, algorithm, extrac
table, keyUsages, result->result()); |
| 357 return promise; | 357 return promise; |
| 358 } | 358 } |
| 359 | 359 |
| 360 ScriptPromise SubtleCrypto::exportKey(ScriptState* scriptState, const String& ra
wFormat, CryptoKey* key) | 360 ScriptPromise SubtleCrypto::exportKey(ScriptState* scriptState, const String& ra
wFormat, CryptoKey* key) |
| 361 { | 361 { |
| 362 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 362 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 363 ScriptPromise promise = result->promise(); | 363 ScriptPromise promise = result->promise(); |
| 364 | 364 |
| 365 if (!canAccessWebCrypto(scriptState, result.get())) | 365 if (!canAccessWebCrypto(scriptState, result.get())) |
| 366 return promise; | 366 return promise; |
| 367 | 367 |
| 368 if (!ensureNotNull(key, "key", result.get())) | 368 if (!ensureNotNull(key, "key", result.get())) |
| 369 return promise; | 369 return promise; |
| 370 | 370 |
| 371 WebCryptoKeyFormat format; | 371 WebCryptoKeyFormat format; |
| 372 if (!CryptoKey::parseFormat(rawFormat, format, result.get())) | 372 if (!CryptoKey::parseFormat(rawFormat, format, result.get())) |
| 373 return promise; | 373 return promise; |
| 374 | 374 |
| 375 if (!key->extractable()) { | 375 if (!key->extractable()) { |
| 376 result->completeWithError(WebCryptoErrorTypeInvalidAccess, "key is not e
xtractable"); | 376 result->completeWithError(WebCryptoErrorTypeInvalidAccess, "key is not e
xtractable"); |
| 377 return promise; | 377 return promise; |
| 378 } | 378 } |
| 379 | 379 |
| 380 Platform::current()->crypto()->exportKey(format, key->key(), result->result(
)); | 380 Platform::current()->crypto()->exportKey(format, key->key(), result->result(
)); |
| 381 return promise; | 381 return promise; |
| 382 } | 382 } |
| 383 | 383 |
| 384 ScriptPromise SubtleCrypto::wrapKey(ScriptState* scriptState, const String& rawF
ormat, CryptoKey* key, CryptoKey* wrappingKey, const AlgorithmIdentifier& rawWra
pAlgorithm) | 384 ScriptPromise SubtleCrypto::wrapKey(ScriptState* scriptState, const String& rawF
ormat, CryptoKey* key, CryptoKey* wrappingKey, const AlgorithmIdentifier& rawWra
pAlgorithm) |
| 385 { | 385 { |
| 386 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 386 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 387 ScriptPromise promise = result->promise(); | 387 ScriptPromise promise = result->promise(); |
| 388 | 388 |
| 389 if (!canAccessWebCrypto(scriptState, result.get())) | 389 if (!canAccessWebCrypto(scriptState, result.get())) |
| 390 return promise; | 390 return promise; |
| 391 | 391 |
| 392 if (!ensureNotNull(key, "key", result.get())) | 392 if (!ensureNotNull(key, "key", result.get())) |
| 393 return promise; | 393 return promise; |
| 394 | 394 |
| 395 if (!ensureNotNull(wrappingKey, "wrappingKey", result.get())) | 395 if (!ensureNotNull(wrappingKey, "wrappingKey", result.get())) |
| 396 return promise; | 396 return promise; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 410 | 410 |
| 411 if (!wrappingKey->canBeUsedForAlgorithm(wrapAlgorithm, WebCryptoKeyUsageWrap
Key, result.get())) | 411 if (!wrappingKey->canBeUsedForAlgorithm(wrapAlgorithm, WebCryptoKeyUsageWrap
Key, result.get())) |
| 412 return promise; | 412 return promise; |
| 413 | 413 |
| 414 Platform::current()->crypto()->wrapKey(format, key->key(), wrappingKey->key(
), wrapAlgorithm, result->result()); | 414 Platform::current()->crypto()->wrapKey(format, key->key(), wrappingKey->key(
), wrapAlgorithm, result->result()); |
| 415 return promise; | 415 return promise; |
| 416 } | 416 } |
| 417 | 417 |
| 418 ScriptPromise SubtleCrypto::unwrapKey(ScriptState* scriptState, const String& ra
wFormat, const DOMArrayPiece& wrappedKey, CryptoKey* unwrappingKey, const Algori
thmIdentifier& rawUnwrapAlgorithm, const AlgorithmIdentifier& rawUnwrappedKeyAlg
orithm, bool extractable, const Vector<String>& rawKeyUsages) | 418 ScriptPromise SubtleCrypto::unwrapKey(ScriptState* scriptState, const String& ra
wFormat, const DOMArrayPiece& wrappedKey, CryptoKey* unwrappingKey, const Algori
thmIdentifier& rawUnwrapAlgorithm, const AlgorithmIdentifier& rawUnwrappedKeyAlg
orithm, bool extractable, const Vector<String>& rawKeyUsages) |
| 419 { | 419 { |
| 420 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 420 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 421 ScriptPromise promise = result->promise(); | 421 ScriptPromise promise = result->promise(); |
| 422 | 422 |
| 423 if (!canAccessWebCrypto(scriptState, result.get())) | 423 if (!canAccessWebCrypto(scriptState, result.get())) |
| 424 return promise; | 424 return promise; |
| 425 | 425 |
| 426 if (!ensureNotNull(wrappedKey, "wrappedKey", result.get())) | 426 if (!ensureNotNull(wrappedKey, "wrappedKey", result.get())) |
| 427 return promise; | 427 return promise; |
| 428 if (!ensureNotNull(unwrappingKey, "unwrappingKey", result.get())) | 428 if (!ensureNotNull(unwrappingKey, "unwrappingKey", result.get())) |
| 429 return promise; | 429 return promise; |
| 430 | 430 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 446 | 446 |
| 447 if (!unwrappingKey->canBeUsedForAlgorithm(unwrapAlgorithm, WebCryptoKeyUsage
UnwrapKey, result.get())) | 447 if (!unwrappingKey->canBeUsedForAlgorithm(unwrapAlgorithm, WebCryptoKeyUsage
UnwrapKey, result.get())) |
| 448 return promise; | 448 return promise; |
| 449 | 449 |
| 450 Platform::current()->crypto()->unwrapKey(format, wrappedKey.bytes(), wrapped
Key.byteLength(), unwrappingKey->key(), unwrapAlgorithm, unwrappedKeyAlgorithm,
extractable, keyUsages, result->result()); | 450 Platform::current()->crypto()->unwrapKey(format, wrappedKey.bytes(), wrapped
Key.byteLength(), unwrappingKey->key(), unwrapAlgorithm, unwrappedKeyAlgorithm,
extractable, keyUsages, result->result()); |
| 451 return promise; | 451 return promise; |
| 452 } | 452 } |
| 453 | 453 |
| 454 ScriptPromise SubtleCrypto::deriveBits(ScriptState* scriptState, const Algorithm
Identifier& rawAlgorithm, CryptoKey* baseKey, unsigned lengthBits) | 454 ScriptPromise SubtleCrypto::deriveBits(ScriptState* scriptState, const Algorithm
Identifier& rawAlgorithm, CryptoKey* baseKey, unsigned lengthBits) |
| 455 { | 455 { |
| 456 RefPtr<CryptoResultImpl> result = CryptoResultImpl::create(scriptState); | 456 RefPtrWillBeRawPtr<CryptoResultImpl> result = CryptoResultImpl::create(scrip
tState); |
| 457 ScriptPromise promise = result->promise(); | 457 ScriptPromise promise = result->promise(); |
| 458 | 458 |
| 459 if (!canAccessWebCrypto(scriptState, result.get())) | 459 if (!canAccessWebCrypto(scriptState, result.get())) |
| 460 return promise; | 460 return promise; |
| 461 | 461 |
| 462 if (!ensureNotNull(baseKey, "baseKey", result.get())) | 462 if (!ensureNotNull(baseKey, "baseKey", result.get())) |
| 463 return promise; | 463 return promise; |
| 464 | 464 |
| 465 WebCryptoAlgorithm algorithm; | 465 WebCryptoAlgorithm algorithm; |
| 466 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationDeriveBits, algorithm, r
esult.get())) | 466 if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationDeriveBits, algorithm, r
esult.get())) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 501 |
| 502 WebCryptoAlgorithm keyLengthAlgorithm; | 502 WebCryptoAlgorithm keyLengthAlgorithm; |
| 503 if (!parseAlgorithm(rawDerivedKeyType, WebCryptoOperationGetKeyLength, keyLe
ngthAlgorithm, result.get())) | 503 if (!parseAlgorithm(rawDerivedKeyType, WebCryptoOperationGetKeyLength, keyLe
ngthAlgorithm, result.get())) |
| 504 return promise; | 504 return promise; |
| 505 | 505 |
| 506 Platform::current()->crypto()->deriveKey(algorithm, baseKey->key(), importAl
gorithm, keyLengthAlgorithm, extractable, keyUsages, result->result()); | 506 Platform::current()->crypto()->deriveKey(algorithm, baseKey->key(), importAl
gorithm, keyLengthAlgorithm, extractable, keyUsages, result->result()); |
| 507 return promise; | 507 return promise; |
| 508 } | 508 } |
| 509 | 509 |
| 510 } // namespace blink | 510 } // namespace blink |
| OLD | NEW |