Commit graph

66 commits

Author SHA1 Message Date
Tom Cosgrove
8a1f784ece Fix typos in doxygen commands in new bignum modules
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2023-02-01 08:43:54 +00:00
Mihir Raj Singh
432cacf5c2 bignum_mod_raw: Renamed m -> N in mbedtls_mpi_mod_raw_neg()
Signed-off-by: Mihir Raj Singh <mihirrajsingh123@gmail.com>
2023-01-17 11:25:26 +05:30
Mihir Raj Singh
a43290d556 bignum_mod: Renamed m -> N in mbedtls_mpi_mod_write()
Signed-off-by: Mihir Raj Singh <mihirrajsingh123@gmail.com>
2023-01-16 23:08:17 +05:30
Mihir Raj Singh
fdc314b6fe bignum_mod: Renamed m -> N in mbedtls_mpi_mod_read()
Signed-off-by: Mihir Raj Singh <mihirrajsingh123@gmail.com>
2023-01-16 23:06:16 +05:30
Mihir Raj Singh
928a07ba49 bignum_mod: Renamed m -> N in mbedtls_mpi_mod_modulus_free
Signed-off-by: Mihir Raj Singh <mihirrajsingh123@gmail.com>
2023-01-16 23:04:37 +05:30
Mihir Raj Singh
f438ad1ab9 bignum_mod: Renamed m -> N in mbedtls_mpi_mod_modulus_setup()
Signed-off-by: Mihir Raj Singh <mihirrajsingh123@gmail.com>
2023-01-16 23:03:06 +05:30
Mihir Raj Singh
b6fa940fc4 bignum_mod: Renamed m -> N in mbedtls_mpi_mod_modulus_init()
Signed-off-by: Mihir Raj Singh <mihirrajsingh123@gmail.com>
2023-01-16 23:02:04 +05:30
Mihir Raj Singh
b13a58938a bignum_mod: Renamed m -> N in mbedtls_mpi_mod_residue_setup()
Signed-off-by: Mihir Raj Singh <mihirrajsingh123@gmail.com>
2023-01-16 23:01:25 +05:30
Gilles Peskine
449bd8303e Switch to the new code style
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-11 14:50:10 +01:00
Manuel Pégourié-Gonnard
676766ff77
Merge pull request #6776 from gabor-mezei-arm/6222_bignum_mod_mul
Bignum: Implement fixed width modular multiplication
2022-12-23 10:39:30 +01:00
Manuel Pégourié-Gonnard
2fcb4c1d06
Merge pull request #6747 from gilles-peskine-arm/bignum-mod-random
Bignum mod random
2022-12-23 10:36:22 +01:00
Gilles Peskine
eb2e77f617 Document modulus representation selectors
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-20 19:55:51 +01:00
Gabor Mezei
6a31b7252d
Fix documentation
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-20 17:30:19 +01:00
Gabor Mezei
9db81e9cca
Add mod_mul function
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2022-12-20 17:30:13 +01:00
Gilles Peskine
e162b4725c
Merge pull request #6777 from tom-cosgrove-arm/issue-6292-mod_inv
Bignum: Implement high level fixed width modular inversion
2022-12-17 13:26:02 +01:00
Gilles Peskine
b1eea02f74 Implement and test mbedtls_mpi_mod_random
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-16 10:13:29 +01:00
Manuel Pégourié-Gonnard
057b458583
Merge pull request #6766 from wernerlewis/bignum_mod_docs
Bignum: document conventions for bignum mod and mod_raw
2022-12-16 09:58:36 +01:00
Werner Lewis
6bb49ba121 Document const parameter conventions
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 17:04:43 +00:00
Tom Cosgrove
d692ba4248 Note that (as usual) for mbedtls_mpi_mod_inv() residues must be associated with the modulus
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:56:36 +00:00
Tom Cosgrove
4302d02fa8 Add mbedtls_mpi_mod_inv()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-15 16:56:36 +00:00
Werner Lewis
756a34aadc Use lower case for p and r
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 14:53:43 +00:00
Werner Lewis
0f644f48e9 Add output initialization requirement
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 14:13:32 +00:00
Werner Lewis
214ae64349 Replace \p with \c for non-parameter code typeset
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:36:07 +00:00
Werner Lewis
1d89ebf548 Clarify all functions operate modulo N
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:35:41 +00:00
Werner Lewis
a306886b3a Add modulus to parameter ordering
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:35:41 +00:00
Werner Lewis
2e70b9afef Reword bignum sizes section
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:35:41 +00:00
Werner Lewis
2bd263da1e Fix grammar and spelling
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:35:40 +00:00
Werner Lewis
945a165a3c Clarify output requirements
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:22:27 +00:00
Werner Lewis
eac8be76d6 Remove unnecessary type comment
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 13:22:17 +00:00
Werner Lewis
e1eb75dc99 Specify modulus constraints
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-15 12:27:56 +00:00
Werner Lewis
eed01aabd3 Clarify wording in documentation
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-14 09:44:00 +00:00
Werner Lewis
5e9d2e9019 Add conventions for bignum mod and mod_raw
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-12 14:00:25 +00:00
Werner Lewis
e1b6b7c0ac Implement mbedtls_mpi_mod_add()
Signed-off-by: Werner Lewis <werner.lewis@arm.com>
2022-12-06 11:55:32 +00:00
Tom Cosgrove
62b20488f1 Implement mbedtls_mpi_mod_sub()
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
2022-12-01 14:27:37 +00:00
Janos Follath
1f8afa22a4 Bignum Mod: improve documentation and style
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-28 14:58:08 +00:00
Janos Follath
6eb92c0410 Bignum Mod: improve documentation and style
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-26 17:34:37 +00:00
Janos Follath
ee530cc644 Bignum Mod: improve documentation
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-25 17:55:00 +00:00
Janos Follath
fc6fbb4e96 Bignum Mod: improve documentation
Signed-off-by: Janos Follath <janos.follath@arm.com>

Co-authored-by: Tom Cosgrove <tom.cosgrove@arm.com>
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-25 17:55:00 +00:00
Janos Follath
41427dee80 Bignum Mod: improve documentation
Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-25 17:55:00 +00:00
Janos Follath
91295d2b8f Bignum Mod: remove endianness from modulus
The external representation before included more than just endianness
(like reading in Mongtomery curve scalars or converting hashes to
numbers in a standard compliant way).

These are higher level concepts and are out of scope for Bignum and for
the modulus structure.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-25 17:55:00 +00:00
Janos Follath
3e3fc91c33 Bignum Mod: pass endianness as a parameter
The external representation before included more than just endianness
(like reading in Mongtomery curve scalars or converting hashes to
numbers in a standard compliant way).

These are higher level concepts and are out of scope for Bignum and for
the modulus structure.

Passing endianness as a parameter is a step towards removing it from the
modulus structure.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-25 17:55:00 +00:00
Minos Galanakis
8b375451c5 bignum_mod: Refactored mbedtls_mpi_mod_read/write()
This patch adjusts the I/O methods and the tests.
Documentation has also been updated to be more clear.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-25 17:55:00 +00:00
Minos Galanakis
aed832ac16 bignum_mod: Adjusted input checking for mbedtls_mpi_mod_residue_setup()
This patch adjusts the logic of the size checking of the method,
and refactors the tests. Documentation has also been updated.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-25 17:55:00 +00:00
Minos Galanakis
81f4b11010 bignum_mod: Added mbedtls_mpi_mod_read/write() IO functions
This patch adds input and ouput fucntions in the `bignum_mod` layer.
The data will be automatically converted between Cannonical and
Montgomery representation if required.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-11-25 17:55:00 +00:00
Janos Follath
5933f691a2 Add merge slots to Bignum files
Legacy Bignum is excluded as it doesn't get regular extensions like new
ones.

Each slot uses comments of their respective filetype. Since .data files
don't have a syntax for comments, dummy test cases are used. (These test
cases will never be executed and no noise will be added to tests.)

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-11-02 17:27:25 +00:00
Hanno Becker
cd860dfe02 bignum_mod: Added Montgomery constants
This patch adds the Montgomery constants to the `mbedtls_mpi_mont_struct`.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2022-10-27 11:43:54 +01:00
Gilles Peskine
7aab2fbe41 Add a short description of what each module does
There was already a short introduction to _who_ should use each module, but
not to _what_ each module does.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-04 14:50:17 +02:00
Gilles Peskine
7f887bdc05 Move license out of Doxygen comment
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-10-04 14:50:17 +02:00
Janos Follath
a95f204cd3 Improve documentation
Co-authored-by: Tom Cosgrove <81633263+tom-cosgrove-arm@users.noreply.github.com>
Co-authored-by: Werner Lewis <werner.wmlewis@gmail.com>
Co-authored-by: Minos Galanakis <minos.galanakis@arm.com>

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-08-19 13:11:22 +01:00
Janos Follath
b7a88eca42 Bignum: Apply naming conventions
Numbers:

- A, B for mbedtls_mpi_uint* operands
- a, b for mbedtls_mpi_uint operands
- X or x for result
- HAC references where applicable

Lengths:

- Reserve size or length for length/size in bytes or byte buffers.
- For length of mbedtls_mpi_uint* buffers use limbs
- Length parameters are qualified if possible (eg. input_length or
  a_limbs)

Setup functions:

- The parameters match the corresponding structure member's name
- The structure to set up is a standard lower case name even if in other
  functions different naming conventions would apply

Scope of changes/conventions:

- bignum_core
- bignum_mod
- bignum_mod_raw

Signed-off-by: Janos Follath <janos.follath@arm.com>
2022-08-19 13:11:22 +01:00