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

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

Issue 44993003: [webcrypto] Make WebCryptoAlgorithm "nullable". (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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/WebCryptoAlgorithm.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) 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 explicit WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsType type) 49 explicit WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsType type)
50 : m_type(type) 50 : m_type(type)
51 { 51 {
52 } 52 }
53 53
54 virtual ~WebCryptoAlgorithmParams() { } 54 virtual ~WebCryptoAlgorithmParams() { }
55 55
56 WebCryptoAlgorithmParamsType type() const { return m_type; } 56 WebCryptoAlgorithmParamsType type() const { return m_type; }
57 57
58 private: 58 private:
59 WebCryptoAlgorithmParamsType m_type; 59 const WebCryptoAlgorithmParamsType m_type;
60 }; 60 };
61 61
62 class WebCryptoAesCbcParams : public WebCryptoAlgorithmParams { 62 class WebCryptoAesCbcParams : public WebCryptoAlgorithmParams {
63 public: 63 public:
64 WebCryptoAesCbcParams(const unsigned char* iv, unsigned ivSize) 64 WebCryptoAesCbcParams(const unsigned char* iv, unsigned ivSize)
65 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeAesCbcParams) 65 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeAesCbcParams)
66 , m_iv(iv, ivSize) 66 , m_iv(iv, ivSize)
67 { 67 {
68 } 68 }
69 69
(...skipping 16 matching lines...) Expand all
86 private: 86 private:
87 const unsigned short m_length; 87 const unsigned short m_length;
88 }; 88 };
89 89
90 class WebCryptoHmacParams : public WebCryptoAlgorithmParams { 90 class WebCryptoHmacParams : public WebCryptoAlgorithmParams {
91 public: 91 public:
92 explicit WebCryptoHmacParams(const WebCryptoAlgorithm& hash) 92 explicit WebCryptoHmacParams(const WebCryptoAlgorithm& hash)
93 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeHmacParams) 93 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeHmacParams)
94 , m_hash(hash) 94 , m_hash(hash)
95 { 95 {
96 BLINK_ASSERT(!hash.isNull());
96 } 97 }
97 98
98 const WebCryptoAlgorithm& hash() const { return m_hash; } 99 const WebCryptoAlgorithm& hash() const { return m_hash; }
99 100
100 private: 101 private:
101 WebCryptoAlgorithm m_hash; 102 const WebCryptoAlgorithm m_hash;
102 }; 103 };
103 104
104 class WebCryptoHmacKeyParams : public WebCryptoAlgorithmParams { 105 class WebCryptoHmacKeyParams : public WebCryptoAlgorithmParams {
105 public: 106 public:
106 WebCryptoHmacKeyParams(const WebCryptoAlgorithm& hash, bool hasLength, unsig ned length) 107 WebCryptoHmacKeyParams(const WebCryptoAlgorithm& hash, bool hasLength, unsig ned length)
107 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeHmacKeyParams) 108 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeHmacKeyParams)
108 , m_hash(hash) 109 , m_hash(hash)
109 , m_hasLength(hasLength) 110 , m_hasLength(hasLength)
110 , m_length(length) 111 , m_length(length)
111 { 112 {
113 BLINK_ASSERT(!hash.isNull());
112 } 114 }
113 115
114 const WebCryptoAlgorithm& hash() const { return m_hash; } 116 const WebCryptoAlgorithm& hash() const { return m_hash; }
115 117
116 bool hasLength() const { return m_hasLength; } 118 bool hasLength() const { return m_hasLength; }
117 119
118 bool getLength(unsigned& length) const 120 bool getLength(unsigned& length) const
119 { 121 {
120 if (!m_hasLength) 122 if (!m_hasLength)
121 return false; 123 return false;
122 length = m_length; 124 length = m_length;
123 return true; 125 return true;
124 } 126 }
125 127
126 private: 128 private:
127 WebCryptoAlgorithm m_hash; 129 const WebCryptoAlgorithm m_hash;
128 bool m_hasLength; 130 const bool m_hasLength;
129 unsigned m_length; 131 const unsigned m_length;
130 }; 132 };
131 133
132 class WebCryptoRsaSsaParams : public WebCryptoAlgorithmParams { 134 class WebCryptoRsaSsaParams : public WebCryptoAlgorithmParams {
133 public: 135 public:
134 explicit WebCryptoRsaSsaParams(const WebCryptoAlgorithm& hash) 136 explicit WebCryptoRsaSsaParams(const WebCryptoAlgorithm& hash)
135 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeRsaSsaParams) 137 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeRsaSsaParams)
136 , m_hash(hash) 138 , m_hash(hash)
137 { 139 {
140 BLINK_ASSERT(!hash.isNull());
138 } 141 }
139 142
140 const WebCryptoAlgorithm& hash() const { return m_hash; } 143 const WebCryptoAlgorithm& hash() const { return m_hash; }
141 144
142 private: 145 private:
143 WebCryptoAlgorithm m_hash; 146 const WebCryptoAlgorithm m_hash;
144 }; 147 };
145 148
146 class WebCryptoRsaKeyGenParams : public WebCryptoAlgorithmParams { 149 class WebCryptoRsaKeyGenParams : public WebCryptoAlgorithmParams {
147 public: 150 public:
148 WebCryptoRsaKeyGenParams(unsigned modulusLength, const unsigned char* public Exponent, unsigned publicExponentSize) 151 WebCryptoRsaKeyGenParams(unsigned modulusLength, const unsigned char* public Exponent, unsigned publicExponentSize)
149 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeRsaKeyGenParams) 152 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeRsaKeyGenParams)
150 , m_modulusLength(modulusLength) 153 , m_modulusLength(modulusLength)
151 , m_publicExponent(publicExponent, publicExponentSize) 154 , m_publicExponent(publicExponent, publicExponentSize)
152 { 155 {
153 } 156 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 }; 204 };
202 205
203 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams { 206 class WebCryptoRsaOaepParams : public WebCryptoAlgorithmParams {
204 public: 207 public:
205 WebCryptoRsaOaepParams(const WebCryptoAlgorithm& hash, bool hasLabel, const unsigned char* label, unsigned labelSize) 208 WebCryptoRsaOaepParams(const WebCryptoAlgorithm& hash, bool hasLabel, const unsigned char* label, unsigned labelSize)
206 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeRsaOaepParams) 209 : WebCryptoAlgorithmParams(WebCryptoAlgorithmParamsTypeRsaOaepParams)
207 , m_hash(hash) 210 , m_hash(hash)
208 , m_hasLabel(hasLabel) 211 , m_hasLabel(hasLabel)
209 , m_label(label, labelSize) 212 , m_label(label, labelSize)
210 { 213 {
214 BLINK_ASSERT(!hash.isNull());
211 } 215 }
212 216
213 const WebCryptoAlgorithm& hash() const { return m_hash; } 217 const WebCryptoAlgorithm& hash() const { return m_hash; }
214 218
215 bool hasLabel() const { return m_hasLabel; } 219 bool hasLabel() const { return m_hasLabel; }
216 bool getLabel(const WebVector<unsigned char>*& label) 220 bool getLabel(const WebVector<unsigned char>*& label)
217 { 221 {
218 if (!m_hasLabel) 222 if (!m_hasLabel)
219 return false; 223 return false;
220 label = &m_label; 224 label = &m_label;
221 return true; 225 return true;
222 } 226 }
223 227
224 private: 228 private:
225 const WebCryptoAlgorithm m_hash; 229 const WebCryptoAlgorithm m_hash;
226 const bool m_hasLabel; 230 const bool m_hasLabel;
227 const WebVector<unsigned char> m_label; 231 const WebVector<unsigned char> m_label;
228 }; 232 };
229 233
230 } // namespace WebKit 234 } // namespace WebKit
231 235
232 #endif 236 #endif
OLDNEW
« no previous file with comments | « public/platform/WebCryptoAlgorithm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698