5b55d09
diff -up openssh/pam_ssh_agent_auth-0.10.3/identity.h.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/identity.h
5b55d09
--- openssh/pam_ssh_agent_auth-0.10.3/identity.h.psaa-agent	2016-11-13 04:24:32.000000000 +0100
5b55d09
+++ openssh/pam_ssh_agent_auth-0.10.3/identity.h	2017-09-27 14:25:49.421739027 +0200
87ab5fc
@@ -38,6 +38,12 @@
87ab5fc
 typedef struct identity Identity;
87ab5fc
 typedef struct idlist Idlist;
87ab5fc
 
87ab5fc
+typedef struct {
87ab5fc
+       int     fd;
87ab5fc
+       Buffer  identities;
87ab5fc
+       int     howmany;
87ab5fc
+}      AuthenticationConnection;
87ab5fc
+
87ab5fc
 struct identity {
87ab5fc
     TAILQ_ENTRY(identity) next;
87ab5fc
     AuthenticationConnection *ac;   /* set if agent supports key */
5b55d09
diff -up openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c
5b55d09
--- openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-agent	2017-09-27 14:25:49.420739021 +0200
5b55d09
+++ openssh/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c	2017-09-27 14:25:49.421739027 +0200
87ab5fc
@@ -39,6 +39,7 @@
637556d
 #include "buffer.h"
637556d
 #include "key.h"
637556d
 #include "authfd.h"
637556d
+#include "ssherr.h"
637556d
 #include <stdio.h>
87ab5fc
 #include <openssl/evp.h>
87ab5fc
 #include "ssh2.h"
5b55d09
@@ -291,36 +292,43 @@ pamsshagentauth_find_authorized_keys(con
637556d
 {
87ab5fc
     Buffer session_id2 = { 0 };
637556d
     Identity *id;
637556d
-    Key *key;
637556d
     AuthenticationConnection *ac;
637556d
-    char *comment;
637556d
     uint8_t retval = 0;
87ab5fc
     uid_t uid = getpwnam(ruser)->pw_uid;
73d45fa
+    struct ssh_identitylist *idlist;
a9ad706
+    int r;
a9ad706
+    unsigned int i;
637556d
 
637556d
     OpenSSL_add_all_digests();
87ab5fc
     pamsshagentauth_session_id2_gen(&session_id2, user, ruser, servicename);
637556d
 
637556d
     if ((ac = ssh_get_authentication_connection_for_uid(uid))) {
87ab5fc
         verbose("Contacted ssh-agent of user %s (%u)", ruser, uid);
637556d
-        for (key = ssh_get_first_identity(ac, &comment, 2); key != NULL; key = ssh_get_next_identity(ac, &comment, 2)) 
5b55d09
+		if ((r = ssh_fetch_identitylist(ac->fd, &idlist)) != 0) {
637556d
+			if (r != SSH_ERR_AGENT_NO_IDENTITIES)
637556d
+				fprintf(stderr, "error fetching identities for "
637556d
+				    "protocol %d: %s\n", 2, ssh_err(r));
405790e
+		} else {
637556d
+		for (i = 0; i < idlist->nkeys; i++)
637556d
         {
637556d
-            if(key != NULL) {
637556d
+            if(idlist->keys[i] != NULL) {
637556d
                 id = xcalloc(1, sizeof(*id));
637556d
-                id->key = key;
637556d
-                id->filename = comment;
637556d
+                id->key = idlist->keys[i];
637556d
+                id->filename = idlist->comments[i];
637556d
                 id->ac = ac;
87ab5fc
                 if(userauth_pubkey_from_id(ruser, id, &session_id2)) {
637556d
                     retval = 1;
73d45fa
                 }
73d45fa
-                free(id->filename);
73d45fa
-                key_free(id->key);
73d45fa
                 free(id);
73d45fa
                 if(retval == 1)
637556d
                     break;
637556d
             }
637556d
         }
87ab5fc
         buffer_free(&session_id2);
637556d
-        ssh_close_authentication_connection(ac);
73d45fa
+        ssh_free_identitylist(idlist);
73d45fa
+        ssh_close_authentication_socket(ac->fd);
73d45fa
+        free(ac);
405790e
+        }
637556d
     }
637556d
     else {
637556d
         verbose("No ssh-agent could be contacted");
5b55d09
diff -up openssh/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c
5b55d09
--- openssh/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c.psaa-agent	2017-09-27 14:26:04.277820716 +0200
5b55d09
+++ openssh/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c	2017-09-27 14:26:34.426986497 +0200
5b55d09
@@ -70,7 +70,7 @@ pamsshagentauth_check_authkeys_file(FILE
5b55d09
     char *fp;
5b55d09
 
5b55d09
     found_key = 0;
5b55d09
-    found = key_new(key->type);
5b55d09
+    found = sshkey_new(key->type);
5b55d09
 
5b55d09
     while(read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
5b55d09
         char *cp = NULL; /* *key_options = NULL; */
5b55d09
@@ -80,7 +80,7 @@ pamsshagentauth_check_authkeys_file(FILE
5b55d09
         if(!*cp || *cp == '\n' || *cp == '#')
5b55d09
             continue;
5b55d09
 
5b55d09
-        if(key_read(found, &cp) != 1) {
5b55d09
+        if(sshkey_read(found, &cp) != 0) {
5b55d09
             /* no key? check if there are options for this key */
5b55d09
             int quoted = 0;
5b55d09
 
5b55d09
@@ -94,24 +94,24 @@ pamsshagentauth_check_authkeys_file(FILE
5b55d09
             }
5b55d09
             /* Skip remaining whitespace. */
5b55d09
             for(; *cp == ' ' || *cp == '\t'; cp++);
5b55d09
-            if(key_read(found, &cp) != 1) {
5b55d09
+            if(sshkey_read(found, &cp) != 0) {
5b55d09
                 verbose("user_key_allowed: advance: '%s'", cp);
5b55d09
                 /* still no key? advance to next line */
5b55d09
                 continue;
5b55d09
             }
5b55d09
         }
5b55d09
-        if(key_equal(found, key)) {
5b55d09
+        if(sshkey_equal(found, key)) {
5b55d09
             found_key = 1;
5b55d09
             logit("matching key found: file/command %s, line %lu", file,
5b55d09
                                   linenum);
5b55d09
             fp = sshkey_fingerprint(found, SSH_DIGEST_MD5, SSH_FP_HEX);
5b55d09
             logit("Found matching %s key: %s",
5b55d09
-                                  key_type(found), fp);
5b55d09
+                                  sshkey_type(found), fp);
5b55d09
             free(fp);
5b55d09
             break;
5b55d09
         }
5b55d09
     }
5b55d09
-    key_free(found);
5b55d09
+    sshkey_free(found);
5b55d09
     if(!found_key)
5b55d09
         verbose("key not found");
5b55d09
     return found_key;
5b55d09
diff -up openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-agent openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c
5b55d09
--- openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-agent	2017-09-27 14:25:49.420739021 +0200
5b55d09
+++ openssh/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c	2017-09-27 14:25:49.422739032 +0200
5b55d09
@@ -57,10 +57,11 @@ extern uint8_t  session_id_len;
73d45fa
 int
87ab5fc
 userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
73d45fa
 {
73d45fa
-    Buffer          b = { 0 };
73d45fa
+    Buffer          b;
73d45fa
     char           *pkalg = NULL;
73d45fa
     u_char         *pkblob = NULL, *sig = NULL;
73d45fa
-    u_int           blen = 0, slen = 0;
73d45fa
+    u_int           blen = 0;
73d45fa
+    size_t          slen = 0;
73d45fa
     int             authenticated = 0;
73d45fa
 
73d45fa
     pkalg = (char *) key_ssh_name(id->key);
5b55d09
@@ -84,7 +85,7 @@ userauth_pubkey_from_id(const char *ruse
637556d
     buffer_put_cstring(&b, pkalg);
637556d
     buffer_put_string(&b, pkblob, blen);
637556d
 
637556d
-    if(ssh_agent_sign(id->ac, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b)) != 0)
13073f8
+    if(ssh_agent_sign(id->ac->fd, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b), NULL, 0) != 0)
13073f8
         goto user_auth_clean_exit;
13073f8
 
13073f8
     /* test for correct signature */
3cd4899
diff -up openssh-7.7p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-sshkey openssh-7.7p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c
3cd4899
--- openssh-7.7p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-sshkey	2018-04-04 13:55:02.383899631 +0200
3cd4899
+++ openssh-7.7p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c	2018-04-04 13:58:36.759339845 +0200
3cd4899
@@ -89,7 +89,7 @@ userauth_pubkey_from_id(const char *ruse
3cd4899
         goto user_auth_clean_exit;
3cd4899
 
3cd4899
     /* test for correct signature */
3cd4899
-    if(key_verify(id->key, sig, slen, buffer_ptr(&b), buffer_len(&b)) == 1)
3cd4899
+    if(sshkey_verify(id->key, sig, slen, buffer_ptr(&b), buffer_len(&b), NULL, 0) == 0)
3cd4899
         authenticated = 1;
3cd4899
 
3cd4899
   user_auth_clean_exit: