5 int main(int argc, char *argv[])
7 const char *id = "testuser";
8 const char *pass = "testpassword";
9 const char *nonce = "1";
10 const unsigned char secret[] = {0x52, 0xf3, 0xbe, 0x1f, 0x3e,
11 0x22, 0xa8, 0xee, 0xdf, 0x10,
12 0x86, 0xf2, 0x17, 0xd7, 0x21,
13 0x9d, 0x08, 0x14, 0x48, 0x38};
14 const unsigned char *payload = (unsigned char *)
15 "To authorize or not to authorize?";
16 unsigned char authobj[512];
17 int authsize = sizeof(authobj);
18 unsigned char challenge[128];
19 int challengesize = sizeof(challenge);
21 const unsigned char key[] = {0xcc, 0x21, 0xaa, 0xb7, 0xf5,
22 0x76, 0xd6, 0xe7, 0xed, 0x90,
23 0x69, 0x51, 0x3d, 0x9b, 0x3a,
24 0x9d, 0xa8, 0xcf, 0xf9, 0x2f};
25 unsigned char newsecret[20];
26 int newsecsize = sizeof(newsecret);
27 unsigned char newload[128];
28 int newloadsize=sizeof(newload);
30 rc = make_authobj(id, pass, nonce, secret, sizeof(secret),
31 payload, strlen((char *)payload),
33 printf("make_authobj() rc=%d size=%d\n", rc, authsize);
36 rc = make_challenge(id, pass, nonce, challenge, &challengesize);
37 printf("make_challenge() rc=%d size=%d\n", rc, challengesize);
40 rc = parse_authobj(key, sizeof(key), authobj, authsize,
41 newsecret, &newsecsize, newload, &newloadsize);
42 printf("parse_authobj() rc=%d secretsize=%d payload=\"%.*s\" (%d)\n",
43 rc, newsecsize, newloadsize, newload, newloadsize);
44 if (memcmp(secret, newsecret, newsecsize)) {
45 printf("extracted secret does not match\n");