build: crypto++ support is now optional
possibly also evading "traditional" hash functions. Cubehash is good.
This commit is contained in:
		
							parent
							
								
									1488927e73
								
							
						
					
					
						commit
						3deffb0ebe
					
				|  | @ -28,7 +28,7 @@ echo "${NAME}_CPPFLAGS = -I\$(srcdir)/$i/ ${COMMON_CPPFLAGS}" >>$OUT | ||||||
| echo "${NAME}_CFLAGS = ${COMMON_CFLAGS}" >>$OUT | echo "${NAME}_CFLAGS = ${COMMON_CFLAGS}" >>$OUT | ||||||
| echo "${NAME}_CXXFLAGS = ${COMMON_CXXFLAGS}" >>$OUT | echo "${NAME}_CXXFLAGS = ${COMMON_CXXFLAGS}" >>$OUT | ||||||
| echo "${NAME}_LDFLAGS = ${COMMON_LDFLAGS}" >>$OUT | echo "${NAME}_LDFLAGS = ${COMMON_LDFLAGS}" >>$OUT | ||||||
| echo "${NAME}_LDADD = -lgmp -lcrypto++ ${COMMON_LDADD} " >>$OUT | echo "${NAME}_LDADD = -lgmp @CRYPTOPP_LIBS@ ${COMMON_LDADD} " >>$OUT | ||||||
| 
 | 
 | ||||||
| libtoolize --force && aclocal && autoconf && automake --add-missing | libtoolize --force && aclocal && autoconf && automake --add-missing | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										22
									
								
								configure.ac
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								configure.ac
									
									
									
									
									
								
							|  | @ -18,10 +18,24 @@ AC_PROG_INSTALL | ||||||
| AC_CHECK_HEADERS([gmp.h], , AC_MSG_ERROR([Codecrypt requires gmp.h])) | AC_CHECK_HEADERS([gmp.h], , AC_MSG_ERROR([Codecrypt requires gmp.h])) | ||||||
| AC_CHECK_LIB(gmp, __gmpz_init, , AC_MSG_ERROR([Codecrypt requires libgmp])) | AC_CHECK_LIB(gmp, __gmpz_init, , AC_MSG_ERROR([Codecrypt requires libgmp])) | ||||||
| 
 | 
 | ||||||
| #check for presence of Crypto++ | #check whether to build with crypto++ | ||||||
| AC_LANG_PUSH([C++]) | AC_ARG_WITH([cryptopp], | ||||||
| AC_CHECK_HEADERS([crypto++/sha.h crypto++/tiger.h crypto++/ripemd.h], , AC_MSG_ERROR([Codecrypt requires Crypto++])) | 	AC_HELP_STRING([--with-cryptopp],[Build algorithms that need Crypto++ support]), | ||||||
| AC_LANG_POP([C++]) | 	[WITH_CRYPTOPP=$withval], | ||||||
|  | 	[WITH_CRYPTOPP=yes]) | ||||||
|  | 
 | ||||||
|  | #and check crypto++ | ||||||
|  | if test "$WITH_CRYPTOPP" = "yes"; then | ||||||
|  | 	 | ||||||
|  | 	AC_LANG_PUSH([C++]) | ||||||
|  | 	AC_CHECK_HEADERS([crypto++/sha.h crypto++/tiger.h crypto++/ripemd.h], , AC_MSG_ERROR([Codecrypt requires Crypto++])) | ||||||
|  | 	AC_LANG_POP([C++]) | ||||||
|  | 
 | ||||||
|  | 	AC_DEFINE([HAVE_CRYPTOPP], [1]) | ||||||
|  | 	AC_SUBST([CRYPTOPP_LIBS], [-lcryptopp]) | ||||||
|  | else | ||||||
|  | 	AC_DEFINE([HAVE_CRYPTOPP], [0]) | ||||||
|  | fi | ||||||
| 
 | 
 | ||||||
| #check for standard functions | #check for standard functions | ||||||
| AC_CHECK_FUNCS([memset mkdir], , AC_MSG_ERROR([Required function missing])) | AC_CHECK_FUNCS([memset mkdir], , AC_MSG_ERROR([Required function missing])) | ||||||
|  |  | ||||||
|  | @ -24,6 +24,8 @@ | ||||||
| void fill_algorithm_suite (algorithm_suite&s) | void fill_algorithm_suite (algorithm_suite&s) | ||||||
| { | { | ||||||
| #define do_alg(x) static x var_##x ; var_##x.register_into_suite(s); | #define do_alg(x) static x var_##x ; var_##x.register_into_suite(s); | ||||||
|  | 
 | ||||||
|  | #if HAVE_CRYPTOPP==1 | ||||||
| 	do_alg (algo_mceqd128); | 	do_alg (algo_mceqd128); | ||||||
| 	do_alg (algo_mceqd192); | 	do_alg (algo_mceqd192); | ||||||
| 	do_alg (algo_mceqd256); | 	do_alg (algo_mceqd256); | ||||||
|  | @ -33,6 +35,7 @@ void fill_algorithm_suite (algorithm_suite&s) | ||||||
| 	do_alg (algo_fmtseq128h20); | 	do_alg (algo_fmtseq128h20); | ||||||
| 	do_alg (algo_fmtseq192h20); | 	do_alg (algo_fmtseq192h20); | ||||||
| 	do_alg (algo_fmtseq256h20); | 	do_alg (algo_fmtseq256h20); | ||||||
|  | #endif //HAVE_CRYPTOPP==1
 | ||||||
| 
 | 
 | ||||||
| 	do_alg (algo_mceqd128cube); | 	do_alg (algo_mceqd128cube); | ||||||
| 	do_alg (algo_mceqd192cube); | 	do_alg (algo_mceqd192cube); | ||||||
|  |  | ||||||
|  | @ -38,6 +38,8 @@ static int mceqd_create_keypair (sencode**pub, sencode**priv, prng&rng) | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #if HAVE_CRYPTOPP==1 | ||||||
|  | 
 | ||||||
| int algo_mceqd128::create_keypair (sencode**pub, sencode**priv, prng&rng) | int algo_mceqd128::create_keypair (sencode**pub, sencode**priv, prng&rng) | ||||||
| { | { | ||||||
| 	return mceqd_create_keypair<16, 7, 32, 4> (pub, priv, rng); | 	return mceqd_create_keypair<16, 7, 32, 4> (pub, priv, rng); | ||||||
|  | @ -53,6 +55,8 @@ int algo_mceqd256::create_keypair (sencode**pub, sencode**priv, prng&rng) | ||||||
| 	return mceqd_create_keypair<16, 8, 32, 4> (pub, priv, rng); | 	return mceqd_create_keypair<16, 8, 32, 4> (pub, priv, rng); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #endif //HAVE_CRYPTOPP==1
 | ||||||
|  | 
 | ||||||
| int algo_mceqd128cube::create_keypair (sencode**pub, sencode**priv, prng&rng) | int algo_mceqd128cube::create_keypair (sencode**pub, sencode**priv, prng&rng) | ||||||
| { | { | ||||||
| 	return mceqd_create_keypair<16, 7, 32, 4> (pub, priv, rng); | 	return mceqd_create_keypair<16, 7, 32, 4> (pub, priv, rng); | ||||||
|  | @ -406,9 +410,10 @@ static int fo_decrypt (const bvector&cipher, bvector&plain, | ||||||
|  * Instances for actual encryption/descryption algorithms |  * Instances for actual encryption/descryption algorithms | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|  | #if HAVE_CRYPTOPP==1 | ||||||
|  | 
 | ||||||
| #include "sha_hash.h" | #include "sha_hash.h" | ||||||
| #include "rmd_hash.h" | #include "rmd_hash.h" | ||||||
| #include "cube_hash.h" |  | ||||||
| 
 | 
 | ||||||
| int algo_mceqd128::encrypt (const bvector&plain, bvector&cipher, | int algo_mceqd128::encrypt (const bvector&plain, bvector&cipher, | ||||||
|                             sencode* pubkey, prng&rng) |                             sencode* pubkey, prng&rng) | ||||||
|  | @ -482,6 +487,10 @@ int algo_mceqd256::decrypt (const bvector&cipher, bvector&plain, | ||||||
| 	       (cipher, plain, privkey); | 	       (cipher, plain, privkey); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #endif //HAVE_CRYPTOPP==1
 | ||||||
|  | 
 | ||||||
|  | #include "cube_hash.h" | ||||||
|  | 
 | ||||||
| int algo_mceqd128cube::encrypt (const bvector&plain, bvector&cipher, | int algo_mceqd128cube::encrypt (const bvector&plain, bvector&cipher, | ||||||
|                                 sencode* pubkey, prng&rng) |                                 sencode* pubkey, prng&rng) | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -21,6 +21,8 @@ | ||||||
| 
 | 
 | ||||||
| #include "algorithm.h" | #include "algorithm.h" | ||||||
| 
 | 
 | ||||||
|  | #if HAVE_CRYPTOPP==1 | ||||||
|  | 
 | ||||||
| /*
 | /*
 | ||||||
|  * SHA-based variants |  * SHA-based variants | ||||||
|  */ |  */ | ||||||
|  | @ -91,6 +93,8 @@ public: | ||||||
| 	int create_keypair (sencode**pub, sencode**priv, prng&rng); | 	int create_keypair (sencode**pub, sencode**priv, prng&rng); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | #endif //HAVE_CRYPTOPP==1
 | ||||||
|  | 
 | ||||||
| /*
 | /*
 | ||||||
|  * Cubehash-based variants |  * Cubehash-based variants | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  | @ -19,9 +19,7 @@ | ||||||
| #include "algos_sig.h" | #include "algos_sig.h" | ||||||
| 
 | 
 | ||||||
| #include "fmtseq.h" | #include "fmtseq.h" | ||||||
| #include "sha_hash.h" | #include "hash.h" | ||||||
| #include "rmd_hash.h" |  | ||||||
| #include "tiger_hash.h" |  | ||||||
| #include "arcfour.h" | #include "arcfour.h" | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  | @ -182,6 +180,12 @@ static int fmtseq_create_keypair (sencode**pub, sencode**priv, prng&rng) | ||||||
|  * actual instantiations |  * actual instantiations | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
|  | #if HAVE_CRYPTOPP==1 | ||||||
|  | 
 | ||||||
|  | #include "sha_hash.h" | ||||||
|  | #include "rmd_hash.h" | ||||||
|  | #include "tiger_hash.h" | ||||||
|  | 
 | ||||||
| int algo_fmtseq128::sign (const bvector&msg, | int algo_fmtseq128::sign (const bvector&msg, | ||||||
|                           bvector&sig, |                           bvector&sig, | ||||||
|                           sencode**privkey, |                           sencode**privkey, | ||||||
|  | @ -345,6 +349,8 @@ int algo_fmtseq256h20::create_keypair (sencode**pub, sencode**priv, prng&rng) | ||||||
| 	       (pub, priv, rng); | 	       (pub, priv, rng); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #endif //HAVE_CRYPTOPP==1
 | ||||||
|  | 
 | ||||||
| /*
 | /*
 | ||||||
|  * CubeHash variants of everything above. |  * CubeHash variants of everything above. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  | @ -20,6 +20,8 @@ | ||||||
| #ifndef _ccr_rmd_hash_h_ | #ifndef _ccr_rmd_hash_h_ | ||||||
| #define _ccr_rmd_hash_h_ | #define _ccr_rmd_hash_h_ | ||||||
| 
 | 
 | ||||||
|  | #if HAVE_CRYPTOPP==1 | ||||||
|  | 
 | ||||||
| #include "hash.h" | #include "hash.h" | ||||||
| #include <crypto++/ripemd.h> | #include <crypto++/ripemd.h> | ||||||
| 
 | 
 | ||||||
|  | @ -40,4 +42,6 @@ public: | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | #endif //HAVE_CRYPTOPP==1
 | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -19,6 +19,8 @@ | ||||||
| #ifndef _ccr_sha_hash_h_ | #ifndef _ccr_sha_hash_h_ | ||||||
| #define _ccr_sha_hash_h_ | #define _ccr_sha_hash_h_ | ||||||
| 
 | 
 | ||||||
|  | #if HAVE_CRYPTOPP==1 | ||||||
|  | 
 | ||||||
| #include "hash.h" | #include "hash.h" | ||||||
| 
 | 
 | ||||||
| #include <crypto++/sha.h> | #include <crypto++/sha.h> | ||||||
|  | @ -74,4 +76,6 @@ public: | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | #endif //HAVE_CRYPTOPP==1
 | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -20,6 +20,8 @@ | ||||||
| #ifndef _ccr_tiger_hash_h_ | #ifndef _ccr_tiger_hash_h_ | ||||||
| #define _ccr_tiger_hash_h_ | #define _ccr_tiger_hash_h_ | ||||||
| 
 | 
 | ||||||
|  | #if HAVE_CRYPTOPP==1 | ||||||
|  | 
 | ||||||
| #include "hash.h" | #include "hash.h" | ||||||
| #include <crypto++/tiger.h> | #include <crypto++/tiger.h> | ||||||
| 
 | 
 | ||||||
|  | @ -40,4 +42,6 @@ public: | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | #endif //HAVE_CRYPTOPP==1
 | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue