summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2009-04-02 21:27:26 +0000
committerNils Wallménius <nils@rockbox.org>2009-04-02 21:27:26 +0000
commitdd36c579155c377bfe8ef95ee73a2077d5f73a17 (patch)
treef0c3dd9da43fec5579bdda17ecd5aa4b23523f46
parent0eea6ceac4821017192e3dfbeb46fddfd7a8f8e5 (diff)
downloadrockbox-dd36c579155c377bfe8ef95ee73a2077d5f73a17.tar.gz
rockbox-dd36c579155c377bfe8ef95ee73a2077d5f73a17.zip
keybox: handle user canceling in the vkeyboard in a nicer way, fix a comment so that it makes sense
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20608 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/keybox.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c
index f50e6be19c..ddff1e95d2 100644
--- a/apps/plugins/keybox.c
+++ b/apps/plugins/keybox.c
@@ -22,15 +22,14 @@
22#include "lib/md5.h" 22#include "lib/md5.h"
23PLUGIN_HEADER 23PLUGIN_HEADER
24 24
25
26#define KEYBOX_FILE PLUGIN_DIR "/apps/keybox.dat" 25#define KEYBOX_FILE PLUGIN_DIR "/apps/keybox.dat"
27#define BLOCK_SIZE 8 26#define BLOCK_SIZE 8
28#define MAX_ENTRIES 12*BLOCK_SIZE /* keep this a multiple of BLOCK_SIZE */ 27#define MAX_ENTRIES 12*BLOCK_SIZE /* keep this a multiple of BLOCK_SIZE */
29#define FIELD_LEN 32 /* should be enough for anyone ;) */ 28#define FIELD_LEN 32 /* should be enough for anyone ;) */
30 29
31/* salt 4 bytes (needed for decryption) not encrypted padded with 4 bytes of zeroes 30/* The header begins with the unencrypted salt (4 bytes) padded with 4 bytes of
32 pwhash 16 bytes (to check for the right password) encrypted 31 zeroes. After that comes the encrypted hash of the master password (16 bytes) */
33 encrypted data. */ 32
34 33
35#define HEADER_LEN 24 34#define HEADER_LEN 24
36 35
@@ -203,13 +202,25 @@ static void add_entry(int selected_item)
203 202
204 rb->splash(HZ, "Enter title"); 203 rb->splash(HZ, "Enter title");
205 pw_list.entries[i].title[0] = '\0'; 204 pw_list.entries[i].title[0] = '\0';
206 rb->kbd_input(pw_list.entries[i].title, FIELD_LEN); 205 if (rb->kbd_input(pw_list.entries[i].title, FIELD_LEN))
206 return;
207
207 rb->splash(HZ, "Enter name"); 208 rb->splash(HZ, "Enter name");
208 pw_list.entries[i].name[0] = '\0'; 209 pw_list.entries[i].name[0] = '\0';
209 rb->kbd_input(pw_list.entries[i].name, FIELD_LEN); 210 if (rb->kbd_input(pw_list.entries[i].name, FIELD_LEN))
211 {
212 pw_list.entries[i].title[0] = '\0';
213 return;
214 }
215
210 rb->splash(HZ, "Enter password"); 216 rb->splash(HZ, "Enter password");
211 pw_list.entries[i].password[0] = '\0'; 217 pw_list.entries[i].password[0] = '\0';
212 rb->kbd_input(pw_list.entries[i].password, FIELD_LEN); 218 if (rb->kbd_input(pw_list.entries[i].password, FIELD_LEN))
219 {
220 pw_list.entries[i].title[0] = '\0';
221 pw_list.entries[i].name[0] = '\0';
222 return;
223 }
213 224
214 for (j = 0; j < selected_item; j++) 225 for (j = 0; j < selected_item; j++)
215 { 226 {
@@ -506,9 +517,12 @@ static int enter_pw(char *pw_buf, size_t buflen, bool new_pw)
506 if (new_pw) 517 if (new_pw)
507 { 518 {
508 rb->splash(HZ, "Enter new master password"); 519 rb->splash(HZ, "Enter new master password");
509 rb->kbd_input(buf[0], sizeof(buf[0])); 520 if (rb->kbd_input(buf[0], sizeof(buf[0])))
521 return -1;
522
510 rb->splash(HZ, "Confirm master password"); 523 rb->splash(HZ, "Confirm master password");
511 rb->kbd_input(buf[1], sizeof(buf[1])); 524 if (rb->kbd_input(buf[1], sizeof(buf[1])))
525 return -1;
512 526
513 if (rb->strcmp(buf[0], buf[1])) 527 if (rb->strcmp(buf[0], buf[1]))
514 { 528 {