autotool tweaks, type warnings
authorEugene Crosser <crosser@average.org>
Tue, 29 Oct 2013 10:09:57 +0000 (14:09 +0400)
committerEugene Crosser <crosser@average.org>
Tue, 29 Oct 2013 10:09:57 +0000 (14:09 +0400)
Makefile.am
configure.ac
crypto.c
pcsc_cr.c
test_cr.c
token.h
ykneo.c

index abfd92b217f1bd1a61484abfcc08d746dc2f021a..dc232665f5bfc8cdc58cfccdad16ecf27c9be3d1 100644 (file)
@@ -7,6 +7,8 @@ LIBS = @LIBS@
 pamlibdir = @pamlibdir@
 
 noinst_HEADERS = pcsc_cr.h token.h
+noinst_PROGRAMS = test_cr
+test_cr_DEPENDENCIES = pam_pcsc_cr.la
 
 lib_LTLIBRARIES = pam_pcsc_cr.la
 EXTRA_pam_pcsc_cr_la_SOURCES = ossl_crypto.c tom_prypto.c
index 28632b2ea58dc8b1bfc92ef98cdc2b160ad7f937..e9fd2f3d2a663e92d5d8aee0d4d9bb807556afbf 100644 (file)
@@ -19,27 +19,31 @@ 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],
+PKG_CHECK_MODULES([PCSC], [libpcsclite])
+AC_ARG_WITH(pcsclite-include-path,
+       [  --with-pcsclite-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],
+AC_ARG_WITH(pcsclite-lib-path,
+       [  --with-pcsclite-lib-path=PATH path to pcsclite libs],
        [PCSC_LIBS="-L $withval -lpcsclite"],
        [])
 
 AC_SUBST(PCSC_LIBS)
 AC_SUBST(PCSC_CFLAGS)
+CFLAGS="$PCSC_CFLAGS $CFLAGS"
+LIBS="$PCSC_LIBS $LIBS"
+
+AC_SUBST(CRYPTO_OBJS)
 
 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_CHECK_HEADERS([winscard.h reader.h], [],
+  [AC_MSG_ERROR([[pcsclite headers not found]])])
+AC_CHECK_LIB([pcsclite], [SCardEstablishContext], [],
+  [AC_MSG_ERROR([[pcsclite library not useable]])])
 
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
index cbdae18f8d32ca2349a050a199ecb25b28e9678d..ab6a3c44ad5750376fbf4d0597d161421b7dad67 100644 (file)
--- a/crypto.c
+++ b/crypto.c
@@ -1,23 +1,23 @@
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
 
-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;
-}
+//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 *
index 0559212e1e6946f480623ebb6a0162b82a7cb808..50d67f12a306c0bc399dcbcfbd5672aeb4d08dbe 100644 (file)
--- a/pcsc_cr.c
+++ b/pcsc_cr.c
@@ -13,7 +13,7 @@ static struct token_interface *types[] = {
 
 SCARD_IO_REQUEST pioSendPci;
 
-static LONG find_hb(LPTSTR atr, DWORD atrsize, LPTSTR *hb, LPDWORD hbsize)
+static LONG find_hb(BYTE *atr, DWORD atrsize, BYTE **hb, LPDWORD hbsize)
 {
        int i, j, cont;
        if (atrsize < 2) return SCARD_W_UNSUPPORTED_CARD;
@@ -44,7 +44,7 @@ long pcsc_cr(unsigned char *chal, int csize, unsigned char *resp, int *rsize)
        DWORD nrdrs = SCARD_AUTOALLOCATE, activeproto;
        BYTE atr[33];
        DWORD atrsize;
-       LPTSTR hb;
+       BYTE *hb;
        DWORD hbsize;
        DWORD lrsize;
        int i;
index 987df3f50860357633a8e940a578c15809fa8cc5..9415406d5ef62135ed8f56cc1ae843f03146c6c7 100644 (file)
--- a/test_cr.c
+++ b/test_cr.c
@@ -4,7 +4,7 @@
 #include <string.h>
 #include "pcsc_cr.h"
 
-char chal[] = {
+unsigned char chal[] = {
 0x0f,0x65,0xd1,0x3a,0xfe,0xcb,0xc4,0xb9,0x52,0xb1,0x60,0xcf,0xe8,0x55,0x6a,0xdd,0xfb,0xef,0xf6,0x55,0x83,0x4c,0x8d,0xea,0x38,0xea,0x3b,0x26,0xf7,0x0a,0xe8,0x0d,0x31,0x38,0xee,0x16,0x5d,0xab,0x8b,0x7f,0xf0,0x1b,0xe3,0xbe,0xd8,0x4b,0x6e,0x44,0x42,0x8d,0x0f,0xc1,0x3b,0x23,0xea,0xfe,0xc0,0x68,0xc1,0x0f,0x60,0x6c,0xf4};
 
 static void usage(const char const *cmd)
diff --git a/token.h b/token.h
index 3af9ddb54aef5b790831c05444316ae9337e75d8..e32e3be4d5ecf8c6785e39c8edf5bab167b46977 100644 (file)
--- a/token.h
+++ b/token.h
@@ -8,10 +8,10 @@ extern SCARD_IO_REQUEST pioSendPci;
 struct token_interface {
        char *name;
        int (*parse_option)(char *key, char *val);
-       DWORD (*check_atr_hb)(LPTSTR str, DWORD size);
+       DWORD (*check_atr_hb)(BYTE *str, DWORD size);
        DWORD (*prologue)(SCARDHANDLE hCard,LPTSTR envp[]);
        DWORD (*trancieve)(SCARDHANDLE hCard,LPTSTR envp[],
-               LPTSTR send, DWORD sendsize, LPTSTR recv, LPDWORD recvsize_p);
+               LPTSTR send, DWORD sendsize, BYTE *recv, LPDWORD recvsize_p);
        DWORD (*epilogue)(SCARDHANDLE hCard,LPTSTR envp[]);
 };
 
diff --git a/ykneo.c b/ykneo.c
index 79c86e5302ec3176ac5172f9752171a33b85ca33..68ef65ece0f1db3517fd6e5314a9ab05d89711c6 100644 (file)
--- a/ykneo.c
+++ b/ykneo.c
@@ -30,7 +30,7 @@ static int ykn_parse_option(char *key, char *val)
        return 0;
 }
 
-static DWORD ykn_check_atr_hb(LPTSTR str, DWORD size)
+static DWORD ykn_check_atr_hb(BYTE *str, DWORD size)
 {
        if (size < strlen(NAMEPFX)) return SCARD_W_UNSUPPORTED_CARD;
        if (memcmp(str, NAMEPFX, strlen(NAMEPFX)))
@@ -53,7 +53,7 @@ static DWORD ykn_prologue(SCARDHANDLE hCard,LPTSTR envp[])
 }
 
 static DWORD ykn_trancieve(SCARDHANDLE hCard,LPTSTR envp[],
-       LPTSTR send, DWORD sendsize, LPTSTR recv, LPDWORD recvsize_p)
+       LPTSTR send, DWORD sendsize, BYTE *recv, LPDWORD recvsize_p)
 {
        DWORD rc;
        DWORD rsize = *recvsize_p + 2;