aboutsummaryrefslogtreecommitdiff
path: root/src/include
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/include
parent26d3ef062b33e43e076b7ecef20c4ec3f9441860 (diff)
downloadipxe-13e390d54edde17c8e22b0f6d8897c273a91c5d0.zip
ipxe-13e390d54edde17c8e22b0f6d8897c273a91c5d0.tar.gz
ipxe-13e390d54edde17c8e22b0f6d8897c273a91c5d0.tar.bz2
[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/include')
-rw-r--r--src/include/ipxe/bigint.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/include/ipxe/bigint.h b/src/include/ipxe/bigint.h
index 36138dd..820d306 100644
--- a/src/include/ipxe/bigint.h
+++ b/src/include/ipxe/bigint.h
@@ -8,6 +8,8 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+#include <assert.h>
+
/**
* Define a big-integer type
*
@@ -177,6 +179,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
} while ( 0 )
/**
+ * Copy big integer
+ *
+ * @v source Source big integer
+ * @v dest Destination big integer
+ */
+#define bigint_copy( source, dest ) do { \
+ build_assert ( sizeof ( *(source) ) == sizeof ( *(dest) ) ); \
+ bigint_shrink ( (source), (dest) ); \
+ } while ( 0 )
+
+/**
* Multiply big integers
*
* @v multiplicand Big integer to be multiplied