support odd rsa moduli on security tokens

This commit is contained in:
Vincent Breitmoser 2017-01-13 02:37:42 +01:00
parent d389ec21e2
commit a1127bdf1a

View file

@ -661,7 +661,8 @@ public class SecurityTokenHelper {
byte[] data; byte[] data;
switch (mOpenPgpCapabilities.getFormatForKeyType(KeyType.SIGN).keyFormatType()) { KeyFormat signKeyFormat = mOpenPgpCapabilities.getFormatForKeyType(KeyType.SIGN);
switch (signKeyFormat.keyFormatType()) {
case RSAKeyFormatType: case RSAKeyFormatType:
data = dsi; data = dsi;
break; break;
@ -687,11 +688,12 @@ public class SecurityTokenHelper {
byte[] signature = response.getData(); byte[] signature = response.getData();
// Make sure the signature we received is actually the expected number of bytes long! // Make sure the signature we received is actually the expected number of bytes long!
switch (mOpenPgpCapabilities.getFormatForKeyType(KeyType.SIGN).keyFormatType()) { switch (signKeyFormat.keyFormatType()) {
case RSAKeyFormatType: case RSAKeyFormatType:
if (signature.length != 128 && signature.length != 256 int modulusLength = ((RSAKeyFormat) signKeyFormat).getModulusLength();
&& signature.length != 384 && signature.length != 512) { if (signature.length != (modulusLength / 8)) {
throw new IOException("Bad signature length! Expected 128/256/384/512 bytes, got " + signature.length); throw new IOException("Bad signature length! Expected " + (modulusLength / 8) +
" bytes, got " + signature.length);
} }
break; break;