]> andersk Git - openssh.git/blobdiff - auth-chall.c
- markus@cvs.openbsd.org 2001/04/04 15:50:55
[openssh.git] / auth-chall.c
index e02e99d36a6f55f3f8b22c04a92e94a7fd28dd94..ee7b6cd96531d36aba13b9b3e3ac474412293b4e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001 Markus Friedl. All rights reserved.
+ * Copyright (c) 2001 Markus Friedl.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: auth-chall.c,v 1.1 2001/01/18 17:12:43 markus Exp $");
+RCSID("$OpenBSD: auth-chall.c,v 1.6 2001/03/20 18:57:04 markus Exp $");
 
-#include "ssh.h"
 #include "auth.h"
+#include "log.h"
 
+#ifdef BSD_AUTH
+char *
+get_challenge(Authctxt *authctxt, char *devs)
+{
+       char *challenge;
+
+       if (authctxt->as != NULL) {
+               debug2("try reuse session");
+               challenge = auth_getitem(authctxt->as, AUTHV_CHALLENGE);
+               if (challenge != NULL) {
+                       debug2("reuse bsd auth session");
+                       return challenge;
+               }
+               auth_close(authctxt->as);
+               authctxt->as = NULL;
+       }
+       debug2("new bsd auth session");
+       if (devs == NULL || strlen(devs) == 0)
+               devs = authctxt->style;
+       debug3("bsd auth: devs %s", devs ? devs : "<default>");
+       authctxt->as = auth_userchallenge(authctxt->user, devs, "auth-ssh",
+           &challenge);
+        if (authctxt->as == NULL)
+                return NULL;
+       debug2("get_challenge: <%s>", challenge ? challenge : "EMPTY");
+       return challenge;
+}
+int
+verify_response(Authctxt *authctxt, char *response)
+{
+       int authok;
+
+       if (authctxt->as == 0)
+               error("verify_response: no bsd auth session");
+       authok = auth_userresponse(authctxt->as, response, 0);
+       authctxt->as = NULL;
+       debug("verify_response: <%s> = <%d>", response, authok);
+       return authok != 0;
+}
+#else
 #ifdef SKEY
+#include <skey.h>
+
 char *
 get_challenge(Authctxt *authctxt, char *devs)
 {
        static char challenge[1024];
-        struct skey skey;
+       struct skey skey;
        if (skeychallenge(&skey, authctxt->user, challenge) == -1)
                return NULL;
        strlcat(challenge, "\nS/Key Password: ", sizeof challenge);
@@ -59,3 +101,4 @@ verify_response(Authctxt *authctxt, char *response)
        return 0;
 }
 #endif
+#endif
This page took 0.062305 seconds and 4 git commands to generate.