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

Side by Side Diff: crypto/secure_hash_default.cc

Issue 1882433002: Removing NSS files and USE_OPENSSL flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. 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 unified diff | Download patch
« no previous file with comments | « crypto/rsa_private_key_nss.cc ('k') | crypto/signature_creator.h » ('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) 2012 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 "crypto/secure_hash.h"
6
7 #include <stddef.h>
8
9 #include "base/logging.h"
10 #include "base/pickle.h"
11 #include "crypto/third_party/nss/chromium-blapi.h"
12 #include "crypto/third_party/nss/chromium-sha256.h"
13
14 namespace crypto {
15
16 namespace {
17
18 class SecureHashSHA256NSS : public SecureHash {
19 public:
20 SecureHashSHA256NSS() {
21 SHA256_Begin(&ctx_);
22 }
23
24 SecureHashSHA256NSS(const SecureHashSHA256NSS& other) {
25 SHA256_Clone(&ctx_, const_cast<SHA256Context*>(&other.ctx_));
26 }
27
28 ~SecureHashSHA256NSS() override { memset(&ctx_, 0, sizeof(ctx_)); }
29
30 // SecureHash implementation:
31 void Update(const void* input, size_t len) override {
32 SHA256_Update(&ctx_, static_cast<const unsigned char*>(input), len);
33 }
34
35 void Finish(void* output, size_t len) override {
36 SHA256_End(&ctx_, static_cast<unsigned char*>(output), NULL,
37 static_cast<unsigned int>(len));
38 }
39
40 SecureHash* Clone() const override { return new SecureHashSHA256NSS(*this); }
41
42 size_t GetHashLength() const override { return SHA256_LENGTH; }
43
44 private:
45 SHA256Context ctx_;
46 };
47
48 } // namespace
49
50 SecureHash* SecureHash::Create(Algorithm algorithm) {
51 switch (algorithm) {
52 case SHA256:
53 return new SecureHashSHA256NSS();
54 default:
55 NOTIMPLEMENTED();
56 return NULL;
57 }
58 }
59
60 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/rsa_private_key_nss.cc ('k') | crypto/signature_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698