Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bignum: Rename modulus input argument from m to N in bignum_mod #6780

Closed
minosgalanakis opened this issue Dec 13, 2022 · 11 comments · Fixed by #6903
Closed

Bignum: Rename modulus input argument from m to N in bignum_mod #6780

minosgalanakis opened this issue Dec 13, 2022 · 11 comments · Fixed by #6903
Labels
component-crypto Crypto primitives and low-level interfaces component-test Test framework and CI scripts good-first-issue Good for newcomers priority-medium Medium priority - this can be reviewed as time permits size-s Estimated task size: small (~2d)

Comments

@minosgalanakis
Copy link
Contributor

Suggested enhancement

Replace all references to modulus from m -> N in bignum_mod.c, bignum.h and test_suite_bignum_mod.function

Justification

This is a requirement that was discussed in the review of #6743 and aggreed upon as part of the common conventions for the new bignum interface #6684 .

@minosgalanakis minosgalanakis added component-crypto Crypto primitives and low-level interfaces good-first-issue Good for newcomers size-s Estimated task size: small (~2d) component-test Test framework and CI scripts priority-medium Medium priority - this can be reviewed as time permits labels Dec 13, 2022
@iammihirsig
Copy link
Contributor

iammihirsig commented Dec 29, 2022

Hey , @minosgalanakis I am getting started with my open source journey and like to work on this issue.
I am unclear about :

Replace all references to modulus from m -> N

Can you please explain it further ?
Do I have to replace all m -> to N ?

Example :

if( p_limbs != m->limbs || !mbedtls_mpi_core_lt_ct( p, m->p, m->limbs ) )

Like this :
if( p_limbs != N->limbs || !mbedtls_mpi_core_lt_ct( p, N->p, N->limbs ) )

@minosgalanakis
Copy link
Contributor Author

minosgalanakis commented Dec 29, 2022

Hi @Mihir-Raj-Singh, and thank you for the interest in the project.

Yes that is precicely the ask. Two different ways to represent the modulus have been introduced to the new interface:
mbedtls_mpi_mod_modulus *m and mbedtls_mpi_mod_modulus *N.

The issue is to replace it so that only mbedtls_mpi_mod_modulus *N is used for the shake of consistency.

  • Code: bignum_mod.c, bignum_mod_raw.c, bignum_core.c
  • Documentation: bignum_mod.h, bignum_mod_raw.h, bignum_core.h

n order to make it simpler and quicker to review, I would recommend launching a series of small PR's in succession, each responsible for changing m->N in single function, and it's documentation. They can all be linked to this task. Also since that approach will require some rebasing, it may be better to not have more than two pending review.

@iammihirsig
Copy link
Contributor

Thanks @minosgalanakis ,

I would like to work on this. Please assign me this issue.

If anything is needed further, I will let you know.

@iammihirsig
Copy link
Contributor

Hello @minosgalanakis , I tried renaming modulus input argument in a single function in both files bignum_mod.c and bignum_mod.h

You can refer it here : a433560

  • Is this the correct way to do that ?
  • When do I need to create pull request ?
  • Do i have to edit all the functions separately as I did ?

I'm a little nervous and don't want things to go wrong.
It would be great If you explain things further or suggest me how to move further.

@minosgalanakis
Copy link
Contributor Author

Yes, something like that should suffice.

But you need to make sure that the embedded tests are still passing:

  • Run ctest as described in the documentation
  • Check that the file style is correct by running check_files.py
  • Also in accordance to our DCO we cannot accept contributions that are not signed off. In order to achive that all commits should have a Signed-off-by: Name <email> field in the end. You can add that be rewording the commit. For future commits by using git commit -s syntax will automacially append it to the text message.
  • Also it would be good to follow the commit message structure of existing commits, with one short line for the description, a newline, and a small more verbose text explaining what the commit does. If the modification is minor and self explanatory then the commit body can be ommited. git log --grep='bignum' or git log --grep='Bignum' can give you pointers.

After your personal branch you have made the changes is in good shape, and has passed the tests, you can make the PR request. Again using past PR's as reference can be usefull on how to structure the PR's description.

One the first PR request is ready, and has passed CI you can repeat the process for all functions that need to be renamed.

@iammihirsig
Copy link
Contributor

iammihirsig commented Dec 30, 2022

I tried searching but unable to understand myself.

error

@iammihirsig iammihirsig removed their assignment Dec 30, 2022
@iammihirsig
Copy link
Contributor

Hey @minosgalanakis , I'm getting this error while running check_files.py
Have a look :

python3 check_files.py

Traceback (most recent call last):
  File "/home/scorpion/Desktop/mbedtls/tests/scripts/check_files.py", line 409, in <module>
    run_main()
  File "/home/scorpion/Desktop/mbedtls/tests/scripts/check_files.py", line 402, in run_main
    integrity_check = IntegrityChecker(check_args.log_file)
  File "/home/scorpion/Desktop/mbedtls/tests/scripts/check_files.py", line 345, in __init__
    build_tree.check_repo_path()
  File "/home/scorpion/Desktop/mbedtls/tests/scripts/../../scripts/mbedtls_dev/build_tree.py", line 34, in check_repo_path
    raise Exception("This script must be run from Mbed TLS root")
Exception: This script must be run from Mbed TLS root

How can I fix this ?

@tom-cosgrove-arm
Copy link
Contributor

tom-cosgrove-arm commented Jan 8, 2023

How can I fix this ?

The last line in the output you pasted is Exception: This script must be run from Mbed TLS root.

That means the top of the repository, so:

macos $ ls
3rdparty/    ChangeLog.d/    CONTRIBUTING.md	    doxygen/  Makefile	 SECURITY.md
BRANCHES.md  cmake/	     DartConfiguration.tcl  include/  programs/  SUPPORT.md
BUGS.md      CMakeLists.txt  dco.txt		    library/  README.md  tests/
ChangeLog    configs/	     docs/		    LICENSE   scripts/	 visualc/
macos $ python3 tests/scripts/check_files.py
macos $ echo $?
0

@iammihirsig
Copy link
Contributor

iammihirsig commented Jan 8, 2023

Thanks for the information. It works fine now.

May I ask you what echo $? and 0 means ? What's the purpose of writing it ? and why it outputs 0 ? If I get some error while checking the files still the output will be zero ?

@tom-cosgrove-arm
Copy link
Contributor

tom-cosgrove-arm commented Jan 8, 2023

May I ask you what echo $? and 0 means ?

echo $? means "tell me the exit status of the last command I just ran". And 0 is the usual exit status for "success".

I will normally include this on examples I post where there is no output (like above) to make it clear that the command that I ran succeeded.

If I get some error while checking the files still the output will be zero ?

No, it shouldn't be.

@iammihirsig
Copy link
Contributor

iammihirsig commented Jan 11, 2023

Hello ,
I renamed modulus input argument from m to N in give files as suggested :

  • bignum_mod.c
  • bignum_mod.h
  • bignum_mod_raw.c
  • bignum_mod_raw.h
  • test_suite_bignum_mod.function

Review the PR : #6903

  • Run ctest as described in the documentation

  • Check that the file style is correct by running check_files.py

  • Also in accordance to our DCO we cannot accept contributions that are not signed off. In order to achive that all commits should have a Signed-off-by: Name <email> field in the end. You can add that be rewording the commit. For future commits by using git commit -s syntax will automacially append it to the text message.

  • Also it would be good to follow the commit message structure of existing commits, with one short line for the description, a newline, and a small more verbose text explaining what the commit does. If the modification is minor and self explanatory then the commit body can be ommited. git log --grep='bignum' or git log --grep='Bignum' can give you pointers.

Checklist :

  • Run Ctest ( All test passed successfully)
  • Run check_files.py (File system are correct)
  • Signed the commit

@minosgalanakis minosgalanakis linked a pull request Jan 11, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-crypto Crypto primitives and low-level interfaces component-test Test framework and CI scripts good-first-issue Good for newcomers priority-medium Medium priority - this can be reviewed as time permits size-s Estimated task size: small (~2d)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants