CryptPasswordDialog*passDlg=newCryptPasswordDialog(this,i18n("Enter the new LUKS password for key slot %1").arg(lvi->text(0)));
CryptPasswordDialog*passDlg=newCryptPasswordDialog(this,i18n("Enter the new LUKS password for key slot %1").arg(key_slot),TQString::null,allow_card,card_cert,&use_card);
if(passDlg->exec()==TQDialog::Accepted){
if(passDlg->exec()==TQDialog::Accepted){
new_password=passDlg->password();
new_password=passDlg->password();
if(allow_card&&use_card){
// Create new private key for disk device
if(!TQDir("/etc/trinity/luks").exists()){
TQDirdirectory;
if(!directory.mkdir("/etc/trinity/luks",true)){
KMessageBox::error(this,i18n("<qt><b>Key creation failed</b><br>Please check that you have write access to /etc/trinity and try again</qt>"),i18n("Key creation failure"));
KMessageBox::error(this,i18n("<qt><b>Key creation failed</b><br>Please check that you have write access to /etc/trinity/luks and try again</qt>"),i18n("Key creation failure"));
if(KMessageBox::warningYesNo(this,i18n("<qt><b>You are about to overwrite an existing card key for LUKS key slot %1</b><br>This action cannot be undone<p>Are you sure you want to proceed?</qt>").arg(key_slot),i18n("Confirmation Required"))!=KMessageBox::Yes){
deletecard_cert;
return;
}
}
if(file.open(IO_WriteOnly)){
TQByteArrayrandomKey;
TQByteArrayencryptedRandomKey;
// Create a new secret key using the public key from the card certificate
KMessageBox::error(this,i18n("<qt><b>Key creation failed</b><br>Unable to create new secret key using the provided X509 certificate</qt>"),i18n("Key creation failure"));
KMessageBox::error(this,i18n("<qt><b>Key creation failed</b><br>Please check that you have write access to /etc/trinity/luks/card and try again</qt>"),i18n("Key creation failure"));
deletecard_cert;
return;
}
}
deletepassDlg;
deletepassDlg;
if(!sdevice->cryptOperationsUnlockPasswordSet()){
if(!sdevice->cryptOperationsUnlockPasswordSet()){
TQCStringpassword;
TQCStringpassword;
passDlg=newCryptPasswordDialog(this,i18n("Enter the LUKS device unlock password"));
passDlg=newCryptPasswordDialog(this,i18n("Enter the LUKS device unlock password"), TQString::null,allow_card,card_cert,&use_card);
if((lvi->text(1)==sdevice->cryptKeySlotFriendlyName(TDELUKSKeySlotStatus::Inactive))||(KMessageBox::warningYesNo(this,i18n("<qt><b>You are about to overwrite the key in key slot %1</b><br>This action cannot be undone<p>Are you sure you want to proceed?</qt>").arg(lvi->text(0)),i18n("Confirmation Required"))==KMessageBox::Yes)){
if((lvi->text(1)==sdevice->cryptKeySlotFriendlyName(TDELUKSKeySlotStatus::Inactive))||(KMessageBox::warningYesNo(this,i18n("<qt><b>You are about to overwrite the key in key slot %1</b><br>This action cannot be undone<p>Are you sure you want to proceed?</qt>").arg(key_slot),i18n("Confirmation Required"))==KMessageBox::Yes)){
if(KMessageBox::warningYesNo(this,i18n("<qt><b>You are about to purge the key in key slot %1</b><br>This action cannot be undone<p>Are you sure you want to proceed?</qt>").arg(lvi->text(0)),i18n("Confirmation Required"))==KMessageBox::Yes){
if(KMessageBox::warningYesNo(this,i18n("<qt><b>You are about to purge the key in key slot %1</b><br>This action cannot be undone<p>Are you sure you want to proceed?</qt>").arg(lvi->text(0)),i18n("Confirmation Required"))==KMessageBox::Yes){
if(KMessageBox::warningYesNo(this,i18n("<qt><b>You are about to purge the last active key from the device!</b><p>This action will render the contents of the encrypted device permanently inaccessable and cannot be undone<p>Are you sure you want to proceed?</qt>"),i18n("Confirmation Required"))!=KMessageBox::Yes){
if(KMessageBox::warningYesNo(this,i18n("<qt><b>You are about to purge the last active key from the device!</b><p>This action will render the contents of the encrypted device permanently inaccessable and cannot be undone<p>Are you sure you want to proceed?</qt>"),i18n("Confirmation Required"))!=KMessageBox::Yes){
KMessageBox::error(this,i18n("<qt><b>Key purge failed</b><br>The key in key slot %1 is still active</qt>").arg(lvi->text(0)),i18n("Key purge failure"));
KMessageBox::error(this,i18n("<qt><b>Key purge failed</b><br>The key in key slot %1 is still active</qt>").arg(lvi->text(0)),i18n("Key purge failure"));
}
}
else{
// See if there was a cryptographic card key associated with this device and slot
// Parse the file name and find the matching key slot
intcurrent_card_keyslot=-1;
TQStringfileName=luksKeyFileInfo->absFilePath();
TQStringfileNameSlot=fileName;
intpos=fileNameSlot.find("_slot");
if(pos>=0){
fileNameSlot.remove(0,pos+strlen("_slot"));
current_card_keyslot=fileNameSlot.toInt();
if(current_card_keyslot>=0){
if((unsignedint)current_card_keyslot==key_slot){
if(!TQFile(fileName).remove()){
KMessageBox::error(this,i18n("<qt><b>Card key purge failed</b><br>The card key for slot %1 has been fully deactivated but is still present on your system<br>This does not present a significant security risk</qt>").arg(lvi->text(0)),i18n("Key purge failure"));