Bug 1343202 - Move Buffer definition into its own file; r=keeler,rbarnes
authorStephanie Ouillon <stephouillon@mozilla.com>
Thu, 17 Aug 2017 09:23:29 +0200
changeset 426736 8192716611b6
parent 426735 bd9c5474a5e4
child 426737 ee4c6aa368ff
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler, rbarnes
bugs1343202
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1343202 - Move Buffer definition into its own file; r=keeler,rbarnes MozReview-Commit-ID: JHAXllvfG3x
security/certverifier/Buffer.cpp
security/certverifier/Buffer.h
security/certverifier/SignedCertificateTimestamp.cpp
security/certverifier/SignedCertificateTimestamp.h
security/certverifier/moz.build
new file mode 100644
--- /dev/null
+++ b/security/certverifier/Buffer.cpp
@@ -0,0 +1,24 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "Buffer.h"
+
+namespace mozilla {
+
+bool
+operator==(const ct::Buffer& a, const ct::Buffer& b)
+{
+  return (a.empty() && b.empty()) ||
+    (a.length() == b.length() && memcmp(a.begin(), b.begin(), a.length()) == 0);
+}
+
+bool
+operator!=(const ct::Buffer& a, const ct::Buffer& b)
+{
+  return !(a == b);
+}
+
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/security/certverifier/Buffer.h
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef Buffer_h
+#define Buffer_h
+
+#include "mozilla/Vector.h"
+
+namespace mozilla { namespace ct {
+
+typedef Vector<uint8_t> Buffer;
+
+} } // namespace mozilla::ct
+
+namespace mozilla {
+
+// Comparison operators are placed under mozilla namespace since
+// mozilla::ct::Buffer is actually mozilla::Vector.
+bool operator==(const ct::Buffer& a, const ct::Buffer& b);
+bool operator!=(const ct::Buffer& a, const ct::Buffer& b);
+
+} // namespace mozilla
+
+
+#endif // Buffer_h
--- a/security/certverifier/SignedCertificateTimestamp.cpp
+++ b/security/certverifier/SignedCertificateTimestamp.cpp
@@ -21,26 +21,8 @@ bool
 DigitallySigned::SignatureParametersMatch(HashAlgorithm aHashAlgorithm,
   SignatureAlgorithm aSignatureAlgorithm) const
 {
   return (hashAlgorithm == aHashAlgorithm) &&
          (signatureAlgorithm == aSignatureAlgorithm);
 }
 
 } } // namespace mozilla::ct
-
-
-namespace mozilla {
-
-bool
-operator==(const ct::Buffer& a, const ct::Buffer& b)
-{
-  return (a.empty() && b.empty()) ||
-    (a.length() == b.length() && memcmp(a.begin(), b.begin(), a.length()) == 0);
-}
-
-bool
-operator!=(const ct::Buffer& a, const ct::Buffer& b)
-{
-  return !(a == b);
-}
-
-} // namespace mozilla
--- a/security/certverifier/SignedCertificateTimestamp.h
+++ b/security/certverifier/SignedCertificateTimestamp.h
@@ -2,25 +2,24 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef SignedCertificateTimestamp_h
 #define SignedCertificateTimestamp_h
 
+#include "Buffer.h"
 #include "mozilla/Vector.h"
 #include "pkix/Input.h"
 #include "pkix/Result.h"
 
 // Structures related to Certificate Transparency (RFC 6962).
 namespace mozilla { namespace ct {
 
-typedef Vector<uint8_t> Buffer;
-
 // LogEntry struct in RFC 6962, Section 3.1.
 struct LogEntry
 {
 
   // LogEntryType enum in RFC 6962, Section 3.1.
   enum class Type {
     X509 = 0,
     Precert = 1
@@ -101,18 +100,9 @@ inline pkix::Result InputToBuffer(pkix::
   if (!buffer.append(input.UnsafeGetData(), input.GetLength())) {
     return pkix::Result::FATAL_ERROR_NO_MEMORY;
   }
   return pkix::Success;
 }
 
 } } // namespace mozilla::ct
 
-namespace mozilla {
-
-// Comparison operators are placed under mozilla namespace since
-// mozilla::ct::Buffer is actually mozilla::Vector.
-bool operator==(const ct::Buffer& a, const ct::Buffer& b);
-bool operator!=(const ct::Buffer& a, const ct::Buffer& b);
-
-} // namespace mozilla
-
 #endif // SignedCertificateTimestamp_h
--- a/security/certverifier/moz.build
+++ b/security/certverifier/moz.build
@@ -4,27 +4,29 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "Security: PSM")
 
 EXPORTS += [
     'BRNameMatchingPolicy.h',
+    'Buffer.h',
     'CertVerifier.h',
     'CTLog.h',
     'CTPolicyEnforcer.h',
     'CTVerifyResult.h',
     'OCSPCache.h',
     'SignedCertificateTimestamp.h',
     'SignedTreeHead.h',
 ]
 
 UNIFIED_SOURCES += [
     'BRNameMatchingPolicy.cpp',
+    'Buffer.cpp',
     'CertVerifier.cpp',
     'CTDiversityPolicy.cpp',
     'CTLogVerifier.cpp',
     'CTObjectsExtractor.cpp',
     'CTPolicyEnforcer.cpp',
     'CTSerialization.cpp',
     'CTVerifyResult.cpp',
     'MultiLogCTVerifier.cpp',