|
| 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 | + |
1 | 219 | 2016-11-13 Joseph Pecoraro < [email protected]>
|
2 | 220 |
|
3 | 221 | Use #pragma once in WebCore
|
|
0 commit comments