Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h

Issue 1851293002: Remove BLINK_ASSERT() and BLINK_ASSERT_NOT_REACHED() macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check the |callbacks| for nullptr and use explicit delete. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef WebCryptoAlgorithmParams_h 31 #ifndef WebCryptoAlgorithmParams_h
32 #define WebCryptoAlgorithmParams_h 32 #define WebCryptoAlgorithmParams_h
33 33
34 #include "WebCommon.h" 34 #include "WebCommon.h"
35 #include "WebCryptoAlgorithm.h" 35 #include "WebCryptoAlgorithm.h"
36 #include "WebCryptoKey.h" 36 #include "WebCryptoKey.h"
37 #include "WebVector.h" 37 #include "WebVector.h"
38 #include "base/logging.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 // NOTE: For documentation on the meaning of each of the parameters see the 42 // NOTE: For documentation on the meaning of each of the parameters see the
42 // Web crypto spec: 43 // Web crypto spec:
43 // 44 //
44 // http://www.w3.org/TR/WebCryptoAPI 45 // http://www.w3.org/TR/WebCryptoAPI
45 // 46 //
46 // For the most part, the parameters in the spec have the same name, 47 // For the most part, the parameters in the spec have the same name,
47 // except that in the blink code: 48 // except that in the blink code:
(...skipping 22 matching lines...) Expand all
70 71
71 private: 72 private:
72 const WebVector<unsigned char> m_iv; 73 const WebVector<unsigned char> m_iv;
73 }; 74 };
74 75
75 class WebCryptoAlgorithmParamsWithHash : public WebCryptoAlgorithmParams { 76 class WebCryptoAlgorithmParamsWithHash : public WebCryptoAlgorithmParams {
76 public: 77 public:
77 explicit WebCryptoAlgorithmParamsWithHash(const WebCryptoAlgorithm& hash) 78 explicit WebCryptoAlgorithmParamsWithHash(const WebCryptoAlgorithm& hash)
78 : m_hash(hash) 79 : m_hash(hash)
79 { 80 {
80 BLINK_ASSERT(!hash.isNull()); 81 DCHECK(!hash.isNull());
81 } 82 }
82 83
83 const WebCryptoAlgorithm& hash() const { return m_hash; } 84 const WebCryptoAlgorithm& hash() const { return m_hash; }
84 85
85 private: 86 private:
86 const WebCryptoAlgorithm m_hash; 87 const WebCryptoAlgorithm m_hash;
87 }; 88 };
88 89
89 class WebCryptoAesCtrParams : public WebCryptoAlgorithmParams { 90 class WebCryptoAesCtrParams : public WebCryptoAlgorithmParams {
90 public: 91 public:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 , m_hasLengthBits(false) 129 , m_hasLengthBits(false)
129 , m_optionalLengthBits(0) 130 , m_optionalLengthBits(0)
130 { 131 {
131 } 132 }
132 133
133 WebCryptoHmacImportParams(const WebCryptoAlgorithm& hash, bool hasLengthBits , unsigned lengthBits) 134 WebCryptoHmacImportParams(const WebCryptoAlgorithm& hash, bool hasLengthBits , unsigned lengthBits)
134 : WebCryptoAlgorithmParamsWithHash(hash) 135 : WebCryptoAlgorithmParamsWithHash(hash)
135 , m_hasLengthBits(hasLengthBits) 136 , m_hasLengthBits(hasLengthBits)
136 , m_optionalLengthBits(lengthBits) 137 , m_optionalLengthBits(lengthBits)
137 { 138 {
138 BLINK_ASSERT(hasLengthBits || !lengthBits); 139 DCHECK(hasLengthBits || !lengthBits);
139 } 140 }
140 141
141 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeHmacImportParams; } 142 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeHmacImportParams; }
142 143
143 bool hasLengthBits() const { return m_hasLengthBits; } 144 bool hasLengthBits() const { return m_hasLengthBits; }
144 145
145 unsigned optionalLengthBits() const { return m_optionalLengthBits; } 146 unsigned optionalLengthBits() const { return m_optionalLengthBits; }
146 147
147 private: 148 private:
148 const bool m_hasLengthBits; 149 const bool m_hasLengthBits;
149 const unsigned m_optionalLengthBits; 150 const unsigned m_optionalLengthBits;
150 }; 151 };
151 152
152 class WebCryptoHmacKeyGenParams : public WebCryptoAlgorithmParamsWithHash { 153 class WebCryptoHmacKeyGenParams : public WebCryptoAlgorithmParamsWithHash {
153 public: 154 public:
154 WebCryptoHmacKeyGenParams(const WebCryptoAlgorithm& hash, bool hasLengthBits , unsigned lengthBits) 155 WebCryptoHmacKeyGenParams(const WebCryptoAlgorithm& hash, bool hasLengthBits , unsigned lengthBits)
155 : WebCryptoAlgorithmParamsWithHash(hash) 156 : WebCryptoAlgorithmParamsWithHash(hash)
156 , m_hasLengthBits(hasLengthBits) 157 , m_hasLengthBits(hasLengthBits)
157 , m_optionalLengthBits(lengthBits) 158 , m_optionalLengthBits(lengthBits)
158 { 159 {
159 BLINK_ASSERT(hasLengthBits || !lengthBits); 160 DCHECK(hasLengthBits || !lengthBits);
160 } 161 }
161 162
162 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeHmacKeyGenParams; } 163 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeHmacKeyGenParams; }
163 164
164 bool hasLengthBits() const { return m_hasLengthBits; } 165 bool hasLengthBits() const { return m_hasLengthBits; }
165 166
166 unsigned optionalLengthBits() const { return m_optionalLengthBits; } 167 unsigned optionalLengthBits() const { return m_optionalLengthBits; }
167 168
168 private: 169 private:
169 const bool m_hasLengthBits; 170 const bool m_hasLengthBits;
170 const unsigned m_optionalLengthBits; 171 const unsigned m_optionalLengthBits;
171 }; 172 };
172 173
173 class WebCryptoAesGcmParams : public WebCryptoAlgorithmParams { 174 class WebCryptoAesGcmParams : public WebCryptoAlgorithmParams {
174 public: 175 public:
175 WebCryptoAesGcmParams(const unsigned char* iv, unsigned ivSize, bool hasAddi tionalData, const unsigned char* additionalData, unsigned additionalDataSize, bo ol hasTagLengthBits, unsigned char tagLengthBits) 176 WebCryptoAesGcmParams(const unsigned char* iv, unsigned ivSize, bool hasAddi tionalData, const unsigned char* additionalData, unsigned additionalDataSize, bo ol hasTagLengthBits, unsigned char tagLengthBits)
176 : m_iv(iv, ivSize) 177 : m_iv(iv, ivSize)
177 , m_hasAdditionalData(hasAdditionalData) 178 , m_hasAdditionalData(hasAdditionalData)
178 , m_optionalAdditionalData(additionalData, additionalDataSize) 179 , m_optionalAdditionalData(additionalData, additionalDataSize)
179 , m_hasTagLengthBits(hasTagLengthBits) 180 , m_hasTagLengthBits(hasTagLengthBits)
180 , m_optionalTagLengthBits(tagLengthBits) 181 , m_optionalTagLengthBits(tagLengthBits)
181 { 182 {
182 BLINK_ASSERT(hasAdditionalData || !additionalDataSize); 183 DCHECK(hasAdditionalData || !additionalDataSize);
183 BLINK_ASSERT(hasTagLengthBits || !tagLengthBits); 184 DCHECK(hasTagLengthBits || !tagLengthBits);
184 } 185 }
185 186
186 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeAesGcmParams; } 187 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeAesGcmParams; }
187 188
188 const WebVector<unsigned char>& iv() const { return m_iv; } 189 const WebVector<unsigned char>& iv() const { return m_iv; }
189 190
190 bool hasAdditionalData() const { return m_hasAdditionalData; } 191 bool hasAdditionalData() const { return m_hasAdditionalData; }
191 const WebVector<unsigned char>& optionalAdditionalData() const { return m_op tionalAdditionalData; } 192 const WebVector<unsigned char>& optionalAdditionalData() const { return m_op tionalAdditionalData; }
192 193
193 bool hasTagLengthBits() const { return m_hasTagLengthBits; } 194 bool hasTagLengthBits() const { return m_hasTagLengthBits; }
(...skipping 17 matching lines...) Expand all
211 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedImportParams; } 212 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedImportParams; }
212 }; 213 };
213 214
214 class WebCryptoRsaHashedKeyGenParams : public WebCryptoAlgorithmParams { 215 class WebCryptoRsaHashedKeyGenParams : public WebCryptoAlgorithmParams {
215 public: 216 public:
216 explicit WebCryptoRsaHashedKeyGenParams(const WebCryptoAlgorithm& hash, unsi gned modulusLengthBits, const unsigned char* publicExponent, unsigned publicExpo nentSize) 217 explicit WebCryptoRsaHashedKeyGenParams(const WebCryptoAlgorithm& hash, unsi gned modulusLengthBits, const unsigned char* publicExponent, unsigned publicExpo nentSize)
217 : m_modulusLengthBits(modulusLengthBits) 218 : m_modulusLengthBits(modulusLengthBits)
218 , m_publicExponent(publicExponent, publicExponentSize) 219 , m_publicExponent(publicExponent, publicExponentSize)
219 , m_hash(hash) 220 , m_hash(hash)
220 { 221 {
221 BLINK_ASSERT(!hash.isNull()); 222 DCHECK(!hash.isNull());
222 } 223 }
223 224
224 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedKeyGenParams; } 225 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedKeyGenParams; }
225 226
226 unsigned modulusLengthBits() const { return m_modulusLengthBits; } 227 unsigned modulusLengthBits() const { return m_modulusLengthBits; }
227 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo nent; } 228 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo nent; }
228 const WebCryptoAlgorithm& hash() const { return m_hash; } 229 const WebCryptoAlgorithm& hash() const { return m_hash; }
229 230
230 // Converts the public exponent (big-endian WebCrypto BigInteger), 231 // Converts the public exponent (big-endian WebCrypto BigInteger),
231 // with or without leading zeros, to unsigned int. Returns true on success. 232 // with or without leading zeros, to unsigned int. Returns true on success.
(...skipping 16 matching lines...) Expand all
248 const WebVector<unsigned char> m_publicExponent; 249 const WebVector<unsigned char> m_publicExponent;
249 const WebCryptoAlgorithm m_hash; 250 const WebCryptoAlgorithm m_hash;
250 }; 251 };
251 252
252 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams { 253 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams {
253 public: 254 public:
254 WebCryptoRsaOaepParams(bool hasLabel, const unsigned char* label, unsigned l abelSize) 255 WebCryptoRsaOaepParams(bool hasLabel, const unsigned char* label, unsigned l abelSize)
255 : m_hasLabel(hasLabel) 256 : m_hasLabel(hasLabel)
256 , m_optionalLabel(label, labelSize) 257 , m_optionalLabel(label, labelSize)
257 { 258 {
258 BLINK_ASSERT(hasLabel || !labelSize); 259 DCHECK(hasLabel || !labelSize);
259 } 260 }
260 261
261 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaOaepParams; } 262 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaOaepParams; }
262 263
263 bool hasLabel() const { return m_hasLabel; } 264 bool hasLabel() const { return m_hasLabel; }
264 const WebVector<unsigned char>& optionalLabel() const { return m_optionalLab el; } 265 const WebVector<unsigned char>& optionalLabel() const { return m_optionalLab el; }
265 266
266 private: 267 private:
267 const bool m_hasLabel; 268 const bool m_hasLabel;
268 const WebVector<unsigned char> m_optionalLabel; 269 const WebVector<unsigned char> m_optionalLabel;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 unsigned iterations() const { return m_iterations; } 392 unsigned iterations() const { return m_iterations; }
392 393
393 private: 394 private:
394 const WebVector<unsigned char> m_salt; 395 const WebVector<unsigned char> m_salt;
395 const unsigned m_iterations; 396 const unsigned m_iterations;
396 }; 397 };
397 398
398 } // namespace blink 399 } // namespace blink
399 400
400 #endif 401 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/public/platform/WebCommon.h ('k') | third_party/WebKit/public/platform/WebFileSystem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698