diff options
Diffstat (limited to 'nitrocli/src/commands.rs')
-rw-r--r-- | nitrocli/src/commands.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/nitrocli/src/commands.rs b/nitrocli/src/commands.rs index e3e2a14..b018a58 100644 --- a/nitrocli/src/commands.rs +++ b/nitrocli/src/commands.rs @@ -507,6 +507,20 @@ fn choose_pin(pintype: pinentry::PinType) -> Result<String> { } } +/// Change a PIN. +pub fn pin_set(pintype: pinentry::PinType) -> Result<()> { + let device = get_device()?; + let new_pin = choose_pin(pintype)?; + try_with_passphrase( + pintype, + "Could not change the PIN", + |current_pin| match pintype { + pinentry::PinType::Admin => device.change_admin_pin(¤t_pin, &new_pin), + pinentry::PinType::User => device.change_user_pin(¤t_pin, &new_pin), + }, + ) +} + /// Unblock and reset the user PIN. pub fn pin_unblock() -> Result<()> { let device = get_device()?; |