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 "components/webcrypto/algorithms/rsa.h"
6 #include "components/webcrypto/algorithms/rsa_sign.h"
7 #include "components/webcrypto/status.h"
8 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
14 class RsaPssImplementation
: public RsaHashedAlgorithm
{
16 RsaPssImplementation()
17 : RsaHashedAlgorithm(blink::WebCryptoKeyUsageVerify
,
18 blink::WebCryptoKeyUsageSign
) {}
20 const char* GetJwkAlgorithm(
21 const blink::WebCryptoAlgorithmId hash
) const override
{
23 case blink::WebCryptoAlgorithmIdSha1
:
25 case blink::WebCryptoAlgorithmIdSha256
:
27 case blink::WebCryptoAlgorithmIdSha384
:
29 case blink::WebCryptoAlgorithmIdSha512
:
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
,
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
);
56 scoped_ptr
<AlgorithmImplementation
> CreateRsaPssImplementation() {
57 return make_scoped_ptr(new RsaPssImplementation
);
60 } // namespace webcrypto