Class KeyGrip


  • public final class KeyGrip
    extends Object
    Utilities to compute the keygrip of a key. A keygrip is a SHA1 hash over the public key parameters and is used internally by the gpg-agent to find the secret key belonging to a public key: the secret key is stored in a file under ~/.gnupg/private-keys-v1.d/ with a name "<keygrip>.key". While this storage organization is an implementation detail of GPG, the way keygrips are computed is not; they are computed by libgcrypt and their definition is stable.
    • Method Detail

      • getKeyGrip

        @NonNull
        public static byte[] getKeyGrip​(org.bouncycastle.openpgp.PGPPublicKey publicKey)
                                 throws org.bouncycastle.openpgp.PGPException
        Computes the keygrip for a PGPPublicKey.
        Parameters:
        publicKey - to get the keygrip of
        Returns:
        the keygrip
        Throws:
        org.bouncycastle.openpgp.PGPException - if an unknown key type is encountered.