6 int main(int argc, char *argv[])
8 const char *id = "testuser";
9 const char *pass = "testpassword";
10 const char *nonce = "1";
11 const unsigned char secret[] = {0xb4, 0x62, 0xf2, 0x60, 0x87,
12 0x78, 0x16, 0x87, 0xde, 0xce,
13 0x80, 0x09, 0x24, 0x0b, 0x93,
14 0xfc, 0xa0, 0xfc, 0x56, 0x56};
15 const unsigned char *payload = (unsigned char *)
16 "To authorize or not to authorize?";
17 unsigned char authobj[128];
18 int authsize = sizeof(authobj);
19 unsigned char challenge[128];
20 int challengesize = sizeof(challenge);
22 unsigned char key[20];
23 int keysize = sizeof(key);
24 unsigned char newsecret[20];
25 int newsecsize = sizeof(newsecret);
26 unsigned char newload[128];
27 int newloadsize=sizeof(newload);
29 rc = make_authobj(id, pass, nonce, secret, sizeof(secret),
30 payload, strlen((char *)payload),
32 printf("make_authobj() rc=%d size=%d\n", rc, authsize);
35 rc = make_challenge(id, pass, nonce, challenge, &challengesize);
36 printf("make_challenge() rc=%d size=%d\n", rc, challengesize);
38 rc = hmac(secret, sizeof(secret), challenge, challengesize,
40 printf("hmac(secret, challenge) rc=%d new_key_size=%d\n",
44 rc = parse_authobj(key, sizeof(key), authobj, authsize,
45 newsecret, &newsecsize, newload, &newloadsize);
46 printf("parse_authobj() rc=%d secretsize=%d payload=\"%.*s\" (%d)\n",
47 rc, newsecsize, newloadsize, newload, newloadsize);
48 if (memcmp(secret, newsecret, newsecsize)) {
49 printf("extracted secret does not match\n");