Skip to content

Commit

Permalink
Add Base64 input validation. Closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett committed Jun 10, 2015
1 parent e13dd8d commit 966d34b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ android {
applicationId "org.cipherdyne.fwknop2"
minSdkVersion 15
targetSdkVersion 19
versionCode 2
versionCode 3
versionName "1.0"
ndk {
moduleName 'libfwknop'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (txt_NickName.getText().toString().equalsIgnoreCase("")) { // Need to create a new Nick
toast.setText("You Must choose a unique Nickname."); // choosing a used nick will just overwrite it. So really
toast.show();
} else if(chkb64hmac.isChecked() && txt_HMAC.getText().toString().length() % 4 != 0) { // base64 must have a multiple of 4 length
toast.setText("Hmac is not a valid Base64, not a multiple of 4.");
toast.show();
} else if(chkb64hmac.isChecked() && !(txt_HMAC.getText().toString().matches("^[A-Za-z0-9+/]+={0,2}$"))) { // looks for disallowed b64 characters
toast.setText("Hmac is not a valid Base64, Contains disallowed characters.");
toast.show();
} else if(chkb64key.isChecked() && txt_KEY.getText().toString().length() % 4 != 0) {
toast.setText("Key is not a valid Base64, not a multiple of 4.");
toast.show();
} else if(chkb64key.isChecked() && !(txt_KEY.getText().toString().matches("^[A-Za-z0-9+/]+={0,2}$"))) { // looks for disallowed b64 characters
toast.setText("Key is not a valid Base64, Contains disallowed characters.");
toast.show();
} else if (!(txt_ports.getText().toString().matches("tcp/\\d.*") || txt_ports.getText().toString().matches("udp/\\d.*"))) {
toast.setText("Access ports must be in the form of 'tcp/22'");
toast.show();
Expand Down

0 comments on commit 966d34b

Please sign in to comment.