Class KeyGrip
java.lang.Object
org.eclipse.jgit.gpg.bc.internal.keys.KeyGrip
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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
getKeyGrip
(org.bouncycastle.openpgp.PGPPublicKey publicKey) Computes the keygrip for aPGPPublicKey
.private static org.bouncycastle.asn1.x9.X9ECParameters
getX9Parameters
(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOID) private static void
private static void
(package private) static byte[]
hashCurve25519
(SHA1 grip, BigInteger q) Computes the keygrip for a curve25519 public key.(package private) static byte[]
hashEd25519
(SHA1 grip, BigInteger q) Computes the keygrip for an ed25519 public key.private static void
hashQ25519
(SHA1 grip, BigInteger q)
-
Field Details
-
OID_OPENPGP_ED25519
-
OID_RFC8410_CURVE25519
-
OID_RFC8410_ED25519
-
CURVE25519
private static org.bouncycastle.asn1.ASN1ObjectIdentifier CURVE25519
-
-
Constructor Details
-
KeyGrip
private KeyGrip()
-
-
Method Details
-
getKeyGrip
@NonNull public static byte[] getKeyGrip(org.bouncycastle.openpgp.PGPPublicKey publicKey) throws org.bouncycastle.openpgp.PGPException Computes the keygrip for aPGPPublicKey
.- Parameters:
publicKey
- to get the keygrip of- Returns:
- the keygrip
- Throws:
org.bouncycastle.openpgp.PGPException
- if an unknown key type is encountered.
-
hash
-
hash
-
hashQ25519
private static void hashQ25519(SHA1 grip, BigInteger q) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
hashEd25519
Computes the keygrip for an ed25519 public key.Package-visible for tests only.
- Parameters:
grip
- initializedSHA1
q
- the public key's EC point- Returns:
- the keygrip
- Throws:
org.bouncycastle.openpgp.PGPException
- if q indicates uncompressed format
-
hashCurve25519
Computes the keygrip for a curve25519 public key.Package-visible for tests only.
- Parameters:
grip
- initializedSHA1
q
- the public key's EC point- Returns:
- the keygrip
- Throws:
org.bouncycastle.openpgp.PGPException
- if q indicates uncompressed format
-
getX9Parameters
private static org.bouncycastle.asn1.x9.X9ECParameters getX9Parameters(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOID)
-