version 1.29, 2004/05/08 00:21:31 |
version 1.29.8.1, 2006/09/30 04:06:51 |
|
|
|
/* $OpenBSD$ */ |
/* |
/* |
* Copyright (c) 2001 Markus Friedl. All rights reserved. |
* Copyright (c) 2001 Markus Friedl. All rights reserved. |
* |
* |
|
|
*/ |
*/ |
|
|
#ifdef SMARTCARD |
#ifdef SMARTCARD |
#include "includes.h" |
|
RCSID("$OpenBSD$"); |
|
|
|
|
#include <sys/types.h> |
|
|
#include <openssl/evp.h> |
#include <openssl/evp.h> |
|
|
#include <sectok.h> |
#include <sectok.h> |
|
#include <string.h> |
|
|
|
#include "xmalloc.h" |
#include "key.h" |
#include "key.h" |
#include "log.h" |
#include "log.h" |
#include "xmalloc.h" |
|
#include "misc.h" |
#include "misc.h" |
#include "scard.h" |
#include "scard.h" |
|
|
|
|
if (status == SCARD_ERROR_NOCARD) { |
if (status == SCARD_ERROR_NOCARD) { |
return SCARD_ERROR_NOCARD; |
return SCARD_ERROR_NOCARD; |
} |
} |
if (status < 0 ) { |
if (status < 0) { |
error("sc_open failed"); |
error("sc_open failed"); |
return status; |
return status; |
} |
} |
|
|
olen = len = sw = 0; |
olen = len = sw = 0; |
if (sc_fd < 0) { |
if (sc_fd < 0) { |
status = sc_init(); |
status = sc_init(); |
if (status < 0 ) |
if (status < 0) |
goto err; |
goto err; |
} |
} |
if (padding != RSA_PKCS1_PADDING) |
if (padding != RSA_PKCS1_PADDING) |
|
|
len = sw = 0; |
len = sw = 0; |
if (sc_fd < 0) { |
if (sc_fd < 0) { |
status = sc_init(); |
status = sc_init(); |
if (status < 0 ) |
if (status < 0) |
goto err; |
goto err; |
} |
} |
if (padding != RSA_PKCS1_PADDING) |
if (padding != RSA_PKCS1_PADDING) |
|
|
key_free(k); |
key_free(k); |
return NULL; |
return NULL; |
} |
} |
if (status < 0 ) { |
if (status < 0) { |
error("sc_read_pubkey failed"); |
error("sc_read_pubkey failed"); |
key_free(k); |
key_free(k); |
return NULL; |
return NULL; |
} |
} |
keys = xmalloc((nkeys+1) * sizeof(Key *)); |
keys = xcalloc((nkeys+1), sizeof(Key *)); |
|
|
n = key_new(KEY_RSA1); |
n = key_new(KEY_RSA1); |
BN_copy(n->rsa->n, k->rsa->n); |
BN_copy(n->rsa->n, k->rsa->n); |