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->QueryKnownToValidate(query); |
| 35 * QueryKnownToValidate: the key is complete, query the validation status. |
| 36 * This should only be called once. AddData must not be called after calling |
| 37 * this function. |
| 38 * |
| 39 * cache->SetKnownToValidate(query); |
| 40 * SetKnownToValidate: set the database entry for the given key. |
| 41 * QueryKnownToValidate must be called first. |
| 42 * |
| 43 * cache->DestroyQuery(query); |
| 44 * DestroyQuery: cleanup and deallocate the query object. |
| 45 */ |
| 46 |
| 47 struct NaClValidationCache { |
| 48 void *handle; |
| 49 void *(*CreateQuery)(void *handle); |
| 50 void (*AddData)(void *query, const unsigned char *data, size_t length); |
| 51 int (*QueryKnownToValidate)(void *query); |
| 52 void (*SetKnownToValidate)(void *query); |
| 53 void (*DestroyQuery)(void *query); |
| 54 }; |
| 55 |
| 56 EXTERN_C_END |
| 57 |
| 58 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_VALIDATION_CACHE_H_ */ |
OLD | NEW |