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

Side by Side Diff: crypto/hmac_openssl.cc

Issue 618123007: Fix crypto_unittests on Windows BoringSSL port. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « crypto/ec_signature_creator_openssl.cc ('k') | crypto/signature_creator_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "crypto/hmac.h" 5 #include "crypto/hmac.h"
6 6
7 #include <openssl/hmac.h> 7 #include <openssl/hmac.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 plat_->key.assign(plat_->key.size(), 0); 47 plat_->key.assign(plat_->key.size(), 0);
48 STLClearObject(&plat_->key); 48 STLClearObject(&plat_->key);
49 } 49 }
50 50
51 bool HMAC::Sign(const base::StringPiece& data, 51 bool HMAC::Sign(const base::StringPiece& data,
52 unsigned char* digest, 52 unsigned char* digest,
53 size_t digest_length) const { 53 size_t digest_length) const {
54 DCHECK(!plat_->key.empty()); // Init must be called before Sign. 54 DCHECK(!plat_->key.empty()); // Init must be called before Sign.
55 55
56 ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> result(digest, digest_length); 56 ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> result(digest, digest_length);
57 return ::HMAC(hash_alg_ == SHA1 ? EVP_sha1() : EVP_sha256(), 57 return ::HMAC(hash_alg_ == SHA1 ? EVP_sha1() : EVP_sha256(),
Ryan Sleevi 2014/10/01 20:34:03 Can also go the cheap way that's more idiomatic fo
davidben 2014/10/02 00:21:36 Done.
58 &plat_->key[0], plat_->key.size(), 58 &plat_->key[0], plat_->key.size(),
59 reinterpret_cast<const unsigned char*>(data.data()), 59 reinterpret_cast<const unsigned char*>(data.data()),
60 data.size(), 60 data.size(),
61 result.safe_buffer(), NULL); 61 result.safe_buffer(), NULL) != NULL;
62 } 62 }
63 63
64 } // namespace crypto 64 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/ec_signature_creator_openssl.cc ('k') | crypto/signature_creator_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698