X-Git-Url: http://andersk.mit.edu/gitweb/openssh.git/blobdiff_plain/912da63547305753cf209d75486ca27f93778fe0..08427260e5ea97e0f35e55b5472049bfcf8ba5d7:/scard.c diff --git a/scard.c b/scard.c index 237a4e43..9fd3ca1b 100644 --- a/scard.c +++ b/scard.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scard.c,v 1.33 2006/07/25 02:01:34 stevesk Exp $ */ +/* $OpenBSD: scard.c,v 1.36 2006/11/06 21:25:28 markus Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -26,14 +26,17 @@ #include "includes.h" #if defined(SMARTCARD) && defined(USE_SECTOK) -#include +#include #include +#include #include +#include + +#include "xmalloc.h" #include "key.h" #include "log.h" -#include "xmalloc.h" #include "misc.h" #include "scard.h" @@ -127,7 +130,7 @@ sc_init(void) if (status == SCARD_ERROR_NOCARD) { return SCARD_ERROR_NOCARD; } - if (status < 0 ) { + if (status < 0) { error("sc_open failed"); return status; } @@ -217,7 +220,7 @@ sc_private_decrypt(int flen, u_char *from, u_char *to, RSA *rsa, olen = len = sw = 0; if (sc_fd < 0) { status = sc_init(); - if (status < 0 ) + if (status < 0) goto err; } if (padding != RSA_PKCS1_PADDING) @@ -257,7 +260,7 @@ sc_private_encrypt(int flen, u_char *from, u_char *to, RSA *rsa, len = sw = 0; if (sc_fd < 0) { status = sc_init(); - if (status < 0 ) + if (status < 0) goto err; } if (padding != RSA_PKCS1_PADDING) @@ -380,7 +383,7 @@ sc_get_keys(const char *id, const char *pin) key_free(k); return NULL; } - if (status < 0 ) { + if (status < 0) { error("sc_read_pubkey failed"); key_free(k); return NULL; @@ -388,15 +391,17 @@ sc_get_keys(const char *id, const char *pin) keys = xcalloc((nkeys+1), sizeof(Key *)); n = key_new(KEY_RSA1); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("sc_get_keys: BN_copy failed"); RSA_set_method(n->rsa, sc_get_rsa()); n->flags |= KEY_FLAG_EXT; keys[0] = n; n = key_new(KEY_RSA); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("sc_get_keys: BN_copy failed"); RSA_set_method(n->rsa, sc_get_rsa()); n->flags |= KEY_FLAG_EXT; keys[1] = n;