Chromium Code Reviews| 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 // TODO(eroman): Is this right? Not enumerated in WebCrypto spec. |
|
Ryan Sleevi
2014/10/17 21:08:14
Where do you see that? It is - https://dvcs.w3.org
eroman
2014/10/17 22:53:38
Confirmed, thanks! (Removed the comment).
... My
| |
| 27 return "PS1"; | |
| 26 case blink::WebCryptoAlgorithmIdSha256: | 28 case blink::WebCryptoAlgorithmIdSha256: |
| 27 return "RS256"; | 29 return "PS256"; |
| 28 case blink::WebCryptoAlgorithmIdSha384: | 30 case blink::WebCryptoAlgorithmIdSha384: |
| 29 return "RS384"; | 31 return "PS384"; |
| 30 case blink::WebCryptoAlgorithmIdSha512: | 32 case blink::WebCryptoAlgorithmIdSha512: |
| 31 return "RS512"; | 33 return "PS512"; |
| 32 default: | 34 default: |
| 33 return NULL; | 35 return NULL; |
| 34 } | 36 } |
| 35 } | 37 } |
| 36 | 38 |
| 37 virtual Status Sign(const blink::WebCryptoAlgorithm& algorithm, | 39 virtual Status Sign(const blink::WebCryptoAlgorithm& algorithm, |
| 38 const blink::WebCryptoKey& key, | 40 const blink::WebCryptoKey& key, |
| 39 const CryptoData& data, | 41 const CryptoData& data, |
| 40 std::vector<uint8_t>* buffer) const override { | 42 std::vector<uint8_t>* buffer) const override { |
| 41 return RsaSign(key, data, buffer); | 43 return RsaSign( |
| 44 key, algorithm.rsaPssParams()->saltLengthBytes(), data, buffer); | |
| 42 } | 45 } |
| 43 | 46 |
| 44 virtual Status Verify(const blink::WebCryptoAlgorithm& algorithm, | 47 virtual Status Verify(const blink::WebCryptoAlgorithm& algorithm, |
| 45 const blink::WebCryptoKey& key, | 48 const blink::WebCryptoKey& key, |
| 46 const CryptoData& signature, | 49 const CryptoData& signature, |
| 47 const CryptoData& data, | 50 const CryptoData& data, |
| 48 bool* signature_match) const override { | 51 bool* signature_match) const override { |
| 49 return RsaVerify(key, signature, data, signature_match); | 52 return RsaVerify(key, |
| 53 algorithm.rsaPssParams()->saltLengthBytes(), | |
| 54 signature, | |
| 55 data, | |
| 56 signature_match); | |
| 50 } | 57 } |
| 51 }; | 58 }; |
| 52 | 59 |
| 53 } // namespace | 60 } // namespace |
| 54 | 61 |
| 55 AlgorithmImplementation* CreatePlatformRsaSsaImplementation() { | 62 AlgorithmImplementation* CreatePlatformRsaPssImplementation() { |
| 56 return new RsaSsaImplementation; | 63 return new RsaPssImplementation; |
| 57 } | 64 } |
| 58 | 65 |
| 59 } // namespace webcrypto | 66 } // namespace webcrypto |
| 60 | 67 |
| 61 } // namespace content | 68 } // namespace content |
| OLD | NEW |