Support Nitrokey Start and Storage

This commit is contained in:
Dominik Schürmann
2017-11-06 13:17:55 +01:00
parent 106dbdf4a9
commit 9c1915423a
6 changed files with 18 additions and 11 deletions

View File

@@ -96,8 +96,8 @@ public abstract class SecurityTokenInfo implements Parcelable {
} }
public enum TokenType { public enum TokenType {
YUBIKEY_NEO, YUBIKEY_4, FIDESMO, NITROKEY_PRO, NITROKEY_STORAGE, NITROKEY_START, YUBIKEY_NEO, YUBIKEY_4, FIDESMO, NITROKEY_PRO, NITROKEY_STORAGE, NITROKEY_START_OLD,
GNUK_OLD, GNUK_UNKNOWN, GNUK_1_25_AND_NEWER, LEDGER_NANO_S, UNKNOWN NITROKEY_START_1_25_AND_NEWER, GNUK_OLD, GNUK_1_25_AND_NEWER, LEDGER_NANO_S, UNKNOWN
} }
private static final HashSet<TokenType> SUPPORTED_USB_TOKENS = new HashSet<>(Arrays.asList( private static final HashSet<TokenType> SUPPORTED_USB_TOKENS = new HashSet<>(Arrays.asList(
@@ -105,15 +105,18 @@ public abstract class SecurityTokenInfo implements Parcelable {
TokenType.YUBIKEY_4, TokenType.YUBIKEY_4,
TokenType.NITROKEY_PRO, TokenType.NITROKEY_PRO,
TokenType.NITROKEY_STORAGE, TokenType.NITROKEY_STORAGE,
TokenType.NITROKEY_START_OLD,
TokenType.NITROKEY_START_1_25_AND_NEWER,
TokenType.GNUK_OLD, TokenType.GNUK_OLD,
TokenType.GNUK_UNKNOWN,
TokenType.GNUK_1_25_AND_NEWER TokenType.GNUK_1_25_AND_NEWER
)); ));
private static final HashSet<TokenType> SUPPORTED_USB_SETUP = new HashSet<>(Arrays.asList( private static final HashSet<TokenType> SUPPORTED_USB_SETUP = new HashSet<>(Arrays.asList(
TokenType.YUBIKEY_NEO, TokenType.YUBIKEY_NEO,
TokenType.YUBIKEY_4, // Not clear, will be tested: https://github.com/open-keychain/open-keychain/issues/2069 TokenType.YUBIKEY_4,
TokenType.NITROKEY_PRO, TokenType.NITROKEY_PRO,
TokenType.NITROKEY_STORAGE,
TokenType.NITROKEY_START_1_25_AND_NEWER,
TokenType.GNUK_1_25_AND_NEWER TokenType.GNUK_1_25_AND_NEWER
)); ));

View File

@@ -211,7 +211,11 @@ public class UsbTransport implements Transport {
case PRODUCT_NITROKEY_PRO: case PRODUCT_NITROKEY_PRO:
return TokenType.NITROKEY_PRO; return TokenType.NITROKEY_PRO;
case PRODUCT_NITROKEY_START: case PRODUCT_NITROKEY_START:
return TokenType.NITROKEY_START; String serialNo = usbConnection.getSerial();
SecurityTokenInfo.Version gnukVersion = SecurityTokenInfo.parseGnukVersionString(serialNo);
boolean versionGreaterEquals125 = gnukVersion != null
&& SecurityTokenInfo.Version.create("1.2.5").compareTo(gnukVersion) <= 0;
return versionGreaterEquals125 ? TokenType.NITROKEY_START_1_25_AND_NEWER : TokenType.NITROKEY_START_OLD;
case PRODUCT_NITROKEY_STORAGE: case PRODUCT_NITROKEY_STORAGE:
return TokenType.NITROKEY_STORAGE; return TokenType.NITROKEY_STORAGE;
} }

View File

@@ -98,7 +98,7 @@ class ManageSecurityTokenContract {
void requestStoragePermission(); void requestStoragePermission();
void showErrorCannotReset(boolean isGnuk); void showErrorCannotReset(boolean isGnukOrNitrokeyStart);
void showErrorCannotUnlock(); void showErrorCannotUnlock();
} }
} }

View File

@@ -353,8 +353,8 @@ public class ManageSecurityTokenFragment extends Fragment implements ManageSecur
} }
@Override @Override
public void showErrorCannotReset(boolean isGnuk) { public void showErrorCannotReset(boolean isGnukOrNitrokeyStart) {
if (isGnuk) { if (isGnukOrNitrokeyStart) {
Notify.create(getActivity(), R.string.token_error_cannot_reset_gnuk_old, Style.ERROR).show(); Notify.create(getActivity(), R.string.token_error_cannot_reset_gnuk_old, Style.ERROR).show();
} else { } else {
Notify.create(getActivity(), R.string.token_error_cannot_reset, Style.ERROR).show(); Notify.create(getActivity(), R.string.token_error_cannot_reset, Style.ERROR).show();

View File

@@ -365,9 +365,9 @@ class ManageSecurityTokenPresenter implements ManageSecurityTokenMvpPresenter {
public void onClickResetToken() { public void onClickResetToken() {
if (!tokenInfo.isResetSupported()) { if (!tokenInfo.isResetSupported()) {
TokenType tokenType = tokenInfo.getTokenType(); TokenType tokenType = tokenInfo.getTokenType();
boolean isGnuk = tokenType == TokenType.GNUK_OLD || tokenType == TokenType.GNUK_UNKNOWN; boolean isGnukOrNitrokeyStart = tokenType == TokenType.GNUK_OLD || tokenType == TokenType.NITROKEY_START_OLD;
view.showErrorCannotReset(isGnuk); view.showErrorCannotReset(isGnukOrNitrokeyStart);
return; return;
} }

View File

@@ -1927,7 +1927,7 @@
<item quantity="other">"%d attempts left"</item> <item quantity="other">"%d attempts left"</item>
</plurals> </plurals>
<string name="token_error_locked_indefinitely">Too many reset attempts. Token cannot be unlocked!</string> <string name="token_error_locked_indefinitely">Too many reset attempts. Token cannot be unlocked!</string>
<string name="token_error_cannot_reset_gnuk_old">"The Gnuk Token does not support reset until version 1.2.5"</string> <string name="token_error_cannot_reset_gnuk_old">"The Gnuk Token/Nitrokey Start does not support reset until version 1.2.5"</string>
<string name="token_error_cannot_reset">"This Security Token does not support reset"</string> <string name="token_error_cannot_reset">"This Security Token does not support reset"</string>
<string name="token_menu_change_pin">Change PIN</string> <string name="token_menu_change_pin">Change PIN</string>