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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 153 } |
154 | 154 |
155 unsigned modulusLength() const { return m_modulusLength; } | 155 unsigned modulusLength() const { return m_modulusLength; } |
156 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo
nent; } | 156 const WebVector<unsigned char>& publicExponent() const { return m_publicExpo
nent; } |
157 | 157 |
158 private: | 158 private: |
159 const unsigned m_modulusLength; | 159 const unsigned m_modulusLength; |
160 const WebVector<unsigned char> m_publicExponent; | 160 const WebVector<unsigned char> m_publicExponent; |
161 }; | 161 }; |
162 | 162 |
| 163 class WebCryptoAesGcmParams : public WebCryptoAlgorithmParams { |
| 164 public: |
| 165 WebCryptoAesGcmParams(const unsigned char* iv, unsigned ivSize, bool hasAddi
tionalData, const unsigned char* additionalData, unsigned additionalDataSize, bo
ol hasTagLength, unsigned char tagLength) |
| 166 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeAesGcmParams) |
| 167 , m_iv(iv, ivSize) |
| 168 , m_hasAdditionalData(hasAdditionalData) |
| 169 , m_additionalData(additionalData, additionalDataSize) |
| 170 , m_hasTagLength(hasTagLength) |
| 171 , m_tagLength(tagLength) |
| 172 { |
| 173 } |
| 174 |
| 175 const WebVector<unsigned char>& iv() const { return m_iv; } |
| 176 |
| 177 bool hasAdditionalData() const { return m_hasAdditionalData; } |
| 178 bool getAdditionalData(const WebVector<unsigned char>*& additionalData) |
| 179 { |
| 180 if (!m_hasAdditionalData) |
| 181 return false; |
| 182 additionalData = &m_additionalData; |
| 183 return true; |
| 184 } |
| 185 |
| 186 bool hasTagLength() const { return m_hasTagLength; } |
| 187 bool getTagLength(unsigned& tagLength) |
| 188 { |
| 189 if (!m_hasTagLength) |
| 190 return false; |
| 191 tagLength = m_tagLength; |
| 192 return true; |
| 193 } |
| 194 |
| 195 private: |
| 196 const WebVector<unsigned char> m_iv; |
| 197 const bool m_hasAdditionalData; |
| 198 const WebVector<unsigned char> m_additionalData; |
| 199 const bool m_hasTagLength; |
| 200 const unsigned char m_tagLength; |
| 201 }; |
| 202 |
| 203 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams { |
| 204 public: |
| 205 WebCryptoRsaOaepParams(const WebCryptoAlgorithm& hash, bool hasLabel, const
unsigned char* label, unsigned labelSize) |
| 206 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeRsaOaepParams) |
| 207 , m_hash(hash) |
| 208 , m_hasLabel(hasLabel) |
| 209 , m_label(label, labelSize) |
| 210 { |
| 211 } |
| 212 |
| 213 const WebCryptoAlgorithm& hash() const { return m_hash; } |
| 214 |
| 215 bool hasLabel() const { return m_hasLabel; } |
| 216 bool getLabel(const WebVector<unsigned char>*& label) |
| 217 { |
| 218 if (!m_hasLabel) |
| 219 return false; |
| 220 label = &m_label; |
| 221 return true; |
| 222 } |
| 223 |
| 224 private: |
| 225 const WebCryptoAlgorithm m_hash; |
| 226 const bool m_hasLabel; |
| 227 const WebVector<unsigned char> m_label; |
| 228 }; |
| 229 |
163 } // namespace WebKit | 230 } // namespace WebKit |
164 | 231 |
165 #endif | 232 #endif |
OLD | NEW |