Skip to content

Commit

Permalink
upstream commit
Browse files Browse the repository at this point in the history
switch from Key typedef with struct sshkey; ok djm@

Upstream-ID: 3067d33e04efbe5131ce8f70668c47a58e5b7a1f
  • Loading branch information
mfriedl authored and djmdjm committed May 31, 2017
1 parent c221219 commit 54d90ac
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 103 deletions.
6 changes: 3 additions & 3 deletions auth.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: auth.c,v 1.120 2017/05/17 01:24:17 djm Exp $ */
/* $OpenBSD: auth.c,v 1.121 2017/05/30 08:52:19 markus Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
Expand Down Expand Up @@ -428,7 +428,7 @@ authorized_principals_file(struct passwd *pw)

/* return ok if key exists in sysfile or userfile */
HostStatus
check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
check_key_in_hostfiles(struct passwd *pw, struct sshkey *key, const char *host,
const char *sysfile, const char *userfile)
{
char *user_hostfile;
Expand Down Expand Up @@ -695,7 +695,7 @@ getpwnamallow(const char *user)

/* Returns 1 if key is revoked by revoked_keys_file, 0 otherwise */
int
auth_key_is_revoked(Key *key)
auth_key_is_revoked(struct sshkey *key)
{
char *fp = NULL;
int r;
Expand Down
27 changes: 14 additions & 13 deletions auth.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: auth.h,v 1.89 2016/08/13 17:47:41 markus Exp $ */
/* $OpenBSD: auth.h,v 1.90 2017/05/30 08:52:19 markus Exp $ */

/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
Expand Down Expand Up @@ -117,9 +117,10 @@ auth_rhosts2(struct passwd *, const char *, const char *, const char *);

int auth_password(Authctxt *, const char *);

int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
int user_key_allowed(struct passwd *, Key *, int);
void pubkey_auth_info(Authctxt *, const Key *, const char *, ...)
int hostbased_key_allowed(struct passwd *, const char *, char *,
struct sshkey *);
int user_key_allowed(struct passwd *, struct sshkey *, int);
void pubkey_auth_info(Authctxt *, const struct sshkey *, const char *, ...)
__attribute__((__format__ (printf, 3, 4)));
void auth2_record_userkey(Authctxt *, struct sshkey *);
int auth2_userkey_already_used(Authctxt *, struct sshkey *);
Expand Down Expand Up @@ -182,22 +183,22 @@ char *authorized_principals_file(struct passwd *);

FILE *auth_openkeyfile(const char *, struct passwd *, int);
FILE *auth_openprincipals(const char *, struct passwd *, int);
int auth_key_is_revoked(Key *);
int auth_key_is_revoked(struct sshkey *);

const char *auth_get_canonical_hostname(struct ssh *, int);

HostStatus
check_key_in_hostfiles(struct passwd *, Key *, const char *,
check_key_in_hostfiles(struct passwd *, struct sshkey *, const char *,
const char *, const char *);

/* hostkey handling */
Key *get_hostkey_by_index(int);
Key *get_hostkey_public_by_index(int, struct ssh *);
Key *get_hostkey_public_by_type(int, int, struct ssh *);
Key *get_hostkey_private_by_type(int, int, struct ssh *);
int get_hostkey_index(Key *, int, struct ssh *);
int sshd_hostkey_sign(Key *, Key *, u_char **, size_t *,
const u_char *, size_t, const char *, u_int);
struct sshkey *get_hostkey_by_index(int);
struct sshkey *get_hostkey_public_by_index(int, struct ssh *);
struct sshkey *get_hostkey_public_by_type(int, int, struct ssh *);
struct sshkey *get_hostkey_private_by_type(int, int, struct ssh *);
int get_hostkey_index(struct sshkey *, int, struct ssh *);
int sshd_hostkey_sign(struct sshkey *, struct sshkey *, u_char **,
size_t *, const u_char *, size_t, const char *, u_int);

/* debug messages during authentication */
void auth_debug_add(const char *fmt,...) __attribute__((format(printf, 1, 2)));
Expand Down
6 changes: 3 additions & 3 deletions auth2-hostbased.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: auth2-hostbased.c,v 1.26 2016/03/07 19:02:43 djm Exp $ */
/* $OpenBSD: auth2-hostbased.c,v 1.27 2017/05/30 08:52:19 markus Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
Expand Down Expand Up @@ -59,7 +59,7 @@ static int
userauth_hostbased(Authctxt *authctxt)
{
Buffer b;
Key *key = NULL;
struct sshkey *key = NULL;
char *pkalg, *cuser, *chost, *service;
u_char *pkblob, *sig;
u_int alen, blen, slen;
Expand Down Expand Up @@ -158,7 +158,7 @@ userauth_hostbased(Authctxt *authctxt)
/* return 1 if given hostkey is allowed */
int
hostbased_key_allowed(struct passwd *pw, const char *cuser, char *chost,
Key *key)
struct sshkey *key)
{
struct ssh *ssh = active_state; /* XXX */
const char *resolvedname, *ipaddr, *lookup, *reason;
Expand Down
19 changes: 10 additions & 9 deletions auth2-pubkey.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: auth2-pubkey.c,v 1.62 2017/01/30 01:03:00 djm Exp $ */
/* $OpenBSD: auth2-pubkey.c,v 1.63 2017/05/30 08:52:19 markus Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
Expand Down Expand Up @@ -78,7 +78,7 @@ static int
userauth_pubkey(Authctxt *authctxt)
{
Buffer b;
Key *key = NULL;
struct sshkey *key = NULL;
char *pkalg, *userstyle, *fp = NULL;
u_char *pkblob, *sig;
u_int alen, blen, slen;
Expand Down Expand Up @@ -220,7 +220,8 @@ userauth_pubkey(Authctxt *authctxt)
}

void
pubkey_auth_info(Authctxt *authctxt, const Key *key, const char *fmt, ...)
pubkey_auth_info(Authctxt *authctxt, const struct sshkey *key,
const char *fmt, ...)
{
char *fp, *extra;
va_list ap;
Expand Down Expand Up @@ -761,12 +762,12 @@ match_principals_command(struct passwd *user_pw, const struct sshkey *key)
* returns 1 if the key is allowed or 0 otherwise.
*/
static int
check_authkeys_file(FILE *f, char *file, Key* key, struct passwd *pw)
check_authkeys_file(FILE *f, char *file, struct sshkey* key, struct passwd *pw)
{
char line[SSH_MAX_PUBKEY_BYTES];
int found_key = 0;
u_long linenum = 0;
Key *found;
struct sshkey *found;

found_key = 0;

Expand Down Expand Up @@ -876,7 +877,7 @@ check_authkeys_file(FILE *f, char *file, Key* key, struct passwd *pw)

/* Authenticate a certificate key against TrustedUserCAKeys */
static int
user_cert_trusted_ca(struct passwd *pw, Key *key)
user_cert_trusted_ca(struct passwd *pw, struct sshkey *key)
{
char *ca_fp, *principals_file = NULL;
const char *reason;
Expand Down Expand Up @@ -942,7 +943,7 @@ user_cert_trusted_ca(struct passwd *pw, Key *key)
* returns 1 if the key is allowed or 0 otherwise.
*/
static int
user_key_allowed2(struct passwd *pw, Key *key, char *file)
user_key_allowed2(struct passwd *pw, struct sshkey *key, char *file)
{
FILE *f;
int found_key = 0;
Expand All @@ -965,7 +966,7 @@ user_key_allowed2(struct passwd *pw, Key *key, char *file)
* returns 1 if the key is allowed or 0 otherwise.
*/
static int
user_key_command_allowed2(struct passwd *user_pw, Key *key)
user_key_command_allowed2(struct passwd *user_pw, struct sshkey *key)
{
FILE *f = NULL;
int r, ok, found_key = 0;
Expand Down Expand Up @@ -1088,7 +1089,7 @@ user_key_command_allowed2(struct passwd *user_pw, Key *key)
* Check whether key authenticates and authorises the user.
*/
int
user_key_allowed(struct passwd *pw, Key *key, int auth_attempt)
user_key_allowed(struct passwd *pw, struct sshkey *key, int auth_attempt)
{
u_int success, i;
char *file;
Expand Down
6 changes: 3 additions & 3 deletions monitor.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: monitor.c,v 1.167 2017/02/03 23:05:57 djm Exp $ */
/* $OpenBSD: monitor.c,v 1.168 2017/05/30 08:52:19 markus Exp $ */
/*
* Copyright 2002 Niels Provos <[email protected]>
* Copyright 2002 Markus Friedl <[email protected]>
Expand Down Expand Up @@ -1119,7 +1119,7 @@ mm_answer_pam_free_ctx(int sock, Buffer *m)
int
mm_answer_keyallowed(int sock, Buffer *m)
{
Key *key;
struct sshkey *key;
char *cuser, *chost;
u_char *blob;
u_int bloblen, pubkey_auth_attempt;
Expand Down Expand Up @@ -1332,7 +1332,7 @@ monitor_valid_hostbasedblob(u_char *data, u_int datalen, char *cuser,
int
mm_answer_keyverify(int sock, Buffer *m)
{
Key *key;
struct sshkey *key;
u_char *signature, *data, *blob;
u_int signaturelen, datalen, bloblen;
int verified = 0;
Expand Down
14 changes: 8 additions & 6 deletions monitor_wrap.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: monitor_wrap.c,v 1.90 2017/05/17 01:24:17 djm Exp $ */
/* $OpenBSD: monitor_wrap.c,v 1.91 2017/05/30 08:52:19 markus Exp $ */
/*
* Copyright 2002 Niels Provos <[email protected]>
* Copyright 2002 Markus Friedl <[email protected]>
Expand Down Expand Up @@ -216,7 +216,7 @@ mm_choose_dh(int min, int nbits, int max)
#endif

int
mm_key_sign(Key *key, u_char **sigp, u_int *lenp,
mm_key_sign(struct sshkey *key, u_char **sigp, u_int *lenp,
const u_char *data, u_int datalen, const char *hostkey_alg)
{
struct kex *kex = *pmonitor->m_pkex;
Expand Down Expand Up @@ -375,22 +375,23 @@ mm_auth_password(Authctxt *authctxt, char *password)
}

int
mm_user_key_allowed(struct passwd *pw, Key *key, int pubkey_auth_attempt)
mm_user_key_allowed(struct passwd *pw, struct sshkey *key,
int pubkey_auth_attempt)
{
return (mm_key_allowed(MM_USERKEY, NULL, NULL, key,
pubkey_auth_attempt));
}

int
mm_hostbased_key_allowed(struct passwd *pw, const char *user, const char *host,
Key *key)
struct sshkey *key)
{
return (mm_key_allowed(MM_HOSTKEY, user, host, key, 0));
}

int
mm_key_allowed(enum mm_keytype type, const char *user, const char *host,
Key *key, int pubkey_auth_attempt)
struct sshkey *key, int pubkey_auth_attempt)
{
Buffer m;
u_char *blob;
Expand Down Expand Up @@ -435,7 +436,8 @@ mm_key_allowed(enum mm_keytype type, const char *user, const char *host,
*/

int
mm_key_verify(Key *key, u_char *sig, u_int siglen, u_char *data, u_int datalen)
mm_key_verify(struct sshkey *key, u_char *sig, u_int siglen, u_char *data,
u_int datalen)
{
Buffer m;
u_char *blob;
Expand Down
14 changes: 8 additions & 6 deletions monitor_wrap.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: monitor_wrap.h,v 1.32 2016/09/28 16:33:07 djm Exp $ */
/* $OpenBSD: monitor_wrap.h,v 1.33 2017/05/30 08:52:19 markus Exp $ */

/*
* Copyright 2002 Niels Provos <[email protected]>
Expand Down Expand Up @@ -40,16 +40,18 @@ struct Authctxt;
void mm_log_handler(LogLevel, const char *, void *);
int mm_is_monitor(void);
DH *mm_choose_dh(int, int, int);
int mm_key_sign(Key *, u_char **, u_int *, const u_char *, u_int, const char *);
int mm_key_sign(struct sshkey *, u_char **, u_int *, const u_char *, u_int,
const char *);
void mm_inform_authserv(char *, char *);
struct passwd *mm_getpwnamallow(const char *);
char *mm_auth2_read_banner(void);
int mm_auth_password(struct Authctxt *, char *);
int mm_key_allowed(enum mm_keytype, const char *, const char *, Key *, int);
int mm_user_key_allowed(struct passwd *, Key *, int);
int mm_key_allowed(enum mm_keytype, const char *, const char *, struct sshkey *,
int);
int mm_user_key_allowed(struct passwd *, struct sshkey *, int);
int mm_hostbased_key_allowed(struct passwd *, const char *,
const char *, Key *);
int mm_key_verify(Key *, u_char *, u_int, u_char *, u_int);
const char *, struct sshkey *);
int mm_key_verify(struct sshkey *, u_char *, u_int, u_char *, u_int);

#ifdef GSSAPI
OM_uint32 mm_ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
Expand Down
6 changes: 3 additions & 3 deletions ssh-pkcs11-client.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssh-pkcs11-client.c,v 1.6 2015/12/11 00:20:04 mmcc Exp $ */
/* $OpenBSD: ssh-pkcs11-client.c,v 1.7 2017/05/30 08:52:19 markus Exp $ */
/*
* Copyright (c) 2010 Markus Friedl. All rights reserved.
*
Expand Down Expand Up @@ -106,7 +106,7 @@ static int
pkcs11_rsa_private_encrypt(int flen, const u_char *from, u_char *to, RSA *rsa,
int padding)
{
Key key;
struct sshkey key; /* XXX */
u_char *blob, *signature = NULL;
u_int blen, slen = 0;
int ret = -1;
Expand Down Expand Up @@ -186,7 +186,7 @@ pkcs11_start_helper(void)
int
pkcs11_add_provider(char *name, char *pin, Key ***keysp)
{
Key *k;
struct sshkey *k;
int i, nkeys;
u_char *blob;
u_int blen;
Expand Down
14 changes: 7 additions & 7 deletions ssh-pkcs11-helper.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssh-pkcs11-helper.c,v 1.12 2016/02/15 09:47:49 dtucker Exp $ */
/* $OpenBSD: ssh-pkcs11-helper.c,v 1.13 2017/05/30 08:52:19 markus Exp $ */
/*
* Copyright (c) 2010 Markus Friedl. All rights reserved.
*
Expand Down Expand Up @@ -42,7 +42,7 @@
/* borrows code from sftp-server and ssh-agent */

struct pkcs11_keyinfo {
Key *key;
struct sshkey *key;
char *providername;
TAILQ_ENTRY(pkcs11_keyinfo) next;
};
Expand All @@ -60,7 +60,7 @@ Buffer iqueue;
Buffer oqueue;

static void
add_key(Key *k, char *name)
add_key(struct sshkey *k, char *name)
{
struct pkcs11_keyinfo *ki;

Expand All @@ -87,8 +87,8 @@ del_keys_by_name(char *name)
}

/* lookup matching 'private' key */
static Key *
lookup_key(Key *k)
static struct sshkey *
lookup_key(struct sshkey *k)
{
struct pkcs11_keyinfo *ki;

Expand All @@ -114,7 +114,7 @@ static void
process_add(void)
{
char *name, *pin;
Key **keys;
struct sshkey **keys;
int i, nkeys;
u_char *blob;
u_int blen;
Expand Down Expand Up @@ -170,7 +170,7 @@ process_sign(void)
u_char *blob, *data, *signature = NULL;
u_int blen, dlen, slen = 0;
int ok = -1;
Key *key, *found;
struct sshkey *key, *found;
Buffer msg;

blob = get_string(&blen);
Expand Down
10 changes: 5 additions & 5 deletions ssh.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssh.c,v 1.459 2017/05/02 08:06:33 jmc Exp $ */
/* $OpenBSD: ssh.c,v 1.460 2017/05/30 08:52:19 markus Exp $ */
/*
* Author: Tatu Ylonen <[email protected]>
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
Expand Down Expand Up @@ -1278,7 +1278,7 @@ main(int ac, char **av)
if (options.hostbased_authentication) {
sensitive_data.nkeys = 9;
sensitive_data.keys = xcalloc(sensitive_data.nkeys,
sizeof(Key));
sizeof(struct sshkey)); /* XXX */
for (i = 0; i < sensitive_data.nkeys; i++)
sensitive_data.keys[i] = NULL;

Expand Down Expand Up @@ -1849,16 +1849,16 @@ load_public_identity_files(void)
{
char *filename, *cp, thishost[NI_MAXHOST];
char *pwdir = NULL, *pwname = NULL;
Key *public;
struct sshkey *public;
struct passwd *pw;
int i;
u_int n_ids, n_certs;
char *identity_files[SSH_MAX_IDENTITY_FILES];
Key *identity_keys[SSH_MAX_IDENTITY_FILES];
struct sshkey *identity_keys[SSH_MAX_IDENTITY_FILES];
char *certificate_files[SSH_MAX_CERTIFICATE_FILES];
struct sshkey *certificates[SSH_MAX_CERTIFICATE_FILES];
#ifdef ENABLE_PKCS11
Key **keys;
struct sshkey **keys;
int nkeys;
#endif /* PKCS11 */

Expand Down
Loading

0 comments on commit 54d90ac

Please sign in to comment.