From 4f3247d992b2d4152da0ebc0daf828c874e0b1f1 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Tue, 29 Oct 2013 11:32:10 +0400 Subject: [PATCH] switch to autotools --- Makefile | 10 ---------- Makefile.am | 22 ++++++++++++++++++++++ autogen.sh | 2 ++ configure.ac | 45 +++++++++++++++++++++++++++++++++++++++++++++ crypto.c | 30 ++++++++++++++++++++++++++++++ ossl_crypto.c | 0 tom_crypto.c | 0 7 files changed, 99 insertions(+), 10 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 crypto.c create mode 100644 ossl_crypto.c create mode 100644 tom_crypto.c diff --git a/Makefile b/Makefile deleted file mode 100644 index 80c9948..0000000 --- a/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# http://pcsclite.alioth.debian.org/pcsclite.html - -CFLAGS += -g $(shell pkg-config --cflags libpcsclite) -LDLIBS += $(shell pkg-config --libs libpcsclite) - -test_cr: test_cr.o pcsc_cr.o ykneo.o - -test_cr.o: pcsc_cr.h -pcsc_cr.o: pcsc_cr.h token.h -ykneo.o: token.h diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..9c5f034 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,22 @@ +# $Id: Makefile.am 295 2005-05-13 14:58:27Z crosser $ + +AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 + +LIBS = @LIBS@ +pamlibdir = @pamlibdir@ + +noinst_HEADERS = pcsc_cr.h token.h + +pam_pcsc_cr_LTLIBRARIES = pam_pcsc_cr.la +EXTRA_pam_pcsc_cr_la_SOURCES = ossl_crypto.c tom_prypto.c +pam_pcsc_cr_la_SOURCES = crypto.c pcsc_cr.c ykneo.c +pam_pcsc_cr_la_LDFLAGS = -module -avoid-version +pam_pcsc_cr_la_LIBADD = @CRYPTO_OBJS@ +pam_pcsc_cr_la_DEPENDENCIES = @CRYPTO_OBJS@ + +EXTRA_DIST = autogen.sh + +TESTS = test_cr + +CLEANFILES = test_cr diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..08240fd --- /dev/null +++ b/autogen.sh @@ -0,0 +1,2 @@ +#!/bin/sh +autoreconf -i -f diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..28632b2 --- /dev/null +++ b/configure.ac @@ -0,0 +1,45 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_INIT([pam_pcsc_cr], 0.0.1) +AC_CONFIG_SRCDIR([pam_pcsc_cr.c]) +AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE +AM_CONFIG_HEADER([config.h]) +AC_LANG_C +AC_PROG_CC + +if test "X$CC" = "Xgcc"; then + CFLAGS="$CFLAGS -Wall -g" +fi + +AC_PROG_MAKE_SET +AC_SUBST(PROGS)dnl +AC_SUBST(LIBPROGS)dnl +AC_PROG_INSTALL +AM_PROG_LIBTOOL +PKG_PROG_PKG_CONFIG + +PKG_CHECK_MODULES([PCSC], [pcsclite]) +AC_ARG_WITH(pcsc-include-path, + [ --with-pcsc-include-path=PATH path to pcsclite includes], + [PCSC_CFLAGS="-I $withval"], + []) +AC_ARG_WITH(pcsc-lib-path, + [ --with-pcsc-lib-path=PATH path to pcsclite libs], + [PCSC_LIBS="-L $withval -lpcsclite"], + []) + +AC_SUBST(PCSC_LIBS) +AC_SUBST(PCSC_CFLAGS) + +dnl Checks for header files. +AC_HEADER_STDC +AC_HEADER_TIME + +AC_CHECK_LIB(libpcsclite, SCardEstablishContext) +if test x$ac_cv_lib_SCardEstablishContext != xyes; then + AC_MSG_ERROR([Cannot find usable libpcsclite]) +fi + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/crypto.c b/crypto.c new file mode 100644 index 0000000..cbdae18 --- /dev/null +++ b/crypto.c @@ -0,0 +1,30 @@ +#include +#include + +int main() +{ + EVP_CIPHER_CTX ctx; + unsigned char key[32] = {0}; + unsigned char iv[16] = {0}; + unsigned char in[16] = {0}; + unsigned char out[32]; /* at least one block longer than in[] */ + int outlen1, outlen2; + + EVP_EncryptInit(&ctx, EVP_aes_256_cbc(), key, iv); + EVP_EncryptUpdate(&ctx, out, &outlen1, in, sizeof(in)); + EVP_EncryptFinal(&ctx, out + outlen1, &outlen2); + + printf("ciphertext length: %d\n", outlen1 + outlen2); + + return 0; +} + +// result = HMAC(EVP_sha256(), key, 999, data, 888, NULL, NULL); +// EVP_MD * + +// HMAC_CTX hctx; +// HMAC_CTX_init(&hctx); +// if (HMAC_Init(&hctx, key, keylen, EVP_sha1())) success; +// if (HMAC_Update(&hctx, data, datalen)) success; +// if (HMAC_Final(&hctx, &digest, &digestlen)) success +// HMAC_CTX_cleanup(&hctx); diff --git a/ossl_crypto.c b/ossl_crypto.c new file mode 100644 index 0000000..e69de29 diff --git a/tom_crypto.c b/tom_crypto.c new file mode 100644 index 0000000..e69de29 -- 2.39.2