Class KeyGrip
- java.lang.Object
-
- org.eclipse.jgit.gpg.bc.internal.keys.KeyGrip
-
public final class KeyGrip extends java.lang.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.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
OID_OPENPGP_ED25519
private static java.lang.String
OID_RFC8410_CURVE25519
private static java.lang.String
OID_RFC8410_ED25519
-
Constructor Summary
Constructors Modifier Constructor Description private
KeyGrip()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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
hash(SHA1 grip, byte[] data)
private static void
hash(SHA1 grip, byte[] data, char id, boolean zeroPad)
(package private) static byte[]
hashCurve25519(SHA1 grip, java.math.BigInteger q)
Computes the keygrip for a curve25519 public key.(package private) static byte[]
hashEd25519(SHA1 grip, java.math.BigInteger q)
Computes the keygrip for an ed25519 public key.private static void
hashQ25519(SHA1 grip, java.math.BigInteger q)
-
-
-
Method Detail
-
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
private static void hash(SHA1 grip, byte[] data)
-
hash
private static void hash(SHA1 grip, byte[] data, char id, boolean zeroPad)
-
hashQ25519
private static void hashQ25519(SHA1 grip, java.math.BigInteger q) throws org.bouncycastle.openpgp.PGPException
- Throws:
org.bouncycastle.openpgp.PGPException
-
hashEd25519
static byte[] hashEd25519(SHA1 grip, java.math.BigInteger q) throws org.bouncycastle.openpgp.PGPException
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
static byte[] hashCurve25519(SHA1 grip, java.math.BigInteger q) throws org.bouncycastle.openpgp.PGPException
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)
-
-