summaryrefslogtreecommitdiffstats
path: root/net/third_party/nss/ssl/bodge/secure_memcmp.c
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-29 13:00:01 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-29 13:00:01 +0000
commit8fc73c77bef5950266756a691b90b5d1a6b4ee67 (patch)
tree4f83f8fac6584572a90dd9fb270e92fb131ee076 /net/third_party/nss/ssl/bodge/secure_memcmp.c
parent06c3261f668bf413e8f85e4a26593f970cac700a (diff)
downloadchromium_src-8fc73c77bef5950266756a691b90b5d1a6b4ee67.zip
chromium_src-8fc73c77bef5950266756a691b90b5d1a6b4ee67.tar.gz
chromium_src-8fc73c77bef5950266756a691b90b5d1a6b4ee67.tar.bz2
Revert 209278 "Update dependency to NSS >= 3.14.3 and NSPR >= 4.9.2"
> Update dependency to NSS >= 3.14.3 and NSPR >= 4.9.2 > > Technically NSS 3.14.3 depends on NSPR 4.9.5, but Debian stable still > ships 4.9.2 on stable, so this is the lower bound. > > 3.14.3 contains a number of important security fixes, and support for > older systems is no longer desirable. > > BUG=245370 > R=thestig@chromium.org, wtc@chromium.org > > Review URL: https://chromiumcodereview.appspot.com/18063013 TBR=rsleevi@chromium.org Review URL: https://codereview.chromium.org/18181019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209282 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/third_party/nss/ssl/bodge/secure_memcmp.c')
-rw-r--r--net/third_party/nss/ssl/bodge/secure_memcmp.c59
1 files changed, 59 insertions, 0 deletions
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 0000000..b18579c
--- /dev/null
+++ b/net/third_party/nss/ssl/bodge/secure_memcmp.c
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Netscape security libraries.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1994-2000
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// 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;
+}