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

Side by Side Diff: content/child/webcrypto/generate_key_result.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
« no previous file with comments | « content/child/webcrypto/generate_key_result.h ('k') | content/child/webcrypto/jwk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/generate_key_result.h"
6
7 #include "base/logging.h"
8
9 namespace content {
10
11 namespace webcrypto {
12
13 GenerateKeyResult::GenerateKeyResult() : type_(TYPE_NULL) {
14 }
15
16 GenerateKeyResult::Type GenerateKeyResult::type() const {
17 return type_;
18 }
19
20 const blink::WebCryptoKey& GenerateKeyResult::secret_key() const {
21 DCHECK_EQ(TYPE_SECRET_KEY, type_);
22 return secret_key_;
23 }
24
25 const blink::WebCryptoKey& GenerateKeyResult::public_key() const {
26 DCHECK_EQ(TYPE_PUBLIC_PRIVATE_KEY_PAIR, type_);
27 return public_key_;
28 }
29
30 const blink::WebCryptoKey& GenerateKeyResult::private_key() const {
31 DCHECK_EQ(TYPE_PUBLIC_PRIVATE_KEY_PAIR, type_);
32 return private_key_;
33 }
34
35 void GenerateKeyResult::AssignSecretKey(const blink::WebCryptoKey& key) {
36 type_ = TYPE_SECRET_KEY;
37 secret_key_ = key;
38 }
39
40 void GenerateKeyResult::AssignKeyPair(const blink::WebCryptoKey& public_key,
41 const blink::WebCryptoKey& private_key) {
42 type_ = TYPE_PUBLIC_PRIVATE_KEY_PAIR;
43 public_key_ = public_key;
44 private_key_ = private_key;
45 }
46
47 void GenerateKeyResult::Complete(blink::WebCryptoResult* out) const {
48 switch (type_) {
49 case TYPE_NULL:
50 NOTREACHED();
51 break;
52 case TYPE_SECRET_KEY:
53 out->completeWithKey(secret_key());
54 break;
55 case TYPE_PUBLIC_PRIVATE_KEY_PAIR:
56 out->completeWithKeyPair(public_key(), private_key());
57 break;
58 }
59 }
60
61 } // namespace webcrypto
62
63 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/generate_key_result.h ('k') | content/child/webcrypto/jwk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698