Bug 1061992 - remove Chromium hmac code from IPC code. rs=bent
authorJosh Aas <joshmoz@gmail.com>
Tue, 02 Sep 2014 19:33:04 -0500
changeset 226524 71ec25256a20783e27e8f20b092496ad780b3de7
parent 226523 4d82830573115557f50c6de8b4e29620b8f866d2
child 226525 aaa0c099b8ac0c31e7865eee6ed75d7ceaa58047
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs1061992
milestone35.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 1061992 - remove Chromium hmac code from IPC code. rs=bent
ipc/chromium/moz.build
ipc/chromium/src/base/hmac.h
ipc/chromium/src/base/hmac_mac.cc
--- a/ipc/chromium/moz.build
+++ b/ipc/chromium/moz.build
@@ -173,17 +173,16 @@ if os_posix:
             'src/base/message_pump_android.cc',
         ]
         DEFINES['ANDROID'] = True
         DEFINES['_POSIX_MONOTONIC_CLOCK'] = 0
 
 if os_macosx:
     UNIFIED_SOURCES += [
         'src/base/debug_util_mac.cc',
-        'src/base/hmac_mac.cc',
         'src/base/idle_timer.cc',
         'src/base/sys_info_mac.cc',
         'src/base/time_mac.cc',
         'src/chrome/common/mach_message_source_mac.cc',
         'src/chrome/common/transport_dib_mac.cc',
     ]
     SOURCES += [
         'src/base/chrome_application_mac.mm',
deleted file mode 100644
--- a/ipc/chromium/src/base/hmac.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Utility class for calculating the HMAC for a given message. We currently
-// only support SHA1 for the hash algorithm, but this can be extended easily.
-
-#ifndef BASE_HMAC_H_
-#define BASE_HMAC_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/scoped_ptr.h"
-
-namespace base {
-
-// Simplify the interface and reduce includes by abstracting out the internals.
-struct HMACPlatformData;
-
-class HMAC {
- public:
-  // The set of supported hash functions. Extend as required.
-  enum HashAlgorithm {
-    SHA1
-  };
-
-  explicit HMAC(HashAlgorithm hash_alg);
-  ~HMAC();
-
-  // Initializes this instance using |key| of the length |key_length|. Call Init
-  // only once. It returns false on the second or later calls.
-  bool Init(const unsigned char* key, int key_length);
-
-  // Initializes this instance using |key|. Call Init only once. It returns
-  // false on the second or later calls.
-  bool Init(const std::string& key) {
-    return Init(reinterpret_cast<const unsigned char*>(key.data()),
-                static_cast<int>(key.size()));
-  }
-
-  // Calculates the HMAC for the message in |data| using the algorithm supplied
-  // to the constructor and the key supplied to the Init method. The HMAC is
-  // returned in |digest|, which has |digest_length| bytes of storage available.
-  bool Sign(const std::string& data, unsigned char* digest, int digest_length);
-
- private:
-  HashAlgorithm hash_alg_;
-  scoped_ptr<HMACPlatformData> plat_;
-
-  DISALLOW_COPY_AND_ASSIGN(HMAC);
-};
-
-}  // namespace base
-
-#endif  // BASE_HMAC_H_
deleted file mode 100644
--- a/ipc/chromium/src/base/hmac_mac.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) 2008 The Chromium 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 "base/hmac.h"
-
-#include <CommonCrypto/CommonHMAC.h>
-
-#include "base/logging.h"
-
-namespace base {
-
-struct HMACPlatformData {
-  std::string key_;
-};
-
-HMAC::HMAC(HashAlgorithm hash_alg)
-    : hash_alg_(hash_alg), plat_(new HMACPlatformData()) {
-  // Only SHA-1 digest is supported now.
-  DCHECK(hash_alg_ == SHA1);
-}
-
-bool HMAC::Init(const unsigned char *key, int key_length) {
-  if (!plat_->key_.empty()) {
-    // Init must not be called more than once on the same HMAC object.
-    NOTREACHED();
-    return false;
-  }
-
-  plat_->key_.assign(reinterpret_cast<const char*>(key), key_length);
-
-  return true;
-}
-
-HMAC::~HMAC() {
-  // Zero out key copy.
-  plat_->key_.assign(plat_->key_.length(), std::string::value_type());
-  plat_->key_.clear();
-  plat_->key_.reserve(0);
-}
-
-bool HMAC::Sign(const std::string& data,
-                unsigned char* digest,
-                int digest_length) {
-  CCHmacAlgorithm algorithm;
-  int algorithm_digest_length;
-  switch (hash_alg_) {
-    case SHA1:
-      algorithm = kCCHmacAlgSHA1;
-      algorithm_digest_length = CC_SHA1_DIGEST_LENGTH;
-      break;
-    default:
-      NOTREACHED();
-      return false;
-  }
-
-  if (digest_length < algorithm_digest_length) {
-    NOTREACHED();
-    return false;
-  }
-
-  CCHmac(algorithm,
-         plat_->key_.data(), plat_->key_.length(), data.data(), data.length(),
-         digest);
-
-  return true;
-}
-
-}  // namespace base