diff src/c/request.c @ 1104:72670131dace

Basis.serialize; separate file for mhash; run transactional finishers in reverse order; set needs_sig properly
author Adam Chlipala <adamc@hcoop.net>
date Thu, 31 Dec 2009 11:41:57 -0500
parents db52c32dbe42
children 150465f2895c
line wrap: on
line diff
--- a/src/c/request.c	Wed Dec 30 09:52:18 2009 -0500
+++ b/src/c/request.c	Thu Dec 31 11:41:57 2009 -0500
@@ -67,35 +67,6 @@
   return ctx;
 }
 
-#define KEYSIZE 16
-#define PASSSIZE 4
-
-#define HASH_ALGORITHM MHASH_SHA256
-#define HASH_BLOCKSIZE 32
-#define KEYGEN_ALGORITHM KEYGEN_MCRYPT
-
-int uw_hash_blocksize = HASH_BLOCKSIZE;
-
-static int password[PASSSIZE];
-static unsigned char private_key[KEYSIZE];
-
-static void init_crypto(void *logger_data, uw_logger log_error) {
-  KEYGEN kg = {{HASH_ALGORITHM, HASH_ALGORITHM}};
-  int i;
-
-  assert(mhash_get_block_size(HASH_ALGORITHM) == HASH_BLOCKSIZE);
-
-  for (i = 0; i < PASSSIZE; ++i)
-    password[i] = rand();
-
-  if (mhash_keygen_ext(KEYGEN_ALGORITHM, kg,
-                       private_key, sizeof(private_key),
-                       (unsigned char*)password, sizeof(password)) < 0) {
-    log_error(logger_data, "Key generation failed\n");
-    exit(1);
-  }
-}
-
 void uw_request_init(uw_app *app, void *logger_data, uw_logger log_error, uw_logger log_debug) {
   uw_context ctx;
   failure_kind fk;
@@ -121,20 +92,8 @@
   }
 
   uw_free(ctx);
-
-  init_crypto(logger_data, log_error);
 }
 
-void uw_sign(const char *in, char *out) {
-  MHASH td;
-
-  td = mhash_hmac_init(HASH_ALGORITHM, private_key, sizeof(private_key),
-                       mhash_get_hash_pblock(HASH_ALGORITHM));
-  
-  mhash(td, in, strlen(in));
-  if (mhash_hmac_deinit(td, out) < 0)
-    fprintf(stderr, "Signing failed\n");
-}
 
 typedef struct uw_rc {
   size_t path_copy_size;