| 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_malloc< |
| 16 CERTSubjectPublicKeyInfo, | 16 CERTSubjectPublicKeyInfo, |
| 17 crypto::NSSDestroyer<CERTSubjectPublicKeyInfo, | 17 crypto::NSSDestroyer<CERTSubjectPublicKeyInfo, |
| 18 SECKEY_DestroySubjectPublicKeyInfo> > | 18 SECKEY_DestroySubjectPublicKeyInfo> > |
| 19 ScopedCERTSubjectPublicKeyInfo; | 19 ScopedCERTSubjectPublicKeyInfo; |
| 20 | 20 |
| 21 ClientUpdateProtocol::~ClientUpdateProtocol() { | 21 ClientUpdateProtocol::~ClientUpdateProtocol() { |
| 22 if (public_key_) | 22 if (public_key_) |
| 23 SECKEY_DestroyPublicKey(public_key_); | 23 SECKEY_DestroyPublicKey(public_key_); |
| 24 } | 24 } |
| 25 | 25 |
| 26 bool ClientUpdateProtocol::LoadPublicKey(const base::StringPiece& public_key) { | 26 bool ClientUpdateProtocol::LoadPublicKey(const base::StringPiece& public_key) { |
| 27 LOG(ERROR) << "HIIIIIIIIIIIIIIIIIIIIIIIIIII"; |
| 27 crypto::EnsureNSSInit(); | 28 crypto::EnsureNSSInit(); |
| 28 | 29 |
| 29 // The binary blob |public_key| is expected to be a DER-encoded ASN.1 | 30 // The binary blob |public_key| is expected to be a DER-encoded ASN.1 |
| 30 // Subject Public Key Info. | 31 // Subject Public Key Info. |
| 31 SECItem spki_item; | 32 SECItem spki_item; |
| 32 spki_item.type = siBuffer; | 33 spki_item.type = siBuffer; |
| 33 spki_item.data = | 34 spki_item.data = |
| 34 reinterpret_cast<unsigned char*>(const_cast<char*>(public_key.data())); | 35 reinterpret_cast<unsigned char*>(const_cast<char*>(public_key.data())); |
| 35 spki_item.len = static_cast<unsigned int>(public_key.size()); | 36 spki_item.len = static_cast<unsigned int>(public_key.size()); |
| 36 | 37 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 73 |
| 73 encrypted_key_source_.resize(keysize); | 74 encrypted_key_source_.resize(keysize); |
| 74 return SECSuccess == PK11_PubEncryptRaw( | 75 return SECSuccess == PK11_PubEncryptRaw( |
| 75 public_key_, | 76 public_key_, |
| 76 &encrypted_key_source_[0], | 77 &encrypted_key_source_[0], |
| 77 const_cast<unsigned char*>(&key_source[0]), | 78 const_cast<unsigned char*>(&key_source[0]), |
| 78 key_source.size(), | 79 key_source.size(), |
| 79 NULL); | 80 NULL); |
| 80 } | 81 } |
| 81 | 82 |
| OLD | NEW |