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

Unified Diff: net/third_party/nss/ssl/bodge/secure_memcmp.c

Issue 394003: Linux: enable building with a local version of libssl. (Closed)
Patch Set: ... Created 11 years, 1 month 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 | « net/third_party/nss/ssl/bodge/nssrenam.h ('k') | net/third_party/nss/ssl/cmpcert.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/third_party/nss/ssl/bodge/secure_memcmp.c
diff --git a/net/third_party/nss/ssl/bodge/secure_memcmp.c b/net/third_party/nss/ssl/bodge/secure_memcmp.c
new file mode 100644
index 0000000000000000000000000000000000000000..c21e866eff57fb037553aba2d0bc872476bd6e79
--- /dev/null
+++ b/net/third_party/nss/ssl/bodge/secure_memcmp.c
@@ -0,0 +1,23 @@
+// This file exists to provide the secure memcmp function. This was added in
+// NSS 3.12.5.
+
+#include <stdlib.h>
+
+/*
+ * Perform a constant-time compare of two memory regions. The return value is
+ * 0 if the memory regions are equal and non-zero otherwise.
+ */
+int
+NSS_SecureMemcmp(const void *ia, const void *ib, size_t n)
+{
+ const unsigned char *a = (const unsigned char*) ia;
+ const unsigned char *b = (const unsigned char*) ib;
+ size_t i;
+ unsigned char r = 0;
+
+ for (i = 0; i < n; ++i) {
+ r |= *a++ ^ *b++;
+ }
+
+ return r;
+}
« no previous file with comments | « net/third_party/nss/ssl/bodge/nssrenam.h ('k') | net/third_party/nss/ssl/cmpcert.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698