OLD | NEW |
---|---|
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 { | 220 { |
221 BLINK_ASSERT(!hash.isNull()); | 221 BLINK_ASSERT(!hash.isNull()); |
222 } | 222 } |
223 | 223 |
224 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedKeyGenParams; } | 224 virtual WebCryptoAlgorithmParamsType type() const { return WebCryptoAlgorith mParamsTypeRsaHashedKeyGenParams; } |
225 | 225 |
226 unsigned modulusLengthBits() const { return m_modulusLengthBits; } | 226 unsigned modulusLengthBits() const { return m_modulusLengthBits; } |
227 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo nent; } | 227 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo nent; } |
228 const WebCryptoAlgorithm& hash() const { return m_hash; } | 228 const WebCryptoAlgorithm& hash() const { return m_hash; } |
229 | 229 |
230 // Converts the public exponent (big-endian WebCrypto BigInteger), with or w ithout leading zeros, to unsigned int. Returns true on success. | |
231 bool publicExponentToUint32(unsigned* result) const | |
eroman
2015/10/23 19:13:04
Blink style favors the use of references over out
hbos_chromium
2015/10/26 13:21:32
Done.
| |
232 { | |
233 if (m_publicExponent.size() == 0) | |
eroman
2015/10/23 19:13:04
While you are editing things, can you delete these
hbos_chromium
2015/10/26 13:21:32
Done.
| |
234 return false; | |
235 | |
236 *result = 0; | |
237 for (size_t i = 0; i < m_publicExponent.size(); ++i) { | |
238 size_t iReversed = m_publicExponent.size() - i - 1; | |
239 | |
240 if (iReversed >= sizeof(*result) && m_publicExponent[i]) | |
241 return false; // Too large for a uint. | |
242 | |
243 *result |= m_publicExponent[i] << 8 * iReversed; | |
244 } | |
245 return true; | |
246 } | |
230 private: | 247 private: |
231 const unsigned m_modulusLengthBits; | 248 const unsigned m_modulusLengthBits; |
232 const WebVector<unsigned char> m_publicExponent; | 249 const WebVector<unsigned char> m_publicExponent; |
233 const WebCryptoAlgorithm m_hash; | 250 const WebCryptoAlgorithm m_hash; |
234 }; | 251 }; |
235 | 252 |
236 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams { | 253 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams { |
237 public: | 254 public: |
238 WebCryptoRsaOaepParams(bool hasLabel, const unsigned char* label, unsigned l abelSize) | 255 WebCryptoRsaOaepParams(bool hasLabel, const unsigned char* label, unsigned l abelSize) |
239 : m_hasLabel(hasLabel) | 256 : m_hasLabel(hasLabel) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 unsigned iterations() const { return m_iterations; } | 392 unsigned iterations() const { return m_iterations; } |
376 | 393 |
377 private: | 394 private: |
378 const WebVector<unsigned char> m_salt; | 395 const WebVector<unsigned char> m_salt; |
379 const unsigned m_iterations; | 396 const unsigned m_iterations; |
380 }; | 397 }; |
381 | 398 |
382 } // namespace blink | 399 } // namespace blink |
383 | 400 |
384 #endif | 401 #endif |
OLD | NEW |