diff --git a/autogen.sh b/autogen.sh index 9c036e4..7d4207c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -11,7 +11,6 @@ OUT=Makefile.am touch NEWS AUTHORS ChangeLog echo > $OUT -PROGS="ccr-keygen ccr-encrypt ccr-decrypt ccr-info" DISTDIRS="" echo "AUTOMAKE_OPTIONS = subdir-objects" >>$OUT @@ -28,20 +27,15 @@ echo "libcodecrypt_la_LDFLAGS = ${COMMON_LDFLAGS}" >>$OUT #echo "libcodecrypt_la_LDADD = ${COMMON_LDADD} " >>$OUT [ -f "lib/Makefile.am.extra" ] && cat "lib/Makefile.am.extra" >>$OUT -echo "bin_PROGRAMS = $PROGS" >>$OUT -for i in $PROGS -do - name=`echo $i |tr '-' '_'` - dir="src/${i#ccr-}" - echo "${name}dir = $dir/" >>$OUT - echo "${name}_SOURCES = `( find $dir/ -type f -name \*.c ; find $dir/ -type f -name \*.cpp ) |tr \"\n\" \" \" ` " >>$OUT - echo "noinst_HEADERS += `find $dir/ -type f -name \*.h |tr \"\n\" \" \" `" >>$OUT - echo "${name}_CPPFLAGS = -I\$(srcdir)/$i/ ${COMMON_CPPFLAGS}" >>$OUT - echo "${name}_CFLAGS = ${COMMON_CFLAGS}" >>$OUT - echo "${name}_LDFLAGS = ${COMMON_LDFLAGS}" >>$OUT - echo "${name}_LDADD = libcodecrypt.la ${COMMON_LDADD} " >>$OUT - [ -f "$dir/Makefile.am.extra" ] && cat "$dir/Makefile.am.extra" >>$OUT -done +echo "bin_PROGRAMS = ccr" >>$OUT +echo "ccrdir = src/" >>$OUT +echo "ccr_SOURCES = `( find src/ -type f -name \*.c ; find src/ -type f -name \*.cpp ) |tr \"\n\" \" \" ` " >>$OUT +echo "noinst_HEADERS += `find src/ -type f -name \*.h |tr \"\n\" \" \" `" >>$OUT +echo "ccr_CPPFLAGS = -I\$(srcdir)/$i/ ${COMMON_CPPFLAGS}" >>$OUT +echo "ccr_CFLAGS = ${COMMON_CFLAGS}" >>$OUT +echo "ccr_LDFLAGS = ${COMMON_LDFLAGS}" >>$OUT +echo "ccr_LDADD = libcodecrypt.la ${COMMON_LDADD} " >>$OUT +[ -f "src/Makefile.am.extra" ] && cat "src/Makefile.am.extra" >>$OUT libtoolize --force && aclocal && autoconf && automake --add-missing diff --git a/include/codecrypt.h b/include/codecrypt.h index b11e81c..bf78c90 100644 --- a/include/codecrypt.h +++ b/include/codecrypt.h @@ -6,25 +6,61 @@ extern "C" { #endif -struct ccr_mce_pubkey { -}; + /* codecrypt matrix/vector/whatever type */ + typedef char* ccr_mtx; -struct ccr_mce_privkey { -}; + /* macros for faster allocation/accessing */ +#define ccr_mtx_alloc_size(veclen,nvec) ((((veclen)+7)/8)*(nvec)) +#define ccr_mtx_vec_offset ccr_mtx_alloc_size -struct ccr_nd_pubkey { -}; + struct ccr_mce_pubkey { + /* params */ + int n, k, t; -struct ccr_nd_privkey { -}; + /* n*k G' pubkey matrix */ + ccr_mtx g; + }; -int ccr_mce_gen(struct ccr_mce_pubkey*, struct ccr_mce_privkey*); -int ccr_mce_encrypt(struct ccr_mce_pubkey*, const char*, char*); -int ccr_mce_decrypt(struct ccr_mce_privkey*, const char*, char*); + struct ccr_mce_privkey { + /* params */ + int n, k, t; -int ccr_nd_gen(struct ccr_nd_pubkey*, struct ccr_nd_privkey*); -int ccr_nd_encrypt(struct ccr_nd_privkey*, const char*, char*); -int ccr_nd_decrypt(struct ccr_nd_pubkey*, const char*, char*); + /* goppa polynomial of degree t */ + ccr_mtx poly; + + /* inverses of P and S matrices */ + ccr_mtx pinv, sinv; + + /* parity check matrix */ + ccr_mtx h; + }; + + struct ccr_nd_pubkey { + /* params */ + int n, k, t; + + /* pubkey matrix */ + ccr_mtx h; + }; + + struct ccr_nd_privkey { + /* params */ + int n, k, t; + + /* goppa polynomial of degree t */ + ccr_mtx poly; + + /* inverses of P and S matrices */ + ccr_mtx pinv, sinv; + }; + + int ccr_mce_gen (struct ccr_mce_pubkey*, struct ccr_mce_privkey*); + int ccr_mce_encrypt (struct ccr_mce_pubkey*, const char*, char*); + int ccr_mce_decrypt (struct ccr_mce_privkey*, const char*, char*); + + int ccr_nd_gen (struct ccr_nd_pubkey*, struct ccr_nd_privkey*); + int ccr_nd_encrypt (struct ccr_nd_privkey*, const char*, char*); + int ccr_nd_decrypt (struct ccr_nd_pubkey*, const char*, char*); #ifdef __cplusplus } diff --git a/src/decrypt/main.c b/src/decrypt/main.c deleted file mode 100644 index 15d3008..0000000 --- a/src/decrypt/main.c +++ /dev/null @@ -1,4 +0,0 @@ - -int main() { - return 0; -} diff --git a/src/encrypt/main.c b/src/encrypt/main.c deleted file mode 100644 index 15d3008..0000000 --- a/src/encrypt/main.c +++ /dev/null @@ -1,4 +0,0 @@ - -int main() { - return 0; -} diff --git a/src/info/main.c b/src/info/main.c deleted file mode 100644 index 15d3008..0000000 --- a/src/info/main.c +++ /dev/null @@ -1,4 +0,0 @@ - -int main() { - return 0; -} diff --git a/src/keygen/main.c b/src/keygen/main.c deleted file mode 100644 index 15d3008..0000000 --- a/src/keygen/main.c +++ /dev/null @@ -1,4 +0,0 @@ - -int main() { - return 0; -}