PGP – Public Key – Viewing Metadata

Background

Let us quickly touch on tools we can use to view information in Public keys.

Tools

Outline

  1. OpenPGP
    • GPG4Win
      • GNU Private Assistant
  2. PGP Corporation
    • PGP Command Line
      • PGP

In depth

GPG4Win

GNU Private Assistant

Outline
  1. Load Public key
  2. Select Public Key
  3. View Key Information
Images
Image – Key Manager

KeyManager.20190211.0314PM.PNG

PGP Corporation

PGP Command Line

Outline
Syntax
Syntax – Display Key

pgp.exe --list-packets [keyfile]

Syntax – Display Key – Grep on Key ID

pgp.exe --list-packets [keyfile] | find /I "Key ID"<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>

Output
>"F:\PGP Corporation\PGP Command Line"\pgp.exe --list-packets Prod_public.asc | find /I "Key ID"
        Key ID - 0xB7587153C4818072
        Sub: issuer key ID(sub 16)(8 bytes)
                Key ID - 0xB7587153C4818072
        Key ID - 0xF91B56A899D9CBEE
                Sub: issuer key ID(sub 16)(8 bytes)
                        Key ID - 0xF91B56A899D9CBEE
        Sub: issuer key ID(sub 16)(8 bytes)
                Key ID - 0xB7587153C4818072
        Key ID - 0x2E9493F0BADB7C37
        Sub: issuer key ID(sub 16)(8 bytes)
                Key ID - 0x2E9493F0BADB7C37
Prod_public.asc:dump packets (0:packets decoded successfully)     Key ID - 0xD7447ADF906B1C98

                Sub: issuer key ID(sub 16)(8 bytes)
                        Key ID - 0xD7447ADF906B1C98
        Sub: issuer key ID(sub 16)(8 bytes)
                Key ID - 0x2E9493F0BADB7C37

>

Win OS / Preparing Public Key from command Line

Batch

Sample DOS Batch file for importing partner public key, creating self public key, and exporting created key

Code


setlocal

	set "_folderBin=F:\PGP Corporation\PGP Command Line"
	set "_fileBin=pgp.exe"

	set "_folderKeyPublic=pgpkeys"
	set "%_fileKeyPublicPartner=Partner PGP key_PROD_public.asc"
	set "%_fileKeyPublicSelf=Self_PGP_Keys_Prod_public.asc"

	set "_privateKeyRealID=Self_PGP_Keys_Prod "
	set "_privateKeyType=RSA"
	set "_privateKeySize=2048"
	set "_privateKeyPassphrase=lovejones"

	REM Import Public Key Partner
	"%_folderBin%"\%_fileBin% --import "%_folderKeyPublic%\%_fileKeyPublicPartner%"

	REM List Keys
	"%_folderBin%"\%_fileBin%  --list-keys

	REM Generate Key
	"%_folderBin%"\%_fileBin% --gen-key "%_privateKeyRealID%" --key-type %_privateKeyType% --bits %_privateKeySize% --passphrase %_privateKeyPassphrase%

	REM Export Public Key Self
	"%_folderBin%"\%_fileBin% --export "%_privateKeyRealID%" --output "%_folderKeyPublic%\%_fileKeyPublicSelf%"

endlocal