Commit Graph

252 Commits

Author SHA1 Message Date
hasufell ceecf68b59
Merge branch 'master' of ssh://gitlab.hasufell.de:22022/malte/quantumcrypto 2014-05-19 21:32:56 +02:00
hasufell 8fb50d61dd
Merge branch 'master' of ssh://gitlab.hasufell.de:22022/cgawlik/quantumcrypto 2014-05-19 21:30:13 +02:00
malte b997dc65fd POLY->ASCII: added inline comments. 2014-05-18 18:28:39 +02:00
malte 3bf66ce274 POLY->ASCII: Added a function to get a string out of a given polynom. 2014-05-18 18:08:36 +02:00
malte d498ddf1a8 ASCII->POLY: written a function to convert a char* string into a polynom.
The function returns a newly allocated poynom of the string size * 7
7 bits per ASCII symbol.
the function need to be warped so the maximal poynom is corresponding to
the NTRU context.
2014-05-18 10:28:25 +02:00
malte 10f6ebc9e6 Merge branch 'master' of ssh://gitlab.hasufell.de:22022/pcq/quantumcrypto
Conflicts:
	src/poly.c
	src/poly.h
	src/rand.c

merged with master repo
2014-05-13 16:54:31 +02:00
Alexander Rolfes dd68d1a094 Merge branch 'master' of ssh://gitlab.hasufell.de:22022/pcq/quantumcrypto
Conflicts:
	src/poly.h solved
	src/ntru_decrypt.c fixed

ntru_decrypt.c used changed function heading
2014-05-13 09:51:47 +02:00
hasufell 782ccf0524
POLY: improve error handling 2014-05-13 00:20:46 +02:00
hasufell 30e18177e8
POLY: allow signed int in MP_SET_INT
Now you can pass MP_SET_INT(&foo, -1) without having
to call mp_neg() later etc.
2014-05-13 00:12:03 +02:00
Malte 7c5d899055 RAND: improve some spelling 2014-05-12 20:35:06 +02:00
Malte 8db6a83ae3 RAND: changed read_int_dev_urandom() to get_int_dev_urandom() 2014-05-12 20:35:06 +02:00
Malte 2f9ebd52f8 RAND: changed read_int_dev_urandom() to get_int_dev_urandom() 2014-05-12 20:35:06 +02:00
Malte 979ae61726 RAND: changed ntru_get_poly_big() to ntru_get_random_poly() 2014-05-12 20:35:06 +02:00
Malte 7c58d847e9 RAND changed c to coefficient 2014-05-12 20:35:06 +02:00
Malte 79a908de00 RAND: changed from ntru_get_poly_small(int length... to ntru_get_random_poly_ternary(size_t length... 2014-05-12 20:35:06 +02:00
Malte e072eb04e9 RAND: chaged from int check_polynom() to unsigned int check_allowed_zeros()
RAND: merged conflict
2014-05-12 20:34:54 +02:00
Malte a706a23319 RAND: corected spelling 2014-05-12 20:32:34 +02:00
Malte 8f9acfdb9d RAND: changed from make_big_int() to get_random_bigint() 2014-05-12 20:32:34 +02:00
Malte 2e589f4be7 RAND: removed some doxycomment 2014-05-12 20:32:34 +02:00
Malte f459f09e57 RAND: changed from make_small_int() to get_random_ternary() 2014-05-12 20:32:34 +02:00
Malte 3fc925c396 RAND: removed camelCase
changed from randomDataLen to random_DataLen
2014-05-12 20:32:34 +02:00
hasufell 3109d2aec7 BUILD: remove obsolete object 2014-05-12 20:32:34 +02:00
hasufell 456dff26e0 BUILD: remove non-existing header from build 2014-05-12 20:32:34 +02:00
hasufell 23573d07c8 DOC: fix doxygen comment in pb_mod2_to_modq() 2014-05-12 20:32:34 +02:00
hasufell 9520003db1 BUILD: ignore -Wunused-function... this is a library 2014-05-12 20:32:34 +02:00
hasufell 9ddf9709e2 POLY: add pb_mod2_to_modq()
This should make pb_inverse_poly_q() a bit more readable.
TODO: make the algorithm more descriptive in general.
2014-05-12 20:32:34 +02:00
hasufell d9584b2e17 POLY: introduce delete_polynom_multi()
Just a wrapper around delete_polynom() to handle multiple args.
Must be called with NULL as last argument!
2014-05-12 20:32:34 +02:00
hasufell 476379b675 POLY: use our MACROS for error handling
All mp_* and pb_* functions that return an error code
should only be called via a MACRO which handles the error.
2014-05-12 20:32:34 +02:00
hasufell a4603877f9 BUILD: update Makefile for mem.o 2014-05-12 20:32:34 +02:00
hasufell 01c301afdd MEM: introduce our own ntru_malloc() function
Use this instead of malloc().
2014-05-12 20:32:34 +02:00
Malte cb69ea8689 RAND: changed the function declaration to fit the the given needs better. 2014-05-12 20:32:34 +02:00
Malte 4df4a37f9a RAND: added the missing function declaration and comments.
static mp_int *make_big_int(mp_int *upper_bound, mp_int *lower_bound,
        mp_digit randim_int)
static int check_polynom(pb_poly *polynom)
needs to be filled with code.
2014-05-12 20:32:34 +02:00
Malte d871a9104f RAND: fixed some unnecessary import 2014-05-12 20:32:34 +02:00
Malte 1e586c178c rand: added some missing void parameter 2014-05-12 20:32:34 +02:00
Malte 626e2fc27a rand: added a nessary but missing comment on the big int min/max 2014-05-12 20:32:34 +02:00
Malte 0bdddc12e7 rand: Refactoring finished
now there are only 4 static functions left:
static mp_digit read_int_dev_random();
static mp_digit read_int_dev_urandom();
static mp_digit make_small_int(mp_digit random_int, int* sign);
static mp_digit make_big_int(mp_digit random_int, int* sign);
Every function is used twice.
the next goal to copy free code is to make a single function
with function pointer out of these 4:
pb_poly *ntru_get_urnd_poly_small(ntru_context *ctx);
pb_poly *ntru_get_rnd_poly_small(ntru_context *ctx);
pb_poly *ntru_get_urnd_poly_big(ntru_context *ctx);
pb_poly *ntru_get_rnd_poly_big(ntru_context *ctx);
But this need to be checkt by a other group member
2014-05-12 20:32:34 +02:00
Malte 21022c9ff8 rand: extractet some double code into new functions
this is the first step, in the next one i a going to remove
static mp_digit get_urnd_int_small(int *sign);
static mp_digit get_rnd_int_small(int *sign);
static mp_digit get_urnd_int_big(int *sign);
static mp_digit get_rnd_int_big(int *sign);

RAND: merged a conflict
2014-05-12 20:32:14 +02:00
hasufell 60dbab44f5 POLY: fix syntax error within comment
RAND: merged conflict
2014-05-12 20:29:59 +02:00
Malte 90a01a03ec rand: getting small and big polynoms is working
pb_poly *ntru_get_urnd_poly_big(ntru_context *ctx)
pb_poly *ntru_get_rnd_poly_big(ntru_context *ctx)
are written but the testing isen working and
i think it is a bad idea to not use function poniters
at the moment we have about 4 functions that do all the same thing
and differ only in the subfunction call.
But at the moment i cat decide of we shold use
function pinter

RAND: merged conflict
2014-05-12 20:28:22 +02:00
hasufell 99ebda181a POLY: fix pb_inverse_poly_q()
Should be correct now. Had to add get_degree(), because
pb_clamp() in conjunction with pb_cmp() does not give
expected results, see https://github.com/libtom/libtompoly/issues/3
...so don't use it.
2014-05-12 20:17:42 +02:00
hasufell f98be67dd3 BUILD: fix possible linker errors 2014-05-12 20:17:42 +02:00
hasufell 85c48647f5 POLY: cleanup pb_inverse_poly_q()
Also avoid side effects.
2014-05-12 20:17:42 +02:00
hasufell 6990193dcd POLY: cleanup pb_starmultiply()
* avoid side effects
* use MP_DIV instead of MP_MOD
* move mp_modulus initialization to outer scope
2014-05-12 20:17:42 +02:00
hasufell 01785678f0 DOC: fix doxygen comment in delete_polynom() 2014-05-12 20:17:42 +02:00
hasufell ed1fb0f0a9 POLY: add erase_polynom() function 2014-05-12 20:17:42 +02:00
hasufell f8b1649279 POLY: use mp_neg() instead of directly modifying struct 2014-05-12 20:17:42 +02:00
hasufell 5c85862d12 POLY: improve error handling
Use MP_ADD, MP_MUL, PB_ADD, PB_MUL etc instead of the mp_add,...
functions to make use of error handling.
2014-05-12 20:17:42 +02:00
hasufell 85ba70a9c5 POLY: first try of inverting polynomials 2014-05-12 20:17:42 +02:00
hasufell 3184e9093f POLY: rm unnecessary cast 2014-05-12 20:17:42 +02:00
hasufell 3e6345cd47 POLY: fix typo 2014-05-12 20:17:42 +02:00
hasufell 739feea0fe BUILD: fix linker errors when playing in main.c 2014-05-12 20:17:42 +02:00
hasufell c4f6ad4504 POLY: fix error messages 2014-05-12 20:17:42 +02:00
hasufell 2d2ccfbf3f POLY: first try of pb_starmultiply() 2014-05-12 20:17:42 +02:00
hasufell 0d179a0e7d POLY: don't clamp polyonmial in build_polynom()
Otherwise we might hit problems when using this as an
out-polynom in a arithmetic functions. The caller can clamp
it himself, if he needs so.
2014-05-12 20:17:42 +02:00
hasufell f8cac1553f ALL: set context members to unsigned int 2014-05-12 20:17:42 +02:00
hasufell fc4ee3b70b POLY: add build_polynom() method
We can build a polynom via an array of integers or just an empty
one, so that it is initialized and properly allocated.
2014-05-12 20:17:42 +02:00
hasufell be28e18cfb DOC: fix typo 2014-05-12 20:17:42 +02:00
hasufell 66da54b3a3 BUILD: ignore -Wunused-parameter
Can happen in callback functions and so forth.
2014-05-12 20:17:42 +02:00
hasufell 417ce9c0f2 RAND: use unsigned long instead of mp_digit
if we use mp_set_int() instead of mp_set(), then we can use
full unsigned long integers instead of single digits. This
seems a lot safer, especially for future versions of the
random algorithm.

RAND: merged a conflict
2014-05-12 20:16:25 +02:00
hasufell 0470a5fa6e POLY: use size_t 2014-05-12 20:13:22 +02:00
hasufell 22f713fa98 DOC: improve memory handling instructions 2014-05-12 20:13:22 +02:00
Malte 04d5d6d38f rand:ntru_get_rnd_poly_small: written a function to generate a random polynom
like get_urnd_int_small but with the random source from /dev/random
instead of /dev/urandom
2014-05-12 20:13:22 +02:00
Malte 71b8f4cbeb Added static mp_digit get_rnd_int_small(int *sign)
but it takes about ~40minutes to generate a x^500
polynom with /dev/random.
2014-05-12 20:13:22 +02:00
Christoph Prüßner f8f7634c84 DEC
ntru_decrypt now uses pb_normalize
2014-05-12 13:49:00 +02:00
Christoph Prüßner 4030335661 POLY: implemented pb_normalize
normalizes a polynom by defining a numerical range
for each factor of a polynom.
2014-05-12 13:46:59 +02:00
Anton Oster 9ff66b8555 ENC: added ecrypt func 2014-05-12 10:33:04 +02:00
Anton Oster e41438476d rename files and write pb_encrypt func 2014-05-08 12:50:30 +02:00
Alexander Rolfes 1412ba0d1a CODE: Fixed missing bracket 2014-05-05 21:56:44 +02:00
Alexander Rolfes 01a08fdafa CODE: Rename of key-Parameters
Renamed private_key and Fp to priv_key and priv_key_inv
2014-05-05 21:53:41 +02:00
Alexander Rolfes dd73a662a0 DOXYGEN: Documentation of ntru_decrypt function
Removed unnecessary comments inside of function and wrote
a Doxygen compliant comment above the function
2014-05-05 21:51:58 +02:00
Christoph Prüßner 74a3fa88c7 moved some lines 2014-05-05 13:58:53 +02:00
Christoph Prüßner 4e6bb38260 numerous fixes 2014-05-03 17:18:23 +02:00
Christoph Prüßner c326654f14 Merge remote-tracking branch 'OberMaster/master' 2014-05-03 16:13:25 +02:00
Christoph Prüßner 5254cf93f3 changed return type of ntru_decrypt, implemented second starmultiply,
fixed numerical operations to mp_operations
2014-05-03 16:02:09 +02:00
Christoph Prüßner fa97531eac implemented the coefficient shift into a range of -q/2 and q/2 2014-05-03 14:57:05 +02:00
Christoph Prüßner b4a7870e97 fixed pointer arithmetical mistakes 2014-05-03 14:07:12 +02:00
Christoph Prüßner 7349c7e8be used pb_starmultiply for the first multiplication and added p, q, N 2014-05-03 14:03:03 +02:00
Christoph Prüßner 4de50e2390 removed redundant multiplication functions 2014-05-03 13:51:00 +02:00
Christoph Prüßner ecdc32f5e0 first implementation of "pseudocode algorithm" (ms_corourke.pdf) 2014-05-02 13:00:00 +02:00
Christoph Prüßner 9cfb19ea78 added commentary and implemented the pseudocode algorithm
(ms_corourke.pdf)
2014-05-02 12:18:33 +02:00
hasufell e29064a666
POLY: fix pb_inverse_poly_p and convert to pb_mp_mul()
Was still using the old build_polynom() API.
2014-04-30 17:29:16 +02:00
hasufell 8fbcbe4144
POLY: rearrange header declarations 2014-04-30 17:23:39 +02:00
hasufell f6b5c8de19
POLY: simplify pb_inverse_poly_q() a bit 2014-04-30 17:23:24 +02:00
hasufell 8817cd79b2
POLY: use break instead of goto 2014-04-30 17:22:57 +02:00
hasufell afa06ce0b9
POLY: remove unused context parameter of build_polynom() 2014-04-30 17:22:25 +02:00
hasufell f2b4183c68
POLY: add pb_mp_mul() 2014-04-30 17:19:58 +02:00
hasufell 9c89b79627
POLY: add init_integers() 2014-04-30 17:18:08 +02:00
hasufell 12fa21f5b2
POLY: make get_degree() public 2014-04-30 17:16:50 +02:00
hasufell 942f90a0ef
POLY: small cleanup
* rm printf stuff
* rename goto-statements
* improve inline doc
* rm unused variables
2014-04-29 19:59:59 +02:00
hasufell c5f540c4aa
Merge branch 'master' of ssh://gitlab.hasufell.de:22022/pcq/quantumcrypto into poly
Conflicts:
	src/Makefile
	src/poly.c
	src/poly.h
2014-04-29 14:35:28 +02:00
hasufell 4d5f44c900
POLY: first try of implementing pb_inverse_poly_p()
This ends up as an infinite loop though.
2014-04-29 14:27:52 +02:00
hasufell 777a086c53
DOC: improve inline comments in pb_inverse_poly_q()
These should also match the actual mathematical computations.
2014-04-29 14:27:15 +02:00
Anton Oster 8e49f3aa8b ENC: added defines/includes 2014-04-29 13:16:19 +02:00
C. Gawlik b00b7125a3 pcq_encrypt.c / .h 2014-04-29 10:32:10 +02:00
hasufell 180d2acc1b BUILD: remove obsolete object 2014-04-28 12:21:20 +02:00
hasufell 7c8a7580f5 BUILD: remove non-existing header from build 2014-04-28 12:19:26 +02:00
Christoph Prüßner bd3396b225 Merge remote-tracking branch 'OberMaster/master' 2014-04-23 14:03:23 +02:00
Christoph Prüßner 98bdd670d8 added ntru_decrypt function to ntru_decrypt.c 2014-04-23 13:58:57 +02:00
Christoph Prüßner 74ddfe65e7 remodified gitignore and defined function "ntru_decrypt(..)" 2014-04-23 13:45:03 +02:00
Christoph Prüßner ac004e5cfe Added the following files: ntru_decrypt.(c|h) 2014-04-23 13:19:37 +02:00
hasufell 12b8b08700
DOC: fix doxygen comment in pb_mod2_to_modq() 2014-04-22 20:47:10 +02:00
hasufell 2763b22374
BUILD: ignore -Wunused-function... this is a library 2014-04-22 20:47:10 +02:00
hasufell abd2727215
POLY: add pb_mod2_to_modq()
This should make pb_inverse_poly_q() a bit more readable.
TODO: make the algorithm more descriptive in general.
2014-04-22 20:47:10 +02:00
hasufell 6c0f94435e
POLY: introduce delete_polynom_multi()
Just a wrapper around delete_polynom() to handle multiple args.
Must be called with NULL as last argument!
2014-04-22 20:47:10 +02:00
hasufell 5459f94937
POLY: use our MACROS for error handling
All mp_* and pb_* functions that return an error code
should only be called via a MACRO which handles the error.
2014-04-22 20:47:10 +02:00
hasufell f8c3dc9790
BUILD: update Makefile for mem.o 2014-04-22 20:47:09 +02:00
hasufell 5d875ca847
MEM: introduce our own ntru_malloc() function
Use this instead of malloc().
2014-04-22 20:47:03 +02:00
hasufell 6b15bd1614
DOC: fix doxygen comment in pb_mod2_to_modq() 2014-04-22 20:46:13 +02:00
hasufell 12a54416fb
BUILD: ignore -Wunused-function... this is a library 2014-04-22 20:46:13 +02:00
hasufell ae01f6e3cf
Merge branch 'poly' 2014-04-22 20:46:13 +02:00
hasufell 1231328e51
POLY: add pb_mod2_to_modq()
This should make pb_inverse_poly_q() a bit more readable.
TODO: make the algorithm more descriptive in general.
2014-04-22 20:46:13 +02:00
hasufell 320af3c617
POLY: introduce delete_polynom_multi()
Just a wrapper around delete_polynom() to handle multiple args.
Must be called with NULL as last argument!
2014-04-22 20:46:12 +02:00
hasufell 6594a022fe
POLY: use our MACROS for error handling
All mp_* and pb_* functions that return an error code
should only be called via a MACRO which handles the error.
2014-04-22 20:46:12 +02:00
hasufell e33bd66d05
BUILD: update Makefile for mem.o 2014-04-22 20:46:12 +02:00
hasufell 2488e4b33a
MEM: introduce our own ntru_malloc() function
Use this instead of malloc().
2014-04-22 20:46:04 +02:00
hasufell 565ce61273
POLY: fix syntax error within comment 2014-04-20 16:46:47 +02:00
hasufell 302cd5e4d8
POLY: fix pb_inverse_poly_q()
Should be correct now. Had to add get_degree(), because
pb_clamp() in conjunction with pb_cmp() does not give
expected results, see https://github.com/libtom/libtompoly/issues/3
...so don't use it.
2014-04-17 23:43:29 +02:00
hasufell 3428dedc2c
BUILD: fix possible linker errors 2014-04-17 17:37:44 +02:00
hasufell 4bd341e83e
POLY: cleanup pb_inverse_poly_q()
Also avoid side effects.
2014-04-17 17:37:30 +02:00
hasufell cc82e4e3bd
POLY: cleanup pb_starmultiply()
* avoid side effects
* use MP_DIV instead of MP_MOD
* move mp_modulus initialization to outer scope
2014-04-17 17:36:57 +02:00
hasufell 03a05f2dad
DOC: fix doxygen comment in delete_polynom() 2014-04-17 17:35:20 +02:00
hasufell 2300587fec
POLY: add erase_polynom() function 2014-04-17 17:34:48 +02:00
hasufell 8ea687bdf5
POLY: use mp_neg() instead of directly modifying struct 2014-04-17 17:33:05 +02:00
hasufell a49a5d2e8c
POLY: improve error handling
Use MP_ADD, MP_MUL, PB_ADD, PB_MUL etc instead of the mp_add,...
functions to make use of error handling.
2014-04-17 02:09:49 +02:00
hasufell 56b20220ba
POLY: first try of inverting polynomials 2014-04-16 23:23:41 +02:00
hasufell 2a16102b9f
POLY: rm unnecessary cast 2014-04-16 23:18:38 +02:00
hasufell 1179082ac1
POLY: fix typo 2014-04-16 23:17:48 +02:00
hasufell e4cf4331d9
BUILD: fix linker errors when playing in main.c 2014-04-15 23:11:55 +02:00
hasufell cb4d274c58
POLY: fix error messages 2014-04-15 22:54:11 +02:00
hasufell df1df23e09
POLY: first try of pb_starmultiply() 2014-04-15 22:50:42 +02:00
hasufell abf047a264
POLY: don't clamp polyonmial in build_polynom()
Otherwise we might hit problems when using this as an
out-polynom in a arithmetic functions. The caller can clamp
it himself, if he needs so.
2014-04-15 22:50:11 +02:00
hasufell 050dab6243
ALL: set context members to unsigned int 2014-04-15 18:49:33 +02:00
hasufell e60d9c9bac
POLY: add build_polynom() method
We can build a polynom via an array of integers or just an empty
one, so that it is initialized and properly allocated.
2014-04-15 18:49:17 +02:00
hasufell b7b4ffbbea
DOC: fix typo 2014-04-15 18:47:58 +02:00
hasufell 2b8eb4f1fa
BUILD: ignore -Wunused-parameter
Can happen in callback functions and so forth.
2014-04-15 18:47:39 +02:00
hasufell 91c5ea7b82
RAND: use unsigned long instead of mp_digit
if we use mp_set_int() instead of mp_set(), then we can use
full unsigned long integers instead of single digits. This
seems a lot safer, especially for future versions of the
random algorithm.
2014-04-15 18:21:42 +02:00
hasufell 783858a52c
POLY: use size_t 2014-04-15 18:20:08 +02:00
hasufell 5e7c980831
DOC: improve memory handling instructions 2014-04-15 16:56:38 +02:00
hasufell cafc977c64
DOC: improve memory management documentation 2014-04-15 14:23:27 +02:00
hasufell 4a7e50a194
POLY: add delete_polynom() function
This deletes both the internal structure and the pointer.
2014-04-15 14:22:46 +02:00
hasufell b33b0c6b1a
DOC: caller has to handle the memory of returned pointers 2014-04-15 14:16:30 +02:00
hasufell 617e32b9cf
RAND: fix memory leak
pb_init() which is called by init_polynom_size() will call
mp_init_copy() on chara which means that chara being a pointer
itself is useless. We can clear it directly after it has been
copied.
2014-04-15 14:15:41 +02:00
hasufell 255bc5b769
RAND: close the correct file descriptor 2014-04-15 13:43:03 +02:00
hasufell f6e879cba8
LICENSE: fix header 2014-04-15 13:35:04 +02:00
hasufell a547d7d49b
BUILD: add target "main" for testing
main.c does not belong in this repository, but
might be used for testing locally.
2014-04-14 23:51:33 +02:00
hasufell 5df1ebbb45
ALL: prefix external API structs/functions with ntru_ 2014-04-14 23:47:01 +02:00
hasufell e8ec6103aa
RAND: make mp_digit get_urnd_int_small() static
Does not seem to qualify for external API function.
2014-04-14 23:45:38 +02:00
hasufell 565abd95d7
BUILD: add initial Makefiles 2014-04-14 22:29:55 +02:00
hasufell ff40048d55
RAND: basic randomization
No sanity checks like minimum number of non-NULL coefficients
for the polynomial.
2014-04-14 22:29:36 +02:00
hasufell 2029e91c47
POLY: add basic polynomial wrappers
Also provide a draw_polynomial function for human readable
output of the polynomial.
2014-04-14 22:28:35 +02:00