OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/child/webcrypto/openssl/rsa_hashed_algorithm_openssl.h" | |
6 #include "content/child/webcrypto/openssl/rsa_sign_openssl.h" | |
7 #include "content/child/webcrypto/status.h" | |
8 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | |
9 | |
10 namespace content { | |
11 | |
12 namespace webcrypto { | |
13 | |
14 namespace { | |
15 | |
16 class RsaPssImplementation : public RsaHashedAlgorithm { | |
17 public: | |
18 RsaPssImplementation() | |
19 : RsaHashedAlgorithm(blink::WebCryptoKeyUsageVerify, | |
20 blink::WebCryptoKeyUsageSign) {} | |
21 | |
22 const char* GetJwkAlgorithm( | |
23 const blink::WebCryptoAlgorithmId hash) const override { | |
24 switch (hash) { | |
25 case blink::WebCryptoAlgorithmIdSha1: | |
26 return "PS1"; | |
27 case blink::WebCryptoAlgorithmIdSha256: | |
28 return "PS256"; | |
29 case blink::WebCryptoAlgorithmIdSha384: | |
30 return "PS384"; | |
31 case blink::WebCryptoAlgorithmIdSha512: | |
32 return "PS512"; | |
33 default: | |
34 return NULL; | |
35 } | |
36 } | |
37 | |
38 Status Sign(const blink::WebCryptoAlgorithm& algorithm, | |
39 const blink::WebCryptoKey& key, | |
40 const CryptoData& data, | |
41 std::vector<uint8_t>* buffer) const override { | |
42 return RsaSign(key, algorithm.rsaPssParams()->saltLengthBytes(), data, | |
43 buffer); | |
44 } | |
45 | |
46 Status Verify(const blink::WebCryptoAlgorithm& algorithm, | |
47 const blink::WebCryptoKey& key, | |
48 const CryptoData& signature, | |
49 const CryptoData& data, | |
50 bool* signature_match) const override { | |
51 return RsaVerify(key, algorithm.rsaPssParams()->saltLengthBytes(), | |
52 signature, data, signature_match); | |
53 } | |
54 }; | |
55 | |
56 } // namespace | |
57 | |
58 AlgorithmImplementation* CreatePlatformRsaPssImplementation() { | |
59 return new RsaPssImplementation; | |
60 } | |
61 | |
62 } // namespace webcrypto | |
63 | |
64 } // namespace content | |
OLD | NEW |