aboutsummaryrefslogtreecommitdiff
path: root/funccrypt.h
diff options
context:
space:
mode:
authorsegfault <segfault@secmail.pro>2019-06-04 20:11:35 +0200
committersegfault <segfault@secmail.pro>2019-06-04 20:11:35 +0200
commit954a7be6b2cfe22f854c60ad7ab872708d28a8de (patch)
treeee686d789c269809f5cccfdd4207862803350807 /funccrypt.h
parentaa6421d0785ae4e2f0eafc68fedf9aeaf69e4cc6 (diff)
fine tuning; robust error handling; more debug messages
Signed-off-by: segfault <segfault@secmail.pro>
Diffstat (limited to 'funccrypt.h')
-rw-r--r--funccrypt.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/funccrypt.h b/funccrypt.h
index bdac0f3..56d1930 100644
--- a/funccrypt.h
+++ b/funccrypt.h
@@ -21,21 +21,24 @@ typedef struct crypt_header {
} GCC_PACKED crypt_header;
typedef enum crypt_return {
- CRET_ERROR /* Neither prologue marker nor epilogue marker found. */,
- CRET_PROLOGUE /* prologue marker found */,
- CRET_EPILOGUE /* epilogue marker found */,
- CRET_CHECK /* all pre (en|de)cryption checks successful */,
- CRET_OK /* (en|de)cryption succeeded */
+ CRET_ERROR, /* Neither prologue marker nor epilogue marker found. */
+ CRET_ERROR_MEM, /* set memory page protection failed */
+ CRET_PROLOGUE, /* prologue marker found */
+ CRET_EPILOGUE, /* epilogue marker found */
+ CRET_CHECK, /* all pre (en|de)cryption checks successful */
+ CRET_OK_ENC, /* encryption succeeded */
+ CRET_OK_DEC, /* decryption succeeded */
} crypt_return;
#define CRYPT_FUNC_MAXSIZ 0x100
#define CRYPT_FUNC(fn) \
crypt_func((void *)fn)
+#define CRYPT_RETVAL() __cr
#define CRYPT_PROLOGUE(fn) \
crypt_return __cr; \
{ \
__cr = CRYPT_FUNC(fn); \
- if (__cr != CRET_OK) \
+ if (__cr != CRET_OK_DEC) \
asm volatile goto("jmp %l0 \n" \
: : : : cr_epilogue); \
asm volatile goto("jmp %l0 \n" \
@@ -65,7 +68,8 @@ typedef enum crypt_return {
); \
} \
cr_epilogue: \
- CRYPT_FUNC(fn);
+ if (CRYPT_RETVAL() == CRET_OK_DEC) \
+ CRYPT_FUNC(fn);
#define CRYPT_FNDEF(name, ...) \
void name( __VA_ARGS__ ) { \