OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "google_apis/cup/client_update_protocol.h" | 5 #include "google_apis/cup/client_update_protocol.h" |
6 | 6 |
7 #include <keyhi.h> | 7 #include <keyhi.h> |
8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
9 #include <seccomon.h> | 9 #include <seccomon.h> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "crypto/nss_util.h" | 12 #include "crypto/nss_util.h" |
13 #include "crypto/scoped_nss_types.h" | 13 #include "crypto/scoped_nss_types.h" |
14 | 14 |
15 typedef scoped_ptr_malloc< | 15 typedef scoped_ptr<CERTSubjectPublicKeyInfo, |
16 CERTSubjectPublicKeyInfo, | 16 crypto::NSSDestroyer<CERTSubjectPublicKeyInfo, |
17 crypto::NSSDestroyer<CERTSubjectPublicKeyInfo, | 17 SECKEY_DestroySubjectPublicKeyInfo> > |
18 SECKEY_DestroySubjectPublicKeyInfo> > | |
19 ScopedCERTSubjectPublicKeyInfo; | 18 ScopedCERTSubjectPublicKeyInfo; |
20 | 19 |
21 ClientUpdateProtocol::~ClientUpdateProtocol() { | 20 ClientUpdateProtocol::~ClientUpdateProtocol() { |
22 if (public_key_) | 21 if (public_key_) |
23 SECKEY_DestroyPublicKey(public_key_); | 22 SECKEY_DestroyPublicKey(public_key_); |
24 } | 23 } |
25 | 24 |
26 bool ClientUpdateProtocol::LoadPublicKey(const base::StringPiece& public_key) { | 25 bool ClientUpdateProtocol::LoadPublicKey(const base::StringPiece& public_key) { |
27 crypto::EnsureNSSInit(); | 26 crypto::EnsureNSSInit(); |
28 | 27 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 71 |
73 encrypted_key_source_.resize(keysize); | 72 encrypted_key_source_.resize(keysize); |
74 return SECSuccess == PK11_PubEncryptRaw( | 73 return SECSuccess == PK11_PubEncryptRaw( |
75 public_key_, | 74 public_key_, |
76 &encrypted_key_source_[0], | 75 &encrypted_key_source_[0], |
77 const_cast<unsigned char*>(&key_source[0]), | 76 const_cast<unsigned char*>(&key_source[0]), |
78 key_source.size(), | 77 key_source.size(), |
79 NULL); | 78 NULL); |
80 } | 79 } |
81 | 80 |
OLD | NEW |