Package org.bouncycastle.bcpg
Class FingerprintUtil
java.lang.Object
org.bouncycastle.bcpg.FingerprintUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longkeyIdFromFingerprint(int keyVersion, byte[] fingerprint) Derive a key-id from the given key fingerprint.static longkeyIdFromLibrePgpFingerprint(byte[] v5Fingerprint) Derive a 64 bit key-id from a version 5 LibrePGP fingerprint.static longkeyIdFromV4Fingerprint(byte[] v4Fingerprint) Derive a 64 bit key-id from a version 4 OpenPGP fingerprint.static longkeyIdFromV6Fingerprint(byte[] v6Fingerprint) Derive a 64 bit key-id from a version 6 OpenPGP fingerprint.static longlongFromLeftMostBytes(byte[] bytes) Convert the left-most 8 bytes from the given array to a long.static longlongFromRightMostBytes(byte[] bytes) Convert the right-most 8 bytes from the given array to a long.static StringprettifyFingerprint(byte[] fingerprint) static longreadKeyID(byte[] bytes) Read a key-ID from the first 8 octets of the given byte array.static longreadKeyID(byte[] bytes, int offset) Read a key-ID from 8 octets of the given byte array starting at offset.static voidwriteKeyID(long keyID, byte[] bytes) Write the key-ID to the first 8 octets of the given byte array.static voidwriteKeyID(long keyID, byte[] bytes, int offset) Write the key-ID encoded as 8 octets to the given byte array, starting at index offset.
-
Constructor Details
-
FingerprintUtil
public FingerprintUtil()
-
-
Method Details
-
keyIdFromFingerprint
public static long keyIdFromFingerprint(int keyVersion, byte[] fingerprint) Derive a key-id from the given key fingerprint. This method can derive key-ids from v4, v5 (LibrePGP) and v6 keys. For keys with other versions (2,3) it will return 0.- Parameters:
keyVersion- version of the keyfingerprint- fingerprint of the key- Returns:
- derived key-id
-
keyIdFromV6Fingerprint
public static long keyIdFromV6Fingerprint(byte[] v6Fingerprint) Derive a 64 bit key-id from a version 6 OpenPGP fingerprint. For v6 keys, the key-id corresponds to the left-most 8 octets of the fingerprint.- Parameters:
v6Fingerprint- 32 byte fingerprint- Returns:
- key-id
-
keyIdFromLibrePgpFingerprint
public static long keyIdFromLibrePgpFingerprint(byte[] v5Fingerprint) Derive a 64 bit key-id from a version 5 LibrePGP fingerprint. For such keys, the key-id corresponds to the left-most 8 octets of the fingerprint.- Parameters:
v5Fingerprint- 32 byte fingerprint- Returns:
- key-id
-
keyIdFromV4Fingerprint
public static long keyIdFromV4Fingerprint(byte[] v4Fingerprint) Derive a 64 bit key-id from a version 4 OpenPGP fingerprint. For v4 keys, the key-id corresponds to the right-most 8 octets of the fingerprint.- Parameters:
v4Fingerprint- 20 byte fingerprint- Returns:
- key-id
-
longFromLeftMostBytes
public static long longFromLeftMostBytes(byte[] bytes) Convert the left-most 8 bytes from the given array to a long.- Parameters:
bytes- bytes- Returns:
- long
-
longFromRightMostBytes
public static long longFromRightMostBytes(byte[] bytes) Convert the right-most 8 bytes from the given array to a long.- Parameters:
bytes- bytes- Returns:
- long
-
readKeyID
public static long readKeyID(byte[] bytes) Read a key-ID from the first 8 octets of the given byte array.- Parameters:
bytes- byte array- Returns:
- key-ID
-
readKeyID
public static long readKeyID(byte[] bytes, int offset) Read a key-ID from 8 octets of the given byte array starting at offset.- Parameters:
bytes- byte arrayoffset- offset- Returns:
- key-ID
-
writeKeyID
public static void writeKeyID(long keyID, byte[] bytes, int offset) Write the key-ID encoded as 8 octets to the given byte array, starting at index offset.- Parameters:
keyID- keyIDbytes- byte arrayoffset- starting offset
-
writeKeyID
public static void writeKeyID(long keyID, byte[] bytes) Write the key-ID to the first 8 octets of the given byte array.- Parameters:
keyID- keyIDbytes- byte array
-
prettifyFingerprint
-