diff options
author | jsing <> | 2019-10-17 14:28:53 +0000 |
---|---|---|
committer | jsing <> | 2019-10-17 14:28:53 +0000 |
commit | fd5ddb2c2c8843a96f8b820d67e8fdd3652584f2 (patch) | |
tree | 7ed4e105e20b665c90bc3d21f73aa5c72f11fe27 /src | |
parent | fdddd924945f118e2619d3a0d1a3771521a1eca7 (diff) | |
download | openbsd-fd5ddb2c2c8843a96f8b820d67e8fdd3652584f2.tar.gz openbsd-fd5ddb2c2c8843a96f8b820d67e8fdd3652584f2.tar.bz2 openbsd-fd5ddb2c2c8843a96f8b820d67e8fdd3652584f2.zip |
Provide err_clear_last_constant_time() as a way of clearing an error from
the top of the error stack in constant time.
This will be used by upcoming RSA changes.
From OpenSSL 1.1.1d.
ok inoguchi@ tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/constant_time_locl.h | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/err/err.c | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/lib/libcrypto/constant_time_locl.h b/src/lib/libcrypto/constant_time_locl.h index 2cabfb460e..2d511cc0bf 100644 --- a/src/lib/libcrypto/constant_time_locl.h +++ b/src/lib/libcrypto/constant_time_locl.h | |||
@@ -200,6 +200,8 @@ static inline int constant_time_select_int(unsigned int mask, int a, int b) | |||
200 | return (int)(constant_time_select(mask, (unsigned)(a), (unsigned)(b))); | 200 | return (int)(constant_time_select(mask, (unsigned)(a), (unsigned)(b))); |
201 | } | 201 | } |
202 | 202 | ||
203 | void err_clear_last_constant_time(int clear); | ||
204 | |||
203 | __END_HIDDEN_DECLS | 205 | __END_HIDDEN_DECLS |
204 | 206 | ||
205 | #endif /* HEADER_CONSTANT_TIME_LOCL_H */ | 207 | #endif /* HEADER_CONSTANT_TIME_LOCL_H */ |
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index caabfe01d6..f05567e173 100644 --- a/src/lib/libcrypto/err/err.c +++ b/src/lib/libcrypto/err/err.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: err.c,v 1.47 2018/04/03 21:59:37 tb Exp $ */ | 1 | /* $OpenBSD: err.c,v 1.48 2019/10/17 14:28:53 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -1184,3 +1184,24 @@ ERR_pop_to_mark(void) | |||
1184 | es->err_flags[es->top]&=~ERR_FLAG_MARK; | 1184 | es->err_flags[es->top]&=~ERR_FLAG_MARK; |
1185 | return 1; | 1185 | return 1; |
1186 | } | 1186 | } |
1187 | |||
1188 | void | ||
1189 | err_clear_last_constant_time(int clear) | ||
1190 | { | ||
1191 | ERR_STATE *es; | ||
1192 | int top; | ||
1193 | |||
1194 | es = ERR_get_state(); | ||
1195 | if (es == NULL) | ||
1196 | return; | ||
1197 | |||
1198 | top = es->top; | ||
1199 | |||
1200 | es->err_flags[top] &= ~(0 - clear); | ||
1201 | es->err_buffer[top] &= ~(0UL - clear); | ||
1202 | es->err_file[top] = (const char *)((uintptr_t)es->err_file[top] & | ||
1203 | ~((uintptr_t)0 - clear)); | ||
1204 | es->err_line[top] |= 0 - clear; | ||
1205 | |||
1206 | es->top = (top + ERR_NUM_ERRORS - clear) % ERR_NUM_ERRORS; | ||
1207 | } | ||