# BRCM_VERSION=3
[bcm963xx.git] / userapps / opensource / sshd / libtomcrypt / examples / ch2-01.c
1 /* 
2  * Name      : ch2-01.c
3  * Purpose   : Demonstration of reading the RNG
4  * Author    : Tom St Denis
5  *
6  * History   : v0.81 Initial release
7  */
8  
9  /* ch2-02-2 */
10  #include <mycrypt.h>
11  
12  int main(void) 
13  {
14     unsigned char buf[16];
15     unsigned long len;
16     int           ix;
17     
18     /* read the RNG */
19     len = rng_get_bytes(buf, sizeof(buf), NULL);
20     
21     /* verify return */
22     if (len != sizeof(buf)) {
23        printf("Error: Only read %lu bytes.\n", len);
24     } else {
25        printf("Read %lu bytes\n", len);
26        for (ix = 0; ix < sizeof(buf); ix++) {
27            printf("%02x ", buf[ix]);
28        }
29        printf("\n");
30     }
31     
32     return EXIT_SUCCESS;
33 }
34 /* ch2-02-2 */
35