Package org.bouncycastle.gpg
Class KeyGripCalculator
java.lang.Object
org.bouncycastle.gpg.KeyGripCalculator
Compute the GnuPG-style "keygrip" for a public key. The keygrip is a 20-byte
SHA-1 identifier used by GnuPG 2.x to look up a key without exposing the
fingerprint, and is documented in
agent/keyformat.txt of the GnuPG
source tree.
The supplied PGPDigestCalculator must wrap SHA-1; the keygrip
algorithm is fixed by the GnuPG specification.
Currently RSA public keys are supported; the algorithm matches libgcrypt's
_gcry_rsa_compute_keygrip (SHA-1 of the canonical unsigned big-endian
encoding of the modulus n).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]calculateKeygrip(BCPGKey key) Compute the keygrip for the supplied PGP public-key material.
-
Constructor Details
-
KeyGripCalculator
- Parameters:
digestCalculator- a SHA-1 digest calculator used to compute the keygrip.
-
-
Method Details
-
calculateKeygrip
Compute the keygrip for the supplied PGP public-key material.- Parameters:
key- the BCPGKey to be hashed.- Returns:
- 20 bytes of SHA-1 output.
- Throws:
IOException- if writing to the digest calculator fails.IllegalArgumentException- if no keygrip algorithm is registered for the key type.
-