| 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 "components/nacl/loader/nacl_validation_query.h" | 5 #include "components/nacl/loader/nacl_validation_query.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "components/nacl/loader/nacl_validation_db.h" | 8 #include "components/nacl/loader/nacl_validation_db.h" |
| 9 #include "crypto/nss_util.h" | 9 #include "crypto/nss_util.h" |
| 10 #include "native_client/src/include/portability.h" | 10 #include "native_client/src/include/portability.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 hasher_(crypto::HMAC::SHA256), | 36 hasher_(crypto::HMAC::SHA256), |
| 37 db_(db), | 37 db_(db), |
| 38 buffer_length_(0) { | 38 buffer_length_(0) { |
| 39 // Without this line on Linux, HMAC::Init will instantiate a singleton that | 39 // Without this line on Linux, HMAC::Init will instantiate a singleton that |
| 40 // in turn attempts to open a file. Disabling this behavior avoids a ~70 ms | 40 // in turn attempts to open a file. Disabling this behavior avoids a ~70 ms |
| 41 // stall the first time HMAC is used. | 41 // stall the first time HMAC is used. |
| 42 // This function is also called in nacl_helper_linux.cc, but nacl_helper may | 42 // This function is also called in nacl_helper_linux.cc, but nacl_helper may |
| 43 // not be used in all cases. | 43 // not be used in all cases. |
| 44 // TODO(ncbray) remove when nacl_helper becomes the only code path. | 44 // TODO(ncbray) remove when nacl_helper becomes the only code path. |
| 45 // http://code.google.com/p/chromium/issues/detail?id=118263 | 45 // http://code.google.com/p/chromium/issues/detail?id=118263 |
| 46 #if defined(USE_NSS) | 46 #if defined(USE_NSS_CERTS) |
| 47 crypto::ForceNSSNoDBInit(); | 47 crypto::ForceNSSNoDBInit(); |
| 48 #endif | 48 #endif |
| 49 CHECK(hasher_.Init(profile_key)); | 49 CHECK(hasher_.Init(profile_key)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void NaClValidationQuery::AddData(const char* data, size_t length) { | 52 void NaClValidationQuery::AddData(const char* data, size_t length) { |
| 53 CHECK(state_ == READY); | 53 CHECK(state_ == READY); |
| 54 CHECK(buffer_length_ <= sizeof(buffer_)); | 54 CHECK(buffer_length_ <= sizeof(buffer_)); |
| 55 // Chrome's HMAC class doesn't support incremental signing. Work around | 55 // Chrome's HMAC class doesn't support incremental signing. Work around |
| 56 // this by using a (small) temporary buffer to accumulate data. | 56 // this by using a (small) temporary buffer to accumulate data. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Make sure any fields introduced in a cross-repo change are zeroed. | 136 // Make sure any fields introduced in a cross-repo change are zeroed. |
| 137 memset(cache, 0, sizeof(*cache)); | 137 memset(cache, 0, sizeof(*cache)); |
| 138 cache->handle = new NaClValidationQueryContext(db, profile_key, nacl_version); | 138 cache->handle = new NaClValidationQueryContext(db, profile_key, nacl_version); |
| 139 cache->CreateQuery = CreateQuery; | 139 cache->CreateQuery = CreateQuery; |
| 140 cache->AddData = AddData; | 140 cache->AddData = AddData; |
| 141 cache->QueryKnownToValidate = QueryKnownToValidate; | 141 cache->QueryKnownToValidate = QueryKnownToValidate; |
| 142 cache->SetKnownToValidate = SetKnownToValidate; | 142 cache->SetKnownToValidate = SetKnownToValidate; |
| 143 cache->DestroyQuery = DestroyQuery; | 143 cache->DestroyQuery = DestroyQuery; |
| 144 return cache; | 144 return cache; |
| 145 } | 145 } |
| OLD | NEW |