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 #include <string.h> |
| 8 |
| 9 #include "native_client/src/trusted/validator/caching/validation_signature.h" |
| 10 #include "native_client/src/trusted/validator/caching/hashing_interface.h" |
| 11 |
| 12 void GetValidationSignature(const HashingInterface *hashing, |
| 13 const ValidationInfo *info, |
| 14 const unsigned char *code, |
| 15 unsigned int code_length, |
| 16 ValidationSignature *sig) { |
| 17 void *ctx = hashing->create(info->key, info->key_length); |
| 18 /* Generic validation info */ |
| 19 hashing->update(ctx, (const unsigned char*) info->isa, |
| 20 strlen(info->isa)); |
| 21 hashing->update(ctx, (const unsigned char*) info->version, |
| 22 strlen(info->version)); |
| 23 hashing->update(ctx, (const unsigned char *) info->cpu_features, |
| 24 sizeof(NaClCPUFeatures)); |
| 25 /* Code identity */ |
| 26 hashing->update(ctx, code, code_length); |
| 27 /* Generate hash and cleanup */ |
| 28 hashing->digest(ctx, sig->data, &sig->length, |
| 29 VALIDATION_SIGNATURE_MAX_LENGTH); |
| 30 } |
OLD | NEW |