mbedtls
mbedtls copied to clipboard
Add the new modulus and the residue structures with low level I/O operations
Description
The task is to add life cycle functions and low level I/O:
- Standard init and free functions for the modulus. The residue doesn't own its memory, it only needs a
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
. - One set of I/O functions (
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
. - Another set of I/O functions (
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
.
Resolve #6016
Status
IN DEVELOPMENT
Todos
- [ ] Tests
- [ ] Documentation
- [ ] Changelog updated
Steps to test or reproduce
Outline the steps to test or reproduce the PR here.
Rebased to development head to resolve merge conflict.
Resolving merge conflict 2nd attempt.
@tom-cosgrove-arm I haven't addressed your comments, I would like to wait with that until you finish your review.
@yanesca I doubt I'm going to see anything else for now, so consider this review pass complete
@gabor-mezei-arm are you looking at the CI failures?
@tom-cosgrove-arm, @wernerlewis We have addressed all the review comments and the PR is ready for review again.
(Sorry @gilles-peskine-arm I didn't mean to re-request your review, I know you are just commenting, it was a misclick.)
I don't have any more comments on things as they are
I think all feedback is addressed and the PR is ready for review again.
(I requested 3 re-reviews, but two reviews are enough. If you get there as the third, you don't need to give a review. That said, all feedback is welcome of course, as always.)
Force pushed, because the automatic sign-off for suggestions is still not working.
@tom-cosgrove-arm , @wernerlewis I have addressed all of the comments and the PR is ready for review again.