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

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: 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
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);
+}

Powered by Google App Engine
This is Rietveld 408576698