--- apple-keychain.patch	2013-07-07 15:45:08.000000000 -0700
+++ apple-keychain.patch.old	2013-07-07 15:36:34.000000000 -0700
@@ -68,17 +68,17 @@
  
  .c.o:
  	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
-@@ -145,8 +145,8 @@
+@@ -138,8 +142,8 @@ libssh.a: $(LIBSSH_OBJS)
  	$(AR) rv $@ $(LIBSSH_OBJS)
  	$(RANLIB) $@
  
 -ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS)
--	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
+-	$(LD) -o $@ $(SSHOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS)
 +ssh$(EXEEXT): $(LIBCOMPAT) libssh.a $(SSHOBJS) $(KEYCHAINOBJS)
-+	$(LD) -o $@ $(SSHOBJS) $(KEYCHAINOBJS) $(LDFLAGS) $(KEYCHAIN_LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS) $(GSSLIBS)
++	$(LD) -o $@ $(SSHOBJS) $(KEYCHAINOBJS) $(LDFLAGS) $(KEYCHAIN_LDFLAGS) -lssh -lopenbsd-compat $(SSHLIBS) $(LIBS)
  
  sshd$(EXEEXT): libssh.a	$(LIBCOMPAT) $(SSHDOBJS)
- 	$(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS) $(GSSLIBS) $(K5LIBS)
+ 	$(LD) -o $@ $(SSHDOBJS) $(LDFLAGS) -lssh -lopenbsd-compat $(SSHDLIBS) $(LIBS)
 @@ -147,11 +151,11 @@ sshd$(EXEEXT): libssh.a	$(LIBCOMPAT) $(SSHDOBJS)
  scp$(EXEEXT): $(LIBCOMPAT) libssh.a scp.o progressmeter.o
  	$(LD) -o $@ scp.o progressmeter.o bufaux.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
@@ -1624,10 +1624,11 @@
  
  /* argv0 */
  extern char *__progname;
-@@ -97,6 +97,16 @@
+@@ -96,7 +97,17 @@
  }
  
  static int
+-delete_file(AuthenticationConnection *ac, const char *filename)
 +add_from_keychain(AuthenticationConnection *ac)
 +{
 +	if (ssh_add_from_keychain(ac) == 0)
@@ -1638,9 +1639,10 @@
 +}
 +
 +static int
- delete_file(AuthenticationConnection *ac, const char *filename, int key_only)
++delete_file(AuthenticationConnection *ac, int keychain, const char *filename)
  {
- 	Key *public = NULL, *cert = NULL;
+ 	Key *public;
+ 	char *comment = NULL;
 @@ -139,7 +150,7 @@
  }
  
@@ -1681,7 +1683,7 @@
  			clear_pass();
  			snprintf(msg, sizeof msg,
  			    "Bad passphrase, try again for %.200s: ", comment);
-@@ -385,13 +395,13 @@
+@@ -351,13 +370,13 @@
  }
  
  static int
@@ -1689,12 +1691,12 @@
 +do_file(AuthenticationConnection *ac, int deleting, int keychain, int key_only, char *file)
  {
  	if (deleting) {
--		if (delete_file(ac, file, key_only) == -1)
-+		if (delete_file(ac, keychain, key_only) == -1)
+-		if (delete_file(ac, file) == -1)
++	  if (delete_file(ac, keychain, file) == -1)
  			return -1;
  	} else {
 -		if (add_file(ac, file, key_only) == -1)
-+		if (add_file(ac, keychain, file, key_only) == -1)
++	  if (add_file(ac, keychain, file, key_only) == -1)
  			return -1;
  	}
  	return 0;
--- openssh-5.9p1-gsskex-all-20110920.patch	2013-07-07 15:27:48.000000000 -0700
+++ openssh-5.9p1-gsskex-all-20110920.patch.old	2013-07-07 15:21:44.000000000 -0700
@@ -163,13 +163,13 @@
 index 3be3aa6..e479a44 100644
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -72,6 +72,7 @@
+@@ -70,6 +70,7 @@ LIBSSH_OBJS=acss.o authfd.o authfile.o bufaux.o bufbn.o buffer.o \
  	atomicio.o key.o dispatch.o kex.o mac.o uidswap.o uuencode.o misc.o \
  	monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
  	kexdh.o kexgex.o kexdhc.o kexgexc.o bufec.o kexecdh.o kexecdhc.o \
 +	kexgssc.o \
- 	msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
- 	jpake.o schnorr.o ssh-pkcs11.o krl.o
+ 	msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o jpake.o \
+ 	schnorr.o ssh-pkcs11.o
  
 @@ -86,7 +87,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
  	auth2-none.o auth2-passwd.o auth2-pubkey.o auth2-jpake.o \
@@ -2137,15 +2137,15 @@
 index 5e7d552..db0443f 100644
 --- a/monitor.h
 +++ b/monitor.h
-@@ -69,6 +69,8 @@
- 	MONITOR_REQ_PAM_RESPOND = 108, MONITOR_ANS_PAM_RESPOND = 109,
- 	MONITOR_REQ_PAM_FREE_CTX = 110, MONITOR_ANS_PAM_FREE_CTX = 111,
- 	MONITOR_REQ_AUDIT_EVENT = 112, MONITOR_REQ_AUDIT_COMMAND = 113,
-+	MONITOR_REQ_GSSSIGN = 114, MONITOR_ANS_GSSSIGN = 115,
-+	MONITOR_REQ_GSSUPCREDS = 116, MONITOR_ANS_GSSUPCREDS = 117,
- 
- };
- 
+@@ -53,6 +53,8 @@ enum monitor_reqtype {
+ 	MONITOR_REQ_GSSSTEP, MONITOR_ANS_GSSSTEP,
+ 	MONITOR_REQ_GSSUSEROK, MONITOR_ANS_GSSUSEROK,
+ 	MONITOR_REQ_GSSCHECKMIC, MONITOR_ANS_GSSCHECKMIC,
++	MONITOR_REQ_GSSSIGN, MONITOR_ANS_GSSSIGN,
++	MONITOR_REQ_GSSUPCREDS, MONITOR_ANS_GSSUPCREDS,
+ 	MONITOR_REQ_PAM_START,
+ 	MONITOR_REQ_PAM_ACCOUNT, MONITOR_ANS_PAM_ACCOUNT,
+ 	MONITOR_REQ_PAM_INIT_CTX, MONITOR_ANS_PAM_INIT_CTX,
 diff --git a/monitor_wrap.c b/monitor_wrap.c
 index 1f60658..fc6bbcd 100644
 --- a/monitor_wrap.c
