mbedtls icon indicating copy to clipboard operation
mbedtls copied to clipboard

Add the new modulus and the residue structures with low level I/O operations

Open gabor-mezei-arm opened this issue 2 years ago • 3 comments

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 the p to NULL and n to 0). (The modulus doesn't own the memory pointed by p either, but will need to allocate memory for mbedtls_mpi_opt_red_struct later). Setup for residue takes a modulus and a raw pointer (mbedtls_mpi_uint*). It takes n from there and fails if the value defined by the raw pointer and n is greater than or equal to the modulus. Setup for the modulus takes p, n, ext_rep, int_rep and calculates plen. All of these have mbedtls_mpi_mod prefix and are declared in library/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 an mbedtls_mpi*. The legacy functions should call these new mpi_core_ functions instead of duplicating code. The function declarations go into library/bignum_core.h.
  • Another set of I/O functions (mbedtls_mpi_mod_raw_read() and mbedtls_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 into library/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.

gabor-mezei-arm avatar Jul 18 '22 21:07 gabor-mezei-arm

Rebased to development head to resolve merge conflict.

yanesca avatar Aug 05 '22 15:08 yanesca

Resolving merge conflict 2nd attempt.

yanesca avatar Aug 05 '22 16:08 yanesca

@tom-cosgrove-arm I haven't addressed your comments, I would like to wait with that until you finish your review.

yanesca avatar Aug 08 '22 13:08 yanesca

@yanesca I doubt I'm going to see anything else for now, so consider this review pass complete

tom-cosgrove-arm avatar Aug 10 '22 15:08 tom-cosgrove-arm

@gabor-mezei-arm are you looking at the CI failures?

tom-cosgrove-arm avatar Aug 12 '22 10:08 tom-cosgrove-arm

@tom-cosgrove-arm, @wernerlewis We have addressed all the review comments and the PR is ready for review again.

yanesca avatar Aug 15 '22 12:08 yanesca

(Sorry @gilles-peskine-arm I didn't mean to re-request your review, I know you are just commenting, it was a misclick.)

yanesca avatar Aug 15 '22 12:08 yanesca

I don't have any more comments on things as they are

tom-cosgrove-arm avatar Aug 18 '22 10:08 tom-cosgrove-arm

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.)

yanesca avatar Aug 19 '22 14:08 yanesca

Force pushed, because the automatic sign-off for suggestions is still not working.

yanesca avatar Aug 22 '22 08:08 yanesca

@tom-cosgrove-arm , @wernerlewis I have addressed all of the comments and the PR is ready for review again.

yanesca avatar Aug 22 '22 09:08 yanesca