Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: public/platform/WebCryptoKeyAlgorithmParams.h

Issue 707743002: WebCrypto: Add ECDSA algorithm (Blink side). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase onto master Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « public/platform/WebCryptoKeyAlgorithm.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 virtual void setString(const char*, const char*) = 0; 46 virtual void setString(const char*, const char*) = 0;
47 virtual void setUint(const char*, unsigned) = 0; 47 virtual void setUint(const char*, unsigned) = 0;
48 virtual void setAlgorithm(const char*, const WebCryptoAlgorithm&) = 0; 48 virtual void setAlgorithm(const char*, const WebCryptoAlgorithm&) = 0;
49 virtual void setUint8Array(const char*, const WebVector<unsigned char>&) = 0 ; 49 virtual void setUint8Array(const char*, const WebVector<unsigned char>&) = 0 ;
50 }; 50 };
51 51
52 enum WebCryptoKeyAlgorithmParamsType { 52 enum WebCryptoKeyAlgorithmParamsType {
53 WebCryptoKeyAlgorithmParamsTypeNone, 53 WebCryptoKeyAlgorithmParamsTypeNone,
54 WebCryptoKeyAlgorithmParamsTypeHmac, 54 WebCryptoKeyAlgorithmParamsTypeHmac,
55 WebCryptoKeyAlgorithmParamsTypeAes, 55 WebCryptoKeyAlgorithmParamsTypeAes,
56 WebCryptoKeyAlgorithmParamsTypeRsaHashed 56 WebCryptoKeyAlgorithmParamsTypeRsaHashed,
57 WebCryptoKeyAlgorithmParamsTypeEc,
57 }; 58 };
58 59
59 class WebCryptoKeyAlgorithmParams { 60 class WebCryptoKeyAlgorithmParams {
60 public: 61 public:
61 virtual ~WebCryptoKeyAlgorithmParams() { } 62 virtual ~WebCryptoKeyAlgorithmParams() { }
62 virtual WebCryptoKeyAlgorithmParamsType type() const 63 virtual WebCryptoKeyAlgorithmParamsType type() const
63 { 64 {
64 return WebCryptoKeyAlgorithmParamsTypeNone; 65 return WebCryptoKeyAlgorithmParamsTypeNone;
65 } 66 }
66 67
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 dict->setUint("modulusLength", m_modulusLengthBits); 163 dict->setUint("modulusLength", m_modulusLengthBits);
163 dict->setUint8Array("publicExponent", m_publicExponent); 164 dict->setUint8Array("publicExponent", m_publicExponent);
164 } 165 }
165 166
166 private: 167 private:
167 unsigned m_modulusLengthBits; 168 unsigned m_modulusLengthBits;
168 WebVector<unsigned char> m_publicExponent; 169 WebVector<unsigned char> m_publicExponent;
169 WebCryptoAlgorithm m_hash; 170 WebCryptoAlgorithm m_hash;
170 }; 171 };
171 172
173 class WebCryptoEcKeyAlgorithmParams : public WebCryptoKeyAlgorithmParams {
174 public:
175 explicit WebCryptoEcKeyAlgorithmParams(WebCryptoNamedCurve namedCurve)
176 : m_namedCurve(namedCurve)
177 {
178 }
179
180 WebCryptoNamedCurve namedCurve() const
181 {
182 return m_namedCurve;
183 }
184
185 virtual WebCryptoKeyAlgorithmParamsType type() const
186 {
187 return WebCryptoKeyAlgorithmParamsTypeEc;
188 }
189
190 virtual void writeToDictionary(WebCryptoKeyAlgorithmDictionary* dict) const
191 {
192 switch (m_namedCurve) {
193 case WebCryptoNamedCurveP256:
194 dict->setString("namedCurve", "P-256");
195 break;
196 case WebCryptoNamedCurveP384:
197 dict->setString("namedCurve", "P-384");
198 break;
199 case WebCryptoNamedCurveP521:
200 dict->setString("namedCurve", "P-521");
201 break;
202 }
203 }
204
205 private:
206 const WebCryptoNamedCurve m_namedCurve;
207 };
208
172 } // namespace blink 209 } // namespace blink
173 210
174 #endif 211 #endif
OLDNEW
« no previous file with comments | « public/platform/WebCryptoKeyAlgorithm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698