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

Side by Side Diff: base/hmac.h

Issue 6683060: Private API for extensions like ssh-client that need access to TCP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sigh-nedness Created 9 years, 9 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 // Utility class for calculating the HMAC for a given message. We currently 5 // Utility class for calculating the HMAC for a given message. We currently
6 // only support SHA1 for the hash algorithm, but this can be extended easily. 6 // only support SHA1 for the hash algorithm, but this can be extended easily.
7 7
8 #ifndef BASE_HMAC_H_ 8 #ifndef BASE_HMAC_H_
9 #define BASE_HMAC_H_ 9 #define BASE_HMAC_H_
10 #pragma once 10 #pragma once
(...skipping 27 matching lines...) Expand all
38 // Initializes this instance using |key|. Call Init only once. It returns 38 // Initializes this instance using |key|. Call Init only once. It returns
39 // false on the second or later calls. 39 // false on the second or later calls.
40 bool Init(const std::string& key) { 40 bool Init(const std::string& key) {
41 return Init(reinterpret_cast<const unsigned char*>(key.data()), 41 return Init(reinterpret_cast<const unsigned char*>(key.data()),
42 static_cast<int>(key.size())); 42 static_cast<int>(key.size()));
43 } 43 }
44 44
45 // Calculates the HMAC for the message in |data| using the algorithm supplied 45 // Calculates the HMAC for the message in |data| using the algorithm supplied
46 // to the constructor and the key supplied to the Init method. The HMAC is 46 // to the constructor and the key supplied to the Init method. The HMAC is
47 // returned in |digest|, which has |digest_length| bytes of storage available. 47 // returned in |digest|, which has |digest_length| bytes of storage available.
48 bool Sign(const std::string& data, unsigned char* digest, int digest_length); 48 bool Sign(
49 const std::string& data, unsigned char* digest, int digest_length) const;
49 50
50 // TODO(albertb): Add a Verify method. 51 // TODO(albertb): Add a Verify method.
51 52
52 private: 53 private:
53 HashAlgorithm hash_alg_; 54 HashAlgorithm hash_alg_;
54 scoped_ptr<HMACPlatformData> plat_; 55 scoped_ptr<HMACPlatformData> plat_;
55 56
56 DISALLOW_COPY_AND_ASSIGN(HMAC); 57 DISALLOW_COPY_AND_ASSIGN(HMAC);
57 }; 58 };
58 59
59 } // namespace base 60 } // namespace base
60 61
61 #endif // BASE_HMAC_H_ 62 #endif // BASE_HMAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698