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

Side by Side Diff: crypto/secure_hash_default.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | « content/zygote/zygote_main_linux.cc ('k') | crypto/secure_hash_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) 2012 The Chromium Authors. All rights reserved. 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 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/secure_hash.h" 5 #include "crypto/secure_hash.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 #include "crypto/third_party/nss/chromium-blapi.h" 9 #include "crypto/third_party/nss/chromium-blapi.h"
10 #include "crypto/third_party/nss/chromium-sha256.h" 10 #include "crypto/third_party/nss/chromium-sha256.h"
(...skipping 17 matching lines...) Expand all
28 // SecureHash implementation: 28 // SecureHash implementation:
29 void Update(const void* input, size_t len) override { 29 void Update(const void* input, size_t len) override {
30 SHA256_Update(&ctx_, static_cast<const unsigned char*>(input), len); 30 SHA256_Update(&ctx_, static_cast<const unsigned char*>(input), len);
31 } 31 }
32 32
33 void Finish(void* output, size_t len) override { 33 void Finish(void* output, size_t len) override {
34 SHA256_End(&ctx_, static_cast<unsigned char*>(output), NULL, 34 SHA256_End(&ctx_, static_cast<unsigned char*>(output), NULL,
35 static_cast<unsigned int>(len)); 35 static_cast<unsigned int>(len));
36 } 36 }
37 37
38 bool Serialize(Pickle* pickle) override; 38 bool Serialize(base::Pickle* pickle) override;
39 bool Deserialize(PickleIterator* data_iterator) override; 39 bool Deserialize(base::PickleIterator* data_iterator) override;
40 40
41 private: 41 private:
42 SHA256Context ctx_; 42 SHA256Context ctx_;
43 }; 43 };
44 44
45 bool SecureHashSHA256NSS::Serialize(Pickle* pickle) { 45 bool SecureHashSHA256NSS::Serialize(base::Pickle* pickle) {
46 if (!pickle) 46 if (!pickle)
47 return false; 47 return false;
48 48
49 if (!pickle->WriteInt(kSecureHashVersion) || 49 if (!pickle->WriteInt(kSecureHashVersion) ||
50 !pickle->WriteString(kSHA256Descriptor) || 50 !pickle->WriteString(kSHA256Descriptor) ||
51 !pickle->WriteBytes(&ctx_, sizeof(ctx_))) { 51 !pickle->WriteBytes(&ctx_, sizeof(ctx_))) {
52 return false; 52 return false;
53 } 53 }
54 54
55 return true; 55 return true;
56 } 56 }
57 57
58 bool SecureHashSHA256NSS::Deserialize(PickleIterator* data_iterator) { 58 bool SecureHashSHA256NSS::Deserialize(base::PickleIterator* data_iterator) {
59 int version; 59 int version;
60 if (!data_iterator->ReadInt(&version)) 60 if (!data_iterator->ReadInt(&version))
61 return false; 61 return false;
62 62
63 if (version > kSecureHashVersion) 63 if (version > kSecureHashVersion)
64 return false; // We don't know how to deal with this. 64 return false; // We don't know how to deal with this.
65 65
66 std::string type; 66 std::string type;
67 if (!data_iterator->ReadString(&type)) 67 if (!data_iterator->ReadString(&type))
68 return false; 68 return false;
(...skipping 16 matching lines...) Expand all
85 switch (algorithm) { 85 switch (algorithm) {
86 case SHA256: 86 case SHA256:
87 return new SecureHashSHA256NSS(); 87 return new SecureHashSHA256NSS();
88 default: 88 default:
89 NOTIMPLEMENTED(); 89 NOTIMPLEMENTED();
90 return NULL; 90 return NULL;
91 } 91 }
92 } 92 }
93 93
94 } // namespace crypto 94 } // namespace crypto
OLDNEW
« no previous file with comments | « content/zygote/zygote_main_linux.cc ('k') | crypto/secure_hash_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698