| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 Loading... |
| 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 WebCryptoKeyAlgorithmParams_h | 31 #ifndef WebCryptoKeyAlgorithmParams_h |
| 32 #define WebCryptoKeyAlgorithmParams_h | 32 #define WebCryptoKeyAlgorithmParams_h |
| 33 | 33 |
| 34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
| 35 #include "WebCryptoAlgorithm.h" | 35 #include "WebCryptoAlgorithm.h" |
| 36 #include "WebVector.h" | 36 #include "WebVector.h" |
| 37 | 37 |
| 38 // FIXME: Delete this once the chromium side has picked up the API change. |
| 39 #define WEBCRYPTO_HMAC_KEY_HAS_LENGTH 1 |
| 40 |
| 38 namespace blink { | 41 namespace blink { |
| 39 | 42 |
| 40 enum WebCryptoKeyAlgorithmParamsType { | 43 enum WebCryptoKeyAlgorithmParamsType { |
| 41 WebCryptoKeyAlgorithmParamsTypeNone, | 44 WebCryptoKeyAlgorithmParamsTypeNone, |
| 42 WebCryptoKeyAlgorithmParamsTypeHmac, | 45 WebCryptoKeyAlgorithmParamsTypeHmac, |
| 43 WebCryptoKeyAlgorithmParamsTypeAes, | 46 WebCryptoKeyAlgorithmParamsTypeAes, |
| 44 WebCryptoKeyAlgorithmParamsTypeRsa, | 47 WebCryptoKeyAlgorithmParamsTypeRsa, |
| 45 WebCryptoKeyAlgorithmParamsTypeRsaHashed | 48 WebCryptoKeyAlgorithmParamsTypeRsaHashed |
| 46 }; | 49 }; |
| 47 | 50 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 70 { | 73 { |
| 71 return WebCryptoKeyAlgorithmParamsTypeAes; | 74 return WebCryptoKeyAlgorithmParamsTypeAes; |
| 72 } | 75 } |
| 73 | 76 |
| 74 private: | 77 private: |
| 75 unsigned short m_lengthBits; | 78 unsigned short m_lengthBits; |
| 76 }; | 79 }; |
| 77 | 80 |
| 78 class WebCryptoHmacKeyAlgorithmParams : public WebCryptoKeyAlgorithmParams { | 81 class WebCryptoHmacKeyAlgorithmParams : public WebCryptoKeyAlgorithmParams { |
| 79 public: | 82 public: |
| 80 explicit WebCryptoHmacKeyAlgorithmParams(const WebCryptoAlgorithm& hash) | 83 WebCryptoHmacKeyAlgorithmParams(const WebCryptoAlgorithm& hash, unsigned len
gthBits) |
| 81 : m_hash(hash) | 84 : m_hash(hash) |
| 85 , m_lengthBits(lengthBits) |
| 82 { | 86 { |
| 83 } | 87 } |
| 84 | 88 |
| 85 const WebCryptoAlgorithm& hash() const | 89 const WebCryptoAlgorithm& hash() const |
| 86 { | 90 { |
| 87 return m_hash; | 91 return m_hash; |
| 88 } | 92 } |
| 89 | 93 |
| 94 unsigned lengthBits() const |
| 95 { |
| 96 return m_lengthBits; |
| 97 } |
| 98 |
| 90 virtual WebCryptoKeyAlgorithmParamsType type() const | 99 virtual WebCryptoKeyAlgorithmParamsType type() const |
| 91 { | 100 { |
| 92 return WebCryptoKeyAlgorithmParamsTypeHmac; | 101 return WebCryptoKeyAlgorithmParamsTypeHmac; |
| 93 } | 102 } |
| 94 | 103 |
| 95 private: | 104 private: |
| 96 WebCryptoAlgorithm m_hash; | 105 WebCryptoAlgorithm m_hash; |
| 106 unsigned m_lengthBits; |
| 97 }; | 107 }; |
| 98 | 108 |
| 99 class WebCryptoRsaKeyAlgorithmParams : public WebCryptoKeyAlgorithmParams { | 109 class WebCryptoRsaKeyAlgorithmParams : public WebCryptoKeyAlgorithmParams { |
| 100 public: | 110 public: |
| 101 WebCryptoRsaKeyAlgorithmParams(unsigned modulusLengthBits, const unsigned ch
ar* publicExponent, unsigned publicExponentSize) | 111 WebCryptoRsaKeyAlgorithmParams(unsigned modulusLengthBits, const unsigned ch
ar* publicExponent, unsigned publicExponentSize) |
| 102 : m_modulusLengthBits(modulusLengthBits) | 112 : m_modulusLengthBits(modulusLengthBits) |
| 103 , m_publicExponent(publicExponent, publicExponentSize) | 113 , m_publicExponent(publicExponent, publicExponentSize) |
| 104 { | 114 { |
| 105 } | 115 } |
| 106 | 116 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 return WebCryptoKeyAlgorithmParamsTypeRsaHashed; | 152 return WebCryptoKeyAlgorithmParamsTypeRsaHashed; |
| 143 } | 153 } |
| 144 | 154 |
| 145 private: | 155 private: |
| 146 WebCryptoAlgorithm m_hash; | 156 WebCryptoAlgorithm m_hash; |
| 147 }; | 157 }; |
| 148 | 158 |
| 149 } // namespace blink | 159 } // namespace blink |
| 150 | 160 |
| 151 #endif | 161 #endif |
| OLD | NEW |