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