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.
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"
16 class RsaPssImplementation
: public RsaHashedAlgorithm
{
18 RsaPssImplementation()
19 : RsaHashedAlgorithm(blink::WebCryptoKeyUsageVerify
,
20 blink::WebCryptoKeyUsageSign
) {}
22 const char* GetJwkAlgorithm(
23 const blink::WebCryptoAlgorithmId hash
) const override
{
25 case blink::WebCryptoAlgorithmIdSha1
:
27 case blink::WebCryptoAlgorithmIdSha256
:
29 case blink::WebCryptoAlgorithmIdSha384
:
31 case blink::WebCryptoAlgorithmIdSha512
:
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
,
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
);
58 AlgorithmImplementation
* CreatePlatformRsaPssImplementation() {
59 return new RsaPssImplementation
;
62 } // namespace webcrypto
64 } // namespace content