Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1425)

Unified Diff: src/trusted/validator/caching/validation_signature.cc

Issue 9430028: Add function for generating validation signatures. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Fixes Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/trusted/validator/caching/validation_signature.h ('k') | src/trusted/validator/x86/nacl_cpuid.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « src/trusted/validator/caching/validation_signature.h ('k') | src/trusted/validator/x86/nacl_cpuid.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698