mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-12-25 11:22:10 +00:00
- markus@cvs.openbsd.org 2002/03/21 16:38:06
[scard.c] make compile w/ openssl 0.9.7
This commit is contained in:
parent
5589f4b55f
commit
0b675b1659
@ -115,6 +115,9 @@
|
|||||||
[clientloop.c ssh.1]
|
[clientloop.c ssh.1]
|
||||||
add built-in command line for adding new port forwardings on the fly.
|
add built-in command line for adding new port forwardings on the fly.
|
||||||
based on a patch from brian wellington. ok markus@.
|
based on a patch from brian wellington. ok markus@.
|
||||||
|
- markus@cvs.openbsd.org 2002/03/21 16:38:06
|
||||||
|
[scard.c]
|
||||||
|
make compile w/ openssl 0.9.7
|
||||||
|
|
||||||
20020317
|
20020317
|
||||||
- (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted,
|
- (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted,
|
||||||
@ -7961,4 +7964,4 @@
|
|||||||
- Wrote replacements for strlcpy and mkdtemp
|
- Wrote replacements for strlcpy and mkdtemp
|
||||||
- Released 1.0pre1
|
- Released 1.0pre1
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.1957 2002/03/22 03:24:32 mouring Exp $
|
$Id: ChangeLog,v 1.1958 2002/03/22 03:28:11 mouring Exp $
|
||||||
|
56
scard.c
56
scard.c
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#ifdef SMARTCARD
|
#ifdef SMARTCARD
|
||||||
RCSID("$OpenBSD: scard.c,v 1.17 2001/12/27 18:22:16 markus Exp $");
|
RCSID("$OpenBSD: scard.c,v 1.18 2002/03/21 16:38:06 markus Exp $");
|
||||||
|
|
||||||
#include <openssl/engine.h>
|
#include <openssl/engine.h>
|
||||||
#include <sectok.h>
|
#include <sectok.h>
|
||||||
@ -34,6 +34,15 @@ RCSID("$OpenBSD: scard.c,v 1.17 2001/12/27 18:22:16 markus Exp $");
|
|||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
#include "scard.h"
|
#include "scard.h"
|
||||||
|
|
||||||
|
#ifdef OPENSSL_VERSION_NUMBER
|
||||||
|
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
|
||||||
|
#define RSA_get_default_openssl_method RSA_get_default_method
|
||||||
|
#define DSA_get_default_openssl_method DSA_get_default_method
|
||||||
|
#define DH_get_default_openssl_method DH_get_default_method
|
||||||
|
#define ENGINE_set_BN_mod_exp(x,y)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CLA_SSH 0x05
|
#define CLA_SSH 0x05
|
||||||
#define INS_DECRYPT 0x10
|
#define INS_DECRYPT 0x10
|
||||||
#define INS_GET_KEYLENGTH 0x20
|
#define INS_GET_KEYLENGTH 0x20
|
||||||
@ -178,7 +187,8 @@ err:
|
|||||||
/* private key operations */
|
/* private key operations */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sc_private_decrypt(int flen, u_char *from, u_char *to, RSA *rsa, int padding)
|
sc_private_decrypt(int flen, const u_char *from, u_char *to, RSA *rsa,
|
||||||
|
int padding)
|
||||||
{
|
{
|
||||||
u_char *padded = NULL;
|
u_char *padded = NULL;
|
||||||
int sw, len, olen, status = -1;
|
int sw, len, olen, status = -1;
|
||||||
@ -197,7 +207,8 @@ sc_private_decrypt(int flen, u_char *from, u_char *to, RSA *rsa, int padding)
|
|||||||
len = BN_num_bytes(rsa->n);
|
len = BN_num_bytes(rsa->n);
|
||||||
padded = xmalloc(len);
|
padded = xmalloc(len);
|
||||||
|
|
||||||
sectok_apdu(sc_fd, CLA_SSH, INS_DECRYPT, 0, 0, len, from, 0, NULL, &sw);
|
sectok_apdu(sc_fd, CLA_SSH, INS_DECRYPT, 0, 0, len, (u_char *)from,
|
||||||
|
0, NULL, &sw);
|
||||||
if (!sectok_swOK(sw)) {
|
if (!sectok_swOK(sw)) {
|
||||||
error("sc_private_decrypt: INS_DECRYPT failed: %s",
|
error("sc_private_decrypt: INS_DECRYPT failed: %s",
|
||||||
sectok_get_sw(sw));
|
sectok_get_sw(sw));
|
||||||
@ -220,7 +231,8 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sc_private_encrypt(int flen, u_char *from, u_char *to, RSA *rsa, int padding)
|
sc_private_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa,
|
||||||
|
int padding)
|
||||||
{
|
{
|
||||||
u_char *padded = NULL;
|
u_char *padded = NULL;
|
||||||
int sw, len, status = -1;
|
int sw, len, status = -1;
|
||||||
@ -238,7 +250,7 @@ sc_private_encrypt(int flen, u_char *from, u_char *to, RSA *rsa, int padding)
|
|||||||
len = BN_num_bytes(rsa->n);
|
len = BN_num_bytes(rsa->n);
|
||||||
padded = xmalloc(len);
|
padded = xmalloc(len);
|
||||||
|
|
||||||
if (RSA_padding_add_PKCS1_type_1(padded, len, from, flen) <= 0) {
|
if (RSA_padding_add_PKCS1_type_1(padded, len, (u_char *)from, flen) <= 0) {
|
||||||
error("RSA_padding_add_PKCS1_type_1 failed");
|
error("RSA_padding_add_PKCS1_type_1 failed");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@ -279,28 +291,20 @@ sc_finish(RSA *rsa)
|
|||||||
/* engine for overloading private key operations */
|
/* engine for overloading private key operations */
|
||||||
|
|
||||||
static ENGINE *smart_engine = NULL;
|
static ENGINE *smart_engine = NULL;
|
||||||
static RSA_METHOD smart_rsa =
|
static RSA_METHOD smart_rsa;
|
||||||
{
|
|
||||||
"sectok",
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
ENGINE *
|
ENGINE *
|
||||||
sc_get_engine(void)
|
sc_get_engine(void)
|
||||||
{
|
{
|
||||||
RSA_METHOD *def;
|
const RSA_METHOD *def;
|
||||||
|
|
||||||
def = RSA_get_default_openssl_method();
|
def = RSA_get_default_openssl_method();
|
||||||
|
|
||||||
|
/* use the OpenSSL version */
|
||||||
|
memcpy(&smart_rsa, def, sizeof(smart_rsa));
|
||||||
|
|
||||||
|
smart_rsa.name = "sectok";
|
||||||
|
|
||||||
/* overload */
|
/* overload */
|
||||||
smart_rsa.rsa_priv_enc = sc_private_encrypt;
|
smart_rsa.rsa_priv_enc = sc_private_encrypt;
|
||||||
smart_rsa.rsa_priv_dec = sc_private_decrypt;
|
smart_rsa.rsa_priv_dec = sc_private_decrypt;
|
||||||
@ -309,22 +313,12 @@ sc_get_engine(void)
|
|||||||
orig_finish = def->finish;
|
orig_finish = def->finish;
|
||||||
smart_rsa.finish = sc_finish;
|
smart_rsa.finish = sc_finish;
|
||||||
|
|
||||||
/* just use the OpenSSL version */
|
|
||||||
smart_rsa.rsa_pub_enc = def->rsa_pub_enc;
|
|
||||||
smart_rsa.rsa_pub_dec = def->rsa_pub_dec;
|
|
||||||
smart_rsa.rsa_mod_exp = def->rsa_mod_exp;
|
|
||||||
smart_rsa.bn_mod_exp = def->bn_mod_exp;
|
|
||||||
smart_rsa.init = def->init;
|
|
||||||
smart_rsa.flags = def->flags;
|
|
||||||
smart_rsa.app_data = def->app_data;
|
|
||||||
smart_rsa.rsa_sign = def->rsa_sign;
|
|
||||||
smart_rsa.rsa_verify = def->rsa_verify;
|
|
||||||
|
|
||||||
if ((smart_engine = ENGINE_new()) == NULL)
|
if ((smart_engine = ENGINE_new()) == NULL)
|
||||||
fatal("ENGINE_new failed");
|
fatal("ENGINE_new failed");
|
||||||
|
|
||||||
ENGINE_set_id(smart_engine, "sectok");
|
ENGINE_set_id(smart_engine, "sectok");
|
||||||
ENGINE_set_name(smart_engine, "libsectok");
|
ENGINE_set_name(smart_engine, "libsectok");
|
||||||
|
|
||||||
ENGINE_set_RSA(smart_engine, &smart_rsa);
|
ENGINE_set_RSA(smart_engine, &smart_rsa);
|
||||||
ENGINE_set_DSA(smart_engine, DSA_get_default_openssl_method());
|
ENGINE_set_DSA(smart_engine, DSA_get_default_openssl_method());
|
||||||
ENGINE_set_DH(smart_engine, DH_get_default_openssl_method());
|
ENGINE_set_DH(smart_engine, DH_get_default_openssl_method());
|
||||||
|
Loading…
Reference in New Issue
Block a user