From 757717db4b0b12c249d3f6a7a27b376e1eedc511 Mon Sep 17 00:00:00 2001 From: Bertrand Jacquin Date: Mon, 27 May 2013 13:48:21 +0200 Subject: app-crypt: initial work on OpenSSL AF_ALG --- app-crypt/openssl-af-alg/Manifest | 6 + .../openssl-af-alg/files/0000-cover-letter.patch | 26 ++++ ...ile-to-build-easily-OpenSSL-engine-AF_ALG.patch | 156 +++++++++++++++++++++ ...-Add-a-.gitignore-to-ignore-builded-files.patch | 30 ++++ .../0003-Fix-warnings-on-Wunused-parameter.patch | 93 ++++++++++++ .../files/0004-Strip-whitespaces.patch | 71 ++++++++++ .../openssl-af-alg/openssl-af-alg-9999.ebuild | 41 ++++++ 7 files changed, 423 insertions(+) create mode 100644 app-crypt/openssl-af-alg/Manifest create mode 100644 app-crypt/openssl-af-alg/files/0000-cover-letter.patch create mode 100644 app-crypt/openssl-af-alg/files/0001-Add-a-Makefile-to-build-easily-OpenSSL-engine-AF_ALG.patch create mode 100644 app-crypt/openssl-af-alg/files/0002-Add-a-.gitignore-to-ignore-builded-files.patch create mode 100644 app-crypt/openssl-af-alg/files/0003-Fix-warnings-on-Wunused-parameter.patch create mode 100644 app-crypt/openssl-af-alg/files/0004-Strip-whitespaces.patch create mode 100644 app-crypt/openssl-af-alg/openssl-af-alg-9999.ebuild (limited to 'app-crypt') diff --git a/app-crypt/openssl-af-alg/Manifest b/app-crypt/openssl-af-alg/Manifest new file mode 100644 index 00000000..d89c8ef5 --- /dev/null +++ b/app-crypt/openssl-af-alg/Manifest @@ -0,0 +1,6 @@ +AUX 0000-cover-letter.patch 765 SHA256 a067362841c7a0072eec21c0bf3c1ee8ff820f807fc1d55f76a5580763294f67 SHA512 28232699bb90ac1b9f64f75cf4b406f31dcc59d6c9dee03ff0fcd183a1e6144c378416e10b9ca5975b6fb42f0e254817c1bf85d7bead23a84315587e6ed7a1da WHIRLPOOL 4863cd3558a40bcec7bf0d2f70b1e98a19087e536bb7640ecb83d0bd0b6ecaafe3561f36804faf987eb2626f551d4a84628029bd446507752d090205fdc5ddd2 +AUX 0001-Add-a-Makefile-to-build-easily-OpenSSL-engine-AF_ALG.patch 3491 SHA256 b114f2e3b198e800a3bbe962d44db41b8f4104b063448d7e8124f1eaf8f067bc SHA512 fb118716c81b6b8324e072376dafc2a44677c7a94bfb4e368b36745685fe16d21bf3672a7255f827e55f4400cea9a4844ac2e475576a20d654d62d913779ced3 WHIRLPOOL b8aff75bfb626e3b8cce605102c6e0d3acb58c73b0d88cc7950f8aa2a4bdf07cceb852e9d280e2c89cd7388f3333e0bd442437a0493449bdc87fe134c86410b4 +AUX 0002-Add-a-.gitignore-to-ignore-builded-files.patch 785 SHA256 0f3135398d75a9969c787dc9b6e1f7c13a4f729a5ca2ef23b0ca2774fa836e65 SHA512 dc6e8332417b28654bab321216bb2eade87a580531c46953db680410d475d6635bdc8077421db1dd5162cf02649fb764439212287337984ed2796a74c3ea8b52 WHIRLPOOL f0c827fae1758dfe6f9e9fe9feaebc4d28d6be840a85d819a3364a139a914ca984373187ac98aa57b6378d2f8bb3b5c6b4c45f30c035093d51d0f78e09ebb798 +AUX 0003-Fix-warnings-on-Wunused-parameter.patch 3068 SHA256 385d3666594bc708155d904f1831542de76c1074e195b8b8b8ceb1d92cc573cd SHA512 552931fd4fd32644458b4ce29d9dffdc7b7b0b359849aaccb73256f09cd27c4b7916011b0e0bf7cefe349c8daf80a69ee577adacc46de909c679c47a521f41f8 WHIRLPOOL a7db891ab5350835becde351fd5d8c1238de7fbc3f57201bb9f996ddfb5c6d76e8964cec50ab8cab75512831ba3cdd04d2d314d35c66278cfbf6b9534f2d2dc3 +AUX 0004-Strip-whitespaces.patch 2302 SHA256 b12f73834b1c3f3d4b8c1adc414d17bd1f709c3ec15949662e345a15a39bc146 SHA512 c62cebcf60cc85496872113d613b79a47b2e18d3dcee8965c464a7f191903e481050ba7ffc617edb2844aa6ff62d1e2c714f13dcb7dfc72a1dd58297b4ab907d WHIRLPOOL d518b927464b36d42d872b92493853b48ec1915867dc0b661d947c4f8e49e6fdc2d55216e42fd3917e43fb427cec2c1610ca2046becb140e8317745f10c6d930 +EBUILD openssl-af-alg-9999.ebuild 880 SHA256 adff48243dbbda2c1fddb7008703215a1467cb3412214368961d7a3a5e858b0c SHA512 d8e9dadb5dbf8ad389355c5e35b9e52e0c43ed07f0f9968dc27f31e66c10d99d5ada6c6fb770d74f89e902877206fbb92aba9b3dc153d54ba30b43c2b7f01014 WHIRLPOOL f4d7756c925446ea034f1e7b3ceafe0d507d898a2ed86ed3b991813ffd9af035649d94edfb3ea1576c2c4707ac12b81b06fdb260c1f0c4c25ce40d260d35bd68 diff --git a/app-crypt/openssl-af-alg/files/0000-cover-letter.patch b/app-crypt/openssl-af-alg/files/0000-cover-letter.patch new file mode 100644 index 00000000..03099328 --- /dev/null +++ b/app-crypt/openssl-af-alg/files/0000-cover-letter.patch @@ -0,0 +1,26 @@ +From e8c6a9066666f174f3f66894464350bb1bc1518e Mon Sep 17 00:00:00 2001 +Message-Id: +From: Bertrand Jacquin +Date: Thu, 31 Jan 2013 21:51:11 +0100 +Subject: [PATCH 0/4] *** SUBJECT HERE *** +To: common@carnivore.it +Cc: nepenthesdev@gmail.com + +*** BLURB HERE *** + +Bertrand Jacquin (4): + Add a Makefile to build easily OpenSSL engine AF_ALG. + Add a .gitignore to ignore builded files + Fix warnings on -Wunused-parameter + Strip whitespaces + + .gitignore | 5 +++ + Makefile | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + e_af_alg.c | 32 +++++++++++-------- + 3 files changed, 127 insertions(+), 12 deletions(-) + create mode 100644 .gitignore + create mode 100644 Makefile + +-- +1.8.0 + diff --git a/app-crypt/openssl-af-alg/files/0001-Add-a-Makefile-to-build-easily-OpenSSL-engine-AF_ALG.patch b/app-crypt/openssl-af-alg/files/0001-Add-a-Makefile-to-build-easily-OpenSSL-engine-AF_ALG.patch new file mode 100644 index 00000000..425561bf --- /dev/null +++ b/app-crypt/openssl-af-alg/files/0001-Add-a-Makefile-to-build-easily-OpenSSL-engine-AF_ALG.patch @@ -0,0 +1,156 @@ +From cfc3cbae5c1c7b084925759add091e997a8e49f7 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: +References: +From: Bertrand Jacquin +Date: Thu, 31 Jan 2013 18:27:17 +0100 +Subject: [PATCH 1/4] Add a Makefile to build easily OpenSSL engine AF_ALG. +To: common@carnivore.it +Cc: nepenthesdev@gmail.com + +Build the project (one of) : + $ make + $ make shared + $ make all + CC e_af_alg.o + LD libaf_alg.so + +Build with verbose output : + $ make V=1 + cc -c -fPIC -O3 -W -Wall -o e_af_alg.o e_af_alg.c + cc -shared -o libaf_alg.so e_af_alg.o -lcrypto + +Build with specific CFLAGS and CC : + $ make CC=i586-pc-linux-gnu-gcc CFLAGS='-march=geode -Os -mmmx -m3dnow -I/data/cross/alix3-i586/firmware/usr/include' + +In this case default one (-fPIC is alway applied). + +Strip library : + $ make strip + STRIP libaf_alg.so.strip + +Build a tar for public release : + $ make dist + TAR e_af_alg-0.tar + XZ e_af_alg-0.txz + +Here, revision is 0 as there is no git tag, but show be replaced with +the git description. + +Signed-off-by: Bertrand Jacquin +--- + Makefile | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 102 insertions(+) + create mode 100644 Makefile + +diff --git a/Makefile b/Makefile +new file mode 100644 +index 0000000..8753910 +--- /dev/null ++++ Makefile +@@ -0,0 +1,102 @@ ++#!/usr/bin/make -f < ++# ++# (c) 2013 - Bertrand Jacquin ++# ++ ++NAME = libaf_alg ++VERSION = $(shell sh -c 'git describe --tags --dirty=-dev 2> /dev/null || echo 0') ++ ++SRC = \ ++ e_af_alg.c ++ ++DOC_FILES = \ ++ README ++ ++CFLAGS = \ ++ -O3 \ ++ -W -Wall ++ ++SPEC_CFLAGS = \ ++ -fPIC ++ ++LDFLAGS = ++ ++SPEC_LDFLAGS = \ ++ -lcrypto ++ ++CC = cc ++LD = $(CC) ++ ++STRIP = strip ++STRIP_FLAGS = --strip-unneeded -R .comment -R .GCC.command.line -R .note.gnu.build-id ++ ++INSTALL = install ++ ++TAR = tar ++XZ = xz ++ ++RM = rm -f ++ ++DESTDIR = ++PREFIX = /usr/local ++LIBDIR = $(PREFIX)/lib/engines ++DOCDIR = $(PREFIX)/share/doc/$(NAME) ++ ++ifeq ($(V),) ++ Q = @ ++ ++ qcmd = @printf " %-8s %s\n" "$(1)" "$(2)"; ++endif # $(V) ++ ++all: shared ++ ++shared: $(NAME).so ++strip: $(NAME).so.strip ++dist: $(NAME)-$(VERSION).txz ++ ++%.o: %.c ++ $(call qcmd,CC,$@) ++ $(Q)$(CC) -c $(SPEC_CFLAGS) $(CFLAGS) -o $@ $< ++ ++$(NAME).so: $(SRC:c=o) ++ $(call qcmd,LD,$@) ++ $(Q)$(LD) -shared -o $@ $^ $(SPEC_LDFLAGS) $(LDFLAGS) ++ ++$(NAME).so.strip: $(NAME).so ++ $(call qcmd,STRIP,$@) ++ $(Q)$(STRIP) $(STRIP_FLAGS) -o $@ $< ++ ++install: install-lib ++install-lib: $(DESTDIR)$(LIBDIR)/$(NAME).so ++install-doc: $(addprefix $(DESTDIR)$(DOCDIR)/, $(DOC_FILES)) ++ ++$(DESTDIR)$(LIBDIR)/$(NAME).so: $(NAME).so ++ $(call qcmd,INSTALL,$@) ++ $(Q)$(INSTALL) -D -m 555 $< $@ ++ ++$(DESTDIR)$(DOCDIR)/%: % ++ $(call qcmd,INSTALL,$@) ++ $(Q)$(INSTALL) -D -m 555 $< $@ ++ ++$(NAME)-$(VERSION).tar: $(SRC) $(DOC_FILES) Makefile ++ $(call qcmd,TAR,$@) ++ $(Q)$(TAR) cf $@ \ ++ --transform "s,^,$(NAME)-$(VERSION)/," \ ++ --force-local --numeric-owner \ ++ $^ ++ ++%.txz: %.tar ++ $(call qcmd,XZ,$@) ++ $(Q)$(XZ) -c > $@ < $< ++ ++clean: ++ $(call qcmd,RM,$(SRC:c=o)) ++ $(Q)$(RM) $(SRC:c=o) ++ $(call qcmd,RM,$(NAME).so) ++ $(Q)$(RM) $(NAME).so $(NAME).so.strip ++ ++dist-clean: clean ++ $(call qcmd,RM,$(NAME)-$(VERSION).tar) ++ $(Q)$(RM) $(NAME)-$(VERSION).tar ++ $(call qcmd,RM,$(NAME)-$(VERSION).txz) ++ $(Q)$(RM) $(NAME)-$(VERSION).txz +-- +1.8.0 + diff --git a/app-crypt/openssl-af-alg/files/0002-Add-a-.gitignore-to-ignore-builded-files.patch b/app-crypt/openssl-af-alg/files/0002-Add-a-.gitignore-to-ignore-builded-files.patch new file mode 100644 index 00000000..a94924f3 --- /dev/null +++ b/app-crypt/openssl-af-alg/files/0002-Add-a-.gitignore-to-ignore-builded-files.patch @@ -0,0 +1,30 @@ +From d01632cb785bbc9524cac3ad96f8c9148c333919 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: +References: +From: Bertrand Jacquin +Date: Thu, 31 Jan 2013 18:33:01 +0100 +Subject: [PATCH 2/4] Add a .gitignore to ignore builded files +To: common@carnivore.it +Cc: nepenthesdev@gmail.com + +Signed-off-by: Bertrand Jacquin +--- + .gitignore | 5 +++++ + 1 file changed, 5 insertions(+) + create mode 100644 .gitignore + +diff --git a/.gitignore b/.gitignore +new file mode 100644 +index 0000000..b7143fc +--- /dev/null ++++ b/.gitignore +@@ -0,0 +1,5 @@ ++*.o ++*.so ++*.so.strip ++*.tar ++*.txz +-- +1.8.0 + diff --git a/app-crypt/openssl-af-alg/files/0003-Fix-warnings-on-Wunused-parameter.patch b/app-crypt/openssl-af-alg/files/0003-Fix-warnings-on-Wunused-parameter.patch new file mode 100644 index 00000000..b8898075 --- /dev/null +++ b/app-crypt/openssl-af-alg/files/0003-Fix-warnings-on-Wunused-parameter.patch @@ -0,0 +1,93 @@ +From c0d836343b3ef303e6048df45845dfebc4cdc854 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: +References: +From: Bertrand Jacquin +Date: Thu, 31 Jan 2013 18:37:03 +0100 +Subject: [PATCH 3/4] Fix warnings on -Wunused-parameter +To: common@carnivore.it +Cc: nepenthesdev@gmail.com + +Signed-off-by: Bertrand Jacquin +--- + e_af_alg.c | 22 ++++++++++++++++------ + 1 file changed, 16 insertions(+), 6 deletions(-) + +diff --git a/e_af_alg.c b/e_af_alg.c +index e253e07..8864523 100644 +--- a/e_af_alg.c ++++ b/e_af_alg.c +@@ -96,6 +96,16 @@ static int af_alg_digests(ENGINE *e, const EVP_MD **digest, const int **nids, in + + #define EVP_CIPHER_block_size_CBC AES_BLOCK_SIZE + ++#define HAVE___ATTRIBUTE__ 1 ++ ++#if HAVE___ATTRIBUTE__ ++# define __UNUSED__ __attribute__((unused)) ++# define __U__ __attribute__((unused)) ++#else ++# define __UNUSED__ ++# define __U__ ++#endif /* HAVE___ATTRIBUTE__ */ ++ + static bool nid_in_nids(int nid, int nids[], int num) + { + int i=0; +@@ -129,7 +139,7 @@ static int *af_alg_cipher_nids = NULL; + static int af_alg_cipher_nids_num = 0; + + +-int af_alg_init(ENGINE * engine) ++int af_alg_init(ENGINE * engine __U__) + { + int sock; + if((sock = socket(AF_ALG, SOCK_SEQPACKET, 0)) == -1) +@@ -138,7 +148,7 @@ int af_alg_init(ENGINE * engine) + return 1; + } + +-int af_alg_finish(ENGINE * engine) ++int af_alg_finish(ENGINE * engine __U__) + { + return 1; + } +@@ -183,7 +193,7 @@ static bool names_to_nids(const char *names, const void*(*by_name)(const char *) + return true; + } + +-static int af_alg_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()) ++static int af_alg_ctrl(ENGINE *e, int cmd, long i __U__, void *p, void (*f)() __U__) + { + OpenSSL_add_all_algorithms(); + switch( cmd ) +@@ -252,7 +262,7 @@ static int af_alg_bind_fn(ENGINE *e, const char *id) + IMPLEMENT_DYNAMIC_CHECK_FN() + IMPLEMENT_DYNAMIC_BIND_FN(af_alg_bind_fn) + +-static int af_alg_aes_init_key (EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) ++static int af_alg_aes_init_key (EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv __U__, int enc __U__) + { + int keylen = EVP_CIPHER_CTX_key_length(ctx); + struct af_alg_cipher_data *acd = (struct af_alg_cipher_data *)ctx->cipher_data; +@@ -382,7 +392,7 @@ static int af_alg_aes_ciphers(EVP_CIPHER_CTX *ctx, unsigned char *out_arg, const + return 1; + } + +-static int af_alg_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid) ++static int af_alg_ciphers(ENGINE *e __U__, const EVP_CIPHER **cipher, const int **nids, int nid) + { + if( !cipher ) + { +@@ -497,7 +507,7 @@ static const EVP_MD af_alg_##digest##_md = { \ + + DECLARE_MD_SHA(sha1) + +-static int af_alg_digests(ENGINE *e, const EVP_MD **digest, const int **nids, int nid) ++static int af_alg_digests(ENGINE *e __U__, const EVP_MD **digest, const int **nids, int nid) + { + if( !digest ) + { +-- +1.8.0 + diff --git a/app-crypt/openssl-af-alg/files/0004-Strip-whitespaces.patch b/app-crypt/openssl-af-alg/files/0004-Strip-whitespaces.patch new file mode 100644 index 00000000..c2a3bee5 --- /dev/null +++ b/app-crypt/openssl-af-alg/files/0004-Strip-whitespaces.patch @@ -0,0 +1,71 @@ +From e8c6a9066666f174f3f66894464350bb1bc1518e Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: +References: +From: Bertrand Jacquin +Date: Thu, 31 Jan 2013 18:38:55 +0100 +Subject: [PATCH 4/4] Strip whitespaces +To: common@carnivore.it +Cc: nepenthesdev@gmail.com + +Signed-off-by: Bertrand Jacquin +--- + e_af_alg.c | 10 ++++------ + 1 file changed, 4 insertions(+), 6 deletions(-) + +diff --git a/e_af_alg.c b/e_af_alg.c +index 8864523..03a0dca 100644 +--- a/e_af_alg.c ++++ b/e_af_alg.c +@@ -9,7 +9,7 @@ + * are met: + * + * 1. Redistributions of source code must retain the above copyright +- * notice, this list of conditions and the following disclaimer. ++ * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in +@@ -138,7 +138,6 @@ static int af_alg_digest_all_nids_num = sizeof(af_alg_digest_all_nids)/sizeof(af + static int *af_alg_cipher_nids = NULL; + static int af_alg_cipher_nids_num = 0; + +- + int af_alg_init(ENGINE * engine __U__) + { + int sock; +@@ -266,7 +265,7 @@ static int af_alg_aes_init_key (EVP_CIPHER_CTX *ctx, const unsigned char *key, c + { + int keylen = EVP_CIPHER_CTX_key_length(ctx); + struct af_alg_cipher_data *acd = (struct af_alg_cipher_data *)ctx->cipher_data; +- ++ + struct sockaddr_alg sa = { + .salg_family = AF_ALG, + .salg_type = "skcipher", +@@ -282,7 +281,7 @@ static int af_alg_aes_init_key (EVP_CIPHER_CTX *ctx, const unsigned char *key, c + + if((acd->tfmfd = socket(AF_ALG, SOCK_SEQPACKET, 0)) == -1) + return 0; +- ++ + if( bind(acd->tfmfd, (struct sockaddr*)&sa, sizeof(sa)) == -1 ) + return 0; + +@@ -378,7 +377,7 @@ static int af_alg_aes_ciphers(EVP_CIPHER_CTX *ctx, unsigned char *out_arg, const + + if (read(acd->op, out_arg+done, len) != len) + return 0; +- ++ + /* do not update IV for following chunks */ + msg.msg_controllen = 0; + done += len; +@@ -528,4 +527,3 @@ static int af_alg_digests(ENGINE *e __U__, const EVP_MD **digest, const int **ni + } + return (*digest != NULL); + } +- +-- +1.8.0 + diff --git a/app-crypt/openssl-af-alg/openssl-af-alg-9999.ebuild b/app-crypt/openssl-af-alg/openssl-af-alg-9999.ebuild new file mode 100644 index 00000000..79e7be72 --- /dev/null +++ b/app-crypt/openssl-af-alg/openssl-af-alg-9999.ebuild @@ -0,0 +1,41 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI=4 + +inherit git-2 eutils toolchain-funcs + +DESCRIPTION="AF_ALG for OpenSSL" +HOMEPAGE="http://src.carnivore.it/users/common/af_alg" + +EGIT_REPO_URI="git://git.carnivore.it/users/common/af_alg.git" +EGIT_COMMIT="HEAD" + +LICENSE="openssl" +SLOT="0" +KEYWORDS="~amd64" +IUSE="" + +DEPEND="dev-libs/openssl" +RDEPEND="${DEPEND}" + +src_prepare () +{ + epatch "${FILESDIR}"/0001-Add-a-Makefile-to-build-easily-OpenSSL-engine-AF_ALG.patch + epatch "${FILESDIR}"/0002-Add-a-.gitignore-to-ignore-builded-files.patch + epatch "${FILESDIR}"/0003-Fix-warnings-on-Wunused-parameter.patch + epatch "${FILESDIR}"/0004-Strip-whitespaces.patch +} + +src_compile () +{ + emake CC="$(tc-getCC)" +} + +src_install () +{ + emake install DESTDIR="${D}" LIBDIR=/usr/$(get_libdir)/engines + + dodoc README +} -- cgit v1.2.3