0
|
1 /* Copyright 2010 Ivo Smits <Ivo@UCIS.nl>. All rights reserved. |
|
2 Redistribution and use in source and binary forms, with or without modification, are |
|
3 permitted provided that the following conditions are met: |
|
4 |
|
5 1. Redistributions of source code must retain the above copyright notice, this list of |
|
6 conditions and the following disclaimer. |
|
7 |
|
8 2. Redistributions in binary form must reproduce the above copyright notice, this list |
|
9 of conditions and the following disclaimer in the documentation and/or other materials |
|
10 provided with the distribution. |
|
11 |
|
12 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|
13 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
14 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR |
|
15 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
16 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
17 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
|
18 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
19 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|
20 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
21 |
|
22 The views and conclusions contained in the software and documentation are those of the |
|
23 authors and should not be interpreted as representing official policies, either expressed |
|
24 or implied, of Ivo Smits.*/ |
|
25 |
|
26 #include "common.c" |
|
27 #include "crypto_box.h" |
|
28 #include <time.h> |
|
29 |
|
30 int main() { |
|
31 print_header(); |
|
32 |
|
33 unsigned char cpublickey[crypto_box_PUBLICKEYBYTES]; |
|
34 unsigned char csecretkey[crypto_box_SECRETKEYBYTES]; |
|
35 int i; |
|
36 |
|
37 crypto_box_keypair(cpublickey, csecretkey); |
|
38 |
|
39 printf("SECRET: "); |
|
40 for (i = 0; i < crypto_box_SECRETKEYBYTES; i++) printf("%02x", csecretkey[i]); |
|
41 printf("\n"); |
|
42 |
|
43 printf("PUBLIC: "); |
|
44 for (i = 0; i < crypto_box_SECRETKEYBYTES; i++) printf("%02x", csecretkey[i]); |
|
45 printf("\n"); |
|
46 |
|
47 return 0; |
|
48 } |
|
49 |
|
50 void randombytes(char* bytes) { |
|
51 char* b; |
|
52 srand(time(NULL)); |
|
53 for (b = bytes; b < bytes + crypto_box_SECRETKEYBYTES; b++) *b = rand() % 255; |
|
54 } |