Add CFLAGS_PCSC, CFLAGS_OPENSC, CFLAGS_ASSUAN, LIBOPENSC

Add PIN_ENTRY instead of hardcoding it to "/usr/local/bin/gpinentry"


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@140 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
aet 2002-01-06 19:40:24 +00:00
parent b9da215428
commit 259efb3b11
9 changed files with 59 additions and 33 deletions

View File

@ -1,9 +1,17 @@
## Makefile.am -- Process this file with automake to produce Makefile.in
INCLUDES = @CFLAGS_PCSC@ @CFLAGS_OPENSC@ @CFLAGS_ASSUAN@
plugindir = $(PLUGINDIR)
if HAVE_SSL
plugin_LTLIBRARIES = opensc-signer.la
else
plugin_LTLIBRARIES =
endif
plugin_LTLIBRARIES = opensc-signer.la
opensc_signer_la_LDFLAGS = -module -avoid-version -lcrypto -lassuan
opensc_signer_la_CFLAGS = $(AM_CFLAGS) -Inpinclude -DXP_UNIX
opensc_signer_la_LDFLAGS = -module -avoid-version
opensc_signer_la_LIBADD = @LIBOPENSC@ @LIBCRYPTO@ @LIBASSUAN@
opensc_signer_la_CFLAGS = $(AM_CFLAGS) -Inpinclude -DXP_UNIX
opensc_signer_la_SOURCES = opensc-crypto.c opensc-support.c \
signer.c stubs.c dialog.c
noinst_HEADERS = opensc-crypto.h opensc-support.h \

View File

@ -1,8 +1,11 @@
#include "signer.h"
#include <assuan.h>
#include <stdarg.h>
#ifndef PIN_ENTRY
#define PIN_ENTRY "/usr/local/bin/gpinentry"
#endif
struct entry_parm_s {
int lines;
size_t size;
@ -31,7 +34,7 @@ int ask_and_verify_pin_code(struct sc_pkcs15_card *p15card,
{
int r;
const char *argv[3];
const char *pgmname = "/usr/local/bin/gpinentry";
const char *pgmname = PIN_ENTRY;
ASSUAN_CONTEXT ctx;
char buf[500];
char errtext[100];

View File

@ -1,12 +1,12 @@
#include <opensc-pkcs15.h>
#include <opensc.h>
#include <openssl/rsa.h>
#include "opensc-crypto.h"
#include "signer.h"
#define DBG(x) { x; }
extern int ask_and_verify_pin_code(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_pin_info *pinfo);
void
sc_close(struct sc_priv_data *priv)
{
@ -61,18 +61,24 @@ static int sc_private_decrypt(int flen, u_char *from, u_char *to, RSA *rsa,
sc_close(priv);
r = sc_init(priv);
if (r) {
//error("SmartCard init failed: %s", sc_strerror(r));
#if 0
error("SmartCard init failed: %s", sc_strerror(r));
#endif
goto err;
}
}
r = sc_pkcs15_find_prkey_by_id(priv->p15card, &priv->cert_id, &key);
if (r) {
//error("Unable to find private key from SmartCard: %s", sc_strerror(r));
#if 0
error("Unable to find private key from SmartCard: %s", sc_strerror(r));
#endif
goto err;
}
r = sc_pkcs15_find_pin_by_auth_id(priv->p15card, &key->com_attr.auth_id, &pin);
if (r) {
// error("Unable to find PIN object from SmartCard: %s", sc_strerror(r));
#if 0
error("Unable to find PIN object from SmartCard: %s", sc_strerror(r));
#endif
goto err;
}
r = ask_and_verify_pin_code(priv->p15card, pin);
@ -83,7 +89,9 @@ static int sc_private_decrypt(int flen, u_char *from, u_char *to, RSA *rsa,
}
r = sc_pkcs15_decipher(priv->p15card, key, from, flen, to, flen);
if (r < 0) {
// error("sc_pkcs15_decipher() failed: %s", sc_strerror(r));
#if 0
error("sc_pkcs15_decipher() failed: %s", sc_strerror(r));
#endif
goto err;
}
return r;
@ -95,7 +103,9 @@ err:
static int
sc_private_encrypt(int flen, u_char *from, u_char *to, RSA *rsa, int padding)
{
// error("unsupported function sc_private_encrypt() called");
#if 0
error("unsupported function sc_private_encrypt() called");
#endif
return -1;
}
@ -111,8 +121,10 @@ sc_sign(int type, u_char *m, unsigned int m_len,
priv = (struct sc_priv_data *) RSA_get_app_data(rsa);
if (priv == NULL)
return -1;
// debug("sc_sign() called on cert %02X: type = %d, m_len = %d",
// priv->cert_id.value[0], type, m_len);
#if 0
debug("sc_sign() called on cert %02X: type = %d, m_len = %d",
priv->cert_id.value[0], type, m_len);
#endif
DBG(printf("sc_sign() called\n"));
if (priv->p15card == NULL) {
sc_close(priv);
@ -188,7 +200,7 @@ static RSA_METHOD libsc_rsa =
NULL,
};
RSA_METHOD * sc_get_method()
RSA_METHOD * sc_get_method(void)
{
RSA_METHOD *def;

View File

@ -1,4 +1,3 @@
#ifndef _OPENSC_CRYPTO_H
#define _OPENSC_CRYPTO_H

View File

@ -1,4 +1,3 @@
#include "opensc-support.h"
#include "opensc-crypto.h"
#include <openssl/x509.h>
@ -24,11 +23,15 @@ static int get_certificate(PluginInstance *inst,
for (i = 0; i < inst->p15card->prkey_count; i++) {
struct sc_pkcs15_prkey_info *key = &inst->p15card->prkey_info[i];
// if (key->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION) {
#if 0
if (key->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION) {
#endif
/* Use the first available non-repudiation key */
cert_id = key->id;
break;
// }
#if 0
}
#endif
}
if (cert_id.len == 0)
return SC_ERROR_OBJECT_NOT_FOUND;
@ -218,8 +221,10 @@ err:
BIO_free(in);
if (p7bio)
BIO_free(p7bio);
/* if (si)
PKCS7_SIGNER_INFO_free(si); */
#if 0
if (si)
PKCS7_SIGNER_INFO_free(si);
#endif
if (pkey)
EVP_PKEY_free(pkey);
if (x509)

View File

@ -1,4 +1,3 @@
#ifndef _OPENSC_SUPPORT_H
#define _OPENSC_SUPPORT_H

View File

@ -40,7 +40,7 @@ NPP_Initialize(void)
jref
NPP_GetJavaClass()
NPP_GetJavaClass(void)
{
printf("NPP_GetJavaClass()\n");
return NULL;

View File

@ -1,7 +1,9 @@
#ifndef _SIGNER_H
#define _SIGNER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <opensc.h>
#include <opensc-pkcs15.h>
#include <X11/Intrinsic.h>

View File

@ -1,15 +1,12 @@
#include <opensc.h>
#include <opensc-pkcs15.h>
#include <openssl/pkcs7.h>
#include <string.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
#include <openssl/pkcs7.h>
#include "opensc-support.h"
#include "opensc-crypto.h"
#include "signer.h"
int test()
int test(void)
{
BIO *in;
PKCS7 *p7;
@ -19,16 +16,17 @@ int test()
if (p7 == NULL) {
goto err;
}
// return prp7(p7);
#if 0
return prp7(p7);
#endif
return 0;
err:
ERR_load_crypto_strings();
ERR_print_errors_fp(stderr);
return 1;
}
int main()
int main(void)
{
PluginInstance pl;
u8 *data;