Attempt to fix change of key attributes during smartcard key creation
This commit is contained in:
parent
1e05b7999e
commit
d00e27ad2e
|
@ -102,11 +102,10 @@ public class SecurityTokenChangeKeyTokenOp {
|
|||
try {
|
||||
secretKey.unlock(passphrase);
|
||||
|
||||
byte[] attributesForSecretKey = createAttributesForSecretKey(slot, secretKey);
|
||||
setKeyAttributes(adminPin, slot, attributesForSecretKey);
|
||||
|
||||
OpenPgpCapabilities openPgpCapabilities = connection.getOpenPgpCapabilities();
|
||||
|
||||
setKeyAttributes(adminPin, slot, SecurityTokenUtils.attributesFromSecretKey(slot, secretKey,
|
||||
openPgpCapabilities.getFormatForKeyType(slot)));
|
||||
|
||||
KeyFormat formatForKeyType = openPgpCapabilities.getFormatForKeyType(slot);
|
||||
switch (formatForKeyType.keyFormatType()) {
|
||||
case RSAKeyFormatType:
|
||||
|
@ -152,6 +151,13 @@ public class SecurityTokenChangeKeyTokenOp {
|
|||
}
|
||||
}
|
||||
|
||||
private byte[] createAttributesForSecretKey(KeyType slot, CanonicalizedSecretKey secretKey) throws IOException {
|
||||
OpenPgpCapabilities openPgpCapabilities = connection.getOpenPgpCapabilities();
|
||||
KeyFormat formatForKeyType = openPgpCapabilities.getFormatForKeyType(slot);
|
||||
|
||||
return SecurityTokenUtils.attributesFromSecretKey(slot, secretKey, formatForKeyType);
|
||||
}
|
||||
|
||||
private void setKeyAttributes(Passphrase adminPin, KeyType keyType, byte[] data) throws IOException {
|
||||
if (!connection.getOpenPgpCapabilities().isAttributesChangable()) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue