Bignum: Add the new modulus and the residue structures with low level I/O operations #6016
Closed
3 tasks
Labels
component-crypto
Crypto primitives and low-level interfaces
enhancement
size-s
Estimated task size: small (~2d)
Add the modulus and the residue structures with low level I/O operations.
Residue structure:
Modulus structure:
(The latter is different from the one in the design document and this is intentional as there were changes based on Gilles's feedback.)
mbedtls_mpi_mont_struct
andmbedtls_mpi_opt_red_struct
are dummy structs for now (eg aliasing tovoid*
).The task is to add life cycle functions and low level I/O:
release
function, that releases the pointer set in setup (sets thep
toNULL
andn
to0
). (The modulus doesn't own the memory pointed byp
either, but will need to allocate memory formbedtls_mpi_opt_red_struct
later). Setup for residue takes a modulus and a raw pointer (mbedtls_mpi_uint*
). It takesn
from there and fails if the value defined by the raw pointer andn
is greater than or equal to the modulus. Setup for the modulus takesp
,n
,ext_rep
,int_rep
and calculatesplen
. All of these havembedtls_mpi_mod
prefix and are declared inlibrary/bignum_mod.h
.mbedtls_mpi_core_read_le()
,mbedtls_mpi_core_write_le()
,mbedtls_mpi_core_read_be()
,mbedtls_mpi_core_write_be()
). These should work exactly like their legacy counterparts (eg.mbedtls_mpi_read_binary()
), but should take a raw pointer (mbedtls_mpi_uint*
) and a length instead of anmbedtls_mpi*
. The legacy functions should call these newmpi_core_
functions instead of duplicating code. The function declarations go intolibrary/bignum_core.h
.mbedtls_mpi_mod_raw_read()
andmbedtls_mpi_mod_raw_write()
) should take a raw pointer (mbedtls_mpi_uint*
) and a modulus. The length and the external representation should be taken from the modulus. The function declarations go intolibrary/bignum_mod_raw.h
.All new function implementations should go into
bignum_new.c
.This task is done when the following changes are merged on
development
:The text was updated successfully, but these errors were encountered: