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

Unified Diff: content/child/webcrypto/generate_key_result.h

Issue 512023002: Refactor the interface for generating keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Run git-cl format Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/webcrypto/algorithm_implementation.cc ('k') | content/child/webcrypto/generate_key_result.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/generate_key_result.h
diff --git a/content/child/webcrypto/generate_key_result.h b/content/child/webcrypto/generate_key_result.h
new file mode 100644
index 0000000000000000000000000000000000000000..fcc13f808555c3086d4cf7f0d0331cb418475710
--- /dev/null
+++ b/content/child/webcrypto/generate_key_result.h
@@ -0,0 +1,60 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_CHILD_WEBCRYPTO_GENERATE_KEY_RESULT_H_
+#define CONTENT_CHILD_WEBCRYPTO_GENERATE_KEY_RESULT_H_
+
+#include "content/common/content_export.h"
+#include "third_party/WebKit/public/platform/WebCrypto.h"
+
+namespace content {
+
+namespace webcrypto {
+
+// This is the result object when generating keys. It encapsulates either a
+// secret key, or a public/private key pair.
+class CONTENT_EXPORT GenerateKeyResult {
+ public:
+ enum Type {
+ // An empty (or "null") result.
+ TYPE_NULL,
+
+ // The result is a secret key, accessible through secret_key()
+ TYPE_SECRET_KEY,
+
+ // The result is a public/private key pair, accessible through public_key()
+ // and private_key()
+ TYPE_PUBLIC_PRIVATE_KEY_PAIR
+ };
+
+ // Initializes a "null" instance.
+ GenerateKeyResult();
+
+ Type type() const;
+
+ const blink::WebCryptoKey& secret_key() const;
+ const blink::WebCryptoKey& public_key() const;
+ const blink::WebCryptoKey& private_key() const;
+
+ void AssignSecretKey(const blink::WebCryptoKey& key);
+ void AssignKeyPair(const blink::WebCryptoKey& public_key,
+ const blink::WebCryptoKey& private_key);
+
+ // Sends the key(s) to the Blink result. Should not be called for "null"
+ // results.
+ void Complete(blink::WebCryptoResult* out) const;
+
+ private:
+ Type type_;
+
+ blink::WebCryptoKey secret_key_;
+ blink::WebCryptoKey public_key_;
+ blink::WebCryptoKey private_key_;
+};
+
+} // namespace webcrypto
+
+} // namespace content
+
+#endif // CONTENT_CHILD_WEBCRYPTO_GENERATE_KEY_RESULT_H_
« no previous file with comments | « content/child/webcrypto/algorithm_implementation.cc ('k') | content/child/webcrypto/generate_key_result.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698