Add set password functionality

This commit is contained in:
Dag Heyman 2017-02-10 14:01:49 +01:00
parent 5fef9d5513
commit dcfe627844
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338
4 changed files with 32 additions and 2 deletions

View File

@ -86,6 +86,18 @@ class Controller(object):
except:
return False
def set_password(self, new_password, password_key):
dev = self._descriptor.open_device(TRANSPORT.CCID)
controller = OathController(dev.driver)
if controller.locked and password_key is not None:
controller.validate(a2b_hex(password_key))
if new_password is not None:
key = derive_key(controller.id, new_password)
controller.set_password(key)
else:
controller.clear_password()
def add_credential(self, name, key, oath_type, digits, algo, touch, password_key):
dev = self._descriptor.open_device(TRANSPORT.CCID)
controller = OathController(dev.driver)

View File

@ -89,8 +89,18 @@ ApplicationWindow {
SetPassword {
id: setPassword
onAccepted: passwordUpdated.open()
}
MessageDialog {
id: passwordUpdated
icon: StandardIcon.Information
title: qsTr("Password set")
text: qsTr("A new password has been set.")
standardButtons: StandardButton.Ok
}
MouseArea {
enabled: device.hasDevice
anchors.fill: parent

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
Dialog {
id: passwordPrompt
id: setPasswordPrompt
title: qsTr("Set new password")
standardButtons: StandardButton.NoButton
@ -61,7 +61,8 @@ Dialog {
if (newPassword.text !== confirmPassword.text) {
noMatch.open()
} else {
close()
device.setPassword(newPassword.text)
accept()
}
}
}

View File

@ -110,6 +110,13 @@ Python {
})
}
function setPassword(password) {
console.log('PROVIDED PW ', password)
do_call('yubikey.controller.set_password', [password, passwordKey], function() {
validate(password)
})
}
function refreshCredentials() {
var now = Math.floor(Date.now() / 1000)