mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-16 09:22:05 +01:00
Fix HardwareSecurity.getIdsOfHardwareBackedKeys()
This commit is contained in:
parent
8c0d096fc6
commit
07320ed3cf
1 changed files with 7 additions and 5 deletions
|
@ -47,8 +47,8 @@ public class HardwareSecurity {
|
||||||
* @param secretKeys secret keys
|
* @param secretKeys secret keys
|
||||||
* @return set of keys with S2K type DIVERT_TO_CARD or GNU_DUMMY_S2K
|
* @return set of keys with S2K type DIVERT_TO_CARD or GNU_DUMMY_S2K
|
||||||
*/
|
*/
|
||||||
public static Set<Long> getIdsOfHardwareBackedKeys(PGPSecretKeyRing secretKeys) {
|
public static Set<SubkeyIdentifier> getIdsOfHardwareBackedKeys(PGPSecretKeyRing secretKeys) {
|
||||||
Set<Long> hardwareBackedKeys = new HashSet<>();
|
Set<SubkeyIdentifier> hardwareBackedKeys = new HashSet<>();
|
||||||
for (PGPSecretKey secretKey : secretKeys) {
|
for (PGPSecretKey secretKey : secretKeys) {
|
||||||
S2K s2K = secretKey.getS2K();
|
S2K s2K = secretKey.getS2K();
|
||||||
if (s2K == null) {
|
if (s2K == null) {
|
||||||
|
@ -56,9 +56,11 @@ public class HardwareSecurity {
|
||||||
}
|
}
|
||||||
|
|
||||||
int type = s2K.getType();
|
int type = s2K.getType();
|
||||||
|
int mode = s2K.getProtectionMode();
|
||||||
// TODO: Is GNU_DUMMY_S2K appropriate?
|
// TODO: Is GNU_DUMMY_S2K appropriate?
|
||||||
if (type == S2K.GNU_PROTECTION_MODE_DIVERT_TO_CARD || type == S2K.GNU_DUMMY_S2K) {
|
if (type == S2K.GNU_DUMMY_S2K && mode == S2K.GNU_PROTECTION_MODE_DIVERT_TO_CARD) {
|
||||||
hardwareBackedKeys.add(secretKey.getKeyID());
|
SubkeyIdentifier hardwareBackedKey = new SubkeyIdentifier(secretKeys, secretKey.getKeyID());
|
||||||
|
hardwareBackedKeys.add(hardwareBackedKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hardwareBackedKeys;
|
return hardwareBackedKeys;
|
||||||
|
@ -75,7 +77,7 @@ public class HardwareSecurity {
|
||||||
// luckily we can instantiate the BcPublicKeyDataDecryptorFactory with null as argument.
|
// luckily we can instantiate the BcPublicKeyDataDecryptorFactory with null as argument.
|
||||||
private final PublicKeyDataDecryptorFactory factory =
|
private final PublicKeyDataDecryptorFactory factory =
|
||||||
new BcPublicKeyDataDecryptorFactory(null);
|
new BcPublicKeyDataDecryptorFactory(null);
|
||||||
private SubkeyIdentifier subkey;
|
private final SubkeyIdentifier subkey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@link HardwareDataDecryptorFactory}.
|
* Create a new {@link HardwareDataDecryptorFactory}.
|
||||||
|
|
Loading…
Reference in a new issue