diff options
author | Andy Polyakov <appro@openssl.org> | 2018-09-01 12:19:30 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2018-11-30 12:51:58 +0000 |
commit | d2cd28b99efa65dbd39cb8db0f2ad992be1aab00 (patch) | |
tree | 5da91fe1accb64c8aa0435090ce43882570dbb66 /crypto/err | |
parent | 89cb61de2af5f0fb07c86de086d57f20d523f6ba (diff) |
err/err.c: add err_clear_last_constant_time.
Expected usage pattern is to unconditionally set error and then
wipe it if there was no actual error.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit f658a3b64d8750642f4975090740865f770c2a1b)
Diffstat (limited to 'crypto/err')
-rw-r--r-- | crypto/err/err.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c index 34061bc662..66a60e907c 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -20,6 +20,7 @@ #include <openssl/opensslconf.h> #include "internal/thread_once.h" #include "internal/ctype.h" +#include "internal/constant_time_locl.h" static int err_load_strings(const ERR_STRING_DATA *str); @@ -878,3 +879,23 @@ int ERR_clear_last_mark(void) es->err_flags[top] &= ~ERR_FLAG_MARK; return 1; } + +void err_clear_last_constant_time(int clear) +{ + ERR_STATE *es; + int top; + + es = ERR_get_state(); + if (es == NULL) + return; + + top = es->top; + + es->err_flags[top] &= ~(0 - clear); + es->err_buffer[top] &= ~(0UL - clear); + es->err_file[top] = (const char *)((uintptr_t)es->err_file[top] & + ~((uintptr_t)0 - clear)); + es->err_line[top] |= 0 - clear; + + es->top = (top + ERR_NUM_ERRORS - clear) % ERR_NUM_ERRORS; +} |