Skip to content

Commit

Permalink
using openssl to generate key of random bytes of KEY_LEN length
Browse files Browse the repository at this point in the history
  • Loading branch information
millerjs committed Oct 14, 2013
1 parent 126a044 commit c34f67e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void locking_function(int mode, int n, const char*file, int line)
// Returns the thread ID
static void threadid_func(CRYPTO_THREADID * id)
{
fprintf(stderr, "[debug] %s\n", "Passing thread ID");
// fprintf(stderr, "[debug] %s\n", "Passing thread ID");
CRYPTO_THREADID_set_numeric(id, THREAD_ID);
}

Expand Down
12 changes: 6 additions & 6 deletions src/udtcat_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ and limitations under the License.
#include "udtcat.h"
#include "udtcat_threads.h"

#define DEBUG 1
#define DEBUG 0
#define EXIT_FAILURE 1

#define prii(x) fprintf(stderr,"debug:%d\n",x)
Expand Down Expand Up @@ -99,7 +99,7 @@ void auth_peer(rs_args* args)
char key[KEY_LEN];
char signed_key[KEY_LEN];

memset(key, 1, KEY_LEN);
RAND_bytes((unsigned char*)key, KEY_LEN);

signed_auth = 0;

Expand All @@ -109,8 +109,8 @@ void auth_peer(rs_args* args)

recv_full(*args->usocket, signed_key, KEY_LEN);

fprintf(stderr, "key: "); print_bytes(key, 16);
fprintf(stderr, "signed_key: "); print_bytes(signed_key, 16);
// fprintf(stderr, "key: "); print_bytes(key, 16);
// fprintf(stderr, "signed_key: "); print_bytes(signed_key, 16);

int crypt_len = KEY_LEN/4;
for (int i = 0; i < crypt_len; i += crypt_len)
Expand All @@ -133,15 +133,15 @@ void sign_auth(rs_args* args)

recv_full(*args->usocket, key, KEY_LEN);

fprintf(stderr, "signing: "); print_bytes(key, 16);
// fprintf(stderr, "signing: "); print_bytes(key, 16);

int crypt_len = KEY_LEN/4;
for (int i = 0; i < crypt_len; i += crypt_len)
pass_to_enc_thread(key+i, key+i, crypt_len, args->c);

join_all_encryption_threads(args->c);

fprintf(stderr, "signed: "); print_bytes(key, 16);
// fprintf(stderr, "signed: "); print_bytes(key, 16);

send_full(*args->usocket, key, KEY_LEN);

Expand Down

0 comments on commit c34f67e

Please sign in to comment.