OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <cryptohi.h> | 5 #include <cryptohi.h> |
6 #include <keyhi.h> | 6 #include <keyhi.h> |
7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
8 #include <secerr.h> | 8 #include <secerr.h> |
9 #include <sechash.h> | 9 #include <sechash.h> |
10 | 10 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 public: | 163 public: |
164 RsaOaepImplementation() | 164 RsaOaepImplementation() |
165 : RsaHashedAlgorithm( | 165 : RsaHashedAlgorithm( |
166 CKF_ENCRYPT | CKF_DECRYPT | CKF_WRAP | CKF_UNWRAP, | 166 CKF_ENCRYPT | CKF_DECRYPT | CKF_WRAP | CKF_UNWRAP, |
167 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageWrapKey, | 167 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageWrapKey, |
168 blink::WebCryptoKeyUsageDecrypt | | 168 blink::WebCryptoKeyUsageDecrypt | |
169 blink::WebCryptoKeyUsageUnwrapKey) {} | 169 blink::WebCryptoKeyUsageUnwrapKey) {} |
170 | 170 |
171 virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, | 171 virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, |
172 bool extractable, | 172 bool extractable, |
173 blink::WebCryptoKeyUsageMask usage_mask, | 173 blink::WebCryptoKeyUsageMask usages, |
174 GenerateKeyResult* result) const override { | 174 GenerateKeyResult* result) const override { |
175 Status status = NssSupportsRsaOaep(); | 175 Status status = NssSupportsRsaOaep(); |
176 if (status.IsError()) | 176 if (status.IsError()) |
177 return status; | 177 return status; |
178 return RsaHashedAlgorithm::GenerateKey( | 178 return RsaHashedAlgorithm::GenerateKey( |
179 algorithm, extractable, usage_mask, result); | 179 algorithm, extractable, usages, result); |
180 } | 180 } |
181 | 181 |
182 virtual Status VerifyKeyUsagesBeforeImportKey( | 182 virtual Status VerifyKeyUsagesBeforeImportKey( |
183 blink::WebCryptoKeyFormat format, | 183 blink::WebCryptoKeyFormat format, |
184 blink::WebCryptoKeyUsageMask usage_mask) const override { | 184 blink::WebCryptoKeyUsageMask usages) const override { |
185 Status status = NssSupportsRsaOaep(); | 185 Status status = NssSupportsRsaOaep(); |
186 if (status.IsError()) | 186 if (status.IsError()) |
187 return status; | 187 return status; |
188 return RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey(format, | 188 return RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey(format, usages); |
189 usage_mask); | |
190 } | 189 } |
191 | 190 |
192 virtual const char* GetJwkAlgorithm( | 191 virtual const char* GetJwkAlgorithm( |
193 const blink::WebCryptoAlgorithmId hash) const override { | 192 const blink::WebCryptoAlgorithmId hash) const override { |
194 switch (hash) { | 193 switch (hash) { |
195 case blink::WebCryptoAlgorithmIdSha1: | 194 case blink::WebCryptoAlgorithmIdSha1: |
196 return "RSA-OAEP"; | 195 return "RSA-OAEP"; |
197 case blink::WebCryptoAlgorithmIdSha256: | 196 case blink::WebCryptoAlgorithmIdSha256: |
198 return "RSA-OAEP-256"; | 197 return "RSA-OAEP-256"; |
199 case blink::WebCryptoAlgorithmIdSha384: | 198 case blink::WebCryptoAlgorithmIdSha384: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 237 |
239 } // namespace | 238 } // namespace |
240 | 239 |
241 AlgorithmImplementation* CreatePlatformRsaOaepImplementation() { | 240 AlgorithmImplementation* CreatePlatformRsaOaepImplementation() { |
242 return new RsaOaepImplementation; | 241 return new RsaOaepImplementation; |
243 } | 242 } |
244 | 243 |
245 } // namespace webcrypto | 244 } // namespace webcrypto |
246 | 245 |
247 } // namespace content | 246 } // namespace content |
OLD | NEW |