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

Side by Side Diff: crypto/secure_hash.h

Issue 2095523002: Make //crypto factories return std::unique_ptr<>s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: I'm blind Created 4 years, 5 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/nss_util_internal.h ('k') | crypto/secure_hash.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 #ifndef CRYPTO_SECURE_HASH_H_ 5 #ifndef CRYPTO_SECURE_HASH_H_
6 #define CRYPTO_SECURE_HASH_H_ 6 #define CRYPTO_SECURE_HASH_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "crypto/crypto_export.h" 13 #include "crypto/crypto_export.h"
12 14
13 namespace crypto { 15 namespace crypto {
14 16
15 // A wrapper to calculate secure hashes incrementally, allowing to 17 // A wrapper to calculate secure hashes incrementally, allowing to
16 // be used when the full input is not known in advance. 18 // be used when the full input is not known in advance.
17 class CRYPTO_EXPORT SecureHash { 19 class CRYPTO_EXPORT SecureHash {
18 public: 20 public:
19 enum Algorithm { 21 enum Algorithm {
20 SHA256, 22 SHA256,
21 }; 23 };
22 virtual ~SecureHash() {} 24 virtual ~SecureHash() {}
23 25
24 static SecureHash* Create(Algorithm type); 26 static std::unique_ptr<SecureHash> Create(Algorithm type);
25 27
26 virtual void Update(const void* input, size_t len) = 0; 28 virtual void Update(const void* input, size_t len) = 0;
27 virtual void Finish(void* output, size_t len) = 0; 29 virtual void Finish(void* output, size_t len) = 0;
28 virtual size_t GetHashLength() const = 0; 30 virtual size_t GetHashLength() const = 0;
29 31
30 // Create a clone of this SecureHash. The returned clone and this both 32 // Create a clone of this SecureHash. The returned clone and this both
31 // represent the same hash state. But from this point on, calling 33 // represent the same hash state. But from this point on, calling
32 // Update()/Finish() on either doesn't affect the state of the other. 34 // Update()/Finish() on either doesn't affect the state of the other.
33 virtual SecureHash* Clone() const = 0; 35 virtual std::unique_ptr<SecureHash> Clone() const = 0;
34 36
35 protected: 37 protected:
36 SecureHash() {} 38 SecureHash() {}
37 39
38 private: 40 private:
39 DISALLOW_COPY_AND_ASSIGN(SecureHash); 41 DISALLOW_COPY_AND_ASSIGN(SecureHash);
40 }; 42 };
41 43
42 } // namespace crypto 44 } // namespace crypto
43 45
44 #endif // CRYPTO_SECURE_HASH_H_ 46 #endif // CRYPTO_SECURE_HASH_H_
OLDNEW
« no previous file with comments | « crypto/nss_util_internal.h ('k') | crypto/secure_hash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698