Merge "Adding tinyDTLS into iotivity repo"
[platform/upstream/iotivity.git] / extlibs / tinydtls / tests / prf-test.c
1 #include <stdio.h>
2
3 #include "tinydtls.h"
4 #include "debug.h"
5 #include "global.h"
6 #include "crypto.h"
7
8 int 
9 main() {
10   /* see http://www.ietf.org/mail-archive/web/tls/current/msg03416.html */
11   unsigned char key[] = { 0x9b, 0xbe, 0x43, 0x6b, 0xa9, 0x40, 0xf0, 0x17, 
12                           0xb1, 0x76, 0x52, 0x84, 0x9a, 0x71, 0xdb, 0x35 };
13   unsigned char label[] = { 0x74, 0x65, 0x73, 0x74, 0x20, 0x6c, 0x61, 0x62, 
14                             0x65, 0x6c};
15   unsigned char random1[] = { 0xa0, 0xba, 0x9f, 0x93, 0x6c, 0xda, 0x31, 0x18};
16   unsigned char random2[] = {0x27, 0xa6, 0xf7, 0x96, 0xff, 0xd5, 0x19, 0x8c
17   };
18   unsigned char buf[200];
19   size_t result;
20   
21   result = dtls_prf(key, sizeof(key),
22                     label, sizeof(label),
23                     random1, sizeof(random1),
24                     random2, sizeof(random2),
25                     buf, 100);
26
27   printf("PRF yields %zu bytes of random data:\n", result);
28   hexdump(buf, result);
29   printf("\n");
30   return 0;
31 }