OLD | NEW |
---|---|
(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_GENERATE_KEY_RESULT_H_ | |
6 #define CONTENT_CHILD_WEBCRYPTO_GENERATE_KEY_RESULT_H_ | |
7 | |
8 #include "content/common/content_export.h" | |
9 #include "third_party/WebKit/public/platform/WebCrypto.h" | |
10 | |
11 namespace content { | |
12 | |
13 namespace webcrypto { | |
14 | |
15 // This is the result object when generating keys. It encapsulates either a | |
16 // secret key, or a public/private key pair. | |
17 class CONTENT_EXPORT GenerateKeyResult { | |
18 public: | |
19 enum Type { | |
20 // An empty (or "null") result. | |
21 TYPE_NULL, | |
22 | |
23 // The result is a secret key, accessible through secret_key() | |
24 TYPE_SECRET_KEY, | |
25 | |
26 // The result is a public/private key pair, accessible through public_key() | |
27 // and private_key() | |
28 TYPE_PUBLIC_PRIVATE_KEY_PAIR | |
29 }; | |
30 | |
31 // Initializes a "null" instance. | |
32 GenerateKeyResult(); | |
33 | |
34 Type type() const; | |
35 | |
36 // Changes the type of the result. To subsequently assign the key(s) use the | |
37 // mutable_* methods. | |
38 void set_type(Type type); | |
39 | |
40 const blink::WebCryptoKey& secret_key() const; | |
41 const blink::WebCryptoKey& public_key() const; | |
42 const blink::WebCryptoKey& private_key() const; | |
43 | |
44 blink::WebCryptoKey* mutable_secret_key(); | |
45 blink::WebCryptoKey* mutable_public_key(); | |
46 blink::WebCryptoKey* mutable_private_key(); | |
47 | |
48 // Sends the key(s) to the Blink result. Should not be called for "null" | |
49 // results. | |
50 void Complete(blink::WebCryptoResult* out) const; | |
51 | |
52 private: | |
53 Type type_; | |
54 | |
55 blink::WebCryptoKey secret_key_; | |
56 blink::WebCryptoKey public_key_; | |
57 blink::WebCryptoKey private_key_; | |
Ryan Sleevi
2014/10/17 21:01:58
since blink::WebCryptoKey types are direct-assigna
eroman
2014/10/17 22:43:12
Done. I agree mutable_ was a bit odd and not idiom
| |
58 }; | |
59 | |
60 } // namespace webcrypto | |
61 | |
62 } // namespace content | |
63 | |
64 #endif // CONTENT_CHILD_WEBCRYPTO_GENERATE_KEY_RESULT_H_ | |
OLD | NEW |