#define WM_DONEKEY (WM_XUSER + 1)
-#define KEYSIZE 1024
-
-/*
- * TODO:
- * - test the generated keys for actual working-RSA-key-hood
- * - variable key size
- */
+#define DEFAULT_KEYSIZE 1024
/* ----------------------------------------------------------------------
* Progress report code. This is really horrible :-)
struct rsa_key_thread_params {
HWND progressbar; /* notify this with progress */
HWND dialog; /* notify this on completion */
+ int keysize; /* bits in key */
struct RSAKey *key;
struct RSAAux *aux;
};
struct progress prog;
prog.progbar = params->progressbar;
- rsa_generate(params->key, params->aux, KEYSIZE, progress_update, &prog);
+ rsa_generate(params->key, params->aux,
+ params->keysize, progress_update, &prog);
PostMessage(params->dialog, WM_DONEKEY, 0, 0);
int generation_thread_exists;
int key_exists;
int entropy_got, entropy_required, entropy_size;
+ int keysize;
unsigned *entropy;
struct RSAKey key;
struct RSAAux aux;
IDC_GENSTATIC, IDC_GENERATE,
IDC_LOADSTATIC, IDC_LOAD,
IDC_SAVESTATIC, IDC_SAVE,
+ IDC_BOX_PARAMS, IDC_BOXT_PARAMS,
+ IDC_BITSSTATIC, IDC_BITS,
IDC_ABOUT,
};
static const int nokey_ids[] = { IDC_NOKEY, 0 };
static const char generating_msg[] =
"Please wait while a key is generated...";
static const char entropy_msg[] =
- "Please move the mouse in this window to generate randomness";
+ "Please generate some randomness by moving the mouse over the blank area.";
struct MainDlgState *state;
switch (msg) {
staticbtn(&cp, "Save the generated key to a new file",
IDC_SAVESTATIC, "&Save", IDC_SAVE);
endbox(&cp);
+ beginbox(&cp, "Actions",
+ IDC_BOX_ACTIONS, IDC_BOXT_ACTIONS);
+ staticedit(&cp, "Number of &bits in a generated key:",
+ IDC_BITSSTATIC, IDC_BITS, 20);
+ endbox(&cp);
}
+ SetDlgItemInt(hwnd, IDC_BITS, DEFAULT_KEYSIZE, FALSE);
+
/*
* Initially, hide the progress bar and the key display,
* and show the no-key display. Also disable the Save
params = malloc(sizeof(*params));
params->progressbar = GetDlgItem(hwnd, IDC_PROGRESS);
params->dialog = hwnd;
+ params->keysize = state->keysize;
params->key = &state->key;
params->aux = &state->aux;
state->key_exists = FALSE;
SetDlgItemText(hwnd, IDC_GENERATING, entropy_msg);
state->collecting_entropy = TRUE;
+ {
+ BOOL ok;
+ state->keysize = GetDlgItemInt(hwnd, IDC_BITS,
+ &ok, FALSE);
+ if (!ok) state->keysize = DEFAULT_KEYSIZE;
+ }
/*
* My brief statistical tests on mouse movements
- * suggest that there are about 5 bits of
- * randomness in the x position, 5 in the y
+ * suggest that there are about 2.5 bits of
+ * randomness in the x position, 2.5 in the y
* position, and 1.7 in the message time, making
- * 11.7 bits of unpredictability per mouse
- * movement. However, other people have told me
- * it's far less than that, so I'm going to be
- * stupidly cautious and knock that down to a nice
- * round 4.
+ * 5.7 bits of unpredictability per mouse movement.
+ * However, other people have told me it's far less
+ * than that, so I'm going to be stupidly cautious
+ * and knock that down to a nice round 2. With this
+ * method, we require two words per mouse movement,
+ * so with 2 bits per mouse movement we expect 2
+ * bits every 2 words.
*/
- state->entropy_required = (KEYSIZE / 4) * 2;
+ state->entropy_required = (state->keysize/2) * 2;
state->entropy_got = 0;
state->entropy_size = (state->entropy_required *
sizeof(*state->entropy));