Bouncy Castle Cryptography Library 1.85

org.bouncycastle.gpg
Class KeyGripCalculator

java.lang.Object
  extended byorg.bouncycastle.gpg.KeyGripCalculator

public class KeyGripCalculator
extends java.lang.Object

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 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 (SHA-1 of the canonical unsigned big-endian encoding of the modulus n).


Constructor Summary
KeyGripCalculator(PGPDigestCalculator digestCalculator)
           
 
Method Summary
 byte[] calculateKeygrip(BCPGKey key)
          Compute the keygrip for the supplied PGP public-key material.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyGripCalculator

public KeyGripCalculator(PGPDigestCalculator digestCalculator)
Parameters:
digestCalculator - a SHA-1 digest calculator used to compute the keygrip.
Method Detail

calculateKeygrip

public byte[] calculateKeygrip(BCPGKey key)
                        throws java.io.IOException
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:
java.io.IOException - if writing to the digest calculator fails.
java.lang.IllegalArgumentException - if no keygrip algorithm is registered for the key type.

Bouncy Castle Cryptography Library 1.85