#include "includes.h"
#if defined(SMARTCARD) && defined(USE_OPENSC)
+#include <sys/types.h>
+
#include <openssl/evp.h>
#include <openssl/x509.h>
+#include <stdarg.h>
+#include <string.h>
+
#include <opensc/opensc.h>
#include <opensc/pkcs15.h>
#include "key.h"
#include "log.h"
#include "xmalloc.h"
-#include "readpass.h"
+#include "misc.h"
#include "scard.h"
#if OPENSSL_VERSION_NUMBER < 0x00907000L && defined(CRYPTO_LOCK_ENGINE)
int r;
if (padding != RSA_PKCS1_PADDING)
- return -1;
+ return -1;
r = sc_prkey_op_init(rsa, &key_obj, SC_USAGE_DECRYPT);
if (r)
return -1;
convert_rsa_to_rsa1(Key * in, Key * out)
{
struct sc_priv_data *priv;
-
+
out->rsa->flags = in->rsa->flags;
out->flags = in->flags;
RSA_set_method(out->rsa, RSA_get_method(in->rsa));
EVP_PKEY *pubkey = NULL;
u8 *p;
char *tmp;
-
+
debug("sc_read_pubkey() with cert id %02X", cinfo->id.value[0]);
r = sc_pkcs15_read_certificate(p15card, cinfo, &cert);
if (r) {
tmp = key_fingerprint(k, SSH_FP_MD5, SSH_FP_HEX);
debug("fingerprint %d %s", key_size(k), tmp);
xfree(tmp);
-
+
return 0;
err:
if (cert)
}
key_count = r;
}
- keys = xmalloc(sizeof(Key *) * (key_count*2+1));
+ if (key_count > 1024)
+ fatal("Too many keys (%u), expected <= 1024", key_count);
+ keys = xcalloc(key_count * 2 + 1, sizeof(Key *));
for (i = 0; i < key_count; i++) {
sc_pkcs15_object_t *tmp_obj = NULL;
cert_id = ((sc_pkcs15_cert_info_t *)(certs[i]->data))->id;