Manuel Pégourié-Gonnard
67dbe1ef44
Better length checking in ecp_point_read_binary()
2014-07-08 14:20:26 +02:00
Paul Bakker
66d5d076f7
Fix formatting in various code to match spacing from coding style
2014-06-17 17:06:47 +02:00
Paul Bakker
d8bb82665e
Fix code styling for return statements
2014-06-17 14:06:49 +02:00
Paul Bakker
3461772559
Introduce polarssl_zeroize() instead of memset() for zeroization
2014-06-14 16:46:03 +02:00
Paul Bakker
9af723cee7
Fix formatting: remove trailing spaces, #endif with comments (> 10 lines)
2014-05-01 13:03:14 +02:00
Manuel Pégourié-Gonnard
cef4ad2509
Adapt sources to configurable config.h name
2014-04-30 16:40:20 +02:00
Paul Bakker
3d8fb63e11
Added missing MPI_CHK around mpi functions
2014-04-17 12:42:41 +02:00
Manuel Pégourié-Gonnard
c042cf0013
Fix broken tests due to changed error code
...
Introduced in 5246ee5c59
2014-03-26 14:12:20 +01:00
Manuel Pégourié-Gonnard
5246ee5c59
Work around compressed EC public key in some cases
2014-03-19 16:50:59 +01:00
Manuel Pégourié-Gonnard
2a2ae642d8
Fix forgotten curves in #ifdef
2014-02-24 10:29:21 +01:00
Paul Bakker
7dc4c44267
Library files moved to use platform layer
2014-02-06 13:20:16 +01:00
Manuel Pégourié-Gonnard
ac7194133e
Renamings and other fixes
2014-02-06 10:28:38 +01:00
Gergely Budai
e40c469ad3
The default ECDH curve list will be dynamically built in the ecp module based on ecp_supported_curves[].
2014-02-06 10:28:38 +01:00
Manuel Pégourié-Gonnard
6e8e34d61e
Fix ecp_gen_keypair()
...
Too few tries caused failures for some curves (esp. secp224k1)
2014-02-05 15:53:45 +01:00
Paul Bakker
bf98c3dd11
Merged deterministic ECDSA
...
Conflicts:
library/ecdsa.c
2014-01-23 15:48:01 +01:00
Manuel Pégourié-Gonnard
9bcff3905b
Add OIDs and TLS IDs for prime Koblitz curves
2014-01-10 18:32:31 +01:00
Manuel Pégourié-Gonnard
c9573998ca
Fix unchecked error codes in ecp_gen_keypair()
2014-01-06 11:01:38 +01:00
Manuel Pégourié-Gonnard
79f73b96d9
Remove bias in EC private key generation
2014-01-06 10:19:35 +01:00
Paul Bakker
c73879139e
Merged ECP memory usage optimizations
2013-12-31 10:33:47 +01:00
Manuel Pégourié-Gonnard
26bc1c0f5d
Fix a few unchecked return codes in EC
2013-12-30 19:33:33 +01:00
Manuel Pégourié-Gonnard
9e4191c3e7
Add another option to reduce EC memory usage
...
Also document speed/memory trade-offs better.
2013-12-30 19:16:05 +01:00
Paul Bakker
ec4bea7eee
Forced cast to unsigned int for %u format in ecp_selftest()
2013-12-30 19:04:47 +01:00
Manuel Pégourié-Gonnard
1f789b8348
Lessen peak memory usage in EC by freeing earlier
...
Cuts peak usage by 25% :)
2013-12-30 17:36:54 +01:00
Manuel Pégourié-Gonnard
72c172a13d
Save some small memory allocations inside ecp_mul()
2013-12-30 16:04:55 +01:00
Paul Bakker
92bcadb110
Removed 'z' length modifier from low-value size_t in ecp_selftest()
2013-12-30 15:37:17 +01:00
Manuel Pégourié-Gonnard
1f82b041e7
Adapt ecp_group_free() to static constants
2013-12-17 11:27:20 +01:00
Manuel Pégourié-Gonnard
73cc01d7fa
Remove last non-static parts of known EC groups
2013-12-17 11:27:20 +01:00
Manuel Pégourié-Gonnard
731d08b406
Start using constants from ROM for EC groups
2013-12-17 11:27:20 +01:00
Manuel Pégourié-Gonnard
93f41dbdfd
Fix possible issue in corner-case for ecp_mul_mx()
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
7a949d3f5b
Update comments
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
d962273594
Add #ifdef's for curve types
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
7c94d8bcab
WIP #ifdef's
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
b6f45a616c
Avoid potential leak in ecp_mul_mxz()
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
97871ef236
Some operations are not supported with Curve25519
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
357ff65a51
Details in ecp_mul_mxz()
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
fe0af405f9
Adapt ecp_gen_keypair() to Curve25519
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
a0179b8c4a
Change ecp_mul to handle Curve25519 too
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
312d2e8ea2
Adapt key checking functions for Curve25519
2013-12-05 15:58:38 +01:00
Manuel Pégourié-Gonnard
3afa07f05b
Add coordinate randomization for Curve25519
2013-12-05 15:58:37 +01:00
Manuel Pégourié-Gonnard
d9ea82e7d9
Add basic arithmetic for Curve25519
2013-12-05 15:58:37 +01:00
Manuel Pégourié-Gonnard
3c0b4ea97e
Rename a few functions
2013-12-05 15:58:37 +01:00
Manuel Pégourié-Gonnard
d5e0fbe1a3
Remove now useless function
2013-12-02 17:20:39 +01:00
Manuel Pégourié-Gonnard
32b04c1237
Split ecp.c
2013-12-02 16:36:11 +01:00
Manuel Pégourié-Gonnard
43863eeffc
Declare internal variables static in ecp.c
2013-12-02 16:34:24 +01:00
Manuel Pégourié-Gonnard
d35e191434
Drop useless include in ecp.c
2013-12-02 16:34:24 +01:00
Manuel Pégourié-Gonnard
0267e3dc9b
Add ecp_curve_info_from_name()
2013-11-30 15:10:14 +01:00
Manuel Pégourié-Gonnard
104ee1d1f6
Add ecp_genkey(), prettier wrapper
2013-11-30 14:35:07 +01:00
Manuel Pégourié-Gonnard
c57b654a3e
Use t_uint rather than uintXX_t when appropriate
2013-11-26 15:19:56 +01:00
Manuel Pégourié-Gonnard
96c7a92b08
Change mpi_safe_cond_assign() for more const-ness
2013-11-25 18:28:53 +01:00
Manuel Pégourié-Gonnard
918148193d
Enhance ecp_selftest
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
d728350cee
Make memory access pattern constant
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
aade42fd88
Change method for making M odd in ecp_mul()
...
- faster
- avoids M >= N (if m = N-1 or N-2)
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
36daa13d76
Misc details
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
469a209334
Rm subtraction from ecp_add_mixed()
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
01fca5e882
Do point inversion without leaking information
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
44aab79022
Update bibliographic references
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
7f762319ad
Use mpi_shrink() in ecp_precompute()
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
e282012219
Spare some memory
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
edc1a1f482
Small code cleanups
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
ff27b7c968
Tighten ecp_mul() validity checks
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
09ceaf49d0
Rm multiplication using NAF
...
Comb method is at most 1% slower for random points,
and is way faster for fixed point (repeated).
2013-11-21 21:56:38 +01:00
Manuel Pégourié-Gonnard
04a0225388
Optimize w in the comb method
2013-11-21 21:56:37 +01:00
Manuel Pégourié-Gonnard
70c14372c6
Add coordinate randomization back
2013-11-21 21:56:37 +01:00
Manuel Pégourié-Gonnard
c30200e4ce
Fix bound issues
2013-11-21 21:56:37 +01:00
Manuel Pégourié-Gonnard
101a39f55f
Improve comb method (less precomputed points)
2013-11-21 21:56:37 +01:00
Manuel Pégourié-Gonnard
d1c1ba90ca
First version of ecp_mul_comb()
2013-11-21 21:56:20 +01:00
Paul Bakker
6a6087e71d
Added missing inline definition for MSCV and ARM environments
2013-10-28 18:53:08 +01:00
Manuel Pégourié-Gonnard
9fcceac943
Add a comment about modules coupling
2013-10-23 20:56:12 +02:00
Manuel Pégourié-Gonnard
b21c81fb41
Use less memory in fix_negative()
2013-10-23 20:45:04 +02:00
Manuel Pégourié-Gonnard
cae6f3ed45
Reorganize code in ecp.c
2013-10-23 20:19:57 +02:00
Manuel Pégourié-Gonnard
5779cbe582
Make mod_p{224,256,384] a bit faster
...
Speedup is roughly 25%, giving a 6% speedup on ecp_mul() for these curves.
2013-10-23 20:17:00 +02:00
Manuel Pégourié-Gonnard
c04c530a98
Make NIST curves optimisation an option
2013-10-23 16:11:52 +02:00
Manuel Pégourié-Gonnard
0f9149cb0a
Add mod_p384
2013-10-23 15:06:37 +02:00
Manuel Pégourié-Gonnard
ec655c908c
Add mod_p256
2013-10-23 14:50:39 +02:00
Manuel Pégourié-Gonnard
210b458ddc
Document and slightly reorganize mod_pXXX
2013-10-23 14:27:58 +02:00
Manuel Pégourié-Gonnard
2a08c0debc
mod_p224 now working with 8-bit and 16-bit ints
2013-10-23 13:24:55 +02:00
Manuel Pégourié-Gonnard
a47e7058ea
mod_p224 now endian-neutral
2013-10-23 13:24:55 +02:00
Manuel Pégourié-Gonnard
e783f06f73
Start working on mod_p224
...
(Prototype, works only on 32-bit and little-endian 64-bit.)
2013-10-23 13:24:55 +02:00
Manuel Pégourié-Gonnard
cc67aee9c8
Make ecp_mod_p521 a bit faster
2013-10-23 13:24:55 +02:00
Manuel Pégourié-Gonnard
c9e387ca9e
Optimize ecp_modp()
...
Makes it 22% faster, for a 5% gain on ecp_mul()
2013-10-23 13:24:55 +02:00
Manuel Pégourié-Gonnard
d1e7a45fdd
Rework ecp_mod_p192()
...
On x86_64, this makes it 5x faster, and ecp_mul() 17% faster for this curve.
The code is shorter too.
2013-10-23 13:24:55 +02:00
Paul Bakker
b9cfaa0c7f
Explicit conversions and minor changes to prevent MSVC compiler warnings
2013-10-14 15:50:40 +02:00
Manuel Pégourié-Gonnard
0cd6f98c0f
Don't special-case a = -3, not worth it
2013-10-10 15:55:39 +02:00
Manuel Pégourié-Gonnard
b8012fca5f
Adjust dependencies
2013-10-10 15:40:49 +02:00
Manuel Pégourié-Gonnard
0ace4b3154
Use much less variables in ecp_double_jac_gen()
2013-10-10 13:21:48 +02:00
Manuel Pégourié-Gonnard
1c4aa24df1
Add brainpool support for ecp_mul()
2013-10-10 12:56:00 +02:00
Manuel Pégourié-Gonnard
cd7458aafd
Support brainpool curves in ecp_check_pubkey()
2013-10-10 12:56:00 +02:00
Manuel Pégourié-Gonnard
a070ada6d4
Add brainpool curves to ecp_use_kown_dp()
2013-10-10 12:56:00 +02:00
Manuel Pégourié-Gonnard
cec4a53c98
Add domain parameters for Brainpool curves
2013-10-10 12:56:00 +02:00
Manuel Pégourié-Gonnard
8195c1a567
Add identifiers for Brainpool curves
2013-10-10 12:56:00 +02:00
Manuel Pégourié-Gonnard
f24b4a7316
Interface change in ECP info functions
...
ecp_named_curve_from_grp_id() -> ecp_curve_info_from_grp_id()
ecp_grp_id_from_named_curve() -> ecp_curve_info_from_tls_id()
2013-09-24 21:25:53 +02:00
Manuel Pégourié-Gonnard
da179e4870
Add ecp_curve_list(), hide ecp_supported_curves
2013-09-18 15:37:44 +02:00
Manuel Pégourié-Gonnard
161ef968db
Cache pre-computed points for ecp_mul()
...
Up to 1.25 speedup on ECDSA sign for small curves, but mainly useful as a
preparation for fixed-point mult (a few prototypes changed in constness).
2013-09-18 15:37:44 +02:00
Manuel Pégourié-Gonnard
56cd319f0e
Add human-friendly name in ecp_curve_info
2013-09-18 15:37:44 +02:00
Manuel Pégourié-Gonnard
a79d123a55
Make ecp_supported_curves constant
2013-09-18 14:35:57 +02:00
Manuel Pégourié-Gonnard
c972770f78
Prepare ecp_group for future extensions
2013-09-18 14:35:53 +02:00
Manuel Pégourié-Gonnard
456d3b9b0b
Make ECP error codes more specific
2013-09-18 14:35:53 +02:00
Manuel Pégourié-Gonnard
568c9cf878
Add ecp_supported_curves and simplify some code
2013-09-18 14:34:34 +02:00
Manuel Pégourié-Gonnard
7038039f2e
Dissociate TLS and internal EC curve identifiers
...
Allows to add new curves before they get a TLS number
2013-09-18 14:34:34 +02:00
Manuel Pégourié-Gonnard
07de4b1d08
Implement randomized coordinates in ecp_mul()
2013-09-02 16:26:04 +02:00
Manuel Pégourié-Gonnard
e09d2f8261
Change ecp_mul() prototype to allow randomization
...
(Also improve an error code while at it.)
2013-09-02 14:29:09 +02:00
Manuel Pégourié-Gonnard
e09631b7c4
Create ecp_group_copy() and use it
2013-08-20 20:08:29 +02:00
Manuel Pégourié-Gonnard
b694b4896c
Add ecdsa_{read,write}_signature()
2013-08-20 20:04:16 +02:00
Manuel Pégourié-Gonnard
96f3a4e1b3
Rm ecp_keypair.alg
...
Avoid duplicating information already present in pk_context.
2013-07-17 15:59:44 +02:00
Manuel Pégourié-Gonnard
de44a4aecf
Rename ecp_check_prvkey with a 'i' for consistency
2013-07-09 16:42:34 +02:00
Manuel Pégourié-Gonnard
c8dc295e83
Add ecp_check_prvkey, with test
...
Also group key checking and generation functions in ecp.h and ecp.c.
2013-07-08 15:31:18 +02:00
Manuel Pégourié-Gonnard
b8c6e0e3e9
Add ecp_keypair struct, init/free and constants
2013-07-08 15:31:18 +02:00
Paul Bakker
6e339b52e8
Memory-allocation abstraction layer and buffer-based allocator added
2013-07-03 17:22:31 +02:00
Paul Bakker
fd3eac5786
Cleaned up ECP error codes
2013-06-29 23:31:33 +02:00
Paul Bakker
5dc6b5fb05
Made supported curves configurable
2013-06-29 23:26:34 +02:00
Paul Bakker
b6c5d2e1a6
Cleanup up non-prototyped functions (static) and const-correctness
...
More fixes based on the compiler directives -Wcast-qual -Wwrite-strings
-Wmissing-prototypes -Wmissing-declarations. Not everything with regards
to -Wcast-qual has been fixed as some have unwanted consequences for the
rest of the code.
2013-06-25 16:25:17 +02:00
Paul Bakker
a280d0f2b9
Fixed compiler warning for possible uninitialized ret
2013-04-08 13:40:17 +02:00
Manuel Pégourié-Gonnard
98f51815d6
Fix ecp_tls_read_point's signature
2013-02-10 13:38:29 +01:00
Manuel Pégourié-Gonnard
7c145c6418
Fix ecp_tls_read_group's signature
2013-02-10 13:20:52 +01:00
Manuel Pégourié-Gonnard
46106a9d75
Add tests for (and fix bug in) ecp_tls_write_group
2013-02-10 12:51:17 +01:00
Manuel Pégourié-Gonnard
420f1eb675
Fix ecp_tls_write_point's signature
2013-02-10 12:22:46 +01:00
Manuel Pégourié-Gonnard
b325887fad
Add ecp_tls_write_group()
2013-02-10 12:06:19 +01:00
Manuel Pégourié-Gonnard
7e86025f32
Rename ecp_*_binary to ecp_point_*_binary
2013-02-10 10:58:48 +01:00
Manuel Pégourié-Gonnard
d84895dc22
Supress 'format' argument to ecp_read_binary.
...
And adjust error codes for ecp_*_binary while at it.
2013-02-10 10:53:04 +01:00
Manuel Pégourié-Gonnard
0079405918
Add functions for read/write ECPoint records
2013-02-09 19:00:07 +01:00
Manuel Pégourié-Gonnard
1a96728964
Add function parsing a TLS ECParameters record
2013-02-09 17:53:31 +01:00
Manuel Pégourié-Gonnard
6545ca7bed
Add ECDH primitives
2013-01-26 19:11:24 +01:00
Manuel Pégourié-Gonnard
45a035a9ac
Add ecp_gen_keypair()
2013-01-26 14:42:45 +01:00
Paul Bakker
cf4365f560
Updated error codes for ECP
2013-01-16 17:00:43 +01:00
Manuel Pégourié-Gonnard
5e402d88ea
Added ecp_read_binary().
2013-01-16 16:31:54 +01:00
Manuel Pégourié-Gonnard
37d218a8e3
Added support for writing points compressed
2013-01-16 16:31:54 +01:00
Manuel Pégourié-Gonnard
e19feb5b46
Added ecp_write_binary().
2013-01-16 16:31:53 +01:00
Manuel Pégourié-Gonnard
1c33057a63
Added ecp_check_pubkey().
2013-01-16 16:31:53 +01:00
Manuel Pégourié-Gonnard
3680c82c5a
Made choice of w safer and more optimal
2013-01-16 16:31:53 +01:00
Manuel Pégourié-Gonnard
cdd44324e9
Added ecp_normalize_many() for faster precompute()
2013-01-16 16:31:53 +01:00
Manuel Pégourié-Gonnard
b63f9e98f5
Made ecp_mul() faster and truly SPA resistant
2013-01-16 16:31:53 +01:00
Manuel Pégourié-Gonnard
7652a593d6
Added a precompute() function for fast mult
2013-01-16 16:31:53 +01:00
Manuel Pégourié-Gonnard
855560758c
Added function preparing for faster multiplication
2013-01-16 16:31:52 +01:00
Manuel Pégourié-Gonnard
b4a310b472
Added a selftest about SPA resistance
2013-01-16 16:31:52 +01:00
Manuel Pégourié-Gonnard
9674fd0d5e
Added ecp_sub() as a variant of ecp_add()
2013-01-16 16:31:52 +01:00
Manuel Pégourié-Gonnard
1c2782cc7c
Changed to jacobian coordinates everywhere
2013-01-16 16:31:52 +01:00
Manuel Pégourié-Gonnard
773ed546a2
Added a nbits member to ecp_group
2013-01-16 16:31:52 +01:00
Manuel Pégourié-Gonnard
4bdd47d2cb
Multiplication by negative is now forbidden
2013-01-16 16:31:52 +01:00
Manuel Pégourié-Gonnard
8433824d5f
Added fast mod_p192
2013-01-16 16:31:52 +01:00
Manuel Pégourié-Gonnard
4712325777
Clarifications in comments; code cosmetics & style
2013-01-16 16:31:52 +01:00
Manuel Pégourié-Gonnard
dada4da33f
Moved domain paramaters to ecp.c
2013-01-16 16:31:51 +01:00
Manuel Pégourié-Gonnard
62aad14139
Added slot for fast modp, with mod_p521
2013-01-16 16:31:51 +01:00
Manuel Pégourié-Gonnard
84d1aea1ac
Now reducing mod p after every single operation
2013-01-16 16:31:51 +01:00
Manuel Pégourié-Gonnard
e0c16922f9
Point multiplication using Jacobian coordinates
2013-01-16 16:31:51 +01:00
Manuel Pégourié-Gonnard
7e0adfbcc5
Replaced add_generic with add_mixed
2013-01-16 16:31:51 +01:00
Manuel Pégourié-Gonnard
989c32bc3e
Replaced double_generic with double_jac
2013-01-16 16:31:51 +01:00
Manuel Pégourié-Gonnard
27b1ba8be0
Changed ecp_mul() to always add the same point
2013-01-16 16:31:51 +01:00
Manuel Pégourié-Gonnard
d070f51224
Started introducting Jacobian coordinates
2013-01-16 16:31:51 +01:00
Manuel Pégourié-Gonnard
4b8c3f2a1c
Moved tests from selftest to tests/test_suite_ecp
2013-01-16 16:31:50 +01:00
Manuel Pégourié-Gonnard
a5402fee04
Added ecp_use_known_dp()
2013-01-16 16:31:50 +01:00
Manuel Pégourié-Gonnard
efaa31e9ae
Implemented multiplication
2013-01-16 16:31:50 +01:00
Manuel Pégourié-Gonnard
b4ab8a8137
Fixed memory leak due to typo
2013-01-16 16:31:50 +01:00
Manuel Pégourié-Gonnard
de532ee73f
Implemented generic doubling
2013-01-16 16:31:50 +01:00
Manuel Pégourié-Gonnard
ab38b70816
Fixed add_generic
2013-01-16 16:31:50 +01:00
Manuel Pégourié-Gonnard
b505c2796c
Got first tests working, fixed ecp_copy()
2013-01-16 16:31:49 +01:00
Manuel Pégourié-Gonnard
d0dc6317e1
Added a few test cases for addition
2013-01-16 16:31:49 +01:00
Manuel Pégourié-Gonnard
847395a8a9
Added ecp_XXX_read_string()
2013-01-16 16:31:49 +01:00
Manuel Pégourié-Gonnard
7cfcea349c
Documented error codes properly
2013-01-16 16:31:49 +01:00
Manuel Pégourié-Gonnard
ae180d0f20
Got started on ecp_add(): generic case done
2013-01-16 16:31:49 +01:00
Manuel Pégourié-Gonnard
883f313516
Added ecp_copy() (for points)
2013-01-16 16:31:49 +01:00
Manuel Pégourié-Gonnard
5179e463d5
Allowed point at infinity, supressed ecp_double()
2013-01-16 16:31:49 +01:00
Manuel Pégourié-Gonnard
1e8c8ecd95
Implemented ecp_{point,group}_free()
2013-01-16 16:31:49 +01:00
Manuel Pégourié-Gonnard
39d2adbbd0
Added (skeleton) ecp.[ch]
2013-01-16 16:31:48 +01:00