File: sasl_plain.c

package info (click to toggle)
cvm 0.97-0.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,036 kB
  • sloc: ansic: 4,065; sh: 2,758; makefile: 235; sql: 15
file content (31 lines) | stat: -rw-r--r-- 776 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <string.h>
#include "sasl.h"
#include "sasl_internal.h"

static int response1(struct sasl_state* ss,
		     const str* response, str* challenge)
{
  unsigned i;
  unsigned j;
  if (response->len == 0)
    return SASL_RESP_BAD;
  if ((i = str_findfirst(response, 0)) == (unsigned)-1)
    return SASL_RESP_BAD;
  ++i;
  if ((j = str_findnext(response, 0, i)) == (unsigned)-1)
    return SASL_RESP_BAD;
  ++j;
  return sasl_authenticate_plain(ss, response->s+i, response->s+j);
  (void)challenge;
}

int sasl_plain_start(struct sasl_state* ss,
		     const str* response, str* challenge)
{
  if (response)
    return response1(ss, response, challenge);
  if (!str_truncate(challenge, 0))
    return SASL_TEMP_FAIL;
  ss->response = response1;
  return SASL_CHALLENGE;
}