Skip to content

Commit f50d056

Browse files
sjaeckelkarel-m
authored andcommitted
Introduce LTC_NO_STRUCT_PADDING.
Directly use it in `ltc_rsa_op_parameters`. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
1 parent 459bd79 commit f50d056

4 files changed

Lines changed: 11 additions & 1 deletion

File tree

.ci/build_options.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ options=(
1818
-DLTC_MECC_FP
1919
-DLTC_NO_TABLES
2020
-DLTC_NO_FAST
21+
-DLTC_NO_STRUCT_PADDING
2122
-DLTC_NO_ASM
2223
-DLTC_NO_DEPRECATED_APIS
2324
-DLTC_NO_ECC_TIMING_RESISTANT

doc/crypt.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9454,6 +9454,10 @@ \subsection{LTC\_CLEAN\_STACK}
94549454
When this functions is defined the functions that store key material on the stack will clean up afterwards.
94559455
Assumes that you have no memory paging with the stack.
94569456

9457+
\subsection{LTC\_NO\_STRUCT\_PADDING}
9458+
Per default the library adds padding to some structs, which are likely to be extended sometime in the future, in order
9459+
to provide ABI compatibility to previous versions. To trim down struct sizes where possible, define this macro.
9460+
94579461
\subsection{LTC\_TEST}
94589462
When this has been defined the various self--test functions (for ciphers, hashes, prngs, etc) are included in the build. This is the default configuration.
94599463
If LTC\_NO\_TEST has been defined, the testing routines will be compacted and only return CRYPT\_NOP.

src/headers/tomcrypt_custom.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@
153153
/* clean the stack of functions which put private information on stack */
154154
/* #define LTC_CLEAN_STACK */
155155

156+
/* enable this in case you want to disable padding elements in structs */
157+
/* #define LTC_NO_STRUCT_PADDING */
158+
156159
/* disable all file related functions */
157160
/* #define LTC_NO_FILE */
158161

src/headers/tomcrypt_pk.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ typedef struct ltc_rsa_op_parameters {
125125
const unsigned char *lparam;
126126
unsigned long lparamlen;
127127
} crypt;
128+
#ifndef LTC_NO_STRUCT_PADDING
128129
/* let's make space for potential future extensions */
129-
ulong64 dummy[8];
130+
void* padding[8];
131+
#endif
130132
} u;
131133
} ltc_rsa_op_parameters;
132134

0 commit comments

Comments
 (0)