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