Chromium Code Reviews| 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 #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() | |
| 14 : type_(TYPE_NULL), | |
| 15 secret_key_(blink::WebCryptoKey::createNull()), | |
| 16 public_key_(blink::WebCryptoKey::createNull()), | |
| 17 private_key_(blink::WebCryptoKey::createNull()) { | |
| 18 } | |
| 19 | |
| 20 GenerateKeyResult::Type GenerateKeyResult::type() const { | |
| 21 return type_; | |
| 22 } | |
| 23 | |
| 24 void GenerateKeyResult::set_type(Type type) { | |
| 25 type_ = type; | |
| 26 } | |
| 27 | |
| 28 const blink::WebCryptoKey& GenerateKeyResult::secret_key() const { | |
| 29 DCHECK_EQ(TYPE_SECRET_KEY, type_); | |
| 30 return secret_key_; | |
| 31 } | |
| 32 | |
| 33 const blink::WebCryptoKey& GenerateKeyResult::public_key() const { | |
| 34 DCHECK_EQ(TYPE_PUBLIC_PRIVATE_KEY_PAIR, type_); | |
| 35 return public_key_; | |
| 36 } | |
| 37 | |
| 38 const blink::WebCryptoKey& GenerateKeyResult::private_key() const { | |
| 39 DCHECK_EQ(TYPE_PUBLIC_PRIVATE_KEY_PAIR, type_); | |
| 40 return private_key_; | |
| 41 } | |
| 42 | |
| 43 blink::WebCryptoKey* GenerateKeyResult::mutable_secret_key() { | |
| 44 DCHECK_EQ(TYPE_SECRET_KEY, type_); | |
| 45 return &secret_key_; | |
| 46 } | |
| 47 | |
| 48 blink::WebCryptoKey* GenerateKeyResult::mutable_public_key() { | |
| 49 DCHECK_EQ(TYPE_PUBLIC_PRIVATE_KEY_PAIR, type_); | |
| 50 return &public_key_; | |
| 51 ; | |
|
Ryan Sleevi
2014/10/17 21:01:58
del
eroman
2014/10/17 22:43:12
Done.
| |
| 52 } | |
| 53 | |
| 54 blink::WebCryptoKey* GenerateKeyResult::mutable_private_key() { | |
| 55 DCHECK_EQ(TYPE_PUBLIC_PRIVATE_KEY_PAIR, type_); | |
| 56 return &private_key_; | |
| 57 } | |
| 58 | |
| 59 void GenerateKeyResult::Complete(blink::WebCryptoResult* out) const { | |
| 60 switch (type_) { | |
| 61 case TYPE_NULL: | |
| 62 NOTREACHED(); | |
| 63 break; | |
| 64 case TYPE_SECRET_KEY: | |
| 65 out->completeWithKey(secret_key()); | |
| 66 break; | |
| 67 case TYPE_PUBLIC_PRIVATE_KEY_PAIR: | |
| 68 out->completeWithKeyPair(public_key(), private_key()); | |
| 69 break; | |
| 70 } | |
| 71 } | |
| 72 | |
| 73 } // namespace webcrypto | |
| 74 | |
| 75 } // namespace content | |
| OLD | NEW |