Skip to content
This repository was archived by the owner on Jan 29, 2021. It is now read-only.

Commit 578489f

Browse files
committed
2step parameter
&2step=true is not needed anymore, as long as one of the 2step parameters is present, 2tep is done. #4 #5
1 parent 6901b9e commit 578489f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

app/src/main/java/it/netknights/piauthenticator/MainActivity.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ public void onClick(DialogInterface dialog, int which) {
288288
int pos = tokenlist.indexOf(currToken);
289289
tokenlist.remove(pos);
290290
Toast.makeText(MainActivity.this, "Token removed", Toast.LENGTH_SHORT).show();
291+
tokenlistadapter.setTokens(tokenlist);
292+
listview.invalidateViews();
291293
tokenlistadapter.notifyDataSetChanged();
292294
saveTokenlist();
293295
mode.finish();
@@ -459,14 +461,17 @@ public Token makeTokenFromURI(String content) throws Exception {
459461
if (uri.getQueryParameter(ALGORITHM) != null) {
460462
tmp.setAlgorithm(uri.getQueryParameter(ALGORITHM).toUpperCase());
461463
}
462-
boolean pinned = uri.getBooleanQueryParameter("pin", false);
463-
if (pinned) {
464+
if (uri.getBooleanQueryParameter("pin", false)) {
464465
tmp.setWithPIN(true);
465466
tmp.setLocked(true);
466467
}
467-
if (uri.getBooleanQueryParameter("2step", false)) {
468+
//if at least one parameter for 2step is set - start 2step init
469+
if (uri.getQueryParameter("2step_salt") != null ||
470+
uri.getQueryParameter("2step_difficulty") != null ||
471+
uri.getQueryParameter("2step_output") != null) {
472+
468473
int phonepartlength = 10; // default value
469-
if (uri.getQueryParameter("2step_salt") != null) {
474+
if (uri.getQueryParameter("2step_salt") != null) {
470475
phonepartlength = Integer.parseInt(uri.getQueryParameter("2step_salt"));
471476
}
472477
int iterations = 10000;
@@ -475,7 +480,7 @@ public Token makeTokenFromURI(String content) throws Exception {
475480
}
476481
int output_size = 160; //comes in bytes, need to be converted to bit as parameter for pbkdf2
477482
if (uri.getQueryParameter("2step_output") != null) {
478-
output_size = Integer.parseInt(uri.getQueryParameter("2step_output"));
483+
output_size = Integer.parseInt(uri.getQueryParameter("2step_output"))*8;
479484
} else {
480485
//if the output size is not specified, it is derived from the OTP algorithm
481486
if (tmp.getAlgorithm().equals("HmacSHA1")) {

0 commit comments

Comments
 (0)