OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can be | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_VALIDATION_CACHE_H_ | |
8 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_VALIDATION_CACHE_H_ | |
9 | |
10 #include "native_client/src/include/nacl_base.h" | |
11 | |
12 EXTERN_C_BEGIN | |
13 | |
14 /* | |
15 * This interface allows the validator to query a database of validation results | |
16 * while hiding details of how the database is implemented. | |
17 * | |
18 * query = cache->CreateQuery(cache->handle); | |
19 * CreateQuery: create an opaque query object, given an opaque context object. | |
20 * The context object contains persistent variables that will be used for all | |
21 * queries, whereas the query object contains information relevant to a single | |
22 * validation result. | |
23 * | |
24 * cache->AddData(query, data, data_size); | |
25 * AddData: add a blob of binary data to the query. Conceptually, the query | |
26 * will concatenate all the binary data it is given, in the order it is given, | |
27 * and use the concatenated blob as a key to look up validation results in a | |
28 * database. In practice, all of the data is hashed into a reasonabally sized | |
29 * key. The validation cache doesn't care what data it is given, it is the | |
30 * responsibility of the validator to provide enough information to uniquely | |
31 * identify the validation result. This gives flexibility to use different | |
32 * types of keys for different validators and different sources of code. | |
33 * | |
34 * validation_passed = cache->QueryCodeValidates(query); | |
35 * QueryCodeValidates: the key is complete, query the validation status. | |
36 * AddData must not be called after calling this function. | |
37 * | |
38 * cache->SetCodeValidates(query); | |
39 * SetCodeValidates: set the database entry for the given key. | |
40 * QueryCodeValidates must be called first. | |
41 * | |
42 * cache->DestroyQuery(query); | |
43 * DestroyQuery: cleanup and deallocate the query object. | |
44 */ | |
45 | |
46 typedef struct NaClValidationCache { | |
Mark Seaborn
2012/03/01 19:23:12
Suggestion: I'd be inclined to refer to it as 'str
Nick Bray (chromium)
2012/03/01 21:16:58
Done.
| |
47 void *handle; | |
48 void *(*CreateQuery)(void *handle); | |
49 void (*AddData)(void *query, const unsigned char *data, size_t length); | |
50 int (*QueryCodeValidates)(void *query); | |
51 void (*SetCodeValidates)(void *query); | |
52 void (*DestroyQuery)(void *query); | |
53 } NaClValidationCache; | |
54 | |
55 EXTERN_C_END | |
56 | |
57 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_VALIDATION_CACHE_H_ */ | |
OLD | NEW |