This PowerShell script takes a public PGP key and calculates it's fingerprint, then it evaluates whether the public PGP key's fingerprint matches a known fingerprint.
This script uses BouncyCastle.NetFramework (also bc-chsarp).
The PowerShell snippet below will make the script available in the current PowerShell session.
The first time you run PGPEncrypt-Message it will install BouncyCastle.NetFramework.
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
iex (irm https://raw.githubusercontent.com/nstevens1040/PGPVerify-Fingerprint/main/PGPVerify-Fingerprint.ps1)
NAME
PGPVerify-Fingerprint
SYNTAX
PGPVerify-Fingerprint [-recipient_public_key] <string> [-known_fingerprint] <string> [<CommonParameters>]
PARAMETERS
-known_fingerprint <string>
Required? true
Position? 1
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
-recipient_public_key <string>
Required? true
Position? 0
Accept pipeline input? false
Parameter set name (All)
Aliases None
Dynamic? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
None
OUTPUTS
System.Object
ALIASES
None
REMARKS
None
PGPVerify-Fingerprint -recipient_public_key @"
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQGNBGI9mb8BDAC1DyXNrAJPU8NSHVWEsDDax7nZyG3+tYzSqNuFzpbreb3MU1Hh
m94FYy9H46vF8AKs1CzAW0dxuTIcM4zcpw+NQCJ24NxsgxqXMsd6a64+H6sMLBdS
uU+vZcwMOr+7bvlSLYRYMrs45Kfta+KIzE7BZ8uh1Jqkk/ybRV1M4RxiE/65uPYF
z1Hxk85LhwZhqw63mzh7ALp3GRodEECVKSPjopbAeexHNPgWh2Qc0cN8U8TQFltF
qhW3NxBIGHv9kaaLuKghaGLqM/tsU9hk6LkvD8L/yj2SnNeRmbFM6n6Qek28S0gG
tM2bOIxI860PQEuTBEH6vzY+Zpx9W4+5qgDKHH1OJZ0rGNv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