OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_NACL_NACL_VALIDATION_QUERY_H_ | 5 #ifndef CHROME_NACL_NACL_VALIDATION_QUERY_H_ |
6 #define CHROME_NACL_NACL_VALIDATION_QUERY_H_ | 6 #define CHROME_NACL_NACL_VALIDATION_QUERY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // Bytes indicating the "version" of the validator being used. This is used | 32 // Bytes indicating the "version" of the validator being used. This is used |
33 // to implicitly invalidate the cache - changing the version will change the | 33 // to implicitly invalidate the cache - changing the version will change the |
34 // hashes that are produced. | 34 // hashes that are produced. |
35 std::string nacl_version_; | 35 std::string nacl_version_; |
36 }; | 36 }; |
37 | 37 |
38 class NaClValidationQuery { | 38 class NaClValidationQuery { |
39 public: | 39 public: |
40 // SHA256 digest size. | 40 // SHA256 digest size. |
41 static const int kDigestLength = 32; | 41 static const size_t kDigestLength = 32; |
42 | 42 |
43 NaClValidationQuery(NaClValidationDB* db, const std::string& profile_key); | 43 NaClValidationQuery(NaClValidationDB* db, const std::string& profile_key); |
44 | 44 |
45 void AddData(const char* data, size_t length); | 45 void AddData(const char* data, size_t length); |
46 void AddData(const unsigned char* data, size_t length); | 46 void AddData(const unsigned char* data, size_t length); |
47 void AddData(const base::StringPiece& data); | 47 void AddData(const base::StringPiece& data); |
48 | 48 |
49 int QueryKnownToValidate(); | 49 int QueryKnownToValidate(); |
50 | 50 |
51 void SetKnownToValidate(); | 51 void SetKnownToValidate(); |
(...skipping 18 matching lines...) Expand all Loading... |
70 | 70 |
71 crypto::HMAC hasher_; | 71 crypto::HMAC hasher_; |
72 NaClValidationDB* db_; | 72 NaClValidationDB* db_; |
73 | 73 |
74 // The size of buffer_ is a somewhat arbitrary choice. It needs to be at | 74 // The size of buffer_ is a somewhat arbitrary choice. It needs to be at |
75 // at least kDigestLength * 2, but it can be arbitrarily large. In practice | 75 // at least kDigestLength * 2, but it can be arbitrarily large. In practice |
76 // there are 4 calls to AddData (version, architechture, cpu features, and | 76 // there are 4 calls to AddData (version, architechture, cpu features, and |
77 // code), so 4 times digest length means the buffer will not need to be | 77 // code), so 4 times digest length means the buffer will not need to be |
78 // compressed as an intermediate step in the expected use cases. | 78 // compressed as an intermediate step in the expected use cases. |
79 char buffer_[kDigestLength * 4]; | 79 char buffer_[kDigestLength * 4]; |
80 int buffer_length_; | 80 size_t buffer_length_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(NaClValidationQuery); | 82 DISALLOW_COPY_AND_ASSIGN(NaClValidationQuery); |
83 }; | 83 }; |
84 | 84 |
85 // Create a validation cache interface for use by sel_ldr. | 85 // Create a validation cache interface for use by sel_ldr. |
86 struct NaClValidationCache* CreateValidationCache( | 86 struct NaClValidationCache* CreateValidationCache( |
87 NaClValidationDB* db, const std::string& profile_key, | 87 NaClValidationDB* db, const std::string& profile_key, |
88 const std::string& nacl_version); | 88 const std::string& nacl_version); |
89 | 89 |
90 #endif // CHROME_NACL_NACL_VALIDATION_QUERY_H_ | 90 #endif // CHROME_NACL_NACL_VALIDATION_QUERY_H_ |
OLD | NEW |