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

Side by Side Diff: content/child/webcrypto/openssl/rsa_pss_openssl.cc

Issue 1077273002: html_viewer: Move webcrypto to a place where html_viewer can use it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT Created 5 years, 8 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 "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"
9
10 namespace content {
11
12 namespace webcrypto {
13
14 namespace {
15
16 class RsaPssImplementation : public RsaHashedAlgorithm {
17 public:
18 RsaPssImplementation()
19 : RsaHashedAlgorithm(blink::WebCryptoKeyUsageVerify,
20 blink::WebCryptoKeyUsageSign) {}
21
22 const char* GetJwkAlgorithm(
23 const blink::WebCryptoAlgorithmId hash) const override {
24 switch (hash) {
25 case blink::WebCryptoAlgorithmIdSha1:
26 return "PS1";
27 case blink::WebCryptoAlgorithmIdSha256:
28 return "PS256";
29 case blink::WebCryptoAlgorithmIdSha384:
30 return "PS384";
31 case blink::WebCryptoAlgorithmIdSha512:
32 return "PS512";
33 default:
34 return NULL;
35 }
36 }
37
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,
43 buffer);
44 }
45
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);
53 }
54 };
55
56 } // namespace
57
58 AlgorithmImplementation* CreatePlatformRsaPssImplementation() {
59 return new RsaPssImplementation;
60 }
61
62 } // namespace webcrypto
63
64 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/openssl/rsa_oaep_openssl.cc ('k') | content/child/webcrypto/openssl/rsa_sign_openssl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698