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

Side by Side Diff: base/secure_hash_nss.cc

Issue 6276002: Abstracts SHA256 context for NSS / OpenSSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moves to SecureHash (and other comments) Created 9 years, 11 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
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 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/secure_hash.h"
6
7 #include "base/logging.h"
8 #include "base/stl_util-inl.h"
wtc 2011/01/25 19:06:43 Remove this header.
bulach 2011/01/25 20:33:41 Done.
9 #include "base/third_party/nss/blapi.h"
10 #include "base/third_party/nss/sha256.h"
11
12 namespace base {
13
14 namespace {
15
16 class SecureHashSHA256NSS : public SecureHash {
17 public:
18 SecureHashSHA256NSS() {
19 SHA256_Begin(&ctx_);
20 }
21
22 virtual ~SecureHashSHA256NSS() {
23 }
24
25 virtual void Update(const std::string& str) {
26 SHA256_Update(&ctx_, reinterpret_cast<const unsigned char*>(str.data()),
27 static_cast<unsigned int>(str.length()));
28
29 }
30
31 virtual void Finish(void* output, size_t len) {
32 SHA256_End(&ctx_, static_cast<unsigned char*>(output), NULL,
33 static_cast<unsigned int>(len));
34 }
35
36 private:
37 ::SHA256Context ctx_;
wtc 2011/01/25 19:06:43 Nit: you can remove :: now.
bulach 2011/01/25 20:33:41 Done.
38 };
39
40 } // namespace
41
42 SecureHash* SecureHash::Create(Type type) {
43 if (type == TYPE_SHA256)
44 return new SecureHashSHA256NSS();
45 NOTIMPLEMENTED();
46 return NULL;
wtc 2011/01/25 19:06:43 Please use a switch statement to make it easy to a
bulach 2011/01/25 20:33:41 Done.
47 }
48
49 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698