-static int parse_authobj(const unsigned char *key, const int keysize,
- const unsigned char *buffer, const int bufsize,
- unsigned char *secret, int *secsize,
- unsigned char *payload, int *paysize)
-{
- int datasize = bufsize;
- unsigned char *data = alloca(datasize);
- serializer_t srl;
- int tsize;
- unsigned char myhash[HASHSIZE];
- int myhashsize = HASHSIZE;
- unsigned char theirhash[HASHSIZE];
- int theirhashsize = HASHSIZE;
-
- if (decrypt(key, CBLKSIZE, buffer, data, datasize))
- return 1;
- serial_init(&srl, data, datasize);
- tsize = *secsize;
- *secsize = serial_get(&srl, secret, tsize);
- if (*secsize > tsize || *secsize <= 0) return 1;
- tsize = *paysize;
- *paysize = serial_get(&srl, payload, tsize);
- if (*paysize > tsize || *paysize <= 0) return 1;
- if (hash(data, serial_size(&srl), myhash, &myhashsize))
- return 1;
- theirhashsize = serial_get(&srl, theirhash, theirhashsize);
- if (theirhashsize != HASHSIZE) return 1;
- if ((myhashsize != theirhashsize) ||
- memcmp(myhash, theirhash, myhashsize))
- return 1;
- return 0;
-}
-
-struct _auth_obj new_authobj(const char *userid, const char *password,
- const char *nonce,
- const unsigned char *secret, const int secsize,
- const unsigned char *payload, const int paysize)
+static struct _auth_obj
+parse_authobj(const char *userid, const char *password, const char *nonce,
+ const unsigned char *secret, const int secsize,
+ const unsigned char *ablob, const int blobsize,
+ struct _auth_chunk (*fetch_key)(const unsigned char *chal,
+ const int csize))