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

Side by Side Diff: crypto/symmetric_key.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: c Created 9 years, 7 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 #ifndef CRYPTO_SYMMETRIC_KEY_H_ 5 #ifndef CRYPTO_SYMMETRIC_KEY_H_
6 #define CRYPTO_SYMMETRIC_KEY_H_ 6 #define CRYPTO_SYMMETRIC_KEY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 15 matching lines...) Expand all
26 public: 26 public:
27 // Defines the algorithm that a key will be used with. See also 27 // Defines the algorithm that a key will be used with. See also
28 // classs Encrptor. 28 // classs Encrptor.
29 enum Algorithm { 29 enum Algorithm {
30 AES, 30 AES,
31 HMAC_SHA1, 31 HMAC_SHA1,
32 }; 32 };
33 33
34 virtual ~SymmetricKey(); 34 virtual ~SymmetricKey();
35 35
36 // Generates cryptographically strong random bytes. Returns true on success.
37 static bool GenerateRandomBytes(size_t size_in_bits, uint8* out);
wtc 2011/05/16 23:23:29 Please use the recently-added base::RandBytes func
Denis Lagno 2011/05/17 22:15:08 Done.
38
36 // Generates a random key suitable to be used with |algorithm| and of 39 // Generates a random key suitable to be used with |algorithm| and of
37 // |key_size_in_bits| bits. 40 // |key_size_in_bits| bits.
38 // The caller is responsible for deleting the returned SymmetricKey. 41 // The caller is responsible for deleting the returned SymmetricKey.
39 static SymmetricKey* GenerateRandomKey(Algorithm algorithm, 42 static SymmetricKey* GenerateRandomKey(Algorithm algorithm,
40 size_t key_size_in_bits); 43 size_t key_size_in_bits);
41 44
42 // Derives a key from the supplied password and salt using PBKDF2, suitable 45 // Derives a key from the supplied password and salt using PBKDF2, suitable
43 // for use with specified |algorithm|. Note |algorithm| is not the algorithm 46 // for use with specified |algorithm|. Note |algorithm| is not the algorithm
44 // used to derive the key from the password. The caller is responsible for 47 // used to derive the key from the password. The caller is responsible for
45 // deleting the returned SymmetricKey. 48 // deleting the returned SymmetricKey.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // fails with NTE_BAD_KEY/NTE_BAD_LEN 98 // fails with NTE_BAD_KEY/NTE_BAD_LEN
96 std::string raw_key_; 99 std::string raw_key_;
97 #endif 100 #endif
98 101
99 DISALLOW_COPY_AND_ASSIGN(SymmetricKey); 102 DISALLOW_COPY_AND_ASSIGN(SymmetricKey);
100 }; 103 };
101 104
102 } // namespace crypto 105 } // namespace crypto
103 106
104 #endif // CRYPTO_SYMMETRIC_KEY_H_ 107 #endif // CRYPTO_SYMMETRIC_KEY_H_
OLDNEW
« crypto/hmac.h ('K') | « crypto/hmac_win.cc ('k') | crypto/symmetric_key_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698