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

Unified Diff: crypto/hmac_openssl.cc

Issue 1924093006: Removing crypto/third_party/nss/ and removing crypto _win files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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: crypto/hmac_openssl.cc
diff --git a/crypto/hmac_openssl.cc b/crypto/hmac_openssl.cc
deleted file mode 100644
index d88c0914e740057ff3dab07c0f49484438b99f81..0000000000000000000000000000000000000000
--- a/crypto/hmac_openssl.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2011 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 "crypto/hmac.h"
-
-#include <openssl/hmac.h>
-#include <stddef.h>
-
-#include <algorithm>
-#include <memory>
-#include <vector>
-
-#include "base/logging.h"
-#include "base/stl_util.h"
-#include "crypto/openssl_util.h"
-
-namespace crypto {
-
-struct HMACPlatformData {
- std::vector<unsigned char> key;
-};
-
-HMAC::HMAC(HashAlgorithm hash_alg) : hash_alg_(hash_alg) {
- // Only SHA-1 and SHA-256 hash algorithms are supported now.
- DCHECK(hash_alg_ == SHA1 || hash_alg_ == SHA256);
-}
-
-bool HMAC::Init(const unsigned char* key, size_t key_length) {
- // Init must not be called more than once on the same HMAC object.
- DCHECK(!plat_);
- plat_.reset(new HMACPlatformData());
- plat_->key.assign(key, key + key_length);
- return true;
-}
-
-HMAC::~HMAC() {
- if (plat_) {
- // Zero out key copy.
- plat_->key.assign(plat_->key.size(), 0);
- STLClearObject(&plat_->key);
- }
-}
-
-bool HMAC::Sign(const base::StringPiece& data,
- unsigned char* digest,
- size_t digest_length) const {
- DCHECK(plat_); // Init must be called before Sign.
-
- ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> result(digest, digest_length);
- return !!::HMAC(hash_alg_ == SHA1 ? EVP_sha1() : EVP_sha256(),
- plat_->key.data(), plat_->key.size(),
- reinterpret_cast<const unsigned char*>(data.data()),
- data.size(), result.safe_buffer(), NULL);
-}
-
-} // namespace crypto

Powered by Google App Engine
This is Rietveld 408576698