Attempt to fix change of key attributes during smartcard key creation
This commit is contained in:
@@ -102,11 +102,10 @@ public class SecurityTokenChangeKeyTokenOp {
|
|||||||
try {
|
try {
|
||||||
secretKey.unlock(passphrase);
|
secretKey.unlock(passphrase);
|
||||||
|
|
||||||
|
byte[] attributesForSecretKey = createAttributesForSecretKey(slot, secretKey);
|
||||||
|
setKeyAttributes(adminPin, slot, attributesForSecretKey);
|
||||||
|
|
||||||
OpenPgpCapabilities openPgpCapabilities = connection.getOpenPgpCapabilities();
|
OpenPgpCapabilities openPgpCapabilities = connection.getOpenPgpCapabilities();
|
||||||
|
|
||||||
setKeyAttributes(adminPin, slot, SecurityTokenUtils.attributesFromSecretKey(slot, secretKey,
|
|
||||||
openPgpCapabilities.getFormatForKeyType(slot)));
|
|
||||||
|
|
||||||
KeyFormat formatForKeyType = openPgpCapabilities.getFormatForKeyType(slot);
|
KeyFormat formatForKeyType = openPgpCapabilities.getFormatForKeyType(slot);
|
||||||
switch (formatForKeyType.keyFormatType()) {
|
switch (formatForKeyType.keyFormatType()) {
|
||||||
case RSAKeyFormatType:
|
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 {
|
private void setKeyAttributes(Passphrase adminPin, KeyType keyType, byte[] data) throws IOException {
|
||||||
if (!connection.getOpenPgpCapabilities().isAttributesChangable()) {
|
if (!connection.getOpenPgpCapabilities().isAttributesChangable()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user