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

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

Issue 2160943003: Transfer WebCrypto databuffers across the Blink API using blink::WebVector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 class WebCryptoAlgorithmParams { 54 class WebCryptoAlgorithmParams {
55 public: 55 public:
56 WebCryptoAlgorithmParams() { } 56 WebCryptoAlgorithmParams() { }
57 virtual ~WebCryptoAlgorithmParams() { } 57 virtual ~WebCryptoAlgorithmParams() { }
58 virtual WebCryptoAlgorithmParamsType type() const = 0; 58 virtual WebCryptoAlgorithmParamsType type() const = 0;
59 }; 59 };
60 60
61 class WebCryptoAesCbcParams : public WebCryptoAlgorithmParams { 61 class WebCryptoAesCbcParams : public WebCryptoAlgorithmParams {
62 public: 62 public:
63 WebCryptoAesCbcParams(const unsigned char* iv, unsigned ivSize) 63 explicit WebCryptoAesCbcParams(WebVector<unsigned char> iv)
64 : m_iv(iv, ivSize) 64 : m_iv(std::move(iv))
65 { 65 {
66 } 66 }
67 67
68 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeAesCbcParams; } 68 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeAesCbcParams; }
69 69
70 const WebVector<unsigned char>& iv() const { return m_iv; } 70 const WebVector<unsigned char>& iv() const { return m_iv; }
71 71
72 private: 72 private:
73 const WebVector<unsigned char> m_iv; 73 const WebVector<unsigned char> m_iv;
74 }; 74 };
75 75
76 class WebCryptoAlgorithmParamsWithHash : public WebCryptoAlgorithmParams { 76 class WebCryptoAlgorithmParamsWithHash : public WebCryptoAlgorithmParams {
77 public: 77 public:
78 explicit WebCryptoAlgorithmParamsWithHash(const WebCryptoAlgorithm& hash) 78 explicit WebCryptoAlgorithmParamsWithHash(const WebCryptoAlgorithm& hash)
79 : m_hash(hash) 79 : m_hash(hash)
80 { 80 {
81 DCHECK(!hash.isNull()); 81 DCHECK(!hash.isNull());
82 } 82 }
83 83
84 const WebCryptoAlgorithm& hash() const { return m_hash; } 84 const WebCryptoAlgorithm& hash() const { return m_hash; }
85 85
86 private: 86 private:
87 const WebCryptoAlgorithm m_hash; 87 const WebCryptoAlgorithm m_hash;
88 }; 88 };
89 89
90 class WebCryptoAesCtrParams : public WebCryptoAlgorithmParams { 90 class WebCryptoAesCtrParams : public WebCryptoAlgorithmParams {
91 public: 91 public:
92 WebCryptoAesCtrParams(unsigned char lengthBits, const unsigned char* counter , unsigned counterSize) 92 WebCryptoAesCtrParams(unsigned char lengthBits, WebVector<unsigned char> cou nter)
93 : WebCryptoAlgorithmParams() 93 : WebCryptoAlgorithmParams()
94 , m_counter(counter, counterSize) 94 , m_counter(std::move(counter))
95 , m_lengthBits(lengthBits) 95 , m_lengthBits(lengthBits)
96 { 96 {
97 } 97 }
98 98
99 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeAesCtrParams; } 99 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeAesCtrParams; }
100 100
101 const WebVector<unsigned char>& counter() const { return m_counter; } 101 const WebVector<unsigned char>& counter() const { return m_counter; }
102 unsigned char lengthBits() const { return m_lengthBits; } 102 unsigned char lengthBits() const { return m_lengthBits; }
103 103
104 private: 104 private:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 unsigned optionalLengthBits() const { return m_optionalLengthBits; } 167 unsigned optionalLengthBits() const { return m_optionalLengthBits; }
168 168
169 private: 169 private:
170 const bool m_hasLengthBits; 170 const bool m_hasLengthBits;
171 const unsigned m_optionalLengthBits; 171 const unsigned m_optionalLengthBits;
172 }; 172 };
173 173
174 class WebCryptoAesGcmParams : public WebCryptoAlgorithmParams { 174 class WebCryptoAesGcmParams : public WebCryptoAlgorithmParams {
175 public: 175 public:
176 WebCryptoAesGcmParams(const unsigned char* iv, unsigned ivSize, bool hasAddi tionalData, const unsigned char* additionalData, unsigned additionalDataSize, bo ol hasTagLengthBits, unsigned char tagLengthBits) 176 WebCryptoAesGcmParams(WebVector<unsigned char> iv, bool hasAdditionalData, W ebVector<unsigned char> additionalData, bool hasTagLengthBits, unsigned char tag LengthBits)
177 : m_iv(iv, ivSize) 177 : m_iv(std::move(iv))
178 , m_hasAdditionalData(hasAdditionalData) 178 , m_hasAdditionalData(hasAdditionalData)
179 , m_optionalAdditionalData(additionalData, additionalDataSize) 179 , m_optionalAdditionalData(std::move(additionalData))
180 , m_hasTagLengthBits(hasTagLengthBits) 180 , m_hasTagLengthBits(hasTagLengthBits)
181 , m_optionalTagLengthBits(tagLengthBits) 181 , m_optionalTagLengthBits(tagLengthBits)
182 { 182 {
183 DCHECK(hasAdditionalData || !additionalDataSize); 183 DCHECK(hasAdditionalData || m_optionalAdditionalData.isEmpty());
184 DCHECK(hasTagLengthBits || !tagLengthBits); 184 DCHECK(hasTagLengthBits || !tagLengthBits);
185 } 185 }
186 186
187 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeAesGcmParams; } 187 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeAesGcmParams; }
188 188
189 const WebVector<unsigned char>& iv() const { return m_iv; } 189 const WebVector<unsigned char>& iv() const { return m_iv; }
190 190
191 bool hasAdditionalData() const { return m_hasAdditionalData; } 191 bool hasAdditionalData() const { return m_hasAdditionalData; }
192 const WebVector<unsigned char>& optionalAdditionalData() const { return m_op tionalAdditionalData; } 192 const WebVector<unsigned char>& optionalAdditionalData() const { return m_op tionalAdditionalData; }
193 193
(...skipping 13 matching lines...) Expand all
207 explicit WebCryptoRsaHashedImportParams(const WebCryptoAlgorithm& hash) 207 explicit WebCryptoRsaHashedImportParams(const WebCryptoAlgorithm& hash)
208 : WebCryptoAlgorithmParamsWithHash(hash) 208 : WebCryptoAlgorithmParamsWithHash(hash)
209 { 209 {
210 } 210 }
211 211
212 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedImportParams; } 212 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedImportParams; }
213 }; 213 };
214 214
215 class WebCryptoRsaHashedKeyGenParams : public WebCryptoAlgorithmParams { 215 class WebCryptoRsaHashedKeyGenParams : public WebCryptoAlgorithmParams {
216 public: 216 public:
217 explicit WebCryptoRsaHashedKeyGenParams(const WebCryptoAlgorithm& hash, unsi gned modulusLengthBits, const unsigned char* publicExponent, unsigned publicExpo nentSize) 217 WebCryptoRsaHashedKeyGenParams(const WebCryptoAlgorithm& hash, unsigned modu lusLengthBits, WebVector<unsigned char> publicExponent)
218 : m_modulusLengthBits(modulusLengthBits) 218 : m_modulusLengthBits(modulusLengthBits)
219 , m_publicExponent(publicExponent, publicExponentSize) 219 , m_publicExponent(std::move(publicExponent))
220 , m_hash(hash) 220 , m_hash(hash)
221 { 221 {
222 DCHECK(!hash.isNull()); 222 DCHECK(!hash.isNull());
223 } 223 }
224 224
225 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedKeyGenParams; } 225 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedKeyGenParams; }
226 226
227 unsigned modulusLengthBits() const { return m_modulusLengthBits; } 227 unsigned modulusLengthBits() const { return m_modulusLengthBits; }
228 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo nent; } 228 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo nent; }
229 const WebCryptoAlgorithm& hash() const { return m_hash; } 229 const WebCryptoAlgorithm& hash() const { return m_hash; }
(...skipping 15 matching lines...) Expand all
245 } 245 }
246 246
247 private: 247 private:
248 const unsigned m_modulusLengthBits; 248 const unsigned m_modulusLengthBits;
249 const WebVector<unsigned char> m_publicExponent; 249 const WebVector<unsigned char> m_publicExponent;
250 const WebCryptoAlgorithm m_hash; 250 const WebCryptoAlgorithm m_hash;
251 }; 251 };
252 252
253 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams { 253 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams {
254 public: 254 public:
255 WebCryptoRsaOaepParams(bool hasLabel, const unsigned char* label, unsigned l abelSize) 255 WebCryptoRsaOaepParams(bool hasLabel, WebVector<unsigned char> label)
256 : m_hasLabel(hasLabel) 256 : m_hasLabel(hasLabel)
257 , m_optionalLabel(label, labelSize) 257 , m_optionalLabel(std::move(label))
258 { 258 {
259 DCHECK(hasLabel || !labelSize); 259 DCHECK(hasLabel || m_optionalLabel.isEmpty());
260 } 260 }
261 261
262 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaOaepParams; } 262 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaOaepParams; }
263 263
264 bool hasLabel() const { return m_hasLabel; } 264 bool hasLabel() const { return m_hasLabel; }
265 const WebVector<unsigned char>& optionalLabel() const { return m_optionalLab el; } 265 const WebVector<unsigned char>& optionalLabel() const { return m_optionalLab el; }
266 266
267 private: 267 private:
268 const bool m_hasLabel; 268 const bool m_hasLabel;
269 const WebVector<unsigned char> m_optionalLabel; 269 const WebVector<unsigned char> m_optionalLabel;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 virtual WebCryptoAlgorithmParamsType type() const override { return WebCrypt oAlgorithmParamsTypeAesDerivedKeyParams; } 349 virtual WebCryptoAlgorithmParamsType type() const override { return WebCrypt oAlgorithmParamsTypeAesDerivedKeyParams; }
350 350
351 unsigned short lengthBits() const { return m_lengthBits; } 351 unsigned short lengthBits() const { return m_lengthBits; }
352 352
353 private: 353 private:
354 const unsigned short m_lengthBits; 354 const unsigned short m_lengthBits;
355 }; 355 };
356 356
357 class WebCryptoHkdfParams : public WebCryptoAlgorithmParamsWithHash { 357 class WebCryptoHkdfParams : public WebCryptoAlgorithmParamsWithHash {
358 public: 358 public:
359 WebCryptoHkdfParams(const WebCryptoAlgorithm& hash, const unsigned char* sal t, unsigned saltSize, const unsigned char* info, unsigned infoSize) 359 WebCryptoHkdfParams(const WebCryptoAlgorithm& hash, WebVector<unsigned char> salt, WebVector<unsigned char> info)
360 : WebCryptoAlgorithmParamsWithHash(hash) 360 : WebCryptoAlgorithmParamsWithHash(hash)
361 , m_salt(salt, saltSize) 361 , m_salt(std::move(salt))
362 , m_info(info, infoSize) 362 , m_info(std::move(info))
363 { 363 {
364 } 364 }
365 365
366 const WebVector<unsigned char>& salt() const { return m_salt; } 366 const WebVector<unsigned char>& salt() const { return m_salt; }
367 367
368 const WebVector<unsigned char>& info() const { return m_info; } 368 const WebVector<unsigned char>& info() const { return m_info; }
369 369
370 virtual WebCryptoAlgorithmParamsType type() const 370 virtual WebCryptoAlgorithmParamsType type() const
371 { 371 {
372 return WebCryptoAlgorithmParamsTypeHkdfParams; 372 return WebCryptoAlgorithmParamsTypeHkdfParams;
373 } 373 }
374 374
375 private: 375 private:
376 const WebVector<unsigned char> m_salt; 376 const WebVector<unsigned char> m_salt;
377 const WebVector<unsigned char> m_info; 377 const WebVector<unsigned char> m_info;
378 }; 378 };
379 379
380 class WebCryptoPbkdf2Params : public WebCryptoAlgorithmParamsWithHash { 380 class WebCryptoPbkdf2Params : public WebCryptoAlgorithmParamsWithHash {
381 public: 381 public:
382 WebCryptoPbkdf2Params(const WebCryptoAlgorithm& hash, const unsigned char* s alt, unsigned saltLength, unsigned iterations) 382 WebCryptoPbkdf2Params(const WebCryptoAlgorithm& hash, WebVector<unsigned cha r> salt, unsigned iterations)
383 : WebCryptoAlgorithmParamsWithHash(hash) 383 : WebCryptoAlgorithmParamsWithHash(hash)
384 , m_salt(salt, saltLength) 384 , m_salt(std::move(salt))
385 , m_iterations(iterations) 385 , m_iterations(iterations)
386 { 386 {
387 } 387 }
388 388
389 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypePbkdf2Params; } 389 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypePbkdf2Params; }
390 390
391 const WebVector<unsigned char>& salt() const { return m_salt; } 391 const WebVector<unsigned char>& salt() const { return m_salt; }
392 unsigned iterations() const { return m_iterations; } 392 unsigned iterations() const { return m_iterations; }
393 393
394 private: 394 private:
395 const WebVector<unsigned char> m_salt; 395 const WebVector<unsigned char> m_salt;
396 const unsigned m_iterations; 396 const unsigned m_iterations;
397 }; 397 };
398 398
399 } // namespace blink 399 } // namespace blink
400 400
401 #endif 401 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/public/platform/WebCrypto.h ('k') | third_party/WebKit/public/platform/WebVector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698