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

Side by Side Diff: components/webcrypto/algorithm_dispatch.h

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: Copy the msvs_disabled_warnings to the new target. 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 #ifndef CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_
6 #define CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_
7
8 #include <stdint.h>
9 #include <vector>
10
11 #include "base/memory/scoped_ptr.h"
12 #include "third_party/WebKit/public/platform/WebCrypto.h"
13
14 namespace components {
15
16 namespace webcrypto {
17
18 class AlgorithmImplementation;
19 class CryptoData;
20 class GenerateKeyResult;
21 class Status;
22
23 // These functions provide an entry point for synchronous webcrypto operations.
24 //
25 // The inputs to these methods come from Blink, and hence the validations done
26 // by Blink can be assumed:
27 //
28 // * The algorithm parameters are consistent with the algorithm
29 // * The key contains the required usage for the operation
30
31 Status Encrypt(const blink::WebCryptoAlgorithm& algorithm,
32 const blink::WebCryptoKey& key,
33 const CryptoData& data,
34 std::vector<uint8_t>* buffer);
35
36 Status Decrypt(const blink::WebCryptoAlgorithm& algorithm,
37 const blink::WebCryptoKey& key,
38 const CryptoData& data,
39 std::vector<uint8_t>* buffer);
40
41 Status Digest(const blink::WebCryptoAlgorithm& algorithm,
42 const CryptoData& data,
43 std::vector<uint8_t>* buffer);
44
45 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
46 bool extractable,
47 blink::WebCryptoKeyUsageMask usages,
48 GenerateKeyResult* result);
49
50 Status ImportKey(blink::WebCryptoKeyFormat format,
51 const CryptoData& key_data,
52 const blink::WebCryptoAlgorithm& algorithm,
53 bool extractable,
54 blink::WebCryptoKeyUsageMask usages,
55 blink::WebCryptoKey* key);
56
57 Status ExportKey(blink::WebCryptoKeyFormat format,
58 const blink::WebCryptoKey& key,
59 std::vector<uint8_t>* buffer);
60
61 Status Sign(const blink::WebCryptoAlgorithm& algorithm,
62 const blink::WebCryptoKey& key,
63 const CryptoData& data,
64 std::vector<uint8_t>* buffer);
65
66 Status Verify(const blink::WebCryptoAlgorithm& algorithm,
67 const blink::WebCryptoKey& key,
68 const CryptoData& signature,
69 const CryptoData& data,
70 bool* signature_match);
71
72 Status WrapKey(blink::WebCryptoKeyFormat format,
73 const blink::WebCryptoKey& key_to_wrap,
74 const blink::WebCryptoKey& wrapping_key,
75 const blink::WebCryptoAlgorithm& wrapping_algorithm,
76 std::vector<uint8_t>* buffer);
77
78 Status UnwrapKey(blink::WebCryptoKeyFormat format,
79 const CryptoData& wrapped_key_data,
80 const blink::WebCryptoKey& wrapping_key,
81 const blink::WebCryptoAlgorithm& wrapping_algorithm,
82 const blink::WebCryptoAlgorithm& algorithm,
83 bool extractable,
84 blink::WebCryptoKeyUsageMask usages,
85 blink::WebCryptoKey* key);
86
87 Status DeriveBits(const blink::WebCryptoAlgorithm& algorithm,
88 const blink::WebCryptoKey& base_key,
89 unsigned int length_bits,
90 std::vector<uint8_t>* derived_bytes);
91
92 // Derives a key by calling the underlying deriveBits/getKeyLength/importKey
93 // operations.
94 //
95 // Note that whereas the WebCrypto spec uses a single "derivedKeyType"
96 // AlgorithmIdentifier in its specification of deriveKey(), here two separate
97 // AlgorithmIdentifiers are used:
98 //
99 // * |import_algorithm| -- The parameters required by the derived key's
100 // "importKey" operation.
101 //
102 // * |key_length_algorithm| -- The parameters required by the derived key's
103 // "get key length" operation.
104 //
105 // WebCryptoAlgorithm is not a flexible type like AlgorithmIdentifier (it cannot
106 // be easily re-interpreted as a different parameter type).
107 //
108 // Therefore being provided with separate parameter types for the import
109 // parameters and the key length parameters simplifies passing the right
110 // parameters onto ImportKey() and GetKeyLength() respectively.
111 Status DeriveKey(const blink::WebCryptoAlgorithm& algorithm,
112 const blink::WebCryptoKey& base_key,
113 const blink::WebCryptoAlgorithm& import_algorithm,
114 const blink::WebCryptoAlgorithm& key_length_algorithm,
115 bool extractable,
116 blink::WebCryptoKeyUsageMask usages,
117 blink::WebCryptoKey* derived_key);
118
119 scoped_ptr<blink::WebCryptoDigestor> CreateDigestor(
120 blink::WebCryptoAlgorithmId algorithm);
121
122 bool SerializeKeyForClone(const blink::WebCryptoKey& key,
123 blink::WebVector<uint8_t>* key_data);
124
125 bool DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm,
126 blink::WebCryptoKeyType type,
127 bool extractable,
128 blink::WebCryptoKeyUsageMask usages,
129 const CryptoData& key_data,
130 blink::WebCryptoKey* key);
131
132 } // namespace webcrypto
133
134 } // namespace components
135
136 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_DISPATCH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698