summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2016-06-16 12:34:41 -0400
committerFranklin Wei <frankhwei536@gmail.com>2016-06-16 12:34:41 -0400
commit099d0dae216ea4d54bf15f6c20a69a3d28bebf7f (patch)
treea507b14af19a0af1feee36e30104c17f3c25742b /apps/plugins
parent43d0ea6dd15cf5f31fe08c76947b686cc8ab77cb (diff)
downloadrockbox-099d0dae216ea4d54bf15f6c20a69a3d28bebf7f.zip
rockbox-099d0dae216ea4d54bf15f6c20a69a3d28bebf7f.tar.gz
rockbox-099d0dae216ea4d54bf15f6c20a69a3d28bebf7f.tar.bz2
rockbox-099d0dae216ea4d54bf15f6c20a69a3d28bebf7f.tar.xz
fix
Change-Id: I0fc37aa98d68ba3ad70c2e510a1d5c9e929503e7
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/otp.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/apps/plugins/otp.c b/apps/plugins/otp.c
index 8520fb8..1297981 100644
--- a/apps/plugins/otp.c
+++ b/apps/plugins/otp.c
@@ -231,6 +231,8 @@ static bool browse( char *dst, int dst_size, const char *start )
return (browse.flags & BROWSE_SELECTED);
}
+/* a simple AES128-CTR implementation */
+
struct aes_ctr_ctx {
char key[16];
union {
@@ -244,6 +246,9 @@ struct aes_ctr_ctx {
static void aes_ctr_init(struct aes_ctr_ctx *ctx, const char *key, uint64_t nonce)
{
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+ rb->cpu_boost(true);
+#endif
rb->memcpy(ctx->key, key, 16);
ctx->counter.half[0] = nonce;
ctx->counter.half[1] = 0;
@@ -272,6 +277,9 @@ static void aes_ctr_destroy(struct aes_ctr_ctx *ctx)
rb->memset(ctx, 0, sizeof(ctx));
rb->memset(ctx, 0xff, sizeof(ctx));
rb->memset(ctx, 0, sizeof(ctx));
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+ rb->cpu_boost(false);
+#endif
}
static bool read_accts(void)
@@ -321,7 +329,7 @@ static bool read_accts(void)
}
/* decrypt the data with AES128-CTR */
- /* the HMAC-SHA-1 of the password and nonce are truncated to form the key */
+ /* the HMAC-SHA-1 of the password and nonce is truncated to form the key */
char key[20];
hmac_sha1(&nonce, sizeof(nonce), enc_password, rb->strlen(enc_password), key);
@@ -333,7 +341,8 @@ static bool read_accts(void)
aes_ctr_process(&aes_ctx, in, buf, 4);
if(rb->memcmp(buf, magic, 4))
{
- rb->splashf(HZ * 4, "Wrong password!");
+ rb->splashf(HZ * 2, "Wrong password!");
+ aes_ctr_destroy(&aes_ctx);
continue;
}
@@ -359,6 +368,8 @@ static bool read_accts(void)
}
}
+ /* plain, unencrypted format */
+
while(next_slot < max_accts)
{
if(rb->read(fd, accounts + next_slot, sizeof(struct account_t)) != sizeof(struct account_t))
@@ -1143,9 +1154,9 @@ static void encrypt_menu(void)
case 0:
{
char temp_pass[sizeof(enc_password)];
+ char temp_pass2[sizeof(enc_password)];
temp_pass[0] = '\0';
- enc_password[0] = '\0';
if(encrypted)
{
@@ -1168,9 +1179,11 @@ static void encrypt_menu(void)
if(rb->kbd_input(temp_pass, sizeof(temp_pass)) < 0)
break;
+ temp_pass2[0] = '\0';
+
rb->splash(HZ * 2, "Re-enter new password:");
- if(rb->kbd_input(enc_password, sizeof(enc_password)) < 0)
+ if(rb->kbd_input(temp_pass2, sizeof(temp_pass2)) < 0)
break;
if(rb->strcmp(temp_pass, enc_password))
@@ -1179,6 +1192,8 @@ static void encrypt_menu(void)
break;
}
+ rb->strlcpy(enc_password, temp_pass, sizeof(enc_password));
+
encrypted = true;
rb->splash(HZ * 2, "Success.");
break;