From 4ea111bcb58cd903ea40d94893a0d08fd6aa68e5 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 27 May 2015 15:49:57 +0200 Subject: [PATCH] Remove hash.c and stream.c for now. --- demos/hash.c | 45 --------------------------- demos/stream.c | 83 -------------------------------------------------- 2 files changed, 128 deletions(-) delete mode 100644 demos/hash.c delete mode 100644 demos/stream.c diff --git a/demos/hash.c b/demos/hash.c deleted file mode 100644 index 2c765819..00000000 --- a/demos/hash.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * GraxRabble - * Demo programs for libsodium. - */ -#include -#include -#include - -#include /* library header */ - -#include "utils.h" /* utility functions shared by demos */ - -/* - * The library ships with a one-shot SHA-512 implementation. Simply allocate - * all desired data into a single continuous buffer. - */ -static void -hash(void) -{ - unsigned char h[crypto_hash_BYTES]; /* hash output */ - unsigned char m[MAX_INPUT_SIZE]; /* message */ - size_t mlen; /* length */ - - puts("Example: crypto_hash\n"); - - mlen = prompt_input("Input your message > ", (char*)m, sizeof m); - putchar('\n'); - - printf("Hashing message with %s\n", crypto_hash_primitive()); - crypto_hash(h, m, mlen); - fputs("Hash: ", stdout); - print_hex(h, sizeof h); - putchar('\n'); - putchar('\n'); -} - -int -main(void) -{ - sodium_init(); - printf("Using LibSodium %s\n", sodium_version_string()); - - hash(); - return 0; -} diff --git a/demos/stream.c b/demos/stream.c deleted file mode 100644 index 4d9fe1ca..00000000 --- a/demos/stream.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * GraxRabble - * Demo programs for libsodium. - */ -#include -#include -#include - -#include /* library header */ - -#include "utils.h" /* utility functions shared by demos */ - -/* - * Stream utilizes a nonce to generate a sequence of bytes. The library has - * an internal function which XOR data and the stream into an encrypted result. - * - * Note that this method does not supply authentication. Try secretbox instead. - * - * Note that nonce must be different for each message since it provides - * change between each operation. It should be safe to use a counter - * instead of purely random data each time. - */ -static int -stream(void) -{ - unsigned char k[crypto_stream_KEYBYTES]; /* secret key */ - unsigned char n[crypto_stream_NONCEBYTES]; /* message nonce */ - unsigned char m[MAX_INPUT_SIZE]; /* plain-text */ - unsigned char c[MAX_INPUT_SIZE]; /* cipher-text */ - size_t mlen; /* length */ - int r; - - puts("Example: crypto_stream\n"); - - memset(k, 0, sizeof k); - prompt_input("Input your key > ", (char*)k, sizeof k); - putchar('\n'); - - /* nonce must be generated per message, safe to send with message */ - puts("Generating nonce..."); - randombytes_buf(n, sizeof n); - fputs("Nonce: ", stdout); - print_hex(n, sizeof n); - putchar('\n'); - putchar('\n'); - - mlen = prompt_input("Input your message > ", (char*)m, sizeof m); - putchar('\n'); - - printf("Encrypting with (xor) %s\n", crypto_stream_primitive()); - crypto_stream_xor(c, m, mlen, n, k); - putchar('\n'); - - puts("Sending message..."); - puts("Format: nonce::message"); - fputs("Ciphertext: ", stdout); - print_hex(n, sizeof n); - fputs("::", stdout); - print_hex(c, mlen); - putchar('\n'); - putchar('\n'); - - puts("Opening message..."); - r = crypto_stream_xor(m, c, mlen, n, k); - - print_verification(r); - if (r == 0) - printf("Plaintext: %s\n\n", m); - - sodium_memzero(k, sizeof k); /* wipe sensitive data */ - sodium_memzero(m, sizeof m); - sodium_memzero(c, sizeof c); - return r; -} - -int -main(void) -{ - sodium_init(); - printf("Using LibSodium %s\n", sodium_version_string()); - - return stream() != 0; -}