diff options
author | Nikita Mikhailov <nikita.s.mikhailov@gmail.com> | 2016-04-16 01:43:13 +0600 |
---|---|---|
committer | Nikita Mikhailov <nikita.s.mikhailov@gmail.com> | 2016-04-16 11:13:57 +0600 |
commit | a87c65c3f480ae06070607f2cd0f5227012d6cd3 (patch) | |
tree | ccae34b0ea5b0c70d546fd6eb08f7af979107a3a /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken | |
parent | 163aef4c6b57c9501038e0a63408360e67ccf4a0 (diff) | |
download | open-keychain-a87c65c3f480ae06070607f2cd0f5227012d6cd3.tar.gz open-keychain-a87c65c3f480ae06070607f2cd0f5227012d6cd3.tar.bz2 open-keychain-a87c65c3f480ae06070607f2cd0f5227012d6cd3.zip |
Check if security token keys match required once before signing/decryption
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/SecurityTokenHelper.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/SecurityTokenHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/SecurityTokenHelper.java index e3f280e18..ed17fc379 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/SecurityTokenHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/SecurityTokenHelper.java @@ -131,13 +131,13 @@ public class SecurityTokenHelper { private boolean isSlotEmpty(KeyType keyType) throws IOException { // Note: special case: This should not happen, but happens with // https://github.com/FluffyKaon/OpenPGP-Card, thus for now assume true - if (getMasterKeyFingerprint(keyType.getIdx()) == null) return true; + if (getMasterKeyFingerprint(keyType) == null) return true; return keyMatchesFingerPrint(keyType, BLANK_FINGERPRINT); } public boolean keyMatchesFingerPrint(KeyType keyType, byte[] fingerprint) throws IOException { - return java.util.Arrays.equals(getMasterKeyFingerprint(keyType.getIdx()), fingerprint); + return java.util.Arrays.equals(getMasterKeyFingerprint(keyType), fingerprint); } /** @@ -723,10 +723,10 @@ public class SecurityTokenHelper { * Return the fingerprint from application specific data stored on tag, or * null if it doesn't exist. * - * @param idx Index of the key to return the fingerprint from. + * @param keyType key.operatio type * @return The fingerprint of the requested key, or null if not found. */ - public byte[] getMasterKeyFingerprint(int idx) throws IOException { + public byte[] getMasterKeyFingerprint(KeyType keyType) throws IOException { byte[] data = getFingerprints(); if (data == null) { return null; @@ -735,7 +735,7 @@ public class SecurityTokenHelper { // return the master key fingerprint ByteBuffer fpbuf = ByteBuffer.wrap(data); byte[] fp = new byte[20]; - fpbuf.position(idx * 20); + fpbuf.position(keyType.getIdx() * 20); fpbuf.get(fp, 0, 20); return fp; |