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

Side by Side Diff: crypto.h

Issue 3048029: Initial version of tpm_init, a library for taking ownership of the TPM. (Closed) Base URL: ssh://git@chromiumos-git/tpm_init.git
Patch Set: Minor fix to the error code check from TakeOwnership. Created 10 years, 4 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 | « SConstruct ('k') | crypto.cc » ('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) 2009-2010 The Chromium OS 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 // Crypto - class for handling some OpenSSL crypto functions
6
7 #ifndef TPM_INIT_CRYPTO_H_
8 #define TPM_INIT_CRYPTO_H_
9
10 #include <base/basictypes.h>
11 #include <base/file_path.h>
12
13 #include "secure_blob.h"
14
15 namespace tpm_init {
16
17 // Default entropy source is used to seed openssl's random number generator
18 extern const std::string kDefaultEntropySource;
19
20 class Crypto {
21 public:
22
23 // Default constructor, using the default entropy source
24 Crypto();
25
26 virtual ~Crypto();
27
28 // Initializes Crypto
29 bool Init();
30
31 // Seeds the random number generator
32 void SeedRng() const;
33
34 // Returns random bytes of the given length
35 //
36 // Parameters
37 // rand (OUT) - Where to store the random bytes
38 // length - The number of random bytes to store in rand
39 void GetSecureRandom(unsigned char *rand, int length) const;
40
41 // Creates a new RSA key
42 //
43 // Parameters
44 // key_bits - The key size to generate
45 // n (OUT) - the modulus
46 // p (OUT) - the private key
47 bool CreateRsaKey(int key_bits, SecureBlob* n, SecureBlob *p) const;
48
49 // Gets the SHA1 hash of the data provided
50 void GetSha1(const chromeos::Blob& data, int start, int count,
51 SecureBlob* hash) const;
52
53 void AsciiEncodeToBuffer(const chromeos::Blob& blob, char* buffer,
54 int buffer_length);
55
56 private:
57 std::string entropy_source_;
58
59 DISALLOW_COPY_AND_ASSIGN(Crypto);
60 };
61
62 } // namespace tpm_init
63
64 #endif // TPM_INIT_CRYPTO_H_
OLDNEW
« no previous file with comments | « SConstruct ('k') | crypto.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698