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