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

Side by Side Diff: base/crypto/secure_hash_openssl.cc

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixes comments by eroman Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/crypto/secure_hash_default.cc ('k') | base/crypto/secure_hash_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/crypto/secure_hash.h"
6
7 #include <openssl/ssl.h>
8
9 #include "base/basictypes.h"
10 #include "base/logging.h"
11 #include "base/openssl_util.h"
12
13 namespace base {
14
15 namespace {
16
17 class SecureHashSHA256OpenSSL : public SecureHash {
18 public:
19 SecureHashSHA256OpenSSL() {
20 SHA256_Init(&ctx_);
21 }
22
23 virtual ~SecureHashSHA256OpenSSL() {
24 OPENSSL_cleanse(&ctx_, sizeof(ctx_));
25 }
26
27 virtual void Update(const void* input, size_t len) {
28 SHA256_Update(&ctx_, static_cast<const unsigned char*>(input), len);
29 }
30
31 virtual void Finish(void* output, size_t len) {
32 ScopedOpenSSLSafeSizeBuffer<SHA256_DIGEST_LENGTH> result(
33 static_cast<unsigned char*>(output), len);
34 SHA256_Final(result.safe_buffer(), &ctx_);
35 }
36
37 private:
38 SHA256_CTX ctx_;
39 };
40
41 } // namespace
42
43 SecureHash* SecureHash::Create(Algorithm algorithm) {
44 switch (algorithm) {
45 case SHA256:
46 return new SecureHashSHA256OpenSSL();
47 default:
48 NOTIMPLEMENTED();
49 return NULL;
50 }
51 }
52
53 } // namespace base
OLDNEW
« no previous file with comments | « base/crypto/secure_hash_default.cc ('k') | base/crypto/secure_hash_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698