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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « SConstruct ('k') | crypto.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto.h
diff --git a/crypto.h b/crypto.h
new file mode 100644
index 0000000000000000000000000000000000000000..16a54137fca1cb32d08758f20e93b4460d966160
--- /dev/null
+++ b/crypto.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Crypto - class for handling some OpenSSL crypto functions
+
+#ifndef TPM_INIT_CRYPTO_H_
+#define TPM_INIT_CRYPTO_H_
+
+#include <base/basictypes.h>
+#include <base/file_path.h>
+
+#include "secure_blob.h"
+
+namespace tpm_init {
+
+// Default entropy source is used to seed openssl's random number generator
+extern const std::string kDefaultEntropySource;
+
+class Crypto {
+ public:
+
+ // Default constructor, using the default entropy source
+ Crypto();
+
+ virtual ~Crypto();
+
+ // Initializes Crypto
+ bool Init();
+
+ // Seeds the random number generator
+ void SeedRng() const;
+
+ // Returns random bytes of the given length
+ //
+ // Parameters
+ // rand (OUT) - Where to store the random bytes
+ // length - The number of random bytes to store in rand
+ void GetSecureRandom(unsigned char *rand, int length) const;
+
+ // Creates a new RSA key
+ //
+ // Parameters
+ // key_bits - The key size to generate
+ // n (OUT) - the modulus
+ // p (OUT) - the private key
+ bool CreateRsaKey(int key_bits, SecureBlob* n, SecureBlob *p) const;
+
+ // Gets the SHA1 hash of the data provided
+ void GetSha1(const chromeos::Blob& data, int start, int count,
+ SecureBlob* hash) const;
+
+ void AsciiEncodeToBuffer(const chromeos::Blob& blob, char* buffer,
+ int buffer_length);
+
+ private:
+ std::string entropy_source_;
+
+ DISALLOW_COPY_AND_ASSIGN(Crypto);
+};
+
+} // namespace tpm_init
+
+#endif // TPM_INIT_CRYPTO_H_
« no previous file with comments | « SConstruct ('k') | crypto.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698