diff --git a/pynitrokey/cli/nk3/__init__.py b/pynitrokey/cli/nk3/__init__.py index 811c9115..357bbf78 100644 --- a/pynitrokey/cli/nk3/__init__.py +++ b/pynitrokey/cli/nk3/__init__.py @@ -510,6 +510,14 @@ def factory_reset(ctx: Context) -> None: with ctx.connect_device() as device: device.factory_reset() +@nk3.command() +@click.pass_obj +@click.argument("application", type=click.STRING, required=True) +def factory_reset_app(ctx: Context, application: str) -> None: + """Factory reset all functionnality of the device""" + with ctx.connect_device() as device: + device.factory_reset_app(application) + @nk3.command() @click.pass_obj diff --git a/pynitrokey/nk3/admin_app.py b/pynitrokey/nk3/admin_app.py index 2a1a87e4..b785ddbd 100644 --- a/pynitrokey/nk3/admin_app.py +++ b/pynitrokey/nk3/admin_app.py @@ -19,6 +19,7 @@ class AdminCommand(Enum): GET_CONFIG = 0x82 SET_CONFIG = 0x83 FACTORY_RESET = 0x84 + FACTORY_RESET_APP = 0x85 @enum.unique @@ -186,3 +187,7 @@ def factory_reset(self) -> None: else: raise e FactoryResetStatus.check(reply[0], "Failed to factory reset the device") + def factory_reset_app(self, application) -> None: + reply = self._call(AdminCommand.FACTORY_RESET_APP, data=application.encode("ascii"), response_len=1) + assert reply + FactoryResetStatus.check(reply[0], "Failed to factory reset the device") diff --git a/pynitrokey/nk3/device.py b/pynitrokey/nk3/device.py index a7defe12..f73d41f9 100644 --- a/pynitrokey/nk3/device.py +++ b/pynitrokey/nk3/device.py @@ -117,6 +117,9 @@ def version(self) -> Version: def factory_reset(self) -> None: self.admin.factory_reset() + def factory_reset_app(self, app: str) -> None: + self.admin.factory_reset_app(app) + def wink(self) -> None: self.device.wink()