From 461e5fd123e1b1bd758b7effc4dff8a0b7838397 Mon Sep 17 00:00:00 2001 From: Arnaud Fontaine Date: Wed, 22 Sep 2021 15:06:32 +0200 Subject: [PATCH] Fix issue #39: no RSA key import with format 1 by default --- src/fr/anssi/smartpgp/Common.java | 2 +- src/fr/anssi/smartpgp/Constants.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fr/anssi/smartpgp/Common.java b/src/fr/anssi/smartpgp/Common.java index 317a99a..c4d04de 100644 --- a/src/fr/anssi/smartpgp/Common.java +++ b/src/fr/anssi/smartpgp/Common.java @@ -160,7 +160,7 @@ public final class Common { protected static final short writeAlgorithmInformation(final byte key_tag, final byte[] buf, short off) { for(short m = 2; m <= 4; ++m) { - for(byte form = 1; form <= 3; form += 2) { + for(byte form = Constants.RSA_IMPORT_SUPPORTS_FORMAT_1 ? 1 : 3; form <= 3; form += 2) { buf[off++] = key_tag; buf[off++] = (byte)6; /* len */ buf[off++] = (byte)0x01; /* RSA */ diff --git a/src/fr/anssi/smartpgp/Constants.java b/src/fr/anssi/smartpgp/Constants.java index 9887a50..c0b42e2 100644 --- a/src/fr/anssi/smartpgp/Constants.java +++ b/src/fr/anssi/smartpgp/Constants.java @@ -224,4 +224,6 @@ public final class Constants { protected static final short AES_BLOCK_SIZE = (short)16; + protected static final boolean RSA_IMPORT_SUPPORTS_FORMAT_1 = false; + }