From 9cfb19ea7859944f6547569776a6685c4d7dcf75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Pr=C3=BC=C3=9Fner?= Date: Fri, 2 May 2014 12:18:33 +0200 Subject: [PATCH 1/4] added commentary and implemented the pseudocode algorithm (ms_corourke.pdf) --- src/ntru_decrypt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ntru_decrypt.c b/src/ntru_decrypt.c index d385959..3a46676 100644 --- a/src/ntru_decrypt.c +++ b/src/ntru_decrypt.c @@ -19,6 +19,18 @@ * MA 02110-1301 USA */ +// Require: N , q, p, secret key f , inverse polynomial Fp , and encrypted message e. int ntru_decrypt(char *encr_msg, pb_poly *private_key, ntru_context *context, char ** decr_msg){ + // StarMultiply(f, e, a, N, q) + for(int i = 0, i < N, i++){ + if(a[i] < 0 ) { + a[i] = a[i] + q; // Make all coefficients positive + } + if(a[i] > q/2) { + a[i] = a[i] - q // Shift coefficients of a into range (−q/2, q/2) + } + } + // StarMultiply(a, Fp , d, N, p) + // {Decode returns the decrypted message, d, through the argument list.} return 0; } From ecdc32f5e0a55fc6ce647105d0234a97a3f6481e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Pr=C3=BC=C3=9Fner?= Date: Fri, 2 May 2014 13:00:00 +0200 Subject: [PATCH 2/4] first implementation of "pseudocode algorithm" (ms_corourke.pdf) --- src/ntru_decrypt.c | 37 ++++++++++++++++++++++++++++++++++--- src/ntru_decrypt.h | 2 ++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/ntru_decrypt.c b/src/ntru_decrypt.c index 3a46676..d7562a2 100644 --- a/src/ntru_decrypt.c +++ b/src/ntru_decrypt.c @@ -19,9 +19,27 @@ * MA 02110-1301 USA */ +#include "ntru_decrypt.h" + +/* + * Legend + * + * N : highest degree of the polynom + * q : "is given" (... mod q) + * p : "is given" (... mod p) + * f : private key + * Fp: inverse of "modulo p" + * e : encrypted message + * a : result of first multiplication (StarMultiply(f, e, a, N, q)) + * d : result of second multiplication (StarMultiply(a, Fp , d, N, p)), decrypted message + * */ + // Require: N , q, p, secret key f , inverse polynomial Fp , and encrypted message e. int ntru_decrypt(char *encr_msg, pb_poly *private_key, ntru_context *context, char ** decr_msg){ - // StarMultiply(f, e, a, N, q) + // toDo q = ?, p = ?, fp = ? + + pb_poly *a = first_multiply(private_key, encr_msg, q);// StarMultiply(f, e, a, N, q) + for(int i = 0, i < N, i++){ if(a[i] < 0 ) { a[i] = a[i] + q; // Make all coefficients positive @@ -30,7 +48,20 @@ int ntru_decrypt(char *encr_msg, pb_poly *private_key, ntru_context *context, ch a[i] = a[i] - q // Shift coefficients of a into range (−q/2, q/2) } } - // StarMultiply(a, Fp , d, N, p) + char* d = second_multiply(a, fp, p)// StarMultiply(a, Fp , d, N, p) + // {Decode returns the decrypted message, d, through the argument list.} - return 0; + return d; +} + +// toDo fix header file definition and types if needed! +pb_poly* first_multiply(pb_poly *private_key, char *encr_msg, int q) { + // toDo a= f*e mod q + return NULL; +} + +// toDo fix header file definition and types if needed! +char* second_multiply(pb_poly *a, pb_poly *fp, int p) { + //toDo a*Fp mod p + return NULL; } diff --git a/src/ntru_decrypt.h b/src/ntru_decrypt.h index 9da81cc..92ac915 100644 --- a/src/ntru_decrypt.h +++ b/src/ntru_decrypt.h @@ -26,5 +26,7 @@ #include "context.h" int ntru_decrypt(char *encr_msg, pb_poly *private_key, ntru_context *context, char ** decr_msg); +pb_poly* first_multiply(pb_poly*, char*, int); +char* first_multiply(pb_poly*, pb_poly*, int); #endif /* NTRU_DECRYPT */ From 4d438bb925c3cbe2fa036dc07e9d5ac3e2522c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Pr=C3=BC=C3=9Fner?= Date: Sat, 3 May 2014 13:18:15 +0200 Subject: [PATCH 3/4] changed gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 566858b..3837701 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,6 @@ latex/ src/main.c src/main -./.settings/org.eclipse* \ No newline at end of file +./.settings/org.eclipse* + +.project \ No newline at end of file From 06d359936a2bcf9f18b074c7dc3d3e380462c13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Pr=C3=BC=C3=9Fner?= Date: Sat, 3 May 2014 13:19:25 +0200 Subject: [PATCH 4/4] deleted .project file --- .project | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .project diff --git a/.project b/.project deleted file mode 100644 index a2785b2..0000000 --- a/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - Semesterprojekt2014 - - - - - - - -