Adding key B and deleting key A after that, making the process safe.
root@diego:~# cryptsetup luksAddKey DEVICE
Enter any LUKS passphrase:
key slot 0 unlocked.
Enter new passphrase for key slot:
Verify passphrase:
Command successful.
root@diego:~# cryptsetup luksRemoveKey DEVICE
Enter LUKS passphrase to be deleted:
key slot 0 selected for deletion.
Enter any remaining LUKS passphrase:
key slot 0 verified.
Command successful.