| Index: src/trusted/validator/caching/validation_signature.cc
|
| diff --git a/src/trusted/validator/caching/validation_signature.cc b/src/trusted/validator/caching/validation_signature.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5124c10999c126b8c3f50e33d13ff395be788185
|
| --- /dev/null
|
| +++ b/src/trusted/validator/caching/validation_signature.cc
|
| @@ -0,0 +1,29 @@
|
| +/*
|
| + * Copyright (c) 2012 The Native Client Authors. All rights reserved.
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +#include <string.h>
|
| +
|
| +#include "native_client/src/trusted/validator/caching/validation_signature.h"
|
| +#include "native_client/src/trusted/validator/caching/hashing_interface.h"
|
| +
|
| +void GetValidationSignature(const HashingInterface *hashing,
|
| + const ValidationInfo *info,
|
| + const unsigned char *code,
|
| + unsigned int code_length,
|
| + ValidationSignature *sig) {
|
| + void *ctx = hashing->create(info->key, info->key_length);
|
| + /* Generic validation info */
|
| + hashing->update(ctx, (const unsigned char*) info->isa,
|
| + strlen(info->isa));
|
| + hashing->update(ctx, (const unsigned char*) info->version,
|
| + strlen(info->version));
|
| + hashing->update(ctx, (const unsigned char *) info->cpu_features,
|
| + sizeof(NaClCPUFeatures));
|
| + /* Code identity */
|
| + hashing->update(ctx, code, code_length);
|
| + /* Generate hash and cleanup */
|
| + hashing->end(ctx, sig->data, &sig->length, VALIDATION_SIGNATURE_MAX_LENGTH);
|
| +}
|
|
|