|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/authfd.c openssh-4.5p1.nss/authfd.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/authfd.c 2006-09-01 07:38:36.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/authfd.c 2007-05-23 15:01:55.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -626,6 +626,45 @@ ssh_update_card(AuthenticationConnection
|
|
Tomáš Mráz |
c3274c |
return decode_reply(type);
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+int
|
|
Tomáš Mráz |
c3274c |
+ssh_update_nss_key(AuthenticationConnection *auth, int add,
|
|
Tomáš Mráz |
c3274c |
+ const char *tokenname, const char *keyname,
|
|
Tomáš Mráz |
c3274c |
+ const char *pass, u_int life, u_int confirm)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ Buffer msg;
|
|
Tomáš Mráz |
c3274c |
+ int type, constrained = (life || confirm);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (add) {
|
|
Tomáš Mráz |
c3274c |
+ type = constrained ?
|
|
Tomáš Mráz |
c3274c |
+ SSH_AGENTC_ADD_NSS_KEY_CONSTRAINED :
|
|
Tomáš Mráz |
c3274c |
+ SSH_AGENTC_ADD_NSS_KEY;
|
|
Tomáš Mráz |
c3274c |
+ } else
|
|
Tomáš Mráz |
c3274c |
+ type = SSH_AGENTC_REMOVE_NSS_KEY;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ buffer_init(&msg;;
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_char(&msg, type);
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_cstring(&msg, tokenname);
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_cstring(&msg, keyname);
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_cstring(&msg, pass);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (constrained) {
|
|
Tomáš Mráz |
c3274c |
+ if (life != 0) {
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_char(&msg, SSH_AGENT_CONSTRAIN_LIFETIME);
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_int(&msg, life);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ if (confirm != 0)
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_char(&msg, SSH_AGENT_CONSTRAIN_CONFIRM);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (ssh_request_reply(auth, &msg, &msg) == 0) {
|
|
Tomáš Mráz |
c3274c |
+ buffer_free(&msg;;
|
|
Tomáš Mráz |
c3274c |
+ return 0;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ type = buffer_get_char(&msg;;
|
|
Tomáš Mráz |
c3274c |
+ buffer_free(&msg;;
|
|
Tomáš Mráz |
c3274c |
+ return decode_reply(type);
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
/*
|
|
Tomáš Mráz |
c3274c |
* Removes all identities from the agent. This call is not meant to be used
|
|
Tomáš Mráz |
c3274c |
* by normal applications.
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/authfd.h openssh-4.5p1.nss/authfd.h
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/authfd.h 2006-08-05 04:39:39.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/authfd.h 2007-05-17 11:47:39.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -49,6 +49,12 @@
|
|
Tomáš Mráz |
c3274c |
#define SSH2_AGENTC_ADD_ID_CONSTRAINED 25
|
|
Tomáš Mráz |
c3274c |
#define SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED 26
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+/* nss */
|
|
Tomáš Mráz |
c3274c |
+#define SSH_AGENTC_ADD_NSS_KEY 30
|
|
Tomáš Mráz |
c3274c |
+#define SSH_AGENTC_REMOVE_NSS_KEY 31
|
|
Tomáš Mráz |
c3274c |
+#define SSH_AGENTC_ADD_NSS_KEY_CONSTRAINED 32
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
#define SSH_AGENT_CONSTRAIN_LIFETIME 1
|
|
Tomáš Mráz |
c3274c |
#define SSH_AGENT_CONSTRAIN_CONFIRM 2
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
@@ -83,6 +89,8 @@ int ssh_remove_all_identities(Authentic
|
|
Tomáš Mráz |
c3274c |
int ssh_lock_agent(AuthenticationConnection *, int, const char *);
|
|
Tomáš Mráz |
c3274c |
int ssh_update_card(AuthenticationConnection *, int, const char *,
|
|
Tomáš Mráz |
c3274c |
const char *, u_int, u_int);
|
|
Tomáš Mráz |
c3274c |
+int ssh_update_nss_key(AuthenticationConnection *, int, const char *,
|
|
Tomáš Mráz |
c3274c |
+ const char *, const char *, u_int, u_int);
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
int
|
|
Tomáš Mráz |
c3274c |
ssh_decrypt_challenge(AuthenticationConnection *, Key *, BIGNUM *, u_char[16],
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/configure.ac openssh-4.5p1.nss/configure.ac
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/configure.ac 2007-05-15 16:28:07.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/configure.ac 2007-05-15 16:38:56.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -3175,6 +3175,21 @@ AC_ARG_WITH(linux-audit,
|
|
Tomáš Mráz |
c3274c |
])
|
|
Tomáš Mráz |
c3274c |
AC_SUBST(LIBAUDIT)
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+# Check whether user wants NSS support
|
|
Tomáš Mráz |
c3274c |
+LIBNSS_MSG="no"
|
|
Tomáš Mráz |
c3274c |
+LIBNSS=""
|
|
Tomáš Mráz |
c3274c |
+AC_ARG_WITH(nss,
|
|
Tomáš Mráz |
c3274c |
+ [ --with-nss Enable NSS support],
|
|
Tomáš Mráz |
c3274c |
+ [ if test "x$withval" != "xno" ; then
|
|
Tomáš Mráz |
c3274c |
+ AC_DEFINE(HAVE_LIBNSS,1,[Define if you want NSS support.])
|
|
Tomáš Mráz |
c3274c |
+ LIBNSS_MSG="yes"
|
|
Tomáš Mráz |
c3274c |
+ CPPFLAGS="$CPPFLAGS -I/usr/include/nss3 -I/usr/include/nspr4"
|
|
Tomáš Mráz |
0092bb |
+ AC_CHECK_HEADERS(pk11pub.h)
|
|
Tomáš Mráz |
c3274c |
+ LIBNSS="-lnss3"
|
|
Tomáš Mráz |
c3274c |
+ fi
|
|
Tomáš Mráz |
c3274c |
+ ])
|
|
Tomáš Mráz |
c3274c |
+AC_SUBST(LIBNSS)
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
# Check whether user wants Kerberos 5 support
|
|
Tomáš Mráz |
c3274c |
KRB5_MSG="no"
|
|
Tomáš Mráz |
c3274c |
AC_ARG_WITH(kerberos5,
|
|
Tomáš Mráz |
c3274c |
@@ -3997,6 +4012,7 @@ echo " OSF SIA support
|
|
Tomáš Mráz |
c3274c |
echo " KerberosV support: $KRB5_MSG"
|
|
Tomáš Mráz |
c3274c |
echo " SELinux support: $SELINUX_MSG"
|
|
Tomáš Mráz |
c3274c |
echo " Linux audit support: $LINUX_AUDIT_MSG"
|
|
Tomáš Mráz |
c3274c |
+echo " NSS support: $LIBNSS_MSG"
|
|
Tomáš Mráz |
c3274c |
echo " Smartcard support: $SCARD_MSG"
|
|
Tomáš Mráz |
c3274c |
echo " S/KEY support: $SKEY_MSG"
|
|
Tomáš Mráz |
c3274c |
echo " TCP Wrappers support: $TCPW_MSG"
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/key.c openssh-4.5p1.nss/key.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/key.c 2006-11-07 13:14:42.000000000 +0100
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/key.c 2007-06-20 14:30:11.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -93,6 +93,54 @@ key_new(int type)
|
|
Tomáš Mráz |
c3274c |
return k;
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+Key *
|
|
Tomáš Mráz |
c3274c |
+key_new_nss(int type)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ Key *k = key_new(type);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ k->nss = xcalloc(1, sizeof(*k->nss));
|
|
Tomáš Mráz |
c3274c |
+ k->flags = KEY_FLAG_EXT | KEY_FLAG_NSS;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ return k;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+Key *
|
|
Tomáš Mráz |
c3274c |
+key_new_nss_copy(int type, const Key *c)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ Key *k = key_new_nss(type);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ switch (k->type) {
|
|
Tomáš Mráz |
c3274c |
+ case KEY_RSA:
|
|
Tomáš Mráz |
c3274c |
+ if ((BN_copy(k->rsa->n, c->rsa->n) == NULL) ||
|
|
Tomáš Mráz |
c3274c |
+ (BN_copy(k->rsa->e, c->rsa->e) == NULL))
|
|
Tomáš Mráz |
c3274c |
+ fatal("key_new_nss_copy: BN_copy failed");
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ case KEY_DSA:
|
|
Tomáš Mráz |
c3274c |
+ if ((BN_copy(k->dsa->p, c->rsa->p) == NULL) ||
|
|
Tomáš Mráz |
c3274c |
+ (BN_copy(k->dsa->q, c->dsa->q) == NULL) ||
|
|
Tomáš Mráz |
c3274c |
+ (BN_copy(k->dsa->g, c->dsa->g) == NULL) ||
|
|
Tomáš Mráz |
c3274c |
+ (BN_copy(k->dsa->pub_key, c->dsa->pub_key) == NULL))
|
|
Tomáš Mráz |
c3274c |
+ fatal("key_new_nss_copy: BN_copy failed");
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ k->nss->privk = SECKEY_CopyPrivateKey(c->nss->privk);
|
|
Tomáš Mráz |
c3274c |
+ if (k->nss->privk == NULL)
|
|
Tomáš Mráz |
c3274c |
+ fatal("key_new_nss_copy: SECKEY_CopyPrivateKey failed");
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ k->nss->pubk = SECKEY_CopyPublicKey(c->nss->pubk);
|
|
Tomáš Mráz |
c3274c |
+ if (k->nss->pubk == NULL)
|
|
Tomáš Mráz |
c3274c |
+ fatal("key_new_nss_copy: SECKEY_CopyPublicKey failed");
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (c->nss->privk->wincx)
|
|
Tomáš Mráz |
c3274c |
+ k->nss->privk->wincx = xstrdup(c->nss->privk->wincx);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ return k;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
Key *
|
|
Tomáš Mráz |
c3274c |
key_new_private(int type)
|
|
Tomáš Mráz |
c3274c |
{
|
|
Tomáš Mráz |
c3274c |
@@ -148,6 +196,19 @@ key_free(Key *k)
|
|
Tomáš Mráz |
c3274c |
fatal("key_free: bad key type %d", k->type);
|
|
Tomáš Mráz |
c3274c |
break;
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ if (k->flags & KEY_FLAG_NSS) {
|
|
Tomáš Mráz |
c3274c |
+ if (k->nss->privk->wincx != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ memset(k->nss->privk->wincx, 0,
|
|
Tomáš Mráz |
c3274c |
+ strlen(k->nss->privk->wincx));
|
|
Tomáš Mráz |
c3274c |
+ xfree(k->nss->privk->wincx);
|
|
Tomáš Mráz |
c3274c |
+ k->nss->privk->wincx = NULL;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ SECKEY_DestroyPrivateKey(k->nss->privk);
|
|
Tomáš Mráz |
c3274c |
+ SECKEY_DestroyPublicKey(k->nss->pubk);
|
|
Tomáš Mráz |
c3274c |
+ xfree(k->nss);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
xfree(k);
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/key.h openssh-4.5p1.nss/key.h
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/key.h 2006-08-05 04:39:40.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/key.h 2007-05-29 11:19:03.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -29,11 +29,17 @@
|
|
Tomáš Mráz |
c3274c |
#include <openssl/rsa.h>
|
|
Tomáš Mráz |
c3274c |
#include <openssl/dsa.h>
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+#include <nss.h>
|
|
Tomáš Mráz |
c3274c |
+#include <keyhi.h>
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
typedef struct Key Key;
|
|
Tomáš Mráz |
c3274c |
enum types {
|
|
Tomáš Mráz |
c3274c |
KEY_RSA1,
|
|
Tomáš Mráz |
c3274c |
KEY_RSA,
|
|
Tomáš Mráz |
c3274c |
KEY_DSA,
|
|
Tomáš Mráz |
c3274c |
+ KEY_NSS,
|
|
Tomáš Mráz |
c3274c |
KEY_UNSPEC
|
|
Tomáš Mráz |
c3274c |
};
|
|
Tomáš Mráz |
c3274c |
enum fp_type {
|
|
Tomáš Mráz |
c3274c |
@@ -47,16 +53,30 @@ enum fp_rep {
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
/* key is stored in external hardware */
|
|
Tomáš Mráz |
c3274c |
#define KEY_FLAG_EXT 0x0001
|
|
Tomáš Mráz |
c3274c |
+#define KEY_FLAG_NSS 0x0002
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+typedef struct NSSKey NSSKey;
|
|
Tomáš Mráz |
c3274c |
+struct NSSKey {
|
|
Tomáš Mráz |
c3274c |
+ SECKEYPrivateKey *privk;
|
|
Tomáš Mráz |
c3274c |
+ SECKEYPublicKey *pubk;
|
|
Tomáš Mráz |
c3274c |
+};
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
struct Key {
|
|
Tomáš Mráz |
c3274c |
int type;
|
|
Tomáš Mráz |
c3274c |
int flags;
|
|
Tomáš Mráz |
c3274c |
RSA *rsa;
|
|
Tomáš Mráz |
c3274c |
DSA *dsa;
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ NSSKey *nss;
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
};
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
Key *key_new(int);
|
|
Tomáš Mráz |
c3274c |
Key *key_new_private(int);
|
|
Tomáš Mráz |
c3274c |
+Key *key_new_nss(int);
|
|
Tomáš Mráz |
c3274c |
+Key *key_new_nss_copy(int, const Key *);
|
|
Tomáš Mráz |
c3274c |
void key_free(Key *);
|
|
Tomáš Mráz |
c3274c |
Key *key_demote(const Key *);
|
|
Tomáš Mráz |
c3274c |
int key_equal(const Key *, const Key *);
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/Makefile.in openssh-4.5p1.nss/Makefile.in
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/Makefile.in 2007-05-15 16:28:07.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/Makefile.in 2007-05-23 14:05:18.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -43,7 +43,7 @@ CC=@CC@
|
|
Tomáš Mráz |
c3274c |
LD=@LD@
|
|
Tomáš Mráz |
c3274c |
CFLAGS=@CFLAGS@
|
|
Tomáš Mráz |
c3274c |
CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@
|
|
Tomáš Mráz |
c3274c |
-LIBS=@LIBS@
|
|
Tomáš Mráz |
c3274c |
+LIBS=@LIBS@ @LIBNSS@
|
|
Tomáš Mráz |
c3274c |
LIBSELINUX=@LIBSELINUX@
|
|
Tomáš Mráz |
c3274c |
LIBAUDIT=@LIBAUDIT@
|
|
Tomáš Mráz |
c3274c |
SSHDLIBS=@SSHDLIBS@
|
|
Tomáš Mráz |
c3274c |
@@ -75,7 +75,7 @@ LIBSSH_OBJS=acss.o authfd.o authfile.o b
|
|
Tomáš Mráz |
c3274c |
atomicio.o key.o dispatch.o kex.o mac.o uidswap.o uuencode.o misc.o \
|
|
Tomáš Mráz |
c3274c |
monitor_fdpass.o rijndael.o ssh-dss.o ssh-rsa.o dh.o kexdh.o \
|
|
Tomáš Mráz |
c3274c |
kexgex.o kexdhc.o kexgexc.o scard.o msg.o progressmeter.o dns.o \
|
|
Tomáš Mráz |
c3274c |
- entropy.o scard-opensc.o gss-genr.o
|
|
Tomáš Mráz |
c3274c |
+ entropy.o scard-opensc.o gss-genr.o nsskeys.o
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
|
|
Tomáš Mráz |
c3274c |
sshconnect.o sshconnect1.o sshconnect2.o
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/nsskeys.c openssh-4.5p1.nss/nsskeys.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/nsskeys.c 1970-01-01 01:00:00.000000000 +0100
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/nsskeys.c 2007-06-20 17:57:11.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -0,0 +1,327 @@
|
|
Tomáš Mráz |
c3274c |
+/*
|
|
Tomáš Mráz |
c3274c |
+ * Copyright (c) 2001 Markus Friedl. All rights reserved.
|
|
Tomáš Mráz |
c3274c |
+ * Copyright (c) 2007 Red Hat, Inc. All rights reserved.
|
|
Tomáš Mráz |
c3274c |
+ *
|
|
Tomáš Mráz |
c3274c |
+ * Redistribution and use in source and binary forms, with or without
|
|
Tomáš Mráz |
c3274c |
+ * modification, are permitted provided that the following conditions
|
|
Tomáš Mráz |
c3274c |
+ * are met:
|
|
Tomáš Mráz |
c3274c |
+ * 1. Redistributions of source code must retain the above copyright
|
|
Tomáš Mráz |
c3274c |
+ * notice, this list of conditions and the following disclaimer.
|
|
Tomáš Mráz |
c3274c |
+ * 2. Redistributions in binary form must reproduce the above copyright
|
|
Tomáš Mráz |
c3274c |
+ * notice, this list of conditions and the following disclaimer in the
|
|
Tomáš Mráz |
c3274c |
+ * documentation and/or other materials provided with the distribution.
|
|
Tomáš Mráz |
c3274c |
+ *
|
|
Tomáš Mráz |
c3274c |
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
Tomáš Mráz |
c3274c |
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
Tomáš Mráz |
c3274c |
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
Tomáš Mráz |
c3274c |
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
Tomáš Mráz |
c3274c |
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
Tomáš Mráz |
c3274c |
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Tomáš Mráz |
c3274c |
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Tomáš Mráz |
c3274c |
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Tomáš Mráz |
c3274c |
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
Tomáš Mráz |
c3274c |
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Tomáš Mráz |
c3274c |
+ */
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#include "includes.h"
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#include <sys/types.h>
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#include <stdarg.h>
|
|
Tomáš Mráz |
c3274c |
+#include <string.h>
|
|
Tomáš Mráz |
c3274c |
+#include <unistd.h>
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#include <openssl/evp.h>
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#include <nss.h>
|
|
Tomáš Mráz |
c3274c |
+#include <keyhi.h>
|
|
Tomáš Mráz |
c3274c |
+#include <pk11pub.h>
|
|
Tomáš Mráz |
c3274c |
+#include <cert.h>
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#include "xmalloc.h"
|
|
Tomáš Mráz |
c3274c |
+#include "key.h"
|
|
Tomáš Mráz |
c3274c |
+#include "log.h"
|
|
Tomáš Mráz |
c3274c |
+#include "misc.h"
|
|
Tomáš Mráz |
c3274c |
+#include "nsskeys.h"
|
|
Tomáš Mráz |
c3274c |
+#include "pathnames.h"
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+static char *
|
|
Tomáš Mráz |
c3274c |
+password_cb(PK11SlotInfo *slot, PRBool retry, void *arg)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ char *password = arg;
|
|
Tomáš Mráz |
c3274c |
+ if (retry || password == NULL)
|
|
Tomáš Mráz |
c3274c |
+ return NULL;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ return PL_strdup(password);
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+int
|
|
Tomáš Mráz |
c3274c |
+nss_init(PK11PasswordFunc pwfn)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ char *dbpath;
|
|
Tomáš Mráz |
c3274c |
+ char buf[MAXPATHLEN];
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (NSS_IsInitialized())
|
|
Tomáš Mráz |
c3274c |
+ return 0;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if ((dbpath=getenv("NSS_DB_PATH")) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ struct passwd *pw;
|
|
Tomáš Mráz |
c3274c |
+ if ((pw = getpwuid(getuid())) == NULL ||
|
|
Tomáš Mráz |
c3274c |
+ pw->pw_dir == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ return -1;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir,
|
|
Tomáš Mráz |
c3274c |
+ _PATH_SSH_USER_DIR);
|
|
Tomáš Mráz |
c3274c |
+ dbpath = buf;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (NSS_Init(dbpath) != SECSuccess)
|
|
Tomáš Mráz |
c3274c |
+ return -1;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (pwfn == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ pwfn = password_cb;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ PK11_SetPasswordFunc(pwfn);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ return 0;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+static Key *
|
|
Tomáš Mráz |
c3274c |
+make_key_from_privkey(SECKEYPrivateKey *privk, char *password)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ Key *k;
|
|
Tomáš Mráz |
c3274c |
+ switch (SECKEY_GetPrivateKeyType(privk)) {
|
|
Tomáš Mráz |
c3274c |
+ case rsaKey:
|
|
Tomáš Mráz |
c3274c |
+ k = key_new_nss(KEY_RSA);
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ case dsaKey:
|
|
Tomáš Mráz |
c3274c |
+ k = key_new_nss(KEY_DSA);
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ default:
|
|
Tomáš Mráz |
c3274c |
+ return NULL;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ k->nss->pubk = SECKEY_ConvertToPublicKey(privk);
|
|
Tomáš Mráz |
c3274c |
+ if (k->nss->pubk != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ k->nss->privk = SECKEY_CopyPrivateKey(privk);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ if (k->nss->privk != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ if (password != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ k->nss->privk->wincx = xstrdup(password);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ return k;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ key_free(k);
|
|
Tomáš Mráz |
c3274c |
+ return NULL;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+static Key **
|
|
Tomáš Mráz |
c3274c |
+add_key_to_list(Key *k, Key **keys, size_t *i, size_t *allocated)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ if (*allocated < *i + 2) {
|
|
Tomáš Mráz |
c3274c |
+ *allocated += 16;
|
|
Tomáš Mráz |
c3274c |
+ keys = xrealloc(keys, *allocated, sizeof(k));
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ keys[*i] = k;
|
|
Tomáš Mráz |
c3274c |
+ (*i)++;
|
|
Tomáš Mráz |
c3274c |
+ keys[*i] = NULL;
|
|
Tomáš Mráz |
c3274c |
+ return keys;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+static int
|
|
Tomáš Mráz |
c3274c |
+nss_convert_pubkey(Key *k)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ u_char *n;
|
|
Tomáš Mráz |
c3274c |
+ unsigned int len;
|
|
Tomáš Mráz |
c3274c |
+ char *p;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ switch (k->type) {
|
|
Tomáš Mráz |
c3274c |
+ case KEY_RSA:
|
|
Tomáš Mráz |
c3274c |
+ n = k->nss->pubk->u.rsa.modulus.data;
|
|
Tomáš Mráz |
c3274c |
+ len = k->nss->pubk->u.rsa.modulus.len;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (BN_bin2bn(n, len, k->rsa->n) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ fatal("nss_convert_pubkey: BN_bin2bn failed");
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ n = k->nss->pubk->u.rsa.publicExponent.data;
|
|
Tomáš Mráz |
c3274c |
+ len = k->nss->pubk->u.rsa.publicExponent.len;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (BN_bin2bn(n, len, k->rsa->e) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ fatal("nss_convert_pubkey: BN_bin2bn failed");
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ case KEY_DSA:
|
|
Tomáš Mráz |
c3274c |
+ n = k->nss->pubk->u.dsa.params.prime.data;
|
|
Tomáš Mráz |
c3274c |
+ len = k->nss->pubk->u.dsa.params.prime.len;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (BN_bin2bn(n, len, k->dsa->p) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ fatal("nss_convert_pubkey: BN_bin2bn failed");
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ n = k->nss->pubk->u.dsa.params.subPrime.data;
|
|
Tomáš Mráz |
c3274c |
+ len = k->nss->pubk->u.dsa.params.subPrime.len;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (BN_bin2bn(n, len, k->dsa->q) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ fatal("nss_convert_pubkey: BN_bin2bn failed");
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ n = k->nss->pubk->u.dsa.params.base.data;
|
|
Tomáš Mráz |
c3274c |
+ len = k->nss->pubk->u.dsa.params.base.len;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (BN_bin2bn(n, len, k->dsa->g) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ fatal("nss_convert_pubkey: BN_bin2bn failed");
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ n = k->nss->pubk->u.dsa.publicValue.data;
|
|
Tomáš Mráz |
c3274c |
+ len = k->nss->pubk->u.dsa.publicValue.len;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (BN_bin2bn(n, len, k->dsa->pub_key) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ fatal("nss_convert_pubkey: BN_bin2bn failed");
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ p = key_fingerprint(k, SSH_FP_MD5, SSH_FP_HEX);
|
|
Tomáš Mráz |
c3274c |
+ debug("fingerprint %u %s", key_size(k), p);
|
|
Tomáš Mráz |
c3274c |
+ xfree(p);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ return 0;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+static Key **
|
|
Tomáš Mráz |
c3274c |
+nss_find_privkeys(const char *tokenname, const char *keyname,
|
|
Tomáš Mráz |
c3274c |
+ char *password)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ Key *k = NULL;
|
|
Tomáš Mráz |
c3274c |
+ Key **keys = NULL;
|
|
Tomáš Mráz |
c3274c |
+ PK11SlotList *slots;
|
|
Tomáš Mráz |
c3274c |
+ PK11SlotListElement *sle;
|
|
Tomáš Mráz |
c3274c |
+ size_t allocated = 0;
|
|
Tomáš Mráz |
c3274c |
+ size_t i = 0;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if ((slots=PK11_FindSlotsByNames(NULL, NULL, tokenname, PR_TRUE)) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ if (tokenname == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ debug("No NSS token found");
|
|
Tomáš Mráz |
c3274c |
+ } else {
|
|
Tomáš Mráz |
c3274c |
+ debug("NSS token not found: %s", tokenname);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ return NULL;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ for (sle = slots->head; sle; sle = sle->next) {
|
|
Tomáš Mráz |
c3274c |
+ SECKEYPrivateKeyList *list;
|
|
Tomáš Mráz |
c3274c |
+ SECKEYPrivateKeyListNode *node;
|
|
Tomáš Mráz |
c3274c |
+ char *tmppass = password;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (PK11_NeedLogin(sle->slot)) {
|
|
Tomáš Mráz |
c3274c |
+ if (password == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ char *prompt;
|
|
Tomáš Mráz |
c3274c |
+ if (asprintf(&prompt, "Enter passphrase for token %s: ",
|
|
Tomáš Mráz |
c3274c |
+ PK11_GetTokenName(sle->slot)) < 0)
|
|
Tomáš Mráz |
c3274c |
+ fatal("password_cb: asprintf failed");
|
|
Tomáš Mráz |
c3274c |
+ tmppass = read_passphrase(prompt, RP_ALLOW_STDIN);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ PK11_Authenticate(sle->slot, PR_TRUE, tmppass);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ debug("Looking for: %s:%s", tokenname, keyname);
|
|
Tomáš Mráz |
c3274c |
+ list = PK11_ListPrivKeysInSlot(sle->slot, (char *)keyname,
|
|
Tomáš Mráz |
c3274c |
+ tmppass);
|
|
Tomáš Mráz |
c3274c |
+ if (list == NULL && keyname != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ char *fooname;
|
|
Tomáš Mráz |
c3274c |
+ /* NSS bug workaround */
|
|
Tomáš Mráz |
c3274c |
+ if (asprintf(&fooname, "%s~", keyname) < 0) {
|
|
Tomáš Mráz |
c3274c |
+ error("nss_find_privkey: asprintf failed");
|
|
Tomáš Mráz |
c3274c |
+ PK11_FreeSlotList(slots);
|
|
Tomáš Mráz |
c3274c |
+ return NULL;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ list = PK11_ListPrivKeysInSlot(sle->slot, fooname,
|
|
Tomáš Mráz |
c3274c |
+ tmppass);
|
|
Tomáš Mráz |
c3274c |
+ free(fooname);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ if (list == NULL && keyname != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ CERTCertificate *cert;
|
|
Tomáš Mráz |
c3274c |
+ SECKEYPrivateKey *privk;
|
|
Tomáš Mráz |
c3274c |
+ cert = CERT_FindCertByNickname(CERT_GetDefaultCertDB(),
|
|
Tomáš Mráz |
c3274c |
+ (char *)keyname);
|
|
Tomáš Mráz |
c3274c |
+ if (cert == NULL)
|
|
Tomáš Mráz |
c3274c |
+ goto cleanup;
|
|
Tomáš Mráz |
c3274c |
+ privk = PK11_FindPrivateKeyFromCert(sle->slot, cert, tmppass);
|
|
Tomáš Mráz |
c3274c |
+ CERT_DestroyCertificate(cert);
|
|
Tomáš Mráz |
c3274c |
+ if (privk == NULL)
|
|
Tomáš Mráz |
c3274c |
+ goto cleanup;
|
|
Tomáš Mráz |
c3274c |
+ if ((k=make_key_from_privkey(privk, tmppass)) != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ nss_convert_pubkey(k);
|
|
Tomáš Mráz |
c3274c |
+ keys = add_key_to_list(k, keys, &i, &allocated);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ SECKEY_DestroyPrivateKey(privk);
|
|
Tomáš Mráz |
c3274c |
+ } else {
|
|
Tomáš Mráz |
c3274c |
+ if (list == NULL)
|
|
Tomáš Mráz |
c3274c |
+ goto cleanup;
|
|
Tomáš Mráz |
c3274c |
+ for (node=PRIVKEY_LIST_HEAD(list); !PRIVKEY_LIST_END(node, list);
|
|
Tomáš Mráz |
c3274c |
+ node=PRIVKEY_LIST_NEXT(node))
|
|
Tomáš Mráz |
c3274c |
+ if ((k=make_key_from_privkey(node->key, tmppass)) != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ nss_convert_pubkey(k);
|
|
Tomáš Mráz |
c3274c |
+ keys = add_key_to_list(k, keys, &i, &allocated);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ SECKEY_DestroyPrivateKeyList(list);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+cleanup:
|
|
Tomáš Mráz |
c3274c |
+ if (password == NULL && tmppass != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ memset(tmppass, 0, strlen(tmppass));
|
|
Tomáš Mráz |
c3274c |
+ xfree(tmppass);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ PK11_FreeSlotList(slots);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ return keys;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+Key **
|
|
Tomáš Mráz |
c3274c |
+nss_get_keys(const char *tokenname, const char *keyname,
|
|
Tomáš Mráz |
c3274c |
+ char *password)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ Key **keys;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (nss_init(NULL) == -1) {
|
|
Tomáš Mráz |
c3274c |
+ error("Failed to initialize NSS library");
|
|
Tomáš Mráz |
c3274c |
+ return NULL;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ keys = nss_find_privkeys(tokenname, keyname, password);
|
|
Tomáš Mráz |
c3274c |
+ if (keys == NULL && keyname != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ error("Cannot find key in nss, token removed");
|
|
Tomáš Mráz |
c3274c |
+ return NULL;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+#if 0
|
|
Tomáš Mráz |
c3274c |
+ keys = xcalloc(3, sizeof(Key *));
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (k->type == KEY_RSA) {
|
|
Tomáš Mráz |
c3274c |
+ n = key_new_nss_copy(KEY_RSA1, k);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ keys[0] = n;
|
|
Tomáš Mráz |
c3274c |
+ keys[1] = k;
|
|
Tomáš Mráz |
c3274c |
+ keys[2] = NULL;
|
|
Tomáš Mráz |
c3274c |
+ } else {
|
|
Tomáš Mráz |
c3274c |
+ keys[0] = k;
|
|
Tomáš Mráz |
c3274c |
+ keys[1] = NULL;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+ return keys;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+char *
|
|
Tomáš Mráz |
c3274c |
+nss_get_key_label(Key *key)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ char *label, *nickname;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ nickname = PK11_GetPrivateKeyNickname(key->nss->privk);
|
|
Tomáš Mráz |
c3274c |
+ label = xstrdup(nickname);
|
|
Tomáš Mráz |
c3274c |
+ PORT_Free(nickname);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ return label;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#endif /* HAVE_LIBNSS */
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/nsskeys.h openssh-4.5p1.nss/nsskeys.h
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/nsskeys.h 1970-01-01 01:00:00.000000000 +0100
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/nsskeys.h 2007-05-29 11:40:18.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -0,0 +1,39 @@
|
|
Tomáš Mráz |
c3274c |
+/*
|
|
Tomáš Mráz |
c3274c |
+ * Copyright (c) 2001 Markus Friedl. All rights reserved.
|
|
Tomáš Mráz |
c3274c |
+ * Copyright (c) 2007 Red Hat, Inc. All rights reserved.
|
|
Tomáš Mráz |
c3274c |
+ *
|
|
Tomáš Mráz |
c3274c |
+ * Redistribution and use in source and binary forms, with or without
|
|
Tomáš Mráz |
c3274c |
+ * modification, are permitted provided that the following conditions
|
|
Tomáš Mráz |
c3274c |
+ * are met:
|
|
Tomáš Mráz |
c3274c |
+ * 1. Redistributions of source code must retain the above copyright
|
|
Tomáš Mráz |
c3274c |
+ * notice, this list of conditions and the following disclaimer.
|
|
Tomáš Mráz |
c3274c |
+ * 2. Redistributions in binary form must reproduce the above copyright
|
|
Tomáš Mráz |
c3274c |
+ * notice, this list of conditions and the following disclaimer in the
|
|
Tomáš Mráz |
c3274c |
+ * documentation and/or other materials provided with the distribution.
|
|
Tomáš Mráz |
c3274c |
+ *
|
|
Tomáš Mráz |
c3274c |
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
Tomáš Mráz |
c3274c |
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
Tomáš Mráz |
c3274c |
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
Tomáš Mráz |
c3274c |
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
Tomáš Mráz |
c3274c |
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
Tomáš Mráz |
c3274c |
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
Tomáš Mráz |
c3274c |
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
Tomáš Mráz |
c3274c |
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
Tomáš Mráz |
c3274c |
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
Tomáš Mráz |
c3274c |
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Tomáš Mráz |
c3274c |
+ */
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#ifndef NSSKEYS_H
|
|
Tomáš Mráz |
c3274c |
+#define NSSKEYS_H
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+#include <pk11func.h>
|
|
Tomáš Mráz |
c3274c |
+#include <prtypes.h>
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+int nss_init(PK11PasswordFunc);
|
|
Tomáš Mráz |
c3274c |
+Key **nss_get_keys(const char *, const char *, char *);
|
|
Tomáš Mráz |
c3274c |
+char *nss_get_key_label(Key *);
|
|
Tomáš Mráz |
c3274c |
+/*void sc_close(void);*/
|
|
Tomáš Mráz |
c3274c |
+/*int sc_put_key(Key *, const char *);*/
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/readconf.c openssh-4.5p1.nss/readconf.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/readconf.c 2006-09-01 07:38:37.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/readconf.c 2007-06-20 17:51:38.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -124,6 +124,7 @@ typedef enum {
|
|
Tomáš Mráz |
c3274c |
oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
|
|
Tomáš Mráz |
c3274c |
oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,
|
|
Tomáš Mráz |
c3274c |
oHostKeyAlgorithms, oBindAddress, oSmartcardDevice,
|
|
Tomáš Mráz |
c3274c |
+ oUseNSS, oNSSToken,
|
|
Tomáš Mráz |
c3274c |
oClearAllForwardings, oNoHostAuthenticationForLocalhost,
|
|
Tomáš Mráz |
c3274c |
oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
|
|
Tomáš Mráz |
c3274c |
oAddressFamily, oGssAuthentication, oGssDelegateCreds,
|
|
Tomáš Mráz |
c3274c |
@@ -209,6 +210,13 @@ static struct {
|
|
Tomáš Mráz |
c3274c |
#else
|
|
Tomáš Mráz |
c3274c |
{ "smartcarddevice", oUnsupported },
|
|
Tomáš Mráz |
c3274c |
#endif
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ { "usenss", oUseNSS },
|
|
Tomáš Mráz |
c3274c |
+ { "nsstoken", oNSSToken },
|
|
Tomáš Mráz |
c3274c |
+#else
|
|
Tomáš Mráz |
c3274c |
+ { "usenss", oUnsupported },
|
|
Tomáš Mráz |
c3274c |
+ { "nsstoken", oNSSToken },
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
{ "clearallforwardings", oClearAllForwardings },
|
|
Tomáš Mráz |
c3274c |
{ "enablesshkeysign", oEnableSSHKeysign },
|
|
Tomáš Mráz |
c3274c |
{ "verifyhostkeydns", oVerifyHostKeyDNS },
|
|
Tomáš Mráz |
c3274c |
@@ -601,6 +609,14 @@ parse_string:
|
|
Tomáš Mráz |
c3274c |
charptr = &options->smartcard_device;
|
|
Tomáš Mráz |
c3274c |
goto parse_string;
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+ case oUseNSS:
|
|
Tomáš Mráz |
c3274c |
+ intptr = &options->use_nss;
|
|
Tomáš Mráz |
c3274c |
+ goto parse_flag;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ case oNSSToken:
|
|
Tomáš Mráz |
c3274c |
+ charptr = &options->nss_token;
|
|
Tomáš Mráz |
c3274c |
+ goto parse_command;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
case oProxyCommand:
|
|
Tomáš Mráz |
c3274c |
charptr = &options->proxy_command;
|
|
Tomáš Mráz |
c3274c |
parse_command:
|
|
Tomáš Mráz |
c3274c |
@@ -1049,6 +1065,8 @@ initialize_options(Options * options)
|
|
Tomáš Mráz |
c3274c |
options->preferred_authentications = NULL;
|
|
Tomáš Mráz |
c3274c |
options->bind_address = NULL;
|
|
Tomáš Mráz |
c3274c |
options->smartcard_device = NULL;
|
|
Tomáš Mráz |
c3274c |
+ options->use_nss = -1;
|
|
Tomáš Mráz |
c3274c |
+ options->nss_token = NULL;
|
|
Tomáš Mráz |
c3274c |
options->enable_ssh_keysign = - 1;
|
|
Tomáš Mráz |
c3274c |
options->no_host_authentication_for_localhost = - 1;
|
|
Tomáš Mráz |
c3274c |
options->identities_only = - 1;
|
|
Tomáš Mráz |
c3274c |
@@ -1177,6 +1195,8 @@ fill_default_options(Options * options)
|
|
Tomáš Mráz |
c3274c |
options->no_host_authentication_for_localhost = 0;
|
|
Tomáš Mráz |
c3274c |
if (options->identities_only == -1)
|
|
Tomáš Mráz |
c3274c |
options->identities_only = 0;
|
|
Tomáš Mráz |
c3274c |
+ if (options->use_nss == -1)
|
|
Tomáš Mráz |
c3274c |
+ options->use_nss = 0;
|
|
Tomáš Mráz |
c3274c |
if (options->enable_ssh_keysign == -1)
|
|
Tomáš Mráz |
c3274c |
options->enable_ssh_keysign = 0;
|
|
Tomáš Mráz |
c3274c |
if (options->rekey_limit == -1)
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/readconf.h openssh-4.5p1.nss/readconf.h
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/readconf.h 2006-08-05 04:39:40.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/readconf.h 2007-06-18 10:41:58.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -84,6 +84,8 @@ typedef struct {
|
|
Tomáš Mráz |
c3274c |
char *preferred_authentications;
|
|
Tomáš Mráz |
c3274c |
char *bind_address; /* local socket address for connection to sshd */
|
|
Tomáš Mráz |
c3274c |
char *smartcard_device; /* Smartcard reader device */
|
|
Tomáš Mráz |
c3274c |
+ int use_nss; /* Use NSS library for keys */
|
|
Tomáš Mráz |
c3274c |
+ char *nss_token; /* Look for NSS keys on token */
|
|
Tomáš Mráz |
c3274c |
int verify_host_key_dns; /* Verify host key using DNS */
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
int num_identity_files; /* Number of files for RSA/DSA identities. */
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/README.nss openssh-4.5p1.nss/README.nss
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/README.nss 1970-01-01 01:00:00.000000000 +0100
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/README.nss 2007-06-20 18:28:28.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -0,0 +1,36 @@
|
|
Tomáš Mráz |
c3274c |
+How to use NSS tokens with OpenSSH?
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+This version of OpenSSH contains experimental support for authentication using
|
|
Tomáš Mráz |
c3274c |
+keys stored in tokens stored in NSS database. This for example includes any
|
|
Tomáš Mráz |
c3274c |
+PKCS#11 tokens which are installed in your NSS database.
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+As the code is experimental and preliminary only SSH protocol 2 is supported.
|
|
Tomáš Mráz |
f37073 |
+The NSS certificate and token databases are looked for in the ~/.ssh
|
|
Tomáš Mráz |
f37073 |
+directory or in a directory specified by environment variable NSS_DB_PATH.
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+Common operations:
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+(1) tell the ssh client to use the NSS keys:
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ $ ssh -o 'UseNSS yes' otherhost
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if you want to use a specific token:
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ $ ssh -o 'UseNSS yes' -o 'NSS Token My PKCS11 Token' otherhost
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+(2) or tell the agent to use the NSS keys:
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ $ ssh-add -n
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if you want to use a specific token:
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ $ ssh-add -n -T 'My PKCS11 Token'
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+(3) extract the public key from token so it can be added to the
|
|
Tomáš Mráz |
c3274c |
+server:
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ $ ssh-keygen -n
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if you want to use a specific token and/or key:
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ $ ssh-keygen -n -D 'My PKCS11 Token' 'My Key ID'
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+Tomas Mraz, Red Hat, Inc.
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/ssh-add.c openssh-4.5p1.nss/ssh-add.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/ssh-add.c 2006-09-01 07:38:37.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/ssh-add.c 2007-05-29 18:26:08.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -43,6 +43,14 @@
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
#include <openssl/evp.h>
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+#include <nss.h>
|
|
Tomáš Mráz |
c3274c |
+#include <secmod.h>
|
|
Tomáš Mráz |
c3274c |
+#include <pk11pub.h>
|
|
Tomáš Mráz |
c3274c |
+#include <keyhi.h>
|
|
Tomáš Mráz |
c3274c |
+#include <cert.h>
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
#include <fcntl.h>
|
|
Tomáš Mráz |
c3274c |
#include <pwd.h>
|
|
Tomáš Mráz |
c3274c |
#include <stdarg.h>
|
|
Tomáš Mráz |
c3274c |
@@ -56,6 +64,7 @@
|
|
Tomáš Mráz |
c3274c |
#include "rsa.h"
|
|
Tomáš Mráz |
c3274c |
#include "log.h"
|
|
Tomáš Mráz |
c3274c |
#include "key.h"
|
|
Tomáš Mráz |
c3274c |
+#include "nsskeys.h"
|
|
Tomáš Mráz |
c3274c |
#include "buffer.h"
|
|
Tomáš Mráz |
c3274c |
#include "authfd.h"
|
|
Tomáš Mráz |
c3274c |
#include "authfile.h"
|
|
Tomáš Mráz |
c3274c |
@@ -306,6 +315,117 @@ do_file(AuthenticationConnection *ac, in
|
|
Tomáš Mráz |
c3274c |
return 0;
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+static char *
|
|
Tomáš Mráz |
c3274c |
+password_cb(PK11SlotInfo *slot, PRBool retry, void *arg)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ char **passcache = arg;
|
|
Tomáš Mráz |
c3274c |
+ char *password, *p2 = NULL;
|
|
Tomáš Mráz |
c3274c |
+ char *prompt;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (retry)
|
|
Tomáš Mráz |
c3274c |
+ return NULL;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (asprintf(&prompt, "Enter passphrase for token %s: ",
|
|
Tomáš Mráz |
c3274c |
+ PK11_GetTokenName(slot)) < 0)
|
|
Tomáš Mráz |
c3274c |
+ fatal("password_cb: asprintf failed");
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ password = read_passphrase(prompt, RP_ALLOW_STDIN);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (password != NULL && (p2=PL_strdup(password)) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ memset(password, 0, strlen(password));
|
|
Tomáš Mráz |
c3274c |
+ fatal("password_cb: PL_strdup failed");
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (passcache != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ if (*passcache != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ memset(*passcache, 0, strlen(*passcache));
|
|
Tomáš Mráz |
c3274c |
+ xfree(*passcache);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ *passcache = password;
|
|
Tomáš Mráz |
c3274c |
+ } else {
|
|
Tomáš Mráz |
c3274c |
+ memset(password, 0, strlen(password));
|
|
Tomáš Mráz |
c3274c |
+ xfree(password);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ return p2;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+static int
|
|
Tomáš Mráz |
c3274c |
+add_slot_keys(AuthenticationConnection *ac, PK11SlotInfo *slot, int add)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ SECKEYPrivateKeyList *list;
|
|
Tomáš Mráz |
c3274c |
+ SECKEYPrivateKeyListNode *node;
|
|
Tomáš Mráz |
c3274c |
+ char *passcache = NULL;
|
|
Tomáš Mráz |
c3274c |
+ char *tokenname;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ int count = 0;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (PK11_NeedLogin(slot))
|
|
Tomáš Mráz |
c3274c |
+ PK11_Authenticate(slot, PR_TRUE, &passcache);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if ((list=PK11_ListPrivKeysInSlot(slot, NULL, NULL)) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ return 0;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ tokenname = PK11_GetTokenName(slot);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ for (node=PRIVKEY_LIST_HEAD(list); !PRIVKEY_LIST_END(node, list);
|
|
Tomáš Mráz |
c3274c |
+ node=PRIVKEY_LIST_NEXT(node)) {
|
|
Tomáš Mráz |
c3274c |
+ char *keyname;
|
|
Tomáš Mráz |
c3274c |
+ SECKEYPublicKey *pub;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ keyname = PK11_GetPrivateKeyNickname(node->key);
|
|
Tomáš Mráz |
c3274c |
+ if (keyname == NULL || *keyname == '\0') {
|
|
Tomáš Mráz |
c3274c |
+ /* no nickname to refer to */
|
|
Tomáš Mráz |
c3274c |
+ CERTCertificate *cert;
|
|
Tomáš Mráz |
c3274c |
+ char *kn;
|
|
Tomáš Mráz |
c3274c |
+ cert = PK11_GetCertFromPrivateKey(node->key);
|
|
Tomáš Mráz |
c3274c |
+ if (cert == NULL)
|
|
Tomáš Mráz |
c3274c |
+ continue;
|
|
Tomáš Mráz |
c3274c |
+ kn = strchr(cert->nickname, ':');
|
|
Tomáš Mráz |
c3274c |
+ if (kn == NULL)
|
|
Tomáš Mráz |
c3274c |
+ kn = cert->nickname;
|
|
Tomáš Mráz |
c3274c |
+ else
|
|
Tomáš Mráz |
c3274c |
+ kn++;
|
|
Tomáš Mráz |
c3274c |
+ keyname = PORT_Strdup(kn);
|
|
Tomáš Mráz |
c3274c |
+ CERT_DestroyCertificate(cert);
|
|
Tomáš Mráz |
c3274c |
+ if (keyname == NULL)
|
|
Tomáš Mráz |
c3274c |
+ continue;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ pub = SECKEY_ConvertToPublicKey(node->key);
|
|
Tomáš Mráz |
c3274c |
+ if (pub == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ fprintf(stderr, "No public key for: %s:%s\n",
|
|
Tomáš Mráz |
c3274c |
+ tokenname, keyname);
|
|
Tomáš Mráz |
c3274c |
+ continue; /* not possible to obtain public key */
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ SECKEY_DestroyPublicKey(pub);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (ssh_update_nss_key(ac, add, tokenname, keyname,
|
|
Tomáš Mráz |
c3274c |
+ passcache?passcache:"", lifetime, confirm)) {
|
|
Tomáš Mráz |
c3274c |
+ fprintf(stderr, "Key %s: %s:%s\n",
|
|
Tomáš Mráz |
c3274c |
+ add?"added":"removed", tokenname, keyname);
|
|
Tomáš Mráz |
c3274c |
+ count++;
|
|
Tomáš Mráz |
c3274c |
+ } else {
|
|
Tomáš Mráz |
c3274c |
+ fprintf(stderr, "Could not %s key: %s:%s\n",
|
|
Tomáš Mráz |
c3274c |
+ add?"add":"remove", tokenname, keyname);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ PORT_Free(keyname);
|
|
Tomáš Mráz |
c3274c |
+ count++;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (passcache != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ memset(passcache, 0, strlen(passcache));
|
|
Tomáš Mráz |
c3274c |
+ xfree(passcache);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ SECKEY_DestroyPrivateKeyList(list);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ return count;
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
static void
|
|
Tomáš Mráz |
c3274c |
usage(void)
|
|
Tomáš Mráz |
c3274c |
{
|
|
Tomáš Mráz |
c3274c |
@@ -333,6 +453,10 @@ main(int argc, char **argv)
|
|
Tomáš Mráz |
c3274c |
AuthenticationConnection *ac = NULL;
|
|
Tomáš Mráz |
c3274c |
char *sc_reader_id = NULL;
|
|
Tomáš Mráz |
c3274c |
int i, ch, deleting = 0, ret = 0;
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ char *token_id = NULL;
|
|
Tomáš Mráz |
c3274c |
+ int use_nss = 0;
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
|
|
Tomáš Mráz |
c3274c |
sanitise_stdfd();
|
|
Tomáš Mráz |
c3274c |
@@ -350,7 +474,7 @@ main(int argc, char **argv)
|
|
Tomáš Mráz |
c3274c |
"Could not open a connection to your authentication agent.\n");
|
|
Tomáš Mráz |
c3274c |
exit(2);
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
- while ((ch = getopt(argc, argv, "lLcdDxXe:s:t:")) != -1) {
|
|
Tomáš Mráz |
c3274c |
+ while ((ch = getopt(argc, argv, "lLcdDnxXe:s:t:T:")) != -1) {
|
|
Tomáš Mráz |
c3274c |
switch (ch) {
|
|
Tomáš Mráz |
c3274c |
case 'l':
|
|
Tomáš Mráz |
c3274c |
case 'L':
|
|
Tomáš Mráz |
c3274c |
@@ -372,6 +496,11 @@ main(int argc, char **argv)
|
|
Tomáš Mráz |
c3274c |
if (delete_all(ac) == -1)
|
|
Tomáš Mráz |
c3274c |
ret = 1;
|
|
Tomáš Mráz |
c3274c |
goto done;
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ case 'n':
|
|
Tomáš Mráz |
c3274c |
+ use_nss = 1;
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
case 's':
|
|
Tomáš Mráz |
c3274c |
sc_reader_id = optarg;
|
|
Tomáš Mráz |
c3274c |
break;
|
|
Tomáš Mráz |
c3274c |
@@ -386,6 +515,11 @@ main(int argc, char **argv)
|
|
Tomáš Mráz |
c3274c |
goto done;
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
break;
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ case 'T':
|
|
Tomáš Mráz |
c3274c |
+ token_id = optarg;
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
default:
|
|
Tomáš Mráz |
c3274c |
usage();
|
|
Tomáš Mráz |
c3274c |
ret = 1;
|
|
Tomáš Mráz |
c3274c |
@@ -399,6 +533,40 @@ main(int argc, char **argv)
|
|
Tomáš Mráz |
c3274c |
ret = 1;
|
|
Tomáš Mráz |
c3274c |
goto done;
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ if (use_nss) {
|
|
Tomáš Mráz |
c3274c |
+ PK11SlotList *slots;
|
|
Tomáš Mráz |
c3274c |
+ PK11SlotListElement *sle;
|
|
Tomáš Mráz |
c3274c |
+ int count = 0;
|
|
Tomáš Mráz |
c3274c |
+ if (nss_init(password_cb) == -1) {
|
|
Tomáš Mráz |
c3274c |
+ fprintf(stderr, "Failed to initialize NSS library\n");
|
|
Tomáš Mráz |
c3274c |
+ ret = 1;
|
|
Tomáš Mráz |
c3274c |
+ goto done;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if ((slots=PK11_GetAllTokens(CKM_INVALID_MECHANISM, PR_FALSE, PR_FALSE,
|
|
Tomáš Mráz |
c3274c |
+ NULL)) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ fprintf(stderr, "No tokens found\n");
|
|
Tomáš Mráz |
c3274c |
+ ret = 1;
|
|
Tomáš Mráz |
c3274c |
+ goto nss_done;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ for (sle = slots->head; sle; sle = sle->next) {
|
|
Tomáš Mráz |
c3274c |
+ int rv;
|
|
Tomáš Mráz |
c3274c |
+ if ((rv=add_slot_keys(ac, sle->slot, !deleting)) == -1) {
|
|
Tomáš Mráz |
c3274c |
+ ret = 1;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ count += rv;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ if (count == 0) {
|
|
Tomáš Mráz |
c3274c |
+ ret = 1;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+nss_done:
|
|
Tomáš Mráz |
c3274c |
+ NSS_Shutdown();
|
|
Tomáš Mráz |
c3274c |
+ clear_pass();
|
|
Tomáš Mráz |
c3274c |
+ goto done;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
if (argc == 0) {
|
|
Tomáš Mráz |
c3274c |
char buf[MAXPATHLEN];
|
|
Tomáš Mráz |
c3274c |
struct passwd *pw;
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/ssh-agent.c openssh-4.5p1.nss/ssh-agent.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/ssh-agent.c 2006-10-23 19:01:16.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/ssh-agent.c 2007-05-29 11:55:54.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -79,6 +79,10 @@
|
|
Tomáš Mráz |
c3274c |
#include "scard.h"
|
|
Tomáš Mráz |
c3274c |
#endif
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+#include "nsskeys.h"
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
#if defined(HAVE_SYS_PRCTL_H)
|
|
Tomáš Mráz |
c3274c |
#include <sys/prctl.h> /* For prctl() and PR_SET_DUMPABLE */
|
|
Tomáš Mráz |
c3274c |
#endif
|
|
Tomáš Mráz |
c3274c |
@@ -690,6 +694,114 @@ send:
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
#endif /* SMARTCARD */
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+static void
|
|
Tomáš Mráz |
c3274c |
+process_add_nss_key (SocketEntry *e)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ char *tokenname = NULL, *keyname = NULL, *password = NULL;
|
|
Tomáš Mráz |
c3274c |
+ int i, version, success = 0, death = 0, confirm = 0;
|
|
Tomáš Mráz |
c3274c |
+ Key **keys, *k;
|
|
Tomáš Mráz |
c3274c |
+ Identity *id;
|
|
Tomáš Mráz |
c3274c |
+ Idtab *tab;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ tokenname = buffer_get_string(&e->request, NULL);
|
|
Tomáš Mráz |
c3274c |
+ keyname = buffer_get_string(&e->request, NULL);
|
|
Tomáš Mráz |
c3274c |
+ password = buffer_get_string(&e->request, NULL);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ while (buffer_len(&e->request)) {
|
|
Tomáš Mráz |
c3274c |
+ switch (buffer_get_char(&e->request)) {
|
|
Tomáš Mráz |
c3274c |
+ case SSH_AGENT_CONSTRAIN_LIFETIME:
|
|
Tomáš Mráz |
c3274c |
+ death = time(NULL) + buffer_get_int(&e->request);
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ case SSH_AGENT_CONSTRAIN_CONFIRM:
|
|
Tomáš Mráz |
c3274c |
+ confirm = 1;
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ default:
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ if (lifetime && !death)
|
|
Tomáš Mráz |
c3274c |
+ death = time(NULL) + lifetime;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ keys = nss_get_keys(tokenname, keyname, password);
|
|
Tomáš Mráz |
c3274c |
+ /* password is owned by keys[0] now */
|
|
Tomáš Mráz |
c3274c |
+ xfree(tokenname);
|
|
Tomáš Mráz |
c3274c |
+ xfree(keyname);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (keys == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ memset(password, 0, strlen(password));
|
|
Tomáš Mráz |
c3274c |
+ xfree(password);
|
|
Tomáš Mráz |
c3274c |
+ error("nss_get_keys failed");
|
|
Tomáš Mráz |
c3274c |
+ goto send;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ for (i = 0; keys[i] != NULL; i++) {
|
|
Tomáš Mráz |
c3274c |
+ k = keys[i];
|
|
Tomáš Mráz |
c3274c |
+ version = k->type == KEY_RSA1 ? 1 : 2;
|
|
Tomáš Mráz |
c3274c |
+ tab = idtab_lookup(version);
|
|
Tomáš Mráz |
c3274c |
+ if (lookup_identity(k, version) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ id = xmalloc(sizeof(Identity));
|
|
Tomáš Mráz |
c3274c |
+ id->key = k;
|
|
Tomáš Mráz |
c3274c |
+ id->comment = nss_get_key_label(k);
|
|
Tomáš Mráz |
c3274c |
+ id->death = death;
|
|
Tomáš Mráz |
c3274c |
+ id->confirm = confirm;
|
|
Tomáš Mráz |
c3274c |
+ TAILQ_INSERT_TAIL(&tab->idlist, id, next);
|
|
Tomáš Mráz |
c3274c |
+ tab->nentries++;
|
|
Tomáš Mráz |
c3274c |
+ success = 1;
|
|
Tomáš Mráz |
c3274c |
+ } else {
|
|
Tomáš Mráz |
c3274c |
+ key_free(k);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ keys[i] = NULL;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ xfree(keys);
|
|
Tomáš Mráz |
c3274c |
+send:
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_int(&e->output, 1);
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_char(&e->output,
|
|
Tomáš Mráz |
c3274c |
+ success ? SSH_AGENT_SUCCESS : SSH_AGENT_FAILURE);
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+static void
|
|
Tomáš Mráz |
c3274c |
+process_remove_nss_key(SocketEntry *e)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ char *tokenname = NULL, *keyname = NULL, *password = NULL;
|
|
Tomáš Mráz |
c3274c |
+ int i, version, success = 0;
|
|
Tomáš Mráz |
c3274c |
+ Key **keys, *k = NULL;
|
|
Tomáš Mráz |
c3274c |
+ Identity *id;
|
|
Tomáš Mráz |
c3274c |
+ Idtab *tab;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ tokenname = buffer_get_string(&e->request, NULL);
|
|
Tomáš Mráz |
c3274c |
+ keyname = buffer_get_string(&e->request, NULL);
|
|
Tomáš Mráz |
c3274c |
+ password = buffer_get_string(&e->request, NULL);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ keys = nss_get_keys(tokenname, keyname, password);
|
|
Tomáš Mráz |
c3274c |
+ xfree(tokenname);
|
|
Tomáš Mráz |
c3274c |
+ xfree(keyname);
|
|
Tomáš Mráz |
c3274c |
+ xfree(password);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (keys == NULL || keys[0] == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ error("nss_get_keys failed");
|
|
Tomáš Mráz |
c3274c |
+ goto send;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ for (i = 0; keys[i] != NULL; i++) {
|
|
Tomáš Mráz |
c3274c |
+ k = keys[i];
|
|
Tomáš Mráz |
c3274c |
+ version = k->type == KEY_RSA1 ? 1 : 2;
|
|
Tomáš Mráz |
c3274c |
+ if ((id = lookup_identity(k, version)) != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ tab = idtab_lookup(version);
|
|
Tomáš Mráz |
c3274c |
+ TAILQ_REMOVE(&tab->idlist, id, next);
|
|
Tomáš Mráz |
c3274c |
+ tab->nentries--;
|
|
Tomáš Mráz |
c3274c |
+ free_identity(id);
|
|
Tomáš Mráz |
c3274c |
+ success = 1;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ key_free(k);
|
|
Tomáš Mráz |
c3274c |
+ keys[i] = NULL;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ xfree(keys);
|
|
Tomáš Mráz |
c3274c |
+send:
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_int(&e->output, 1);
|
|
Tomáš Mráz |
c3274c |
+ buffer_put_char(&e->output,
|
|
Tomáš Mráz |
c3274c |
+ success ? SSH_AGENT_SUCCESS : SSH_AGENT_FAILURE);
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+#endif /* HAVE_LIBNSS */
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
/* dispatch incoming messages */
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
static void
|
|
Tomáš Mráz |
c3274c |
@@ -785,6 +897,15 @@ process_message(SocketEntry *e)
|
|
Tomáš Mráz |
c3274c |
process_remove_smartcard_key(e);
|
|
Tomáš Mráz |
c3274c |
break;
|
|
Tomáš Mráz |
c3274c |
#endif /* SMARTCARD */
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ case SSH_AGENTC_ADD_NSS_KEY:
|
|
Tomáš Mráz |
c3274c |
+ case SSH_AGENTC_ADD_NSS_KEY_CONSTRAINED:
|
|
Tomáš Mráz |
c3274c |
+ process_add_nss_key(e);
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+ case SSH_AGENTC_REMOVE_NSS_KEY:
|
|
Tomáš Mráz |
c3274c |
+ process_remove_nss_key(e);
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
+#endif /* SMARTCARD */
|
|
Tomáš Mráz |
c3274c |
default:
|
|
Tomáš Mráz |
c3274c |
/* Unknown message. Respond with failure. */
|
|
Tomáš Mráz |
c3274c |
error("Unknown message %d", type);
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/ssh.c openssh-4.5p1.nss/ssh.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/ssh.c 2006-10-23 19:01:16.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/ssh.c 2007-06-20 15:45:40.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -104,6 +104,9 @@
|
|
Tomáš Mráz |
c3274c |
#ifdef SMARTCARD
|
|
Tomáš Mráz |
c3274c |
#include "scard.h"
|
|
Tomáš Mráz |
c3274c |
#endif
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+#include "nsskeys.h"
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
extern char *__progname;
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
0092bb |
@@ -1227,9 +1230,11 @@ load_public_identity_files(void)
|
|
Tomáš Mráz |
c3274c |
int i = 0;
|
|
Tomáš Mráz |
c3274c |
Key *public;
|
|
Tomáš Mráz |
c3274c |
struct passwd *pw;
|
|
Tomáš Mráz |
c3274c |
-#ifdef SMARTCARD
|
|
Tomáš Mráz |
c3274c |
+#if defined(SMARTCARD) || defined(HAVE_LIBNSS)
|
|
Tomáš Mráz |
c3274c |
Key **keys;
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef SMARTCARD
|
|
Tomáš Mráz |
c3274c |
if (options.smartcard_device != NULL &&
|
|
Tomáš Mráz |
c3274c |
options.num_identity_files < SSH_MAX_IDENTITY_FILES &&
|
|
Tomáš Mráz |
c3274c |
(keys = sc_get_keys(options.smartcard_device, NULL)) != NULL) {
|
|
Tomáš Mráz |
0092bb |
@@ -1250,6 +1255,27 @@ load_public_identity_files(void)
|
|
Tomáš Mráz |
c3274c |
xfree(keys);
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
#endif /* SMARTCARD */
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ if (options.use_nss &&
|
|
Tomáš Mráz |
c3274c |
+ options.num_identity_files < SSH_MAX_IDENTITY_FILES &&
|
|
Tomáš Mráz |
c3274c |
+ (keys = nss_get_keys(options.nss_token, NULL, NULL)) != NULL) {
|
|
Tomáš Mráz |
c3274c |
+ int count;
|
|
Tomáš Mráz |
c3274c |
+ for (count = 0; keys[count] != NULL; count++) {
|
|
Tomáš Mráz |
c3274c |
+ memmove(&options.identity_files[1], &options.identity_files[0],
|
|
Tomáš Mráz |
c3274c |
+ sizeof(char *) * (SSH_MAX_IDENTITY_FILES - 1));
|
|
Tomáš Mráz |
c3274c |
+ memmove(&options.identity_keys[1], &options.identity_keys[0],
|
|
Tomáš Mráz |
c3274c |
+ sizeof(Key *) * (SSH_MAX_IDENTITY_FILES - 1));
|
|
Tomáš Mráz |
c3274c |
+ options.num_identity_files++;
|
|
Tomáš Mráz |
c3274c |
+ options.identity_keys[0] = keys[count];
|
|
Tomáš Mráz |
c3274c |
+ options.identity_files[0] = nss_get_key_label(keys[count]);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ if (options.num_identity_files > SSH_MAX_IDENTITY_FILES)
|
|
Tomáš Mráz |
c3274c |
+ options.num_identity_files = SSH_MAX_IDENTITY_FILES;
|
|
Tomáš Mráz |
c3274c |
+ i += count;
|
|
Tomáš Mráz |
c3274c |
+ xfree(keys);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+#endif /* HAVE_LIBNSS */
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
if ((pw = getpwuid(original_real_uid)) == NULL)
|
|
Tomáš Mráz |
c3274c |
fatal("load_public_identity_files: getpwuid failed");
|
|
Tomáš Mráz |
c3274c |
if (gethostname(thishost, sizeof(thishost)) == -1)
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/ssh-dss.c openssh-4.5p1.nss/ssh-dss.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/ssh-dss.c 2006-11-07 13:14:42.000000000 +0100
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/ssh-dss.c 2007-05-25 15:45:19.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -39,6 +39,10 @@
|
|
Tomáš Mráz |
c3274c |
#include "log.h"
|
|
Tomáš Mráz |
c3274c |
#include "key.h"
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+#include <cryptohi.h>
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
#define INTBLOB_LEN 20
|
|
Tomáš Mráz |
c3274c |
#define SIGBLOB_LEN (2*INTBLOB_LEN)
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
@@ -57,6 +61,34 @@ ssh_dss_sign(const Key *key, u_char **si
|
|
Tomáš Mráz |
c3274c |
error("ssh_dss_sign: no DSA key");
|
|
Tomáš Mráz |
c3274c |
return -1;
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ if (key->flags & KEY_FLAG_NSS) {
|
|
Tomáš Mráz |
c3274c |
+ SECItem sigitem;
|
|
Tomáš Mráz |
c3274c |
+ SECItem *rawsig;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ memset(&sigitem, 0, sizeof(sigitem));
|
|
Tomáš Mráz |
c3274c |
+ if (SEC_SignData(&sigitem, (u_char *)data, datalen, key->nss->privk,
|
|
Tomáš Mráz |
c3274c |
+ SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST) != SECSuccess) {
|
|
Tomáš Mráz |
c3274c |
+ error("ssh_dss_sign: sign failed");
|
|
Tomáš Mráz |
c3274c |
+ return -1;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if ((rawsig=DSAU_DecodeDerSig(&sigitem)) == NULL) {
|
|
Tomáš Mráz |
c3274c |
+ error("ssh_dss_sign: der decode failed");
|
|
Tomáš Mráz |
c3274c |
+ SECITEM_ZfreeItem(&sigitem, PR_FALSE);
|
|
Tomáš Mráz |
c3274c |
+ return -1;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ SECITEM_ZfreeItem(&sigitem, PR_FALSE);
|
|
Tomáš Mráz |
c3274c |
+ if (rawsig->len != SIGBLOB_LEN) {
|
|
Tomáš Mráz |
c3274c |
+ error("ssh_dss_sign: unsupported signature length %d",
|
|
Tomáš Mráz |
c3274c |
+ rawsig->len);
|
|
Tomáš Mráz |
c3274c |
+ SECITEM_ZfreeItem(rawsig, PR_TRUE);
|
|
Tomáš Mráz |
c3274c |
+ return -1;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ memcpy(sigblob, rawsig->data, SIGBLOB_LEN);
|
|
Tomáš Mráz |
c3274c |
+ SECITEM_ZfreeItem(rawsig, PR_TRUE);
|
|
Tomáš Mráz |
c3274c |
+ } else {
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
EVP_DigestInit(&md, evp_md);
|
|
Tomáš Mráz |
c3274c |
EVP_DigestUpdate(&md, data, datalen);
|
|
Tomáš Mráz |
c3274c |
EVP_DigestFinal(&md, digest, &dlen);
|
|
Tomáš Mráz |
c3274c |
@@ -80,7 +112,9 @@ ssh_dss_sign(const Key *key, u_char **si
|
|
Tomáš Mráz |
c3274c |
BN_bn2bin(sig->r, sigblob+ SIGBLOB_LEN - INTBLOB_LEN - rlen);
|
|
Tomáš Mráz |
c3274c |
BN_bn2bin(sig->s, sigblob+ SIGBLOB_LEN - slen);
|
|
Tomáš Mráz |
c3274c |
DSA_SIG_free(sig);
|
|
Tomáš Mráz |
c3274c |
-
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
if (datafellows & SSH_BUG_SIGBLOB) {
|
|
Tomáš Mráz |
c3274c |
if (lenp != NULL)
|
|
Tomáš Mráz |
c3274c |
*lenp = SIGBLOB_LEN;
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/ssh-keygen.c openssh-4.5p1.nss/ssh-keygen.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/ssh-keygen.c 2006-11-07 13:14:42.000000000 +0100
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/ssh-keygen.c 2007-06-20 18:24:40.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -52,6 +52,11 @@
|
|
Tomáš Mráz |
c3274c |
#include "scard.h"
|
|
Tomáš Mráz |
c3274c |
#endif
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+#include <nss.h>
|
|
Tomáš Mráz |
c3274c |
+#include "nsskeys.h"
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
/* Number of bits in the RSA/DSA key. This value can be set on the command line. */
|
|
Tomáš Mráz |
c3274c |
#define DEFAULT_BITS 2048
|
|
Tomáš Mráz |
c3274c |
#define DEFAULT_BITS_DSA 1024
|
|
Tomáš Mráz |
c3274c |
@@ -500,6 +505,26 @@ do_download(struct passwd *pw, const cha
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
#endif /* SMARTCARD */
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+static void
|
|
Tomáš Mráz |
c3274c |
+do_nss_download(struct passwd *pw, const char *tokenname, const char *keyname)
|
|
Tomáš Mráz |
c3274c |
+{
|
|
Tomáš Mráz |
c3274c |
+ Key **keys = NULL;
|
|
Tomáš Mráz |
c3274c |
+ int i;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ keys = nss_get_keys(tokenname, keyname, NULL);
|
|
Tomáš Mráz |
c3274c |
+ if (keys == NULL)
|
|
Tomáš Mráz |
c3274c |
+ fatal("cannot find public key in NSS");
|
|
Tomáš Mráz |
c3274c |
+ for (i = 0; keys[i]; i++) {
|
|
Tomáš Mráz |
c3274c |
+ key_write(keys[i], stdout);
|
|
Tomáš Mráz |
c3274c |
+ key_free(keys[i]);
|
|
Tomáš Mráz |
c3274c |
+ fprintf(stdout, "\n");
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ xfree(keys);
|
|
Tomáš Mráz |
c3274c |
+ exit(0);
|
|
Tomáš Mráz |
c3274c |
+}
|
|
Tomáš Mráz |
c3274c |
+#endif /* HAVE_LIBNSS */
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
static void
|
|
Tomáš Mráz |
c3274c |
do_fingerprint(struct passwd *pw)
|
|
Tomáš Mráz |
c3274c |
{
|
|
Tomáš Mráz |
c3274c |
@@ -1057,7 +1082,8 @@ main(int ac, char **av)
|
|
Tomáš Mráz |
c3274c |
Key *private, *public;
|
|
Tomáš Mráz |
c3274c |
struct passwd *pw;
|
|
Tomáš Mráz |
c3274c |
struct stat st;
|
|
Tomáš Mráz |
c3274c |
- int opt, type, fd, download = 0;
|
|
Tomáš Mráz |
c3274c |
+ int opt, type, fd, download = 1;
|
|
Tomáš Mráz |
c3274c |
+ int use_nss = 0;
|
|
Tomáš Mráz |
c3274c |
u_int32_t memory = 0, generator_wanted = 0, trials = 100;
|
|
Tomáš Mráz |
c3274c |
int do_gen_candidates = 0, do_screen_candidates = 0;
|
|
Tomáš Mráz |
c3274c |
int log_level = SYSLOG_LEVEL_INFO;
|
|
Tomáš Mráz |
c3274c |
@@ -1091,7 +1117,7 @@ main(int ac, char **av)
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
while ((opt = getopt(ac, av,
|
|
Tomáš Mráz |
c3274c |
- "degiqpclBHvxXyF:b:f:t:U:D:P:N:C:r:g:R:T:G:M:S:a:W:")) != -1) {
|
|
Tomáš Mráz |
c3274c |
+ "degiqpclnBHvxXyF:b:f:t:U:D:P:N:C:r:g:R:T:G:M:S:a:W:")) != -1) {
|
|
Tomáš Mráz |
c3274c |
switch (opt) {
|
|
Tomáš Mráz |
c3274c |
case 'b':
|
|
Tomáš Mráz |
c3274c |
bits = (u_int32_t)strtonum(optarg, 768, 32768, &errstr);
|
|
Tomáš Mráz |
c3274c |
@@ -1131,6 +1157,10 @@ main(int ac, char **av)
|
|
Tomáš Mráz |
c3274c |
case 'g':
|
|
Tomáš Mráz |
c3274c |
print_generic = 1;
|
|
Tomáš Mráz |
c3274c |
break;
|
|
Tomáš Mráz |
c3274c |
+ case 'n':
|
|
Tomáš Mráz |
c3274c |
+ use_nss = 1;
|
|
Tomáš Mráz |
c3274c |
+ download = 1;
|
|
Tomáš Mráz |
c3274c |
+ break;
|
|
Tomáš Mráz |
c3274c |
case 'P':
|
|
Tomáš Mráz |
c3274c |
identity_passphrase = optarg;
|
|
Tomáš Mráz |
c3274c |
break;
|
|
Tomáš Mráz |
c3274c |
@@ -1162,10 +1192,10 @@ main(int ac, char **av)
|
|
Tomáš Mráz |
c3274c |
case 't':
|
|
Tomáš Mráz |
c3274c |
key_type_name = optarg;
|
|
Tomáš Mráz |
c3274c |
break;
|
|
Tomáš Mráz |
c3274c |
- case 'D':
|
|
Tomáš Mráz |
c3274c |
- download = 1;
|
|
Tomáš Mráz |
c3274c |
- /*FALLTHROUGH*/
|
|
Tomáš Mráz |
c3274c |
case 'U':
|
|
Tomáš Mráz |
c3274c |
+ download = 0;
|
|
Tomáš Mráz |
c3274c |
+ /*FALLTHROUGH*/
|
|
Tomáš Mráz |
c3274c |
+ case 'D':
|
|
Tomáš Mráz |
c3274c |
reader_id = optarg;
|
|
Tomáš Mráz |
c3274c |
break;
|
|
Tomáš Mráz |
c3274c |
case 'v':
|
|
Tomáš Mráz |
c3274c |
@@ -1270,6 +1300,17 @@ main(int ac, char **av)
|
|
Tomáš Mráz |
c3274c |
exit(0);
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (use_nss) {
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ if (download)
|
|
Tomáš Mráz |
c3274c |
+ do_nss_download(pw, reader_id, identity_file);
|
|
Tomáš Mráz |
c3274c |
+ else
|
|
Tomáš Mráz |
c3274c |
+ fatal("no support for NSS key upload.");
|
|
Tomáš Mráz |
c3274c |
+#else
|
|
Tomáš Mráz |
c3274c |
+ fatal("no support for NSS keys.");
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
if (reader_id != NULL) {
|
|
Tomáš Mráz |
c3274c |
#ifdef SMARTCARD
|
|
Tomáš Mráz |
c3274c |
if (download)
|
|
Tomáš Mráz |
c3274c |
diff -urpN openssh-4.5p1/ssh-rsa.c openssh-4.5p1.nss/ssh-rsa.c
|
|
Tomáš Mráz |
c3274c |
--- openssh-4.5p1/ssh-rsa.c 2006-09-01 07:38:37.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
+++ openssh-4.5p1.nss/ssh-rsa.c 2007-05-25 15:44:57.000000000 +0200
|
|
Tomáš Mráz |
c3274c |
@@ -32,6 +32,10 @@
|
|
Tomáš Mráz |
c3274c |
#include "compat.h"
|
|
Tomáš Mráz |
c3274c |
#include "ssh.h"
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+#include <cryptohi.h>
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
static int openssh_RSA_verify(int, u_char *, u_int, u_char *, u_int, RSA *);
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
/* RSASSA-PKCS1-v1_5 (PKCS #1 v2.0 signature) with SHA1 */
|
|
Tomáš Mráz |
c3274c |
@@ -50,6 +54,38 @@ ssh_rsa_sign(const Key *key, u_char **si
|
|
Tomáš Mráz |
c3274c |
error("ssh_rsa_sign: no RSA key");
|
|
Tomáš Mráz |
c3274c |
return -1;
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ slen = RSA_size(key->rsa);
|
|
Tomáš Mráz |
c3274c |
+ sig = xmalloc(slen);
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ if (key->flags & KEY_FLAG_NSS) {
|
|
Tomáš Mráz |
c3274c |
+ SECItem sigitem;
|
|
Tomáš Mráz |
c3274c |
+ SECOidTag alg;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ memset(&sigitem, 0, sizeof(sigitem));
|
|
Tomáš Mráz |
c3274c |
+ alg = (datafellows & SSH_BUG_RSASIGMD5) ?
|
|
Tomáš Mráz |
c3274c |
+ SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION :
|
|
Tomáš Mráz |
c3274c |
+ SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION;
|
|
Tomáš Mráz |
c3274c |
+
|
|
Tomáš Mráz |
c3274c |
+ if (SEC_SignData(&sigitem, (u_char *)data, datalen, key->nss->privk,
|
|
Tomáš Mráz |
c3274c |
+ alg) != SECSuccess) {
|
|
Tomáš Mráz |
c3274c |
+ error("ssh_rsa_sign: sign failed");
|
|
Tomáš Mráz |
c3274c |
+ return -1;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ if (sigitem.len > slen) {
|
|
Tomáš Mráz |
c3274c |
+ error("ssh_rsa_sign: slen %u slen2 %u", slen, sigitem.len);
|
|
Tomáš Mráz |
c3274c |
+ xfree(sig);
|
|
Tomáš Mráz |
c3274c |
+ SECITEM_ZfreeItem(&sigitem, PR_FALSE);
|
|
Tomáš Mráz |
c3274c |
+ return -1;
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ if (sigitem.len < slen) {
|
|
Tomáš Mráz |
c3274c |
+ memset(sig, 0, slen - sigitem.len);
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+ memcpy(sig+slen-sigitem.len, sigitem.data, sigitem.len);
|
|
Tomáš Mráz |
c3274c |
+ SECITEM_ZfreeItem(&sigitem, PR_FALSE);
|
|
Tomáš Mráz |
c3274c |
+ } else {
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
nid = (datafellows & SSH_BUG_RSASIGMD5) ? NID_md5 : NID_sha1;
|
|
Tomáš Mráz |
c3274c |
if ((evp_md = EVP_get_digestbynid(nid)) == NULL) {
|
|
Tomáš Mráz |
c3274c |
error("ssh_rsa_sign: EVP_get_digestbynid %d failed", nid);
|
|
Tomáš Mráz |
c3274c |
@@ -59,9 +95,6 @@ ssh_rsa_sign(const Key *key, u_char **si
|
|
Tomáš Mráz |
c3274c |
EVP_DigestUpdate(&md, data, datalen);
|
|
Tomáš Mráz |
c3274c |
EVP_DigestFinal(&md, digest, &dlen);
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
- slen = RSA_size(key->rsa);
|
|
Tomáš Mráz |
c3274c |
- sig = xmalloc(slen);
|
|
Tomáš Mráz |
c3274c |
-
|
|
Tomáš Mráz |
c3274c |
ok = RSA_sign(nid, digest, dlen, sig, &len, key->rsa);
|
|
Tomáš Mráz |
c3274c |
memset(digest, 'd', sizeof(digest));
|
|
Tomáš Mráz |
c3274c |
|
|
Tomáš Mráz |
c3274c |
@@ -83,6 +116,9 @@ ssh_rsa_sign(const Key *key, u_char **si
|
|
Tomáš Mráz |
c3274c |
xfree(sig);
|
|
Tomáš Mráz |
c3274c |
return -1;
|
|
Tomáš Mráz |
c3274c |
}
|
|
Tomáš Mráz |
c3274c |
+#ifdef HAVE_LIBNSS
|
|
Tomáš Mráz |
c3274c |
+ }
|
|
Tomáš Mráz |
c3274c |
+#endif
|
|
Tomáš Mráz |
c3274c |
/* encode signature */
|
|
Tomáš Mráz |
c3274c |
buffer_init(&b);
|
|
Tomáš Mráz |
c3274c |
buffer_put_cstring(&b, "ssh-rsa");
|