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

Side by Side Diff: content/renderer/webcrypto/shared_crypto.h

Issue 155623005: Refactor to share more code between OpenSSL and NSS implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make CryptoData ctors explicit, and other comments Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 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 #ifndef CONTENT_RENDERER_WEBCRYPTO_SHARED_CRYPTO_H_
6 #define CONTENT_RENDERER_WEBCRYPTO_SHARED_CRYPTO_H_
7
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "content/common/content_export.h"
11 #include "third_party/WebKit/public/platform/WebArrayBuffer.h"
12 #include "third_party/WebKit/public/platform/WebCrypto.h"
13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
14
15 namespace content {
16
17 namespace webcrypto {
18
19 class CryptoData;
20
21 class Status;
22
23 // Do one-time initialization. It is safe to call this multiple times.
24 CONTENT_EXPORT void Init();
Ryan Sleevi 2014/02/13 04:24:24 FTR, I still really dislike this. This is inconsis
eroman 2014/02/13 23:05:38 I'll explore this as a followup. My concern is it
25
26 // PlatformCrypto is a wrapper around either NSS or OpenSSL for doing
27 // synchronous crypto operations.
28 //
29 // The common code in platform_crypto.cc does various input validations and
30 // extracts the relevant information from the blink data types. It then calls
31 // one of the "Platform*()" methods for the platform specific implementation.
Ryan Sleevi 2014/02/13 04:24:24 You should document what PlatformCrypto is within
eroman 2014/02/13 23:05:38 I revamped this documentation by adding an ASCII a
32 //
33 // These functions do the work which is common to both NSS and OpenSSL
34 // implementations. This involves:
35 //
36 // * Validating the key usages
37 // * Validating key exportability
38 // * Validating algorithm with key.algorithm
39 // * Converting the blink key to a more specific platform::{PublicKey,
40 // PrivateKey, SymKey} and making sure it was the right type.
41 // * Validating alogorithm specific parameters (for instance, was the iv for
42 // AES-CBC 16 bytes).
43 // * Parse a JWK
44
45 CONTENT_EXPORT Status Encrypt(const blink::WebCryptoAlgorithm& algorithm,
46 const blink::WebCryptoKey& key,
47 const CryptoData& data,
48 blink::WebArrayBuffer* buffer);
49
50 CONTENT_EXPORT Status Decrypt(const blink::WebCryptoAlgorithm& algorithm,
51 const blink::WebCryptoKey& key,
52 const CryptoData& data,
53 blink::WebArrayBuffer* buffer);
54
55 CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm,
56 const CryptoData& data,
57 blink::WebArrayBuffer* buffer);
58
59 CONTENT_EXPORT Status
60 GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm,
61 bool extractable,
62 blink::WebCryptoKeyUsageMask usage_mask,
63 blink::WebCryptoKey* key);
64
65 CONTENT_EXPORT Status
66 GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm,
67 bool extractable,
68 blink::WebCryptoKeyUsageMask usage_mask,
69 blink::WebCryptoKey* public_key,
70 blink::WebCryptoKey* private_key);
71
72 CONTENT_EXPORT Status
73 ImportKey(blink::WebCryptoKeyFormat format,
74 const CryptoData& key_data,
75 const blink::WebCryptoAlgorithm& algorithm_or_null,
76 bool extractable,
77 blink::WebCryptoKeyUsageMask usage_mask,
78 blink::WebCryptoKey* key);
79
80 CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format,
81 const blink::WebCryptoKey& key,
82 blink::WebArrayBuffer* buffer);
83
84 CONTENT_EXPORT Status Sign(const blink::WebCryptoAlgorithm& algorithm,
85 const blink::WebCryptoKey& key,
86 const CryptoData& data,
87 blink::WebArrayBuffer* buffer);
88
89 CONTENT_EXPORT Status
90 VerifySignature(const blink::WebCryptoAlgorithm& algorithm,
91 const blink::WebCryptoKey& key,
92 const CryptoData& signature,
93 const CryptoData& data,
94 bool* signature_match);
95
96 CONTENT_EXPORT Status
97 ImportKeyJwk(const CryptoData& key_data,
98 const blink::WebCryptoAlgorithm& algorithm_or_null,
99 bool extractable,
100 blink::WebCryptoKeyUsageMask usage_mask,
101 blink::WebCryptoKey* key);
102
103 } // namespace webcrypto
104
105 } // namespace content
106
107 #endif // CONTENT_RENDERER_WEBCRYPTO_SHARED_CRYPTO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698