Commit 9261c4e7 authored by thorsten's avatar thorsten
Browse files

* Removed all depencies to libsodium, so we cannot use onion routing for the moment

parent 06a98be5
......@@ -14,7 +14,7 @@
#include "relaymq_library.h"
// Add your own public definitions here, if you need them
#include <sodium.h>
// #include <sodium.h>
#endif
......@@ -14,6 +14,7 @@
@end
*/
#include <sodium/randombytes.h>
#include "relaymq_classes.h"
#define PREFIX "RelayMQ_MESSAGES"
......@@ -38,6 +39,14 @@ struct _relay_crypto_t {
};
size_t crypto_box_BOXZEROBYTES;
int crypto_box_ZEROBYTES;
static int crypto_box_open(byte *plain, byte *box, size_t size, byte nonce[24], byte *from, const byte *sk);
static int crypto_box(byte *box, byte *plain, size_t size, byte nonce[24], byte *to, const byte *sk);
typedef struct {
char id [sizeof ("MESSAGE")];
byte nonce [8]; // Short nonce, prefixed by "CurveZMQMESSAGE-"
......@@ -106,7 +115,7 @@ s_encrypt (
// Prepare plain text with zero bytes at start for encryption
memset (plain, 0, crypto_box_ZEROBYTES);
memcpy (plain + crypto_box_ZEROBYTES, data, size);
memcpy (plain, data, size);
// Prepare full nonce and store nonce into target
// Handle both short and long nonces
......@@ -140,6 +149,9 @@ s_encrypt (
return rc;
}
static int crypto_box(byte *box, byte *plain, size_t size, byte nonce[24], byte *to, const byte *sk) {
return 0;
}
static zframe_t *
......@@ -192,7 +204,8 @@ s_decrypt (
char *prefix, // Nonce prefix to use, 8 or 16 chars
byte *key_from) // Key to decrypt from, may be null
{
size_t box_size = crypto_box_ZEROBYTES + size;
size_t box_size = + size;
byte *plain = (byte *) malloc (box_size);
byte *box = (byte *) malloc (box_size);
......@@ -218,7 +231,7 @@ s_decrypt (
// If we cannot open the box, it means it's been modified or is unauthentic
if (rc == 0)
memcpy (target, plain + crypto_box_ZEROBYTES, size);
memcpy (target, plain, size);
else
if (self->verbose)
puts ("E: invalid box received, cannot open it");
......@@ -228,6 +241,10 @@ s_decrypt (
return rc;
}
static int crypto_box_open(byte *plain, byte *box, size_t size, byte nonce[24], byte *from, const byte *sk) {
return 0;
}
static zframe_t *
s_process_message (relay_crypto_t *self, byte* from, zframe_t *input)
{
......
......@@ -111,34 +111,33 @@ RELAYMQ_EXPORT void
relay_event_test (bool verbose);
// @end
const char*
relay_event_type_as_string (relay_event_t *self);
relay_event_type_as_string (relay_event_t *self);
relay_event_type_t
relay_event_type_from_string (const char* command);
relay_event_type_from_string (const char* command);
relay_event_t*
relay_event_new ();
relay_event_new ();
// The event payload
void
relay_event_set_callback (relay_event_t *self, relay_identity_t *val);
relay_event_set_callback (relay_event_t *self, relay_identity_t *val);
// The event payload
void
relay_event_set_message (relay_event_t *self, zmsg_t **val);
relay_event_set_message (relay_event_t *self, zmsg_t **val);
// The event payload
void
relay_event_set_header(relay_event_t *self, zhashx_t **val);
relay_event_set_header(relay_event_t *self, zhashx_t **val);
// The event payload
void
relay_event_set_identities (relay_event_t *self, zlistx_t **val);
relay_event_set_identities (relay_event_t *self, zlistx_t **val);
void
relay_event_set_handle (relay_event_t *self, relay_handle_t *val);
relay_event_set_handle (relay_event_t *self, relay_handle_t *val);
#ifdef __cplusplus
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment