Skip to content

Commit acf7f02

Browse files
Move crypto code from ExceptionCode to ExceptionOr
https://bugs.webkit.org/show_bug.cgi?id=164698 Reviewed by Sam Weinig. * bindings/js/JSCryptoAlgorithmDictionary.cpp: (WebCore::JSCryptoAlgorithmDictionary::getAlgorithmIdentifier): Use the new identifier function instead of getIdentifierForName. * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::normalizeCryptoAlgorithmParameters): Ditto. (WebCore::toCryptoKeyUsageBitmap): Removed a stray meaningless const. (WebCore::jsSubtleCryptoFunctionGenerateKeyPromise): Pass ScriptExecutionContext as a reference instead of a pointer. * bindings/js/JSWebKitSubtleCryptoCustom.cpp: (WebCore::createAlgorithmFromJSValue): Use the more efficient version of setDOMException that uses scope. (WebCore::JSWebKitSubtleCrypto::encrypt): Ditto. Also updated to use ExceptionOr instead of ExceptionCode. (WebCore::JSWebKitSubtleCrypto::decrypt): Ditto. (WebCore::JSWebKitSubtleCrypto::sign): Ditto. (WebCore::JSWebKitSubtleCrypto::verify): Ditto. (WebCore::JSWebKitSubtleCrypto::digest): Ditto. (WebCore::JSWebKitSubtleCrypto::generateKey): Ditto. (WebCore::importKey): Ditto. (WebCore::JSWebKitSubtleCrypto::wrapKey): Ditto. (WebCore::JSWebKitSubtleCrypto::unwrapKey): Ditto. * crypto/CryptoAlgorithm.cpp: (WebCore::CryptoAlgorithm::CryptoAlgorithm): Deleted. (WebCore::CryptoAlgorithm::~CryptoAlgorithm): Deleted. (WebCore::CryptoAlgorithm::generateKey): Use ExceptionOr. (WebCore::CryptoAlgorithm::encrypt): Ditto. (WebCore::CryptoAlgorithm::decrypt): Ditto. (WebCore::CryptoAlgorithm::sign): Ditto. (WebCore::CryptoAlgorithm::verify): Ditto. (WebCore::CryptoAlgorithm::digest): Ditto. (WebCore::CryptoAlgorithm::deriveKey): Ditto. (WebCore::CryptoAlgorithm::deriveBits): Ditto. (WebCore::CryptoAlgorithm::importKey): Ditto. (WebCore::CryptoAlgorithm::encryptForWrapKey): Ditto. (WebCore::CryptoAlgorithm::decryptForUnwrapKey): Ditto. * crypto/CryptoAlgorithm.h: Use ExceptionOr. Moved the destructor into the header since it's more efficient for derived classes to have it inlined. Removed the protected constructor because since there are pure virtual functions in the class, there is no risk of anyone misusing the public constructor. * crypto/CryptoAlgorithmRegistry.cpp: (WebCore::CryptoAlgorithmRegistry::identifier): Renamed from getIdentifierForName and changed to use an Optional rather than using a boolean plus an out argument. (WebCore::CryptoAlgorithmRegistry::name): Renamed to name from nameForIdentifier. Also updated to share a single map containing both names and constructors. (WebCore::CryptoAlgorithmRegistry::create): Share single map as above. (WebCore::CryptoAlgorithmRegistry::registerAlgorithm): Updated assertions to a mroe straightforward style. Share single map for names and constructors. * crypto/CryptoAlgorithmRegistry.h: Updated for above. * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp: (WebCore::CryptoAlgorithmAES_CBC::CryptoAlgorithmAES_CBC): Deleted. (WebCore::CryptoAlgorithmAES_CBC::~CryptoAlgorithmAES_CBC): Deleted. (WebCore::CryptoAlgorithmAES_CBC::keyAlgorithmMatches): Use references, ExceptionOr. (WebCore::CryptoAlgorithmAES_CBC::generateKey): Ditto. (WebCore::CryptoAlgorithmAES_CBC::encrypt): Ditto. (WebCore::CryptoAlgorithmAES_CBC::decrypt): Ditto. (WebCore::CryptoAlgorithmAES_CBC::importKey): Ditto. * crypto/algorithms/CryptoAlgorithmAES_CBC.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmAES_KW.cpp: (WebCore::CryptoAlgorithmAES_KW::CryptoAlgorithmAES_KW): Deleted. (WebCore::CryptoAlgorithmAES_KW::~CryptoAlgorithmAES_KW): Deleted. (WebCore::CryptoAlgorithmAES_KW::keyAlgorithmMatches): Use references, ExceptionOr. (WebCore::CryptoAlgorithmAES_KW::generateKey): Ditto. (WebCore::CryptoAlgorithmAES_KW::importKey): Ditto. (WebCore::CryptoAlgorithmAES_KW::encryptForWrapKey): Ditto. (WebCore::CryptoAlgorithmAES_KW::decryptForUnwrapKey): Ditto. * crypto/algorithms/CryptoAlgorithmAES_KW.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmHMAC.cpp: (WebCore::CryptoAlgorithmHMAC::CryptoAlgorithmHMAC): Deleted. (WebCore::CryptoAlgorithmHMAC::~CryptoAlgorithmHMAC): Deleted. (WebCore::CryptoAlgorithmHMAC::generateKey): Use references, ExceptionOr. (WebCore::CryptoAlgorithmHMAC::sign): Ditto. (WebCore::CryptoAlgorithmHMAC::verify): Ditto. (WebCore::CryptoAlgorithmHMAC::importKey): Ditto. * crypto/algorithms/CryptoAlgorithmHMAC.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::CryptoAlgorithmRSAES_PKCS1_v1_5): Deleted. (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::~CryptoAlgorithmRSAES_PKCS1_v1_5): Deleted. (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey): Use references, ExceptionOr. (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt): Ditto. (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt): Ditto. (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey): Ditto. * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp: (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::CryptoAlgorithmRSASSA_PKCS1_v1_5): Deleted. (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::~CryptoAlgorithmRSASSA_PKCS1_v1_5): Deleted. (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey): Use references, ExceptionOr. (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign): Ditto. (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify): Ditto. (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey): Ditto. * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp: (WebCore::CryptoAlgorithmRSA_OAEP::CryptoAlgorithmRSA_OAEP): Deleted. (WebCore::CryptoAlgorithmRSA_OAEP::~CryptoAlgorithmRSA_OAEP): Deleted. (WebCore::CryptoAlgorithmRSA_OAEP::generateKey): Use references, ExceptionOr. (WebCore::CryptoAlgorithmRSA_OAEP::encrypt): Ditto. (WebCore::CryptoAlgorithmRSA_OAEP::decrypt): Ditto. (WebCore::CryptoAlgorithmRSA_OAEP::importKey): Ditto. * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmSHA1.cpp: (WebCore::CryptoAlgorithmSHA1::CryptoAlgorithmSHA1): Deleted. (WebCore::CryptoAlgorithmSHA1::~CryptoAlgorithmSHA1): Deleted. (WebCore::CryptoAlgorithmSHA1::digest): Use ExceptionOr. * crypto/algorithms/CryptoAlgorithmSHA1.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmSHA224.cpp: (WebCore::CryptoAlgorithmSHA224::CryptoAlgorithmSHA224): Deleted. (WebCore::CryptoAlgorithmSHA224::~CryptoAlgorithmSHA224): Deleted. (WebCore::CryptoAlgorithmSHA224::digest): Use ExceptionOr. * crypto/algorithms/CryptoAlgorithmSHA224.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmSHA256.cpp: (WebCore::CryptoAlgorithmSHA256::CryptoAlgorithmSHA256): Deleted. (WebCore::CryptoAlgorithmSHA256::~CryptoAlgorithmSHA256): Deleted. (WebCore::CryptoAlgorithmSHA256::digest): Use ExceptionOr. * crypto/algorithms/CryptoAlgorithmSHA256.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmSHA384.cpp: (WebCore::CryptoAlgorithmSHA384::CryptoAlgorithmSHA384): Deleted. (WebCore::CryptoAlgorithmSHA384::~CryptoAlgorithmSHA384): Deleted. (WebCore::CryptoAlgorithmSHA384::digest): Use ExceptionOr. * crypto/algorithms/CryptoAlgorithmSHA384.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/algorithms/CryptoAlgorithmSHA512.cpp: (WebCore::CryptoAlgorithmSHA512::CryptoAlgorithmSHA512): Deleted. (WebCore::CryptoAlgorithmSHA512::~CryptoAlgorithmSHA512): Deleted. (WebCore::CryptoAlgorithmSHA512::digest): Use ExceptionOr. * crypto/algorithms/CryptoAlgorithmSHA512.h: Updated for above. Also use constexpr for s_name and s_identifier. * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp: (WebCore::calculateSignature): Use Optional instead of a boolean return value and an out argument. (WebCore::CryptoAlgorithmHMAC::platformSign): Use ExceptionOr. (WebCore::CryptoAlgorithmHMAC::platformVerify): Ditto. * crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp: (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt): Ditto. (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt): Ditto. * crypto/gnutls/CryptoAlgorithmAES_KWGnuTLS.cpp: (WebCore::CryptoAlgorithmAES_KW::platformEncrypt): Ditto. (WebCore::CryptoAlgorithmAES_KW::platformDecrypt): Ditto. * crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp: (WebCore::CryptoAlgorithmHMAC::platformSign): Ditto. (WebCore::CryptoAlgorithmHMAC::platformVerify): Ditto. * crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp: (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt): Ditto. (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt): Ditto. * crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp: (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign): Ditto. (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify): Ditto. * crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp: (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt): Ditto. (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt): Ditto. * crypto/keys/CryptoKeyAES.cpp: (WebCore::CryptoKeyAES::buildAlgorithm): Updated to use name instead of nameForIdentifier. * crypto/keys/CryptoKeyHMAC.cpp: Ditto. (WebCore::CryptoKeyHMAC::buildAlgorithm): * crypto/mac/CryptoAlgorithmAES_CBCMac.cpp: (WebCore::CryptoAlgorithmAES_CBC::platformEncrypt): Use ExceptionOr. (WebCore::CryptoAlgorithmAES_CBC::platformDecrypt): Ditto. * crypto/mac/CryptoAlgorithmAES_KWMac.cpp: (WebCore::CryptoAlgorithmAES_KW::platformEncrypt): Ditto. (WebCore::CryptoAlgorithmAES_KW::platformDecrypt): Ditto. * crypto/mac/CryptoAlgorithmHMACMac.cpp: (WebCore::commonCryptoHMACAlgorithm): Renamed from getCommonCryptoHMACAlgorithm and changed to use Optional instead of a boolean return value and an out argument. (WebCore::CryptoAlgorithmHMAC::platformSign): Use ExceptionOr. (WebCore::CryptoAlgorithmHMAC::platformVerify): Ditto. * crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp: (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt): Ditto. (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt): Ditto. * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp: (WebCore::cryptoDigestAlgorithm): Renamed from getCryptoDigestAlgorithm and changed to use Optional instead of a boolean return value and an out argument. (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign): Use ExceptionOr. (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify): Ditto. * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp: (WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt): Ditto. (WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt): Ditto. * crypto/mac/CryptoKeyRSAMac.cpp: (WebCore::CryptoKeyRSA::buildAlgorithm): Updated to use name instead of nameForIdentifier. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@208669 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 46c0f52 commit acf7f02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+708
-835
lines changed

Source/WebCore/ChangeLog

+218
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,221 @@
1+
2016-11-13 Darin Adler <[email protected]>
2+
3+
Move crypto code from ExceptionCode to ExceptionOr
4+
https://bugs.webkit.org/show_bug.cgi?id=164698
5+
6+
Reviewed by Sam Weinig.
7+
8+
* bindings/js/JSCryptoAlgorithmDictionary.cpp:
9+
(WebCore::JSCryptoAlgorithmDictionary::getAlgorithmIdentifier):
10+
Use the new identifier function instead of getIdentifierForName.
11+
* bindings/js/JSSubtleCryptoCustom.cpp:
12+
(WebCore::normalizeCryptoAlgorithmParameters): Ditto.
13+
(WebCore::toCryptoKeyUsageBitmap): Removed a stray meaningless const.
14+
(WebCore::jsSubtleCryptoFunctionGenerateKeyPromise): Pass
15+
ScriptExecutionContext as a reference instead of a pointer.
16+
17+
* bindings/js/JSWebKitSubtleCryptoCustom.cpp:
18+
(WebCore::createAlgorithmFromJSValue): Use the more efficient version
19+
of setDOMException that uses scope.
20+
(WebCore::JSWebKitSubtleCrypto::encrypt): Ditto. Also updated to use
21+
ExceptionOr instead of ExceptionCode.
22+
(WebCore::JSWebKitSubtleCrypto::decrypt): Ditto.
23+
(WebCore::JSWebKitSubtleCrypto::sign): Ditto.
24+
(WebCore::JSWebKitSubtleCrypto::verify): Ditto.
25+
(WebCore::JSWebKitSubtleCrypto::digest): Ditto.
26+
(WebCore::JSWebKitSubtleCrypto::generateKey): Ditto.
27+
(WebCore::importKey): Ditto.
28+
(WebCore::JSWebKitSubtleCrypto::wrapKey): Ditto.
29+
(WebCore::JSWebKitSubtleCrypto::unwrapKey): Ditto.
30+
31+
* crypto/CryptoAlgorithm.cpp:
32+
(WebCore::CryptoAlgorithm::CryptoAlgorithm): Deleted.
33+
(WebCore::CryptoAlgorithm::~CryptoAlgorithm): Deleted.
34+
(WebCore::CryptoAlgorithm::generateKey): Use ExceptionOr.
35+
(WebCore::CryptoAlgorithm::encrypt): Ditto.
36+
(WebCore::CryptoAlgorithm::decrypt): Ditto.
37+
(WebCore::CryptoAlgorithm::sign): Ditto.
38+
(WebCore::CryptoAlgorithm::verify): Ditto.
39+
(WebCore::CryptoAlgorithm::digest): Ditto.
40+
(WebCore::CryptoAlgorithm::deriveKey): Ditto.
41+
(WebCore::CryptoAlgorithm::deriveBits): Ditto.
42+
(WebCore::CryptoAlgorithm::importKey): Ditto.
43+
(WebCore::CryptoAlgorithm::encryptForWrapKey): Ditto.
44+
(WebCore::CryptoAlgorithm::decryptForUnwrapKey): Ditto.
45+
* crypto/CryptoAlgorithm.h: Use ExceptionOr.
46+
Moved the destructor into the header since it's more efficient for
47+
derived classes to have it inlined. Removed the protected constructor
48+
because since there are pure virtual functions in the class, there is
49+
no risk of anyone misusing the public constructor.
50+
51+
* crypto/CryptoAlgorithmRegistry.cpp:
52+
(WebCore::CryptoAlgorithmRegistry::identifier): Renamed from
53+
getIdentifierForName and changed to use an Optional rather than
54+
using a boolean plus an out argument.
55+
(WebCore::CryptoAlgorithmRegistry::name): Renamed to name from
56+
nameForIdentifier. Also updated to share a single map containing
57+
both names and constructors.
58+
(WebCore::CryptoAlgorithmRegistry::create): Share single map as above.
59+
(WebCore::CryptoAlgorithmRegistry::registerAlgorithm): Updated assertions
60+
to a mroe straightforward style. Share single map for names and constructors.
61+
* crypto/CryptoAlgorithmRegistry.h: Updated for above.
62+
63+
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
64+
(WebCore::CryptoAlgorithmAES_CBC::CryptoAlgorithmAES_CBC): Deleted.
65+
(WebCore::CryptoAlgorithmAES_CBC::~CryptoAlgorithmAES_CBC): Deleted.
66+
(WebCore::CryptoAlgorithmAES_CBC::keyAlgorithmMatches): Use references, ExceptionOr.
67+
(WebCore::CryptoAlgorithmAES_CBC::generateKey): Ditto.
68+
(WebCore::CryptoAlgorithmAES_CBC::encrypt): Ditto.
69+
(WebCore::CryptoAlgorithmAES_CBC::decrypt): Ditto.
70+
(WebCore::CryptoAlgorithmAES_CBC::importKey): Ditto.
71+
* crypto/algorithms/CryptoAlgorithmAES_CBC.h: Updated for above.
72+
Also use constexpr for s_name and s_identifier.
73+
74+
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
75+
(WebCore::CryptoAlgorithmAES_KW::CryptoAlgorithmAES_KW): Deleted.
76+
(WebCore::CryptoAlgorithmAES_KW::~CryptoAlgorithmAES_KW): Deleted.
77+
(WebCore::CryptoAlgorithmAES_KW::keyAlgorithmMatches): Use references, ExceptionOr.
78+
(WebCore::CryptoAlgorithmAES_KW::generateKey): Ditto.
79+
(WebCore::CryptoAlgorithmAES_KW::importKey): Ditto.
80+
(WebCore::CryptoAlgorithmAES_KW::encryptForWrapKey): Ditto.
81+
(WebCore::CryptoAlgorithmAES_KW::decryptForUnwrapKey): Ditto.
82+
* crypto/algorithms/CryptoAlgorithmAES_KW.h: Updated for above.
83+
Also use constexpr for s_name and s_identifier.
84+
85+
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
86+
(WebCore::CryptoAlgorithmHMAC::CryptoAlgorithmHMAC): Deleted.
87+
(WebCore::CryptoAlgorithmHMAC::~CryptoAlgorithmHMAC): Deleted.
88+
(WebCore::CryptoAlgorithmHMAC::generateKey): Use references, ExceptionOr.
89+
(WebCore::CryptoAlgorithmHMAC::sign): Ditto.
90+
(WebCore::CryptoAlgorithmHMAC::verify): Ditto.
91+
(WebCore::CryptoAlgorithmHMAC::importKey): Ditto.
92+
* crypto/algorithms/CryptoAlgorithmHMAC.h: Updated for above.
93+
Also use constexpr for s_name and s_identifier.
94+
95+
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
96+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::CryptoAlgorithmRSAES_PKCS1_v1_5): Deleted.
97+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::~CryptoAlgorithmRSAES_PKCS1_v1_5): Deleted.
98+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey): Use references, ExceptionOr.
99+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt): Ditto.
100+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt): Ditto.
101+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::importKey): Ditto.
102+
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.h: Updated for above.
103+
Also use constexpr for s_name and s_identifier.
104+
105+
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
106+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::CryptoAlgorithmRSASSA_PKCS1_v1_5): Deleted.
107+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::~CryptoAlgorithmRSASSA_PKCS1_v1_5): Deleted.
108+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey): Use references, ExceptionOr.
109+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign): Ditto.
110+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify): Ditto.
111+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::importKey): Ditto.
112+
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h: Updated for above.
113+
Also use constexpr for s_name and s_identifier.
114+
115+
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
116+
(WebCore::CryptoAlgorithmRSA_OAEP::CryptoAlgorithmRSA_OAEP): Deleted.
117+
(WebCore::CryptoAlgorithmRSA_OAEP::~CryptoAlgorithmRSA_OAEP): Deleted.
118+
(WebCore::CryptoAlgorithmRSA_OAEP::generateKey): Use references, ExceptionOr.
119+
(WebCore::CryptoAlgorithmRSA_OAEP::encrypt): Ditto.
120+
(WebCore::CryptoAlgorithmRSA_OAEP::decrypt): Ditto.
121+
(WebCore::CryptoAlgorithmRSA_OAEP::importKey): Ditto.
122+
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: Updated for above.
123+
Also use constexpr for s_name and s_identifier.
124+
125+
* crypto/algorithms/CryptoAlgorithmSHA1.cpp:
126+
(WebCore::CryptoAlgorithmSHA1::CryptoAlgorithmSHA1): Deleted.
127+
(WebCore::CryptoAlgorithmSHA1::~CryptoAlgorithmSHA1): Deleted.
128+
(WebCore::CryptoAlgorithmSHA1::digest): Use ExceptionOr.
129+
* crypto/algorithms/CryptoAlgorithmSHA1.h: Updated for above.
130+
Also use constexpr for s_name and s_identifier.
131+
132+
* crypto/algorithms/CryptoAlgorithmSHA224.cpp:
133+
(WebCore::CryptoAlgorithmSHA224::CryptoAlgorithmSHA224): Deleted.
134+
(WebCore::CryptoAlgorithmSHA224::~CryptoAlgorithmSHA224): Deleted.
135+
(WebCore::CryptoAlgorithmSHA224::digest): Use ExceptionOr.
136+
* crypto/algorithms/CryptoAlgorithmSHA224.h: Updated for above.
137+
Also use constexpr for s_name and s_identifier.
138+
139+
* crypto/algorithms/CryptoAlgorithmSHA256.cpp:
140+
(WebCore::CryptoAlgorithmSHA256::CryptoAlgorithmSHA256): Deleted.
141+
(WebCore::CryptoAlgorithmSHA256::~CryptoAlgorithmSHA256): Deleted.
142+
(WebCore::CryptoAlgorithmSHA256::digest): Use ExceptionOr.
143+
* crypto/algorithms/CryptoAlgorithmSHA256.h: Updated for above.
144+
Also use constexpr for s_name and s_identifier.
145+
146+
* crypto/algorithms/CryptoAlgorithmSHA384.cpp:
147+
(WebCore::CryptoAlgorithmSHA384::CryptoAlgorithmSHA384): Deleted.
148+
(WebCore::CryptoAlgorithmSHA384::~CryptoAlgorithmSHA384): Deleted.
149+
(WebCore::CryptoAlgorithmSHA384::digest): Use ExceptionOr.
150+
* crypto/algorithms/CryptoAlgorithmSHA384.h: Updated for above.
151+
Also use constexpr for s_name and s_identifier.
152+
153+
* crypto/algorithms/CryptoAlgorithmSHA512.cpp:
154+
(WebCore::CryptoAlgorithmSHA512::CryptoAlgorithmSHA512): Deleted.
155+
(WebCore::CryptoAlgorithmSHA512::~CryptoAlgorithmSHA512): Deleted.
156+
(WebCore::CryptoAlgorithmSHA512::digest): Use ExceptionOr.
157+
* crypto/algorithms/CryptoAlgorithmSHA512.h: Updated for above.
158+
Also use constexpr for s_name and s_identifier.
159+
160+
* crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
161+
(WebCore::calculateSignature): Use Optional instead of a boolean
162+
return value and an out argument.
163+
(WebCore::CryptoAlgorithmHMAC::platformSign): Use ExceptionOr.
164+
(WebCore::CryptoAlgorithmHMAC::platformVerify): Ditto.
165+
* crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp:
166+
(WebCore::CryptoAlgorithmAES_CBC::platformEncrypt): Ditto.
167+
(WebCore::CryptoAlgorithmAES_CBC::platformDecrypt): Ditto.
168+
* crypto/gnutls/CryptoAlgorithmAES_KWGnuTLS.cpp:
169+
(WebCore::CryptoAlgorithmAES_KW::platformEncrypt): Ditto.
170+
(WebCore::CryptoAlgorithmAES_KW::platformDecrypt): Ditto.
171+
* crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp:
172+
(WebCore::CryptoAlgorithmHMAC::platformSign): Ditto.
173+
(WebCore::CryptoAlgorithmHMAC::platformVerify): Ditto.
174+
* crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp:
175+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt): Ditto.
176+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt): Ditto.
177+
* crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp:
178+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign): Ditto.
179+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify): Ditto.
180+
* crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp:
181+
(WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt): Ditto.
182+
(WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt): Ditto.
183+
184+
* crypto/keys/CryptoKeyAES.cpp:
185+
(WebCore::CryptoKeyAES::buildAlgorithm): Updated to use name instead
186+
of nameForIdentifier.
187+
* crypto/keys/CryptoKeyHMAC.cpp: Ditto.
188+
(WebCore::CryptoKeyHMAC::buildAlgorithm):
189+
190+
* crypto/mac/CryptoAlgorithmAES_CBCMac.cpp:
191+
(WebCore::CryptoAlgorithmAES_CBC::platformEncrypt): Use ExceptionOr.
192+
(WebCore::CryptoAlgorithmAES_CBC::platformDecrypt): Ditto.
193+
* crypto/mac/CryptoAlgorithmAES_KWMac.cpp:
194+
(WebCore::CryptoAlgorithmAES_KW::platformEncrypt): Ditto.
195+
(WebCore::CryptoAlgorithmAES_KW::platformDecrypt): Ditto.
196+
* crypto/mac/CryptoAlgorithmHMACMac.cpp:
197+
(WebCore::commonCryptoHMACAlgorithm): Renamed from
198+
getCommonCryptoHMACAlgorithm and changed to use Optional instead of
199+
a boolean return value and an out argument.
200+
(WebCore::CryptoAlgorithmHMAC::platformSign): Use ExceptionOr.
201+
(WebCore::CryptoAlgorithmHMAC::platformVerify): Ditto.
202+
* crypto/mac/CryptoAlgorithmRSAES_PKCS1_v1_5Mac.cpp:
203+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformEncrypt): Ditto.
204+
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::platformDecrypt): Ditto.
205+
* crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
206+
(WebCore::cryptoDigestAlgorithm): Renamed from
207+
getCryptoDigestAlgorithm and changed to use Optional instead of
208+
a boolean return value and an out argument.
209+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign): Use ExceptionOr.
210+
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify): Ditto.
211+
* crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp:
212+
(WebCore::CryptoAlgorithmRSA_OAEP::platformEncrypt): Ditto.
213+
(WebCore::CryptoAlgorithmRSA_OAEP::platformDecrypt): Ditto.
214+
215+
* crypto/mac/CryptoKeyRSAMac.cpp:
216+
(WebCore::CryptoKeyRSA::buildAlgorithm): Updated to use name instead
217+
of nameForIdentifier.
218+
1219
2016-11-13 Joseph Pecoraro <[email protected]>
2220

3221
Use #pragma once in WebCore

Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ bool JSCryptoAlgorithmDictionary::getAlgorithmIdentifier(ExecState* exec, JSValu
8787
return false;
8888
}
8989

90-
if (!CryptoAlgorithmRegistry::singleton().getIdentifierForName(algorithmName, algorithmIdentifier)) {
90+
auto identifier = CryptoAlgorithmRegistry::singleton().identifier(algorithmName);
91+
if (!identifier) {
9192
setDOMException(exec, NOT_SUPPORTED_ERR);
9293
return false;
9394
}
9495

96+
algorithmIdentifier = *identifier;
9597
return true;
9698
}
9799

Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParame
8181
auto params = convertDictionary<CryptoAlgorithmParameters>(state, value);
8282
RETURN_IF_EXCEPTION(scope, nullptr);
8383

84-
CryptoAlgorithmIdentifier identifier;
85-
if (!CryptoAlgorithmRegistry::singleton().getIdentifierForName(params.name, identifier)) {
84+
auto identifier = CryptoAlgorithmRegistry::singleton().identifier(params.name);
85+
if (!identifier) {
8686
setDOMException(&state, NOT_SUPPORTED_ERR);
8787
return nullptr;
8888
}
8989

9090
std::unique_ptr<CryptoAlgorithmParameters> result;
9191
switch (operation) {
9292
case Operations::Digest:
93-
switch (identifier) {
93+
switch (*identifier) {
9494
case CryptoAlgorithmIdentifier::SHA_1:
9595
case CryptoAlgorithmIdentifier::SHA_224:
9696
case CryptoAlgorithmIdentifier::SHA_256:
@@ -104,7 +104,7 @@ static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParame
104104
}
105105
break;
106106
case Operations::GenerateKey:
107-
switch (identifier) {
107+
switch (*identifier) {
108108
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5: {
109109
auto params = convertDictionary<CryptoAlgorithmRsaKeyGenParams>(state, value);
110110
RETURN_IF_EXCEPTION(scope, nullptr);
@@ -146,7 +146,7 @@ static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParame
146146
}
147147
break;
148148
case Operations::ImportKey:
149-
switch (identifier) {
149+
switch (*identifier) {
150150
case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
151151
result = std::make_unique<CryptoAlgorithmParameters>(params);
152152
break;
@@ -186,15 +186,15 @@ static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParame
186186
return nullptr;
187187
}
188188

189-
result->identifier = identifier;
189+
result->identifier = *identifier;
190190
return result;
191191
}
192192

193193
throwTypeError(&state, scope, ASCIILiteral("Invalid AlgorithmIdentifier"));
194194
return nullptr;
195195
}
196196

197-
static CryptoKeyUsageBitmap toCryptoKeyUsageBitmap(const CryptoKeyUsage usage)
197+
static CryptoKeyUsageBitmap toCryptoKeyUsageBitmap(CryptoKeyUsage usage)
198198
{
199199
switch (usage) {
200200
case CryptoKeyUsage::Encrypt:
@@ -353,7 +353,7 @@ static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<Defer
353353
// The spec suggests we should perform the following task asynchronously regardless what kind of keys it produces
354354
// as of 11 December 2014: https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-generateKey
355355
// That's simply not efficient for AES and HMAC keys. Therefore, we perform it as an async task conditionally.
356-
algorithm->generateKey(WTFMove(params), extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback), scriptExecutionContextFromExecState(&state));
356+
algorithm->generateKey(WTFMove(params), extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state));
357357
}
358358

359359
static void jsSubtleCryptoFunctionImportKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)

0 commit comments

Comments
 (0)