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

Side by Side Diff: net/socket/dns_cert_provenance_checker.cc

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixes comments by eroman Created 9 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 | Annotate | Revision Log
« no previous file with comments | « net/net.gyp ('k') | net/socket/nss_ssl_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/socket/dns_cert_provenance_checker.h" 5 #include "net/socket/dns_cert_provenance_checker.h"
6 6
7 #if !defined(USE_OPENSSL) 7 #if !defined(USE_OPENSSL)
8 8
9 #include <nspr.h> 9 #include <nspr.h>
10 10
11 #include <hasht.h> 11 #include <hasht.h>
12 #include <keyhi.h> 12 #include <keyhi.h>
13 #include <pk11pub.h> 13 #include <pk11pub.h>
14 #include <sechash.h> 14 #include <sechash.h>
15 15
16 #include <set> 16 #include <set>
17 #include <string> 17 #include <string>
18 18
19 #include "base/base64.h" 19 #include "base/base64.h"
20 #include "base/basictypes.h" 20 #include "base/basictypes.h"
21 #include "base/crypto/encryptor.h"
22 #include "base/crypto/symmetric_key.h"
23 #include "base/lazy_instance.h" 21 #include "base/lazy_instance.h"
24 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
25 #include "base/pickle.h" 23 #include "base/pickle.h"
26 #include "base/threading/non_thread_safe.h" 24 #include "base/threading/non_thread_safe.h"
25 #include "crypto/encryptor.h"
26 #include "crypto/symmetric_key.h"
27 #include "net/base/completion_callback.h" 27 #include "net/base/completion_callback.h"
28 #include "net/base/dns_util.h" 28 #include "net/base/dns_util.h"
29 #include "net/base/dnsrr_resolver.h" 29 #include "net/base/dnsrr_resolver.h"
30 #include "net/base/net_errors.h" 30 #include "net/base/net_errors.h"
31 #include "net/base/net_log.h" 31 #include "net/base/net_log.h"
32 32
33 namespace net { 33 namespace net {
34 34
35 namespace { 35 namespace {
36 36
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // The key and IV are 128-bits and generated from a SHA256 hash of the x 295 // The key and IV are 128-bits and generated from a SHA256 hash of the x
296 // value. 296 // value.
297 char key_data[SHA256_LENGTH]; 297 char key_data[SHA256_LENGTH];
298 HASH_HashBuf(HASH_AlgSHA256, reinterpret_cast<uint8*>(key_data), 298 HASH_HashBuf(HASH_AlgSHA256, reinterpret_cast<uint8*>(key_data),
299 x_data->data, x_data->len); 299 x_data->data, x_data->len);
300 PK11_FreeSymKey(pms); 300 PK11_FreeSymKey(pms);
301 301
302 DCHECK_GE(sizeof(key_data), kKeySizeInBytes + kIVSizeInBytes); 302 DCHECK_GE(sizeof(key_data), kKeySizeInBytes + kIVSizeInBytes);
303 std::string raw_key(key_data, kKeySizeInBytes); 303 std::string raw_key(key_data, kKeySizeInBytes);
304 304
305 scoped_ptr<base::SymmetricKey> symkey( 305 scoped_ptr<crypto::SymmetricKey> symkey(
306 base::SymmetricKey::Import(base::SymmetricKey::AES, raw_key)); 306 crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, raw_key));
307 std::string iv(key_data + kKeySizeInBytes, kIVSizeInBytes); 307 std::string iv(key_data + kKeySizeInBytes, kIVSizeInBytes);
308 308
309 base::Encryptor encryptor; 309 crypto::Encryptor encryptor;
310 bool r = encryptor.Init(symkey.get(), base::Encryptor::CBC, iv); 310 bool r = encryptor.Init(symkey.get(), crypto::Encryptor::CBC, iv);
311 CHECK(r); 311 CHECK(r);
312 312
313 std::string plaintext(reinterpret_cast<const char*>(p.data()), p.size()); 313 std::string plaintext(reinterpret_cast<const char*>(p.data()), p.size());
314 std::string ciphertext; 314 std::string ciphertext;
315 encryptor.Encrypt(plaintext, &ciphertext); 315 encryptor.Encrypt(plaintext, &ciphertext);
316 316
317 // We use another Pickle object to serialise the 'outer' wrapping of the 317 // We use another Pickle object to serialise the 'outer' wrapping of the
318 // plaintext. 318 // plaintext.
319 Pickle outer; 319 Pickle outer;
320 outer.WriteInt(kVersion); 320 outer.WriteInt(kVersion);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 355
356 std::string DnsCertProvenanceChecker::BuildEncryptedReport( 356 std::string DnsCertProvenanceChecker::BuildEncryptedReport(
357 const std::string& hostname, 357 const std::string& hostname,
358 const std::vector<std::string>& der_certs) { 358 const std::vector<std::string>& der_certs) {
359 return ""; 359 return "";
360 } 360 }
361 361
362 } // namespace net 362 } // namespace net
363 363
364 #endif // USE_OPENSSL 364 #endif // USE_OPENSSL
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | net/socket/nss_ssl_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698