summaryrefslogtreecommitdiff
path: root/secure_memory.h
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@mit.edu>2015-03-14 19:47:09 -0400
committerGravatar Benjamin Barenblat <bbaren@mit.edu>2015-03-14 19:47:09 -0400
commitaadb9e2e90925a187877241e50110e4ce7ea80a1 (patch)
tree7cb115e040db2a73c10e5da3f0fe4c16c9f39f9b /secure_memory.h
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'secure_memory.h')
-rw-r--r--secure_memory.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/secure_memory.h b/secure_memory.h
new file mode 100644
index 0000000..d48d6d6
--- /dev/null
+++ b/secure_memory.h
@@ -0,0 +1,57 @@
+/*
+ secure_memory.h - definitions of data structures residing in secure memory
+ (c) 2004-2005 Zeljko Vrba <zvrba@globalnet.hr>
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+#ifndef SECURE_MEMORY_H__
+#define SECURE_MEMORY_H__
+
+/**
+ * @file
+ * This defines the contents of the secure memory.
+ */
+
+/** Maximum size of random state. */
+#define MAX_RANDOM_STATE_SIZE 8192
+
+struct secure_memory {
+ unsigned char random_state[MAX_RANDOM_STATE_SIZE];
+ unsigned int random_numbers[64];
+ char passphrase[1];
+};
+
+extern struct secure_memory *G_secure_memory;
+extern unsigned int G_secure_memory_size;
+
+/**
+ * Set up a chunk of secure memory.
+ *
+ * @return 0 if at least one operation failed, 1 otherwise. In either case
+ * the program execution can continue. There may be other side-effects such
+ * as printing warnings. If there was a fatal error, this function will
+ * terminate the program.
+ */
+int secure_memory_init(void);
+
+/** Destroy secure memory. Zeroes it before destruction. */
+void secure_memory_destroy(void);
+
+#endif /* SECURE_MEMORY_H__ */