Changeset 159944 in webkit
- Timestamp:
- Dec 2, 2013 11:50:51 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 12 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r159943 r159944 1 2013-12-02 Alexey Proskuryakov <ap@apple.com> 2 3 Add support for WebCrypto RSA-OAEP 4 https://bugs.webkit.org/show_bug.cgi?id=125084 5 6 Reviewed by Sam Weinig. 7 8 * crypto/subtle/rsa-oaep-key-manipulation-expected.txt: Added. 9 * crypto/subtle/rsa-oaep-key-manipulation.html: Added. 10 * crypto/subtle/rsa-oaep-plaintext-length-expected.txt: Added. 11 * crypto/subtle/rsa-oaep-plaintext-length.html: Added. 12 * crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt: Added. 13 * crypto/subtle/rsa-oaep-wrap-unwrap-aes.html: Added. 14 1 15 2013-12-01 Filip Pizlo <fpizlo@apple.com> 2 16 -
trunk/Source/WebCore/ChangeLog
r159939 r159944 1 2013-12-02 Alexey Proskuryakov <ap@apple.com> 2 3 Add support for WebCrypto RSA-OAEP 4 https://bugs.webkit.org/show_bug.cgi?id=125084 5 6 Reviewed by Sam Weinig. 7 8 Tests: crypto/subtle/rsa-oaep-key-manipulation.html 9 crypto/subtle/rsa-oaep-plaintext-length.html 10 crypto/subtle/rsa-oaep-wrap-unwrap-aes.html 11 12 * WebCore.xcodeproj/project.pbxproj: Added new files. 13 14 * bindings/js/JSCryptoAlgorithmDictionary.cpp: 15 (WebCore::createRsaOaepParams): 16 (WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt): 17 (WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt): 18 (WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey): 19 Added RSA-OAEP parameters. 20 21 * bindings/js/JSCryptoKeySerializationJWK.cpp: 22 (WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm): 23 (WebCore::JSCryptoKeySerializationJWK::keySizeIsValid): 24 (WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON): 25 Support RSA-OAEP in JWK. It is more limited than general WebCrypto, as JWK only 26 allows SHA-1 as hash. 27 28 * crypto/CommonCryptoUtilities.cpp: Added. (WebCore::getCommonCryptoDigestAlgorithm): 29 * crypto/CommonCryptoUtilities.h: Added. 30 Extracted some shared code and forward declarations for CommonCrypto. 31 32 * crypto/CryptoAlgorithmParameters.h: (WebCore::CryptoAlgorithmParameters::Class): 33 * crypto/parameters/CryptoAlgorithmRsaOaepParams.h: Added. 34 Added RsaOaepParams. 35 36 * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp: Added. 37 * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: Added. 38 * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp: Added. 39 40 * crypto/mac/CryptoAlgorithmHMACMac.cpp: 41 (WebCore::getCommonCryptoHMACAlgorithm): 42 (WebCore::CryptoAlgorithmHMAC::platformSign): 43 (WebCore::CryptoAlgorithmHMAC::platformVerify): 44 * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp: 45 * crypto/mac/CryptoKeyMac.cpp: 46 * crypto/mac/CryptoKeyRSAMac.cpp: 47 Use CommonCryptoUtilities. 48 49 * crypto/mac/CryptoAlgorithmRegistryMac.cpp: 50 (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): Register RSA-OAEP. 51 1 52 2013-12-02 Andres Gomez <agomez@igalia.com> 2 53 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r159856 r159944 5729 5729 E1FE13641834351100892F13 /* CryptoDigestMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE13621834351100892F13 /* CryptoDigestMac.cpp */; }; 5730 5730 E1FE136718343A1000892F13 /* CryptoDigest.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE136618343A1000892F13 /* CryptoDigest.h */; }; 5731 E1FE136A183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */; }; 5732 E1FE136B183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */; }; 5733 E1FE136D183FE21D00892F13 /* CryptoAlgorithmRsaOaepParams.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE136C183FE21D00892F13 /* CryptoAlgorithmRsaOaepParams.h */; }; 5734 E1FE1370183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE136E183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp */; }; 5735 E1FE137418402A6700892F13 /* CommonCryptoUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE137218402A6700892F13 /* CommonCryptoUtilities.cpp */; }; 5736 E1FE137518402A6700892F13 /* CommonCryptoUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */; }; 5731 5737 E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5732 5738 E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; }; … … 12849 12855 E1FE13621834351100892F13 /* CryptoDigestMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoDigestMac.cpp; path = mac/CryptoDigestMac.cpp; sourceTree = "<group>"; }; 12850 12856 E1FE136618343A1000892F13 /* CryptoDigest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoDigest.h; sourceTree = "<group>"; }; 12857 E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSA_OAEP.cpp; sourceTree = "<group>"; }; 12858 E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRSA_OAEP.h; sourceTree = "<group>"; }; 12859 E1FE136C183FE21D00892F13 /* CryptoAlgorithmRsaOaepParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoAlgorithmRsaOaepParams.h; path = parameters/CryptoAlgorithmRsaOaepParams.h; sourceTree = "<group>"; }; 12860 E1FE136E183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoAlgorithmRSA_OAEPMac.cpp; path = mac/CryptoAlgorithmRSA_OAEPMac.cpp; sourceTree = "<group>"; }; 12861 E1FE137218402A6700892F13 /* CommonCryptoUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonCryptoUtilities.cpp; sourceTree = "<group>"; }; 12862 E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoUtilities.h; sourceTree = "<group>"; }; 12851 12863 E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadGlobalData.h; sourceTree = "<group>"; }; 12852 12864 E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGlobalData.cpp; sourceTree = "<group>"; }; … … 20407 20419 isa = PBXGroup; 20408 20420 children = ( 20421 E1FE137218402A6700892F13 /* CommonCryptoUtilities.cpp */, 20422 E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */, 20409 20423 E125F843182425C900D84CD9 /* CryptoAlgorithmAES_CBCMac.cpp */, 20410 20424 E125F8371822F1EB00D84CD9 /* CryptoAlgorithmHMACMac.cpp */, 20411 20425 E1BB84AC1822CA7400525043 /* CryptoAlgorithmRegistryMac.cpp */, 20412 20426 E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */, 20427 E1FE136E183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp */, 20413 20428 E19AC3F8182566F700349426 /* CryptoKeyMac.cpp */, 20414 20429 E164FAA418315E1A00DB4E61 /* CryptoKeyRSAMac.cpp */, … … 20425 20440 E125F82F1822F11B00D84CD9 /* CryptoAlgorithmHMAC.cpp */, 20426 20441 E125F8301822F11B00D84CD9 /* CryptoAlgorithmHMAC.h */, 20442 E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */, 20443 E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */, 20427 20444 E1BD3317182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp */, 20428 20445 E1BD3318182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h */, … … 22438 22455 93309DDF099E64920056E581 /* DeleteFromTextNodeCommand.h in Headers */, 22439 22456 07C59B6417F4D1C4000FBCBB /* MockMediaStreamCenter.h in Headers */, 22457 E1FE136B183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h in Headers */, 22440 22458 93309DE1099E64920056E581 /* DeleteSelectionCommand.h in Headers */, 22441 22459 FD1660A513787C6D001FFA7B /* DenormalDisabler.h in Headers */, … … 22587 22605 2ED609BD1145B07100C8684E /* DOMFormData.h in Headers */, 22588 22606 BC1A37B6097C715F0019F3D8 /* DOMHTML.h in Headers */, 22607 E1FE137518402A6700892F13 /* CommonCryptoUtilities.h in Headers */, 22589 22608 85DF81270AA7787200486AD7 /* DOMHTMLAnchorElement.h in Headers */, 22590 22609 B595FF471824CEE300FF51CD /* RenderIterator.h in Headers */, … … 23707 23726 078E092B17D14D1C00420AA1 /* RTCStatsRequestImpl.h in Headers */, 23708 23727 B266CD4E0C3AEC6500EB08D2 /* JSSVGException.h in Headers */, 23728 E1FE136D183FE21D00892F13 /* CryptoAlgorithmRsaOaepParams.h in Headers */, 23709 23729 B2FA3D6B0AB75A6F000E5AC4 /* JSSVGFEBlendElement.h in Headers */, 23710 23730 B2FA3D6D0AB75A6F000E5AC4 /* JSSVGFEColorMatrixElement.h in Headers */, … … 26713 26733 BC6932730D7E293900AE44D1 /* JSDOMWindowBase.cpp in Sources */, 26714 26734 BCD9C2620C17AA67005C90A2 /* JSDOMWindowCustom.cpp in Sources */, 26735 E1FE136A183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp in Sources */, 26715 26736 BCBFB53C0DCD29CF0019B3E5 /* JSDOMWindowShell.cpp in Sources */, 26716 26737 FD7868B9136B999200D403DF /* JSDynamicsCompressorNode.cpp in Sources */, … … 28160 28181 2E3BBF071162DA1100B9409A /* UUID.cpp in Sources */, 28161 28182 50D32857163B313F0016111E /* ValidatedCustomFilterOperation.cpp in Sources */, 28183 E1FE137418402A6700892F13 /* CommonCryptoUtilities.cpp in Sources */, 28162 28184 F5A154271279534D00D0B0C0 /* ValidationMessage.cpp in Sources */, 28163 28185 FD3160AE12B026F700C1A359 /* VectorMath.cpp in Sources */, … … 28203 28225 A0EE0DF5144F825500F80B0D /* WebGLDebugRendererInfo.cpp in Sources */, 28204 28226 A0EE0DF7144F825500F80B0D /* WebGLDebugShaders.cpp in Sources */, 28227 E1FE1370183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp in Sources */, 28205 28228 6E3FAE8E14733FDB00E42307 /* WebGLDepthTexture.cpp in Sources */, 28206 28229 6EBF0E5412A8929800DB1709 /* WebGLExtension.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp
r159717 r159944 36 36 #include "CryptoAlgorithmRsaKeyGenParams.h" 37 37 #include "CryptoAlgorithmRsaKeyParamsWithHash.h" 38 #include "CryptoAlgorithmRsaOaepParams.h" 38 39 #include "CryptoAlgorithmRsaSsaParams.h" 39 40 #include "ExceptionCode.h" … … 245 246 } 246 247 247 static std::unique_ptr<CryptoAlgorithmParameters> createRsa SsaParams(ExecState* exec, JSValue value)248 static std::unique_ptr<CryptoAlgorithmParameters> createRsaOaepParams(ExecState* exec, JSValue value) 248 249 { 249 250 if (!value.isObject()) { … … 253 254 254 255 JSDictionary jsDictionary(exec, value.getObject()); 255 auto result = std::make_unique<CryptoAlgorithmRsa SsaParams>();256 auto result = std::make_unique<CryptoAlgorithmRsaOaepParams>(); 256 257 257 258 if (!getHashAlgorithm(jsDictionary, result->hash)) { … … 260 261 } 261 262 263 JSValue labelValue = getProperty(exec, value.getObject(), "label"); 264 if (exec->hadException()) 265 return nullptr; 266 267 result->hasLabel = !labelValue.isUndefinedOrNull(); 268 if (!result->hasLabel) 269 return std::move(result); 270 271 CryptoOperationData labelData; 272 if (!cryptoOperationDataFromJSValue(exec, labelValue, labelData)) { 273 ASSERT(exec->hadException()); 274 return nullptr; 275 } 276 277 result->label.append(labelData.first, labelData.second); 278 262 279 return std::move(result); 263 280 } 264 281 282 static std::unique_ptr<CryptoAlgorithmParameters> createRsaSsaParams(ExecState* exec, JSValue value) 283 { 284 if (!value.isObject()) { 285 throwTypeError(exec); 286 return nullptr; 287 } 288 289 JSDictionary jsDictionary(exec, value.getObject()); 290 auto result = std::make_unique<CryptoAlgorithmRsaSsaParams>(); 291 292 if (!getHashAlgorithm(jsDictionary, result->hash)) { 293 ASSERT(exec->hadException()); 294 return nullptr; 295 } 296 297 return std::move(result); 298 } 299 265 300 std::unique_ptr<CryptoAlgorithmParameters> JSCryptoAlgorithmDictionary::createParametersForEncrypt(ExecState* exec, CryptoAlgorithmIdentifier algorithm, JSValue value) 266 301 { … … 269 304 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 270 305 case CryptoAlgorithmIdentifier::RSA_PSS: 271 case CryptoAlgorithmIdentifier::RSA_OAEP: 306 setDOMException(exec, NOT_SUPPORTED_ERR); 307 return nullptr; 308 case CryptoAlgorithmIdentifier::RSA_OAEP: 309 return createRsaOaepParams(exec, value); 272 310 case CryptoAlgorithmIdentifier::ECDSA: 273 311 case CryptoAlgorithmIdentifier::ECDH: … … 301 339 case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5: 302 340 case CryptoAlgorithmIdentifier::RSA_PSS: 303 case CryptoAlgorithmIdentifier::RSA_OAEP: 341 setDOMException(exec, NOT_SUPPORTED_ERR); 342 return nullptr; 343 case CryptoAlgorithmIdentifier::RSA_OAEP: 344 return createRsaOaepParams(exec, value); 304 345 case CryptoAlgorithmIdentifier::ECDSA: 305 346 case CryptoAlgorithmIdentifier::ECDH: … … 529 570 return createRsaKeyParamsWithHash(exec, value); 530 571 case CryptoAlgorithmIdentifier::RSA_PSS: 531 case CryptoAlgorithmIdentifier::RSA_OAEP:532 case CryptoAlgorithmIdentifier::ECDSA:533 case CryptoAlgorithmIdentifier::ECDH:534 case CryptoAlgorithmIdentifier::AES_CTR:535 case CryptoAlgorithmIdentifier::AES_CBC:536 case CryptoAlgorithmIdentifier::AES_CMAC:537 case CryptoAlgorithmIdentifier::AES_GCM:538 case CryptoAlgorithmIdentifier::AES_CFB:539 572 return std::make_unique<CryptoAlgorithmParameters>(); 573 case CryptoAlgorithmIdentifier::RSA_OAEP: 574 return createRsaKeyParamsWithHash(exec, value); 575 case CryptoAlgorithmIdentifier::ECDSA: 576 case CryptoAlgorithmIdentifier::ECDH: 577 case CryptoAlgorithmIdentifier::AES_CTR: 578 case CryptoAlgorithmIdentifier::AES_CBC: 579 case CryptoAlgorithmIdentifier::AES_CMAC: 580 case CryptoAlgorithmIdentifier::AES_GCM: 581 case CryptoAlgorithmIdentifier::AES_CFB: 582 return std::make_unique<CryptoAlgorithmParameters>(); 540 583 case CryptoAlgorithmIdentifier::HMAC: 541 584 return createHmacParams(exec, value); -
trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp
r159717 r159944 191 191 algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5); 192 192 parameters = createRSAKeyParametersWithHash(CryptoAlgorithmIdentifier::SHA_512); 193 } else if (m_jwkAlgorithmName == "RSA-OAEP") { 194 algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSA_OAEP); 195 parameters = createRSAKeyParametersWithHash(CryptoAlgorithmIdentifier::SHA_1); 193 196 } else if (m_jwkAlgorithmName == "A128CBC") { 194 197 algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::AES_CBC); … … 219 222 if (algorithm->identifier() == CryptoAlgorithmIdentifier::HMAC) 220 223 return toCryptoAlgorithmHmacParams(*parameters).hash == toCryptoAlgorithmHmacParams(*suggestedParameters).hash; 221 if (algorithm->identifier() == CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5) { 224 if (algorithm->identifier() == CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5 225 || algorithm->identifier() == CryptoAlgorithmIdentifier::RSA_OAEP) { 222 226 CryptoAlgorithmRsaKeyParamsWithHash& rsaKeyParameters = toCryptoAlgorithmRsaKeyParamsWithHash(*parameters); 223 227 CryptoAlgorithmRsaKeyParamsWithHash& suggestedRSAKeyParameters = toCryptoAlgorithmRsaKeyParamsWithHash(*suggestedParameters); … … 284 288 if (m_jwkAlgorithmName == "RS512") 285 289 return sizeInBits >= 2048; 290 if (m_jwkAlgorithmName == "RSA_OAEP") 291 return sizeInBits >= 2048; 286 292 return true; 287 293 } … … 537 543 break; 538 544 } 545 break; 546 } 547 case CryptoAlgorithmIdentifier::RSA_OAEP: { 548 const CryptoKeyRSA& rsaKey = toCryptoKeyRSA(key); 549 CryptoAlgorithmIdentifier hash; 550 // WebCrypto RSA-OAEP keys are not tied to any particular hash, unless previously imported from JWK, which only supports SHA-1. 551 if (rsaKey.isRestrictedToHash(hash) && hash != CryptoAlgorithmIdentifier::SHA_1) 552 break; 553 if (rsaKey.keySizeInBits() < 2048) 554 break; 555 jwkAlgorithm = "RSA-OAEP"; 539 556 break; 540 557 } -
trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h
r159717 r159944 47 47 RsaKeyGenParams, 48 48 RsaKeyParamsWithHash, 49 RsaOaepParams, 49 50 RsaSsaParams 50 51 }; -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp
r159717 r159944 36 36 namespace WebCore { 37 37 38 static bool getCommonCrypto Algorithm(CryptoAlgorithmIdentifier hashFunction, CCHmacAlgorithm& algorithm)38 static bool getCommonCryptoHMACAlgorithm(CryptoAlgorithmIdentifier hashFunction, CCHmacAlgorithm& algorithm) 39 39 { 40 40 switch (hashFunction) { … … 92 92 { 93 93 CCHmacAlgorithm algorithm; 94 if (!getCommonCrypto Algorithm(parameters.hash, algorithm)) {94 if (!getCommonCryptoHMACAlgorithm(parameters.hash, algorithm)) { 95 95 ec = NOT_SUPPORTED_ERR; 96 96 return; … … 105 105 { 106 106 CCHmacAlgorithm algorithm; 107 if (!getCommonCrypto Algorithm(parameters.hash, algorithm)) {107 if (!getCommonCryptoHMACAlgorithm(parameters.hash, algorithm)) { 108 108 ec = NOT_SUPPORTED_ERR; 109 109 return; -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp
r159717 r159944 29 29 #if ENABLE(SUBTLE_CRYPTO) 30 30 31 #include "CommonCryptoUtilities.h" 31 32 #include "CryptoAlgorithmRsaSsaParams.h" 32 33 #include "CryptoDigest.h" … … 35 36 #include <CommonCrypto/CommonCryptor.h> 36 37 37 #if defined(__has_include)38 #if __has_include(<CommonCrypto/CommonRSACryptor.h>)39 #include <CommonCrypto/CommonRSACryptor.h>40 #endif41 #endif42 43 #ifndef _CC_RSACRYPTOR_H_44 enum {45 ccPKCS1Padding = 100146 };47 typedef uint32_t CCAsymmetricPadding;48 49 enum {50 kCCDigestSHA1 = 8,51 kCCDigestSHA224 = 9,52 kCCDigestSHA256 = 10,53 kCCDigestSHA384 = 11,54 kCCDigestSHA512 = 12,55 };56 typedef uint32_t CCDigestAlgorithm;57 58 enum {59 kCCNotVerified = -430660 };61 #endif62 63 extern "C" CCCryptorStatus CCRSACryptorSign(CCRSACryptorRef privateKey, CCAsymmetricPadding padding, const void *hashToSign, size_t hashSignLen, CCDigestAlgorithm digestType, size_t saltLen, void *signedData, size_t *signedDataLen);64 extern "C" CCCryptorStatus CCRSACryptorVerify(CCRSACryptorRef publicKey, CCAsymmetricPadding padding, const void *hash, size_t hashLen, CCDigestAlgorithm digestType, size_t saltLen, const void *signedData, size_t signedDataLen);65 66 38 namespace WebCore { 67 68 static bool getCommonCryptoDigestAlgorithm(CryptoAlgorithmIdentifier hashFunction, CCDigestAlgorithm& algorithm)69 {70 switch (hashFunction) {71 case CryptoAlgorithmIdentifier::SHA_1:72 algorithm = kCCDigestSHA1;73 return true;74 case CryptoAlgorithmIdentifier::SHA_224:75 algorithm = kCCDigestSHA224;76 return true;77 case CryptoAlgorithmIdentifier::SHA_256:78 algorithm = kCCDigestSHA256;79 return true;80 case CryptoAlgorithmIdentifier::SHA_384:81 algorithm = kCCDigestSHA384;82 return true;83 case CryptoAlgorithmIdentifier::SHA_512:84 algorithm = kCCDigestSHA512;85 return true;86 default:87 return false;88 }89 }90 39 91 40 void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoAlgorithmRsaSsaParams& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec) -
trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp
r159717 r159944 32 32 #include "CryptoAlgorithmHMAC.h" 33 33 #include "CryptoAlgorithmRSASSA_PKCS1_v1_5.h" 34 #include "CryptoAlgorithmRSA_OAEP.h" 34 35 #include "CryptoAlgorithmSHA1.h" 35 36 #include "CryptoAlgorithmSHA224.h" … … 45 46 registerAlgorithm<CryptoAlgorithmHMAC>(); 46 47 registerAlgorithm<CryptoAlgorithmRSASSA_PKCS1_v1_5>(); 48 registerAlgorithm<CryptoAlgorithmRSA_OAEP>(); 47 49 registerAlgorithm<CryptoAlgorithmSHA1>(); 48 50 registerAlgorithm<CryptoAlgorithmSHA224>(); -
trunk/Source/WebCore/crypto/mac/CryptoKeyMac.cpp
r159390 r159944 29 29 #if ENABLE(SUBTLE_CRYPTO) 30 30 31 #if defined(__has_include) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) 32 #if __has_include(<CommonCrypto/CommonRandomSPI.h>) 33 #include <CommonCrypto/CommonRandomSPI.h> 34 #endif 35 #endif 36 37 typedef struct __CCRandom *CCRandomRef; 38 extern const CCRandomRef kCCRandomDefault; 39 extern "C" int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count); 31 #include "CommonCryptoUtilities.h" 40 32 41 33 namespace WebCore { -
trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp
r159578 r159944 29 29 #if ENABLE(SUBTLE_CRYPTO) 30 30 31 #include "CommonCryptoUtilities.h" 31 32 #include "CryptoAlgorithmDescriptionBuilder.h" 32 33 #include "CryptoAlgorithmRegistry.h" … … 34 35 #include "CryptoKeyPair.h" 35 36 #include <CommonCrypto/CommonCryptor.h> 36 37 #if defined(__has_include)38 #if __has_include(<CommonCrypto/CommonRSACryptor.h>)39 #include <CommonCrypto/CommonRSACryptor.h>40 #endif41 #endif42 43 #ifndef _CC_RSACRYPTOR_H_44 enum {45 ccRSAKeyPublic = 0,46 ccRSAKeyPrivate = 147 };48 typedef uint32_t CCRSAKeyType;49 #endif50 51 extern "C" CCCryptorStatus CCRSACryptorCreateFromData(CCRSAKeyType keyType, uint8_t *modulus, size_t modulusLength, uint8_t *exponent, size_t exponentLength, uint8_t *p, size_t pLength, uint8_t *q, size_t qLength, CCRSACryptorRef *ref);52 extern "C" CCCryptorStatus CCRSACryptorGeneratePair(size_t keysize, uint32_t e, CCRSACryptorRef *publicKey, CCRSACryptorRef *privateKey);53 extern "C" CCRSACryptorRef CCRSACryptorGetPublicKeyFromPrivateKey(CCRSACryptorRef privkey);54 extern "C" void CCRSACryptorRelease(CCRSACryptorRef key);55 extern "C" CCCryptorStatus CCRSAGetKeyComponents(CCRSACryptorRef rsaKey, uint8_t *modulus, size_t *modulusLength, uint8_t *exponent, size_t *exponentLength, uint8_t *p, size_t *pLength, uint8_t *q, size_t *qLength);56 extern "C" CCRSAKeyType CCRSAGetKeyType(CCRSACryptorRef key);57 37 58 38 namespace WebCore {
Note: See TracChangeset
for help on using the changeset viewer.