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..4128d7fa56e6ebbd7c3de78b9f909d9ec9f4cd65 |
--- /dev/null |
+++ b/src/trusted/validator/caching/validation_signature.cc |
@@ -0,0 +1,30 @@ |
+/* |
+ * 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->digest(ctx, sig->data, &sig->length, |
+ VALIDATION_SIGNATURE_MAX_LENGTH); |
+} |