From aadb9e2e90925a187877241e50110e4ce7ea80a1 Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Sat, 14 Mar 2015 19:47:09 -0400 Subject: Imported Upstream version 1.3 --- secure_memory.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 secure_memory.h (limited to 'secure_memory.h') 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 + + 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__ */ -- cgit v1.2.3