| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 // FIXME: Delete this once the chromium side has picked up the API change. | 38 // FIXME: Delete this once the chromium side has picked up the API change. |
| 39 #define WEBCRYPTO_HMAC_KEY_HAS_LENGTH 1 | 39 #define WEBCRYPTO_HMAC_KEY_HAS_LENGTH 1 |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 enum WebCryptoKeyAlgorithmParamsType { | 43 enum WebCryptoKeyAlgorithmParamsType { |
| 44 WebCryptoKeyAlgorithmParamsTypeNone, | 44 WebCryptoKeyAlgorithmParamsTypeNone, |
| 45 WebCryptoKeyAlgorithmParamsTypeHmac, | 45 WebCryptoKeyAlgorithmParamsTypeHmac, |
| 46 WebCryptoKeyAlgorithmParamsTypeAes, | 46 WebCryptoKeyAlgorithmParamsTypeAes, |
| 47 WebCryptoKeyAlgorithmParamsTypeRsa, | |
| 48 WebCryptoKeyAlgorithmParamsTypeRsaHashed | 47 WebCryptoKeyAlgorithmParamsTypeRsaHashed |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 class WebCryptoKeyAlgorithmParams { | 50 class WebCryptoKeyAlgorithmParams { |
| 52 public: | 51 public: |
| 53 virtual ~WebCryptoKeyAlgorithmParams() { } | 52 virtual ~WebCryptoKeyAlgorithmParams() { } |
| 54 virtual WebCryptoKeyAlgorithmParamsType type() const | 53 virtual WebCryptoKeyAlgorithmParamsType type() const |
| 55 { | 54 { |
| 56 return WebCryptoKeyAlgorithmParamsTypeNone; | 55 return WebCryptoKeyAlgorithmParamsTypeNone; |
| 57 } | 56 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 virtual WebCryptoKeyAlgorithmParamsType type() const | 98 virtual WebCryptoKeyAlgorithmParamsType type() const |
| 100 { | 99 { |
| 101 return WebCryptoKeyAlgorithmParamsTypeHmac; | 100 return WebCryptoKeyAlgorithmParamsTypeHmac; |
| 102 } | 101 } |
| 103 | 102 |
| 104 private: | 103 private: |
| 105 WebCryptoAlgorithm m_hash; | 104 WebCryptoAlgorithm m_hash; |
| 106 unsigned m_lengthBits; | 105 unsigned m_lengthBits; |
| 107 }; | 106 }; |
| 108 | 107 |
| 109 class WebCryptoRsaKeyAlgorithmParams : public WebCryptoKeyAlgorithmParams { | 108 class WebCryptoRsaHashedKeyAlgorithmParams : public WebCryptoKeyAlgorithmParams
{ |
| 110 public: | 109 public: |
| 111 WebCryptoRsaKeyAlgorithmParams(unsigned modulusLengthBits, const unsigned ch
ar* publicExponent, unsigned publicExponentSize) | 110 WebCryptoRsaHashedKeyAlgorithmParams(unsigned modulusLengthBits, const unsig
ned char* publicExponent, unsigned publicExponentSize, const WebCryptoAlgorithm&
hash) |
| 112 : m_modulusLengthBits(modulusLengthBits) | 111 : m_modulusLengthBits(modulusLengthBits) |
| 113 , m_publicExponent(publicExponent, publicExponentSize) | 112 , m_publicExponent(publicExponent, publicExponentSize) |
| 113 , m_hash(hash) |
| 114 { | 114 { |
| 115 } | 115 } |
| 116 | 116 |
| 117 unsigned modulusLengthBits() const | 117 unsigned modulusLengthBits() const |
| 118 { | 118 { |
| 119 return m_modulusLengthBits; | 119 return m_modulusLengthBits; |
| 120 } | 120 } |
| 121 | 121 |
| 122 const WebVector<unsigned char>& publicExponent() const | 122 const WebVector<unsigned char>& publicExponent() const |
| 123 { | 123 { |
| 124 return m_publicExponent; | 124 return m_publicExponent; |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual WebCryptoKeyAlgorithmParamsType type() const | |
| 128 { | |
| 129 return WebCryptoKeyAlgorithmParamsTypeRsa; | |
| 130 } | |
| 131 | |
| 132 private: | |
| 133 unsigned m_modulusLengthBits; | |
| 134 WebVector<unsigned char> m_publicExponent; | |
| 135 }; | |
| 136 | |
| 137 class WebCryptoRsaHashedKeyAlgorithmParams : public WebCryptoRsaKeyAlgorithmPara
ms { | |
| 138 public: | |
| 139 WebCryptoRsaHashedKeyAlgorithmParams(unsigned modulusLengthBits, const unsig
ned char* publicExponent, unsigned publicExponentSize, const WebCryptoAlgorithm&
hash) | |
| 140 : WebCryptoRsaKeyAlgorithmParams(modulusLengthBits, publicExponent, publ
icExponentSize) | |
| 141 , m_hash(hash) | |
| 142 { | |
| 143 } | |
| 144 | |
| 145 const WebCryptoAlgorithm& hash() const | 127 const WebCryptoAlgorithm& hash() const |
| 146 { | 128 { |
| 147 return m_hash; | 129 return m_hash; |
| 148 } | 130 } |
| 149 | 131 |
| 150 virtual WebCryptoKeyAlgorithmParamsType type() const | 132 virtual WebCryptoKeyAlgorithmParamsType type() const |
| 151 { | 133 { |
| 152 return WebCryptoKeyAlgorithmParamsTypeRsaHashed; | 134 return WebCryptoKeyAlgorithmParamsTypeRsaHashed; |
| 153 } | 135 } |
| 154 | 136 |
| 155 private: | 137 private: |
| 138 unsigned m_modulusLengthBits; |
| 139 WebVector<unsigned char> m_publicExponent; |
| 156 WebCryptoAlgorithm m_hash; | 140 WebCryptoAlgorithm m_hash; |
| 157 }; | 141 }; |
| 158 | 142 |
| 159 } // namespace blink | 143 } // namespace blink |
| 160 | 144 |
| 161 #endif | 145 #endif |
| OLD | NEW |