aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2024-01-19 12:29:29 +0000
committerMichael Brown <mcb30@ipxe.org>2024-01-19 12:29:29 +0000
commit13e390d54edde17c8e22b0f6d8897c273a91c5d0 (patch)
tree1c10cef32907d68686cee4a8a2ec68a7a51b5d10 /src/tests
parent26d3ef062b33e43e076b7ecef20c4ec3f9441860 (diff)
downloadipxe-13e390d54edde17c8e22b0f6d8897c273a91c5d0.tar.gz
[crypto] Add bigint_copy() as a convenient wrapper macro
Big integers may be efficiently copied using bigint_shrink() (which will always copy only the size of the destination integer), but this is potentially confusing to a reader of the code. Provide bigint_copy() as an alias for bigint_shrink() so that the intention of the calling code may be more obvious. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/bigint_test.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tests/bigint_test.c b/src/tests/bigint_test.c
index 02568dffb..484c59134 100644
--- a/src/tests/bigint_test.c
+++ b/src/tests/bigint_test.c
@@ -149,6 +149,16 @@ void bigint_shrink_sample ( const bigint_element_t *source0,
bigint_shrink ( source, dest );
}
+void bigint_copy_sample ( const bigint_element_t *source0,
+ bigint_element_t *dest0, unsigned int size ) {
+ const bigint_t ( size ) *source __attribute__ (( may_alias ))
+ = ( ( const void * ) source0 );
+ bigint_t ( size ) *dest __attribute__ (( may_alias ))
+ = ( ( void * ) dest0 );
+
+ bigint_copy ( source, dest );
+}
+
void bigint_multiply_sample ( const bigint_element_t *multiplicand0,
unsigned int multiplicand_size,
const bigint_element_t *multiplier0,