Changeset 158578 in webkit
- Timestamp:
- Nov 4, 2013 9:37:20 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 6 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r158576 r158578 1 2013-11-04 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r158526. 4 http://trac.webkit.org/changeset/158526 5 https://bugs.webkit.org/show_bug.cgi?id=123744 6 7 it broke the build (Requested by jessieberlin on #webkit). 8 9 * crypto/subtle/aes-cbc-generate-key-expected.txt: Removed. 10 * crypto/subtle/aes-cbc-generate-key.html: Removed. 11 * crypto/subtle/hmac-generate-key-expected.txt: Removed. 12 * crypto/subtle/hmac-generate-key.html: Removed. 13 * crypto/subtle/sha-1-expected.txt: 14 1 15 2013-11-04 Robert Plociennik <r.plociennik@samsung.com> 2 16 -
trunk/LayoutTests/crypto/subtle/sha-1-expected.txt
r158526 r158578 12 12 SHA1 of [new Uint8Array([0, 1, 2, 3, 4]), new Uint8Array(5, 6, 7, 8, 9, 10])] 13 13 = [2c 7e 7c 38 4f 78 29 69 42 82 b1 e3 a6 21 6d ef 80 82 d0 55] 14 PASS crypto.subtle.generateKey('sha-1') threw exception Error: NotSupportedError: DOM Exception 9.14 PASS crypto.subtle.generateKey('sha-1') threw exception TypeError: undefined is not a function (evaluating 'crypto.subtle.generateKey('sha-1')'). 15 15 PASS successfullyParsed is true 16 16 -
trunk/Source/WebCore/ChangeLog
r158574 r158578 1 2013-11-04 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r158526. 4 http://trac.webkit.org/changeset/158526 5 https://bugs.webkit.org/show_bug.cgi?id=123744 6 7 it broke the build (Requested by jessieberlin on #webkit). 8 9 * WebCore.xcodeproj/project.pbxproj: 10 * bindings/js/JSCryptoAlgorithmDictionary.cpp: 11 (WebCore::createAesCbcParams): 12 (WebCore::createHmacParams): 13 (WebCore::createHmacKeyParams): 14 (WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey): 15 * bindings/js/JSSubtleCryptoCustom.cpp: 16 * crypto/CryptoAlgorithmAesKeyGenParams.h: Removed. 17 * crypto/CryptoKey.cpp: 18 * crypto/CryptoKey.h: 19 * crypto/CryptoKeyAES.cpp: 20 * crypto/CryptoKeyAES.h: 21 * crypto/CryptoKeyMac.cpp: Removed. 22 * crypto/SubtleCrypto.idl: 23 * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: 24 * crypto/algorithms/CryptoAlgorithmHMAC.cpp: 25 * crypto/keys/CryptoKeyHMAC.cpp: 26 * crypto/keys/CryptoKeyHMAC.h: 27 * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp: 28 (WebCore::CryptoAlgorithmAES_CBC::generateKey): 29 * crypto/mac/CryptoAlgorithmHMACMac.cpp: 30 (WebCore::CryptoAlgorithmHMAC::generateKey): 31 1 32 2013-11-04 Przemyslaw Szymanski <p.szymanski3@samsung.com> 2 33 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r158561 r158578 20177 20177 E19AC3E01824DC6900349426 /* CryptoAlgorithmSHA384Mac.cpp */, 20178 20178 E19AC3E11824DC6900349426 /* CryptoAlgorithmSHA512Mac.cpp */, 20179 E19AC3F8182566F700349426 /* CryptoKeyMac.cpp */,20180 20179 ); 20181 20180 name = mac; … … 20218 20217 children = ( 20219 20218 E125F8391824104800D84CD9 /* CryptoAlgorithmAesCbcParams.h */, 20220 E19AC3F61824E5D100349426 /* CryptoAlgorithmAesKeyGenParams.h */,20221 20219 E19DA29B18189ADD00088BC8 /* CryptoAlgorithmHmacKeyParams.h */, 20222 20220 E1C6571E1816E50300256CDD /* CryptoAlgorithmHmacParams.h */, … … 23194 23192 76808B50159DADFA002B5233 /* JSHTMLDialogElement.h in Headers */, 23195 23193 1A85B1E70A1B240500D8C87C /* JSHTMLDirectoryElement.h in Headers */, 23196 E19AC3F71824E5D100349426 /* CryptoAlgorithmAesKeyGenParams.h in Headers */,23197 23194 1A85B2B70A1B2AC700D8C87C /* JSHTMLDivElement.h in Headers */, 23198 23195 1A85B1E90A1B240500D8C87C /* JSHTMLDListElement.h in Headers */, … … 27013 27010 E19AC3E51824DC6900349426 /* CryptoAlgorithmSHA512Mac.cpp in Sources */, 27014 27011 D6E528A3149A926D00EFE1F3 /* MutationObserverInterestGroup.cpp in Sources */, 27015 E19AC3F9182566F700349426 /* CryptoKeyMac.cpp in Sources */,27016 27012 D6E276AF14637455001D280A /* MutationObserverRegistration.cpp in Sources */, 27017 27013 C6F08FBC1430FE8F00685849 /* MutationRecord.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp
r158526 r158578 30 30 31 31 #include "CryptoAlgorithmAesCbcParams.h" 32 #include "CryptoAlgorithmAesKeyGenParams.h"33 32 #include "CryptoAlgorithmHmacKeyParams.h" 34 33 #include "CryptoAlgorithmHmacParams.h" … … 128 127 return nullptr; 129 128 130 autoresult = std::make_unique<CryptoAlgorithmAesCbcParams>();129 std::unique_ptr<CryptoAlgorithmAesCbcParams> result = std::make_unique<CryptoAlgorithmAesCbcParams>(); 131 130 132 131 CryptoOperationData ivData; … … 146 145 } 147 146 148 static std::unique_ptr<CryptoAlgorithmParameters> create AesKeyGenParams(JSC::ExecState* exec, JSC::JSValue value)147 static std::unique_ptr<CryptoAlgorithmParameters> createHmacParams(JSC::ExecState* exec, JSC::JSValue value) 149 148 { 150 149 if (!value.isObject()) { … … 153 152 } 154 153 155 auto result = std::make_unique<CryptoAlgorithmAesKeyGenParams>();156 157 JSValue lengthValue = getProperty(exec, value.getObject(), "length"); 158 if ( exec->hadException())159 return nullptr;160 161 result->length = toUInt16(exec, lengthValue, EnforceRange);154 JSDictionary jsDictionary(exec, value.getObject()); 155 std::unique_ptr<CryptoAlgorithmHmacParams> result = std::make_unique<CryptoAlgorithmHmacParams>(); 156 157 if (!getHashAlgorithm(jsDictionary, result->hash)) { 158 ASSERT(exec->hadException()); 159 return nullptr; 160 } 162 161 163 162 return std::move(result); 164 163 } 165 164 166 static std::unique_ptr<CryptoAlgorithmParameters> createHmac Params(JSC::ExecState* exec, JSC::JSValue value)165 static std::unique_ptr<CryptoAlgorithmParameters> createHmacKeyParams(JSC::ExecState* exec, JSC::JSValue value) 167 166 { 168 167 if (!value.isObject()) { … … 172 171 173 172 JSDictionary jsDictionary(exec, value.getObject()); 174 auto result = std::make_unique<CryptoAlgorithmHmacParams>();173 std::unique_ptr<CryptoAlgorithmHmacKeyParams> result = std::make_unique<CryptoAlgorithmHmacKeyParams>(); 175 174 176 175 if (!getHashAlgorithm(jsDictionary, result->hash)) { … … 179 178 } 180 179 181 return std::move(result);182 }183 184 static std::unique_ptr<CryptoAlgorithmParameters> createHmacKeyParams(JSC::ExecState* exec, JSC::JSValue value)185 {186 if (!value.isObject()) {187 throwTypeError(exec);188 return nullptr;189 }190 191 JSDictionary jsDictionary(exec, value.getObject());192 auto result = std::make_unique<CryptoAlgorithmHmacKeyParams>();193 194 if (!getHashAlgorithm(jsDictionary, result->hash)) {195 ASSERT(exec->hadException());196 return nullptr;197 }198 199 180 result->hasLength = jsDictionary.get("length", result->length); 200 181 if (exec->hadException()) … … 364 345 } 365 346 366 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value) 367 { 368 switch (algorithm) { 369 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 370 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 371 case CryptoAlgorithmIdentifier::RSA_PSS: 372 case CryptoAlgorithmIdentifier::RSA_OAEP: 373 case CryptoAlgorithmIdentifier::ECDSA: 374 case CryptoAlgorithmIdentifier::ECDH: 375 setDOMException(exec, NOT_SUPPORTED_ERR); 376 return nullptr; 377 case CryptoAlgorithmIdentifier::AES_CTR: 378 case CryptoAlgorithmIdentifier::AES_CBC: 379 case CryptoAlgorithmIdentifier::AES_CMAC: 380 case CryptoAlgorithmIdentifier::AES_GCM: 381 case CryptoAlgorithmIdentifier::AES_CFB: 382 return createAesKeyGenParams(exec, value); 347 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForGenerateKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue) 348 { 349 switch (algorithm) { 350 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 351 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 352 case CryptoAlgorithmIdentifier::RSA_PSS: 353 case CryptoAlgorithmIdentifier::RSA_OAEP: 354 case CryptoAlgorithmIdentifier::ECDSA: 355 case CryptoAlgorithmIdentifier::ECDH: 356 case CryptoAlgorithmIdentifier::AES_CTR: 357 case CryptoAlgorithmIdentifier::AES_CBC: 358 case CryptoAlgorithmIdentifier::AES_CMAC: 359 case CryptoAlgorithmIdentifier::AES_GCM: 360 case CryptoAlgorithmIdentifier::AES_CFB: 361 case CryptoAlgorithmIdentifier::HMAC: 362 case CryptoAlgorithmIdentifier::DH: 363 case CryptoAlgorithmIdentifier::SHA_1: 364 case CryptoAlgorithmIdentifier::SHA_224: 365 case CryptoAlgorithmIdentifier::SHA_256: 366 case CryptoAlgorithmIdentifier::SHA_384: 367 case CryptoAlgorithmIdentifier::SHA_512: 368 case CryptoAlgorithmIdentifier::CONCAT: 369 case CryptoAlgorithmIdentifier::HKDF_CTR: 370 case CryptoAlgorithmIdentifier::PBKDF2: 371 setDOMException(exec, NOT_SUPPORTED_ERR); 372 return nullptr; 373 } 374 } 375 376 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue) 377 { 378 switch (algorithm) { 379 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 380 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 381 case CryptoAlgorithmIdentifier::RSA_PSS: 382 case CryptoAlgorithmIdentifier::RSA_OAEP: 383 case CryptoAlgorithmIdentifier::ECDSA: 384 case CryptoAlgorithmIdentifier::ECDH: 385 case CryptoAlgorithmIdentifier::AES_CTR: 386 case CryptoAlgorithmIdentifier::AES_CBC: 387 case CryptoAlgorithmIdentifier::AES_CMAC: 388 case CryptoAlgorithmIdentifier::AES_GCM: 389 case CryptoAlgorithmIdentifier::AES_CFB: 390 case CryptoAlgorithmIdentifier::HMAC: 391 case CryptoAlgorithmIdentifier::DH: 392 case CryptoAlgorithmIdentifier::SHA_1: 393 case CryptoAlgorithmIdentifier::SHA_224: 394 case CryptoAlgorithmIdentifier::SHA_256: 395 case CryptoAlgorithmIdentifier::SHA_384: 396 case CryptoAlgorithmIdentifier::SHA_512: 397 case CryptoAlgorithmIdentifier::CONCAT: 398 case CryptoAlgorithmIdentifier::HKDF_CTR: 399 case CryptoAlgorithmIdentifier::PBKDF2: 400 setDOMException(exec, NOT_SUPPORTED_ERR); 401 return nullptr; 402 } 403 } 404 405 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue) 406 { 407 switch (algorithm) { 408 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 409 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 410 case CryptoAlgorithmIdentifier::RSA_PSS: 411 case CryptoAlgorithmIdentifier::RSA_OAEP: 412 case CryptoAlgorithmIdentifier::ECDSA: 413 case CryptoAlgorithmIdentifier::ECDH: 414 case CryptoAlgorithmIdentifier::AES_CTR: 415 case CryptoAlgorithmIdentifier::AES_CBC: 416 case CryptoAlgorithmIdentifier::AES_CMAC: 417 case CryptoAlgorithmIdentifier::AES_GCM: 418 case CryptoAlgorithmIdentifier::AES_CFB: 419 case CryptoAlgorithmIdentifier::HMAC: 420 case CryptoAlgorithmIdentifier::DH: 421 case CryptoAlgorithmIdentifier::SHA_1: 422 case CryptoAlgorithmIdentifier::SHA_224: 423 case CryptoAlgorithmIdentifier::SHA_256: 424 case CryptoAlgorithmIdentifier::SHA_384: 425 case CryptoAlgorithmIdentifier::SHA_512: 426 case CryptoAlgorithmIdentifier::CONCAT: 427 case CryptoAlgorithmIdentifier::HKDF_CTR: 428 case CryptoAlgorithmIdentifier::PBKDF2: 429 setDOMException(exec, NOT_SUPPORTED_ERR); 430 return nullptr; 431 } 432 } 433 434 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForImportKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value) 435 { 436 switch (algorithm) { 437 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 438 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 439 case CryptoAlgorithmIdentifier::RSA_PSS: 440 case CryptoAlgorithmIdentifier::RSA_OAEP: 441 case CryptoAlgorithmIdentifier::ECDSA: 442 case CryptoAlgorithmIdentifier::ECDH: 443 case CryptoAlgorithmIdentifier::AES_CTR: 444 case CryptoAlgorithmIdentifier::AES_CBC: 445 case CryptoAlgorithmIdentifier::AES_CMAC: 446 case CryptoAlgorithmIdentifier::AES_GCM: 447 case CryptoAlgorithmIdentifier::AES_CFB: 448 return std::make_unique<CryptoAlgorithmParameters>(); 383 449 case CryptoAlgorithmIdentifier::HMAC: 384 450 return createHmacKeyParams(exec, value); 385 451 case CryptoAlgorithmIdentifier::DH: 386 case CryptoAlgorithmIdentifier::SHA_1:387 case CryptoAlgorithmIdentifier::SHA_224:388 case CryptoAlgorithmIdentifier::SHA_256:389 case CryptoAlgorithmIdentifier::SHA_384:390 case CryptoAlgorithmIdentifier::SHA_512:391 case CryptoAlgorithmIdentifier::CONCAT:392 case CryptoAlgorithmIdentifier::HKDF_CTR:393 case CryptoAlgorithmIdentifier::PBKDF2:394 setDOMException(exec, NOT_SUPPORTED_ERR);395 return nullptr;396 }397 }398 399 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)400 {401 switch (algorithm) {402 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:403 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:404 case CryptoAlgorithmIdentifier::RSA_PSS:405 case CryptoAlgorithmIdentifier::RSA_OAEP:406 case CryptoAlgorithmIdentifier::ECDSA:407 case CryptoAlgorithmIdentifier::ECDH:408 case CryptoAlgorithmIdentifier::AES_CTR:409 case CryptoAlgorithmIdentifier::AES_CBC:410 case CryptoAlgorithmIdentifier::AES_CMAC:411 case CryptoAlgorithmIdentifier::AES_GCM:412 case CryptoAlgorithmIdentifier::AES_CFB:413 case CryptoAlgorithmIdentifier::HMAC:414 case CryptoAlgorithmIdentifier::DH:415 case CryptoAlgorithmIdentifier::SHA_1:416 case CryptoAlgorithmIdentifier::SHA_224:417 case CryptoAlgorithmIdentifier::SHA_256:418 case CryptoAlgorithmIdentifier::SHA_384:419 case CryptoAlgorithmIdentifier::SHA_512:420 case CryptoAlgorithmIdentifier::CONCAT:421 case CryptoAlgorithmIdentifier::HKDF_CTR:422 case CryptoAlgorithmIdentifier::PBKDF2:423 setDOMException(exec, NOT_SUPPORTED_ERR);424 return nullptr;425 }426 }427 428 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForDeriveBits(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)429 {430 switch (algorithm) {431 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:432 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:433 case CryptoAlgorithmIdentifier::RSA_PSS:434 case CryptoAlgorithmIdentifier::RSA_OAEP:435 case CryptoAlgorithmIdentifier::ECDSA:436 case CryptoAlgorithmIdentifier::ECDH:437 case CryptoAlgorithmIdentifier::AES_CTR:438 case CryptoAlgorithmIdentifier::AES_CBC:439 case CryptoAlgorithmIdentifier::AES_CMAC:440 case CryptoAlgorithmIdentifier::AES_GCM:441 case CryptoAlgorithmIdentifier::AES_CFB:442 case CryptoAlgorithmIdentifier::HMAC:443 case CryptoAlgorithmIdentifier::DH:444 case CryptoAlgorithmIdentifier::SHA_1:445 case CryptoAlgorithmIdentifier::SHA_224:446 case CryptoAlgorithmIdentifier::SHA_256:447 case CryptoAlgorithmIdentifier::SHA_384:448 case CryptoAlgorithmIdentifier::SHA_512:449 case CryptoAlgorithmIdentifier::CONCAT:450 case CryptoAlgorithmIdentifier::HKDF_CTR:451 case CryptoAlgorithmIdentifier::PBKDF2:452 setDOMException(exec, NOT_SUPPORTED_ERR);453 return nullptr;454 }455 }456 457 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForImportKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue value)458 {459 switch (algorithm) {460 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:461 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:462 case CryptoAlgorithmIdentifier::RSA_PSS:463 case CryptoAlgorithmIdentifier::RSA_OAEP:464 case CryptoAlgorithmIdentifier::ECDSA:465 case CryptoAlgorithmIdentifier::ECDH:466 case CryptoAlgorithmIdentifier::AES_CTR:467 case CryptoAlgorithmIdentifier::AES_CBC:468 case CryptoAlgorithmIdentifier::AES_CMAC:469 case CryptoAlgorithmIdentifier::AES_GCM:470 case CryptoAlgorithmIdentifier::AES_CFB:471 452 return std::make_unique<CryptoAlgorithmParameters>(); 472 case CryptoAlgorithmIdentifier::HMAC: 473 return createHmacKeyParams(exec, value); 453 case CryptoAlgorithmIdentifier::SHA_1: 454 case CryptoAlgorithmIdentifier::SHA_224: 455 case CryptoAlgorithmIdentifier::SHA_256: 456 case CryptoAlgorithmIdentifier::SHA_384: 457 case CryptoAlgorithmIdentifier::SHA_512: 458 case CryptoAlgorithmIdentifier::CONCAT: 459 case CryptoAlgorithmIdentifier::HKDF_CTR: 460 case CryptoAlgorithmIdentifier::PBKDF2: 461 setDOMException(exec, NOT_SUPPORTED_ERR); 462 return nullptr; 463 } 464 } 465 466 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForExportKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue) 467 { 468 switch (algorithm) { 469 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: 470 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 471 case CryptoAlgorithmIdentifier::RSA_PSS: 472 case CryptoAlgorithmIdentifier::RSA_OAEP: 473 case CryptoAlgorithmIdentifier::ECDSA: 474 case CryptoAlgorithmIdentifier::ECDH: 475 case CryptoAlgorithmIdentifier::AES_CTR: 476 case CryptoAlgorithmIdentifier::AES_CBC: 477 case CryptoAlgorithmIdentifier::AES_CMAC: 478 case CryptoAlgorithmIdentifier::AES_GCM: 479 case CryptoAlgorithmIdentifier::AES_CFB: 480 case CryptoAlgorithmIdentifier::HMAC: 474 481 case CryptoAlgorithmIdentifier::DH: 475 482 return std::make_unique<CryptoAlgorithmParameters>(); … … 487 494 } 488 495 489 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForExportKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue)490 {491 switch (algorithm) {492 case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:493 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:494 case CryptoAlgorithmIdentifier::RSA_PSS:495 case CryptoAlgorithmIdentifier::RSA_OAEP:496 case CryptoAlgorithmIdentifier::ECDSA:497 case CryptoAlgorithmIdentifier::ECDH:498 case CryptoAlgorithmIdentifier::AES_CTR:499 case CryptoAlgorithmIdentifier::AES_CBC:500 case CryptoAlgorithmIdentifier::AES_CMAC:501 case CryptoAlgorithmIdentifier::AES_GCM:502 case CryptoAlgorithmIdentifier::AES_CFB:503 case CryptoAlgorithmIdentifier::HMAC:504 case CryptoAlgorithmIdentifier::DH:505 return std::make_unique<CryptoAlgorithmParameters>();506 case CryptoAlgorithmIdentifier::SHA_1:507 case CryptoAlgorithmIdentifier::SHA_224:508 case CryptoAlgorithmIdentifier::SHA_256:509 case CryptoAlgorithmIdentifier::SHA_384:510 case CryptoAlgorithmIdentifier::SHA_512:511 case CryptoAlgorithmIdentifier::CONCAT:512 case CryptoAlgorithmIdentifier::HKDF_CTR:513 case CryptoAlgorithmIdentifier::PBKDF2:514 setDOMException(exec, NOT_SUPPORTED_ERR);515 return nullptr;516 }517 }518 519 496 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForWrapKey(JSC::ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSC::JSValue) 520 497 { -
trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
r158526 r158578 338 338 } 339 339 340 JSValue JSSubtleCrypto::generateKey(JSC::ExecState* exec)341 {342 if (exec->argumentCount() < 1)343 return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));344 345 auto algorithm = createAlgorithmFromJSValue(exec, exec->uncheckedArgument(0));346 if (!algorithm) {347 ASSERT(exec->hadException());348 return jsUndefined();349 }350 351 auto parameters = JSCryptoAlgorithmDictionary::createParametersForGenerateKey(exec, algorithm->identifier(), exec->uncheckedArgument(0));352 if (!parameters) {353 ASSERT(exec->hadException());354 return jsUndefined();355 }356 357 bool extractable = false;358 if (exec->argumentCount() >= 2) {359 extractable = exec->uncheckedArgument(1).toBoolean(exec);360 if (exec->hadException())361 return jsUndefined();362 }363 364 CryptoKeyUsage keyUsages = 0;365 if (exec->argumentCount() >= 3) {366 if (!cryptoKeyUsagesFromJSValue(exec, exec->argument(2), keyUsages)) {367 ASSERT(exec->hadException());368 return jsUndefined();369 }370 }371 372 JSPromise* promise = JSPromise::createWithResolver(exec->vm(), globalObject());373 auto promiseWrapper = PromiseWrapper::create(globalObject(), promise);374 375 ExceptionCode ec = 0;376 algorithm->generateKey(*parameters, extractable, keyUsages, std::move(promiseWrapper), ec);377 if (ec) {378 setDOMException(exec, ec);379 return jsUndefined();380 }381 382 return promise;383 }384 385 340 JSValue JSSubtleCrypto::importKey(JSC::ExecState* exec) 386 341 { -
trunk/Source/WebCore/crypto/CryptoKey.cpp
r158526 r158578 31 31 #include "CryptoAlgorithmDescriptionBuilder.h" 32 32 #include "CryptoAlgorithmRegistry.h" 33 #include <wtf/CryptographicallyRandomNumber.h>34 33 #include <wtf/text/WTFString.h> 35 34 … … 89 88 } 90 89 91 #if !PLATFORM(MAC)92 Vector<char> CryptoKey::randomData(size_t size)93 {94 Vector<char> result(size);95 cryptographicallyRandomValues(result.data(), result.size());96 return result;97 }98 #endif99 90 } // namespace WebCore 100 91 -
trunk/Source/WebCore/crypto/CryptoKey.h
r158526 r158578 59 59 bool allows(CryptoKeyUsage usage) const { return usage == (m_usages & usage); } 60 60 61 static Vector<char> randomData(size_t);62 63 61 private: 64 62 CryptoAlgorithmIdentifier m_algorithm; -
trunk/Source/WebCore/crypto/CryptoKeyAES.cpp
r158526 r158578 50 50 } 51 51 52 PassRefPtr<CryptoKeyAES> CryptoKeyAES::generate(CryptoAlgorithmIdentifier algorithm, size_t lengthBits, bool extractable, CryptoKeyUsage usages)53 {54 if (lengthBits % 8)55 return nullptr;56 return adoptRef(new CryptoKeyAES(algorithm, randomData(lengthBits / 8), extractable, usages));57 }58 59 52 void CryptoKeyAES::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& builder) const 60 53 { -
trunk/Source/WebCore/crypto/CryptoKeyAES.h
r158526 r158578 43 43 virtual ~CryptoKeyAES(); 44 44 45 static PassRefPtr<CryptoKeyAES> generate(CryptoAlgorithmIdentifier, size_t lengthBits, bool extractable, CryptoKeyUsage);46 47 45 virtual CryptoKeyClass keyClass() const OVERRIDE { return CryptoKeyClass::AES; } 48 46 -
trunk/Source/WebCore/crypto/SubtleCrypto.idl
r158526 r158578 36 36 [Custom] Promise verify(AlgorithmIdentifier algorithm, Key key, CryptoOperationData signature, sequence<CryptoOperationData> data); 37 37 [Custom] Promise digest(AlgorithmIdentifier algorithm, sequence<CryptoOperationData> data); 38 [Custom] Promise generateKey(AlgorithmIdentifier algorithm, optional boolean extractable, optional KeyUsage[] keyUsages);39 38 [Custom] Promise importKey(KeyFormat format, CryptoOperationData keyData, AlgorithmIdentifier? algorithm, optional boolean extractable, optional KeyUsage[] keyUsages); 40 39 }; -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
r158526 r158578 29 29 #if ENABLE(SUBTLE_CRYPTO) 30 30 31 #include "CryptoAlgorithmAes KeyGenParams.h"31 #include "CryptoAlgorithmAesCbcParams.h" 32 32 #include "CryptoKeyAES.h" 33 33 #include "ExceptionCode.h" … … 56 56 } 57 57 58 void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsage usages, std::unique_ptr<PromiseWrapper> promise, ExceptionCode&)59 {60 const CryptoAlgorithmAesKeyGenParams& aesParameters = static_cast<const CryptoAlgorithmAesKeyGenParams&>(parameters);61 62 RefPtr<CryptoKeyAES> result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_CBC, aesParameters.length, extractable, usages);63 if (!result) {64 promise->reject(nullptr);65 return;66 }67 68 promise->fulfill(result.release());69 }70 71 58 void CryptoAlgorithmAES_CBC::importKey(const CryptoAlgorithmParameters&, CryptoKeyFormat format, const CryptoOperationData& data, bool extractable, CryptoKeyUsage usage, std::unique_ptr<PromiseWrapper> promise, ExceptionCode& ec) 72 59 { -
trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp
r158526 r158578 29 29 #if ENABLE(SUBTLE_CRYPTO) 30 30 31 #include "CryptoAlgorithmHmacKeyParams.h"32 31 #include "CryptoAlgorithmHmacParams.h" 33 32 #include "CryptoKeyHMAC.h" … … 57 56 } 58 57 59 void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsage usages, std::unique_ptr<PromiseWrapper> promise, ExceptionCode&)60 {61 const CryptoAlgorithmHmacKeyParams& hmacParameters = static_cast<const CryptoAlgorithmHmacKeyParams&>(parameters);62 63 RefPtr<CryptoKeyHMAC> result = CryptoKeyHMAC::generate(hmacParameters.hasLength ? hmacParameters.length : 0, hmacParameters.hash, extractable, usages);64 if (!result) {65 promise->reject(nullptr);66 return;67 }68 69 promise->fulfill(result.release());70 }71 72 58 void CryptoAlgorithmHMAC::importKey(const CryptoAlgorithmParameters& parameters, CryptoKeyFormat format, const CryptoOperationData& data, bool extractable, CryptoKeyUsage usage, std::unique_ptr<PromiseWrapper> promise, ExceptionCode& ec) 73 59 { -
trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp
r158526 r158578 46 46 } 47 47 48 PassRefPtr<CryptoKeyHMAC> CryptoKeyHMAC::generate(size_t lengthBytes, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsage usages)49 {50 if (!lengthBytes) {51 switch (hash) {52 case CryptoAlgorithmIdentifier::SHA_1:53 case CryptoAlgorithmIdentifier::SHA_224:54 case CryptoAlgorithmIdentifier::SHA_256:55 lengthBytes = 64;56 break;57 case CryptoAlgorithmIdentifier::SHA_384:58 case CryptoAlgorithmIdentifier::SHA_512:59 lengthBytes = 128;60 break;61 default:62 return nullptr;63 }64 }65 66 return adoptRef(new CryptoKeyHMAC(randomData(lengthBytes), hash, extractable, usages));67 }68 69 48 void CryptoKeyHMAC::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& builder) const 70 49 { -
trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h
r158526 r158578 42 42 virtual ~CryptoKeyHMAC(); 43 43 44 // If lengthBytes is 0, a recommended length is used, which is the size of the associated hash function's block size.45 static PassRefPtr<CryptoKeyHMAC> generate(size_t lengthBytes, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsage);46 47 44 virtual CryptoKeyClass keyClass() const OVERRIDE { return CryptoKeyClass::HMAC; } 48 45 -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmAES_CBCMac.cpp
r158526 r158578 116 116 } 117 117 118 void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters&, bool /*extractable*/, CryptoKeyUsage, std::unique_ptr<PromiseWrapper>, ExceptionCode& ec) 119 { 120 // Not yet implemented. 121 ec = NOT_SUPPORTED_ERR; 122 } 123 118 124 } // namespace WebCore 119 125 -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp
r158526 r158578 137 137 } 138 138 139 void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters&, bool /*extractable*/, CryptoKeyUsage, std::unique_ptr<PromiseWrapper>, ExceptionCode& ec) 140 { 141 // Not yet implemented. 142 ec = NOT_SUPPORTED_ERR; 143 } 144 145 139 146 } 140 147
Note: See TracChangeset
for help on using the changeset viewer.