From e4a741479433c58e888e91b3fcea2d66dd011f09 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 24 Sep 2014 12:30:07 +0200 Subject: fix Le fields in APDUs --- .../java/org/sufficientlysecure/keychain/ui/NfcActivity.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcActivity.java index 10c111333..3dc31ee24 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/NfcActivity.java @@ -299,7 +299,7 @@ public class NfcActivity extends ActionBarActivity { if (hash.length != 20) { throw new RuntimeException("Bad hash length (" + hash.length + ", expected 10!"); } - dsi = "30" // Lc TODO 0x30 == 48. shouldn't this be 35, for 15 header bytes + 20 hash? + dsi = "23" // Lc + "3021" // Tag/Length of Sequence, the 0x21 includes all following 33 bytes + "3009" // Tag/Length of Sequence, the 0x09 are the following header bytes + "0605" + "2B0E03021A" // OID of SHA1 @@ -310,13 +310,13 @@ public class NfcActivity extends ActionBarActivity { if (hash.length != 20) { throw new RuntimeException("Bad hash length (" + hash.length + ", expected 20!"); } - dsi = "303021300906052B2403020105000414" + getHex(hash); + dsi = "233021300906052B2403020105000414" + getHex(hash); break; case HashAlgorithmTags.SHA224: if (hash.length != 28) { throw new RuntimeException("Bad hash length (" + hash.length + ", expected 28!"); } - dsi = "34302D300D06096086480165030402040500041C" + getHex(hash); + dsi = "2F302D300D06096086480165030402040500041C" + getHex(hash); break; case HashAlgorithmTags.SHA256: if (hash.length != 32) { @@ -328,13 +328,13 @@ public class NfcActivity extends ActionBarActivity { if (hash.length != 48) { throw new RuntimeException("Bad hash length (" + hash.length + ", expected 48!"); } - dsi = "343041300D060960864801650304020205000430" + getHex(hash); + dsi = "433041300D060960864801650304020205000430" + getHex(hash); break; case HashAlgorithmTags.SHA512: if (hash.length != 64) { throw new RuntimeException("Bad hash length (" + hash.length + ", expected 64!"); } - dsi = "343051300D060960864801650304020305000440" + getHex(hash); + dsi = "533051300D060960864801650304020305000440" + getHex(hash); break; default: throw new RuntimeException("Not supported hash algo!"); @@ -369,6 +369,7 @@ public class NfcActivity extends ActionBarActivity { } // Make sure the signature we received is actually the expected number of bytes long! + // TODO this is only right for RSA 2048 bit keys. Do we support anything else right now? if (signature.length() != 512) { toast("Bad signature length! Expected 256 bytes, got " + signature.length() / 2); return null; -- cgit v1.2.3