authsrvtis.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "ssh.h"
  10. static AuthInfo*
  11. authsrvtisfn(Conn *conn, Msg *m)
  12. {
  13. char *s;
  14. AuthInfo *ai;
  15. Chalstate *c;
  16. free(m);
  17. if((c = auth_challenge("proto=p9cr user=%q role=server", conn->user)) == nil){
  18. sshlog("auth_challenge failed for %s", conn->user);
  19. return nil;
  20. }
  21. s = smprint("Challenge: %s\nResponse: ", c->chal);
  22. if(s == nil){
  23. auth_freechal(c);
  24. return nil;
  25. }
  26. m = allocmsg(conn, SSH_SMSG_AUTH_TIS_CHALLENGE, 4+strlen(s));
  27. putstring(m, s);
  28. sendmsg(m);
  29. free(s);
  30. m = recvmsg(conn, 0);
  31. if(m == nil){
  32. auth_freechal(c);
  33. return nil;
  34. }
  35. if(m->type != SSH_CMSG_AUTH_TIS_RESPONSE){
  36. /*
  37. * apparently you can just give up on
  38. * this protocol and start a new one.
  39. */
  40. unrecvmsg(conn, m);
  41. return nil;
  42. }
  43. c->resp = getstring(m);
  44. c->nresp = strlen(c->resp);
  45. ai = auth_response(c);
  46. auth_freechal(c);
  47. return ai;
  48. }
  49. Authsrv authsrvtis =
  50. {
  51. SSH_AUTH_TIS,
  52. "tis",
  53. SSH_CMSG_AUTH_TIS,
  54. authsrvtisfn,
  55. };