kaikramer / keystore-explorer

KeyStore Explorer is a free GUI replacement for the Java command-line utilities keytool and jarsigner.
https://keystore-explorer.org/
GNU General Public License v3.0
1.7k stars 275 forks source link

opening a PKCS#1 key it shows as PKCS#8 format #436

Closed tulsidas closed 10 months ago

tulsidas commented 1 year ago

Describe the bug The same private key, stored in PEM in both PKCS#1 & PKCS#8 format, when displayed in KeyStore Explorer it shows that both are PKCS#8 (which can be confusing)

For reference, I used the following keys:

PKCS#1

-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCjcGqTkOq0CR3rTx0ZSQSIdTrDrFAYl29611xN8aVgMQIWtDB/
lD0W5TpKPuU9iaiG/sSn/VYt6EzN7Sr332jj7cyl2WrrHI6ujRswNy4HojMuqtfa
b5FFDpRmCuvl35fge18OvoQTJELhhJ1EvJ5KUeZiuJ3u3YyMnxxXzLuKbQIDAQAB
AoGAPrNDz7TKtaLBvaIuMaMXgBopHyQd3jFKbT/tg2Fu5kYm3PrnmCoQfZYXFKCo
ZUFIS/G1FBVWWGpD/MQ9tbYZkKpwuH+t2rGndMnLXiTC296/s9uix7gsjnT4Naci
5N6EN9pVUBwQmGrYUTHFc58ThtelSiPARX7LSU2ibtJSv8ECQQDWBRrrAYmbCUN7
ra0DFT6SppaDtvvuKtb+mUeKbg0B8U4y4wCIK5GH8EyQSwUWcXnNBO05rlUPbifs
DLv/u82lAkEAw39sTJ0KmJJyaChqvqAJ8guulKlgucQJ0Et9ppZyet9iVwNKX/aW
9UlwGBMQdafQ36nd1QMEA8AbAw4D+hw/KQJBANJbHDUGQtk2hrSmZNoV5HXB9Uiq
7v4N71k5ER8XwgM5yVGs2tX8dMM3RhnBEtQXXs9LW1uJZSOQcv7JGXNnhN0CQBZe
nzrJAWxh3XtznHtBfsHWelyCYRIAj4rpCHCmaGUM6IjCVKFUawOYKp5mmAyObkUZ
f8ue87emJLEdynC1CLkCQHduNjP1hemAGWrd6v8BHhE3kKtcK6KHsPvJR5dOfzbd
HAqVePERhISfN6cwZt5p8B3/JUwSR8el66DF7Jm57BM=
-----END RSA PRIVATE KEY-----

PKCS#8

-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKNwapOQ6rQJHetP
HRlJBIh1OsOsUBiXb3rXXE3xpWAxAha0MH+UPRblOko+5T2JqIb+xKf9Vi3oTM3t
KvffaOPtzKXZauscjq6NGzA3LgeiMy6q19pvkUUOlGYK6+Xfl+B7Xw6+hBMkQuGE
nUS8nkpR5mK4ne7djIyfHFfMu4ptAgMBAAECgYA+s0PPtMq1osG9oi4xoxeAGikf
JB3eMUptP+2DYW7mRibc+ueYKhB9lhcUoKhlQUhL8bUUFVZYakP8xD21thmQqnC4
f63asad0ycteJMLb3r+z26LHuCyOdPg1pyLk3oQ32lVQHBCYathRMcVznxOG16VK
I8BFfstJTaJu0lK/wQJBANYFGusBiZsJQ3utrQMVPpKmloO2++4q1v6ZR4puDQHx
TjLjAIgrkYfwTJBLBRZxec0E7TmuVQ9uJ+wMu/+7zaUCQQDDf2xMnQqYknJoKGq+
oAnyC66UqWC5xAnQS32mlnJ632JXA0pf9pb1SXAYExB1p9Dfqd3VAwQDwBsDDgP6
HD8pAkEA0lscNQZC2TaGtKZk2hXkdcH1SKru/g3vWTkRHxfCAznJUaza1fx0wzdG
GcES1Bdez0tbW4llI5By/skZc2eE3QJAFl6fOskBbGHde3Oce0F+wdZ6XIJhEgCP
iukIcKZoZQzoiMJUoVRrA5gqnmaYDI5uRRl/y57zt6YksR3KcLUIuQJAd242M/WF
6YAZat3q/wEeETeQq1wrooew+8lHl05/Nt0cCpV48RGEhJ83pzBm3mnwHf8lTBJH
x6XroMXsmbnsEw==
-----END PRIVATE KEY-----

To Reproduce Steps to reproduce the behavior:

  1. Copy key to clipboard
  2. Press CTRL-L
  3. See format being always PKCS#8

Expected behavior I expect PKCS#1 keys to show that the format is actually PKCS#1

Screenshots For the PKCS#1 key pasted above: image

Environment

kaikramer commented 1 year ago

Thanks for taking the time to create a bug report!

The reason for this is that at the point in time when this dialog is displayed, the key is already converted into a Java key object and the internal format of the JRE is always PKCS#8.

I agree that this is confusing, especially when one uses the "Examine Clipboard" or "Examine File" feature to open the key details. I'll see what I can do about it.

tulsidas commented 1 year ago

Maybe some metadata can be passed to the Key object to be displayed which can eventually override the Key attributes. I'll take a look in the source code

El sáb., 13 de mayo de 2023 13:14, Kai Kramer @.***> escribió:

Thanks for taking the time to create a bug report!

The reason for this is that at the point in time when this dialog is displayed, the key is already converted into a Java key object and the internal format of the JRE is always PKCS#8.

I agree that this is confusing, especially when one uses the "Examine Clipboard" or "Examine File" feature to open the key details. I'll see what I can do about it.

— Reply to this email directly, view it on GitHub https://github.com/kaikramer/keystore-explorer/issues/436#issuecomment-1546702363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABPDDBJWC34MHIYBHWE4WTXF6XNNANCNFSM6AAAAAAX72TRLE . You are receiving this because you authored the thread.Message ID: @.***>

kaikramer commented 10 months ago

@tulsidas Are you working on this? If you need some guidance, just let me know.

tulsidas commented 10 months ago

Oh my! I thought this was a couple of months ago, turns out it was in May last year! 😓

I didn't do any work on this, but I pledge to do it, given how much I use KeyStore Explorer in my daily job

@kaikramer if you have any pointers on which packages I should start looking into, great, otherwise don't worry I can manage