Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: components/webcrypto/openssl/rsa_pss_openssl.cc

Issue 1304063015: [refactor] Rename the webcrypto/openssl and webcrypto/test directories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@jwk_refactor
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698