From 43bd0e2ea3fbc2d2943db818a0574d9dbdc501ec Mon Sep 17 00:00:00 2001 From: Christian Gawlik Date: Tue, 8 Apr 2014 10:39:29 +0200 Subject: [PATCH 1/9] git Test --- uebung1.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 uebung1.txt diff --git a/uebung1.txt b/uebung1.txt new file mode 100644 index 0000000..12c5cc8 --- /dev/null +++ b/uebung1.txt @@ -0,0 +1,2 @@ +ausdhna oahs dokn sdokasnd +asfhd \ No newline at end of file From 5f49d73148bff93f161cce53e3c6eb35116a26d5 Mon Sep 17 00:00:00 2001 From: Christian Gawlik Date: Tue, 8 Apr 2014 11:01:37 +0200 Subject: [PATCH 2/9] geb mir ein konflikt --- konflikt | 1 + 1 file changed, 1 insertion(+) create mode 100644 konflikt diff --git a/konflikt b/konflikt new file mode 100644 index 0000000..51bcfe9 --- /dev/null +++ b/konflikt @@ -0,0 +1 @@ +hier kommt gleich ein Fehler From 0b17897d6abab4c40a6b95d26edc643a43551ffd Mon Sep 17 00:00:00 2001 From: Christian Gawlik Date: Wed, 16 Apr 2014 20:47:54 +0200 Subject: [PATCH 3/9] is si --- konflikt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 konflikt diff --git a/konflikt b/konflikt deleted file mode 100644 index 51bcfe9..0000000 --- a/konflikt +++ /dev/null @@ -1 +0,0 @@ -hier kommt gleich ein Fehler From a7e56757fedbf87c8e87f223e70c4a11bf8e4a43 Mon Sep 17 00:00:00 2001 From: Christian Gawlik Date: Wed, 16 Apr 2014 20:48:23 +0200 Subject: [PATCH 4/9] weg damit --- uebung1.txt | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 uebung1.txt diff --git a/uebung1.txt b/uebung1.txt deleted file mode 100644 index 12c5cc8..0000000 --- a/uebung1.txt +++ /dev/null @@ -1,2 +0,0 @@ -ausdhna oahs dokn sdokasnd -asfhd \ No newline at end of file From b00b7125a336f5f9c5360b912aecc0308d4cbe91 Mon Sep 17 00:00:00 2001 From: "C. Gawlik" Date: Tue, 29 Apr 2014 10:32:10 +0200 Subject: [PATCH 5/9] pcq_encrypt.c / .h --- src/pcq_encrypt.c | 20 ++++++++++++++++++++ src/pcq_encrypt.h | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/pcq_encrypt.c create mode 100644 src/pcq_encrypt.h diff --git a/src/pcq_encrypt.c b/src/pcq_encrypt.c new file mode 100644 index 0000000..798e38c --- /dev/null +++ b/src/pcq_encrypt.c @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2014 FH Bielefeld + * + * This file is part of a FH Bielefeld project. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ diff --git a/src/pcq_encrypt.h b/src/pcq_encrypt.h new file mode 100644 index 0000000..798e38c --- /dev/null +++ b/src/pcq_encrypt.h @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2014 FH Bielefeld + * + * This file is part of a FH Bielefeld project. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ From ce199b225fe4a20082fcd69f080b22c022221d45 Mon Sep 17 00:00:00 2001 From: Anton Oster Date: Tue, 29 Apr 2014 10:43:06 +0200 Subject: [PATCH 6/9] added defines/includes --- src/pcq_encrypt.c | 2 ++ src/pcq_encrypt.h | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/pcq_encrypt.c b/src/pcq_encrypt.c index 798e38c..5db7ad8 100644 --- a/src/pcq_encrypt.c +++ b/src/pcq_encrypt.c @@ -18,3 +18,5 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ + +#include "pcq_encrypt.h" diff --git a/src/pcq_encrypt.h b/src/pcq_encrypt.h index 798e38c..22df6d0 100644 --- a/src/pcq_encrypt.h +++ b/src/pcq_encrypt.h @@ -18,3 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ + +#ifndef PCQ_ENCRYPT_H +#define PCQ_ENCRYPT_H + +#include +#include + +#endif From 8e49f3aa8b5d94cc224e2928de957eb3dbd42c17 Mon Sep 17 00:00:00 2001 From: Anton Oster Date: Tue, 29 Apr 2014 10:43:06 +0200 Subject: [PATCH 7/9] ENC: added defines/includes --- src/pcq_encrypt.c | 2 ++ src/pcq_encrypt.h | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/pcq_encrypt.c b/src/pcq_encrypt.c index 798e38c..5db7ad8 100644 --- a/src/pcq_encrypt.c +++ b/src/pcq_encrypt.c @@ -18,3 +18,5 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ + +#include "pcq_encrypt.h" diff --git a/src/pcq_encrypt.h b/src/pcq_encrypt.h index 798e38c..22df6d0 100644 --- a/src/pcq_encrypt.h +++ b/src/pcq_encrypt.h @@ -18,3 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ + +#ifndef PCQ_ENCRYPT_H +#define PCQ_ENCRYPT_H + +#include +#include + +#endif From e41438476da75f518c5b21cc51da24cb80c183d9 Mon Sep 17 00:00:00 2001 From: Anton Oster Date: Thu, 8 May 2014 12:50:30 +0200 Subject: [PATCH 8/9] rename files and write pb_encrypt func --- src/pcq_encrypt.c | 22 ---------- src/pqc_encrypt.c | 65 ++++++++++++++++++++++++++++ src/{pcq_encrypt.h => pqc_encrypt.h} | 14 ++++-- 3 files changed, 76 insertions(+), 25 deletions(-) delete mode 100644 src/pcq_encrypt.c create mode 100644 src/pqc_encrypt.c rename src/{pcq_encrypt.h => pqc_encrypt.h} (80%) diff --git a/src/pcq_encrypt.c b/src/pcq_encrypt.c deleted file mode 100644 index 5db7ad8..0000000 --- a/src/pcq_encrypt.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2014 FH Bielefeld - * - * This file is part of a FH Bielefeld project. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -#include "pcq_encrypt.h" diff --git a/src/pqc_encrypt.c b/src/pqc_encrypt.c new file mode 100644 index 0000000..435bcd8 --- /dev/null +++ b/src/pqc_encrypt.c @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2014 FH Bielefeld + * + * This file is part of a FH Bielefeld project. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ + +#include "pcq_encrypt.h" + +/* + * encrypt the msg, using the math: + * e = (h ∗ r) + m (mod q) + * + * e = the encrypted poly + * h = the public key + * r = the random poly + * m = the message poly + * q = large mod + * + * @param ctx ntru_context* the ntru context + * @param rnd pb_poly* the random poly + * @param msg pb_poly* the message to encrypt + * @param pubKey pb_poly* the public key + * @param out pb_poly* the output poly + */ +void pb_encrypt(ntru_context *ctx, + pb_poly *rnd, + pb_poly *msg, + pb_poly *pubKey, + pb_poly *out) { + + mp_int *tmpOut; + mp_int *tmpMsg; + mp_int mp_mod; + + init_integer(&mp_mod); + MP_SET_INT(&mp_mod,(unsigned long)ctx->q); + + pb_starmultiply(pubKey, rnd, out, ctx, ctx->q); + + tmpOut = out->terms; + tmpMsg = msg->terms; + + for(unsigned int i = 0; i <= ctx->N-1; i++) { + mp_add(tmpOut,tmpMsg,tmpOut); + mp_mod(tmpOut,mp_mod,tmpOut); + + tmpOut++; + tmpMsg++; + } +} diff --git a/src/pcq_encrypt.h b/src/pqc_encrypt.h similarity index 80% rename from src/pcq_encrypt.h rename to src/pqc_encrypt.h index 22df6d0..7be7636 100644 --- a/src/pcq_encrypt.h +++ b/src/pqc_encrypt.h @@ -19,10 +19,18 @@ * MA 02110-1301 USA */ -#ifndef PCQ_ENCRYPT_H -#define PCQ_ENCRYPT_H +#ifndef PQC_ENCRYPT_H +#define PQC_ENCRYPT_H #include #include +#include "context.h" +#include "poly.h" -#endif +void pb_encrypt(ntru_context *ctx, + pb_poly *rnd, + pb_poly *msg, + pb_poly *pubKey, + pb_poly *out); + +#endif /* PQC_ENCRYPT_H */ From 9ff66b8555ac0e18366b19bde08f48d9c31c1663 Mon Sep 17 00:00:00 2001 From: Anton Oster Date: Mon, 12 May 2014 10:33:04 +0200 Subject: [PATCH 9/9] ENC: added ecrypt func --- src/pqc_encrypt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pqc_encrypt.c b/src/pqc_encrypt.c index 435bcd8..fd92ee2 100644 --- a/src/pqc_encrypt.c +++ b/src/pqc_encrypt.c @@ -41,8 +41,8 @@ void pb_encrypt(ntru_context *ctx, pb_poly *rnd, pb_poly *msg, pb_poly *pubKey, - pb_poly *out) { - + pb_poly *out) +{ mp_int *tmpOut; mp_int *tmpMsg; mp_int mp_mod;