diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-02 15:29:09 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-09-02 15:29:09 +0200 |
| commit | 4f13051f763cab3d431847305eff913e4bf9d77a (patch) | |
| tree | bb20393d714ede1a0200653e2bddbbb694b56f16 /scratchpad/scratchpad.c | |
| parent | dffdb1388991c5b5688139bfa093c8581a0f3a36 (diff) | |
| download | cmix-4f13051f763cab3d431847305eff913e4bf9d77a.tar.gz cmix-4f13051f763cab3d431847305eff913e4bf9d77a.tar.bz2 cmix-4f13051f763cab3d431847305eff913e4bf9d77a.zip | |
Changed to api to be less repetative in use.
Diffstat (limited to 'scratchpad/scratchpad.c')
| -rw-r--r-- | scratchpad/scratchpad.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/scratchpad/scratchpad.c b/scratchpad/scratchpad.c index 848493d..c0730fd 100644 --- a/scratchpad/scratchpad.c +++ b/scratchpad/scratchpad.c @@ -2,25 +2,49 @@ #include "cmix.h" #include "message.h" +#include "curve25519.h" + #include <stdio.h> +#include <string.h> int main(int argc, char* argv[]) { - struct CmixBufferImpl buffer_impl = get_cmix_Curve25519_buffer_implementation(); - char* buffer = buffer_impl.allocate_cmix_buffer(3); + struct Api api = get_curve25519_implementation(); + + struct KeyPair pair1 = api.create_key_pair(); + struct KeyPair pair2 = api.create_key_pair(); + + struct SharedKey sk1 = api.derive_shared_key(pair1, pair2.pub, false); + struct SharedKey sk2 = api.derive_shared_key(pair2, pair1.pub, true); + + if(memcmp(sk1.shared, sk2.shared, sk1.shared_len) != 0) { + exit(-1); + } else { + printf("Yoepie!"); + } + + api.free_key_pair(pair1); + api.free_key_pair(pair2); + + api.free_shared_key(sk1); + api.free_shared_key(sk2); + + +// struct CmixBufferImpl buffer_impl = get_cmix_Curve25519_buffer_implementation(); +// char* buffer = buffer_impl.allocate_cmix_buffer(3); - int message_size = buffer_impl.message_length(); +// int message_size = buffer_impl.message_length(); - for(int i=0; i < 3; i++) { - buffer[i*message_size] = 'h'; - } +// for(int i=0; i < 3; i++) { +// buffer[i*message_size] = 'h'; +// } - for(int i=0; i < 3; i++) { - putc(buffer[i*message_size], stdout); - putc('\n', stdout); - } +// for(int i=0; i < 3; i++) { +// putc(buffer[i*message_size], stdout); +// putc('\n', stdout); +// } - buffer_impl.deallocate_cmix_buffer(buffer); +// buffer_impl.deallocate_cmix_buffer(buffer); return 0; } |
