Top Constructors Methods
org.bouncycastle.bcpg

public Class FingerprintUtil

extends Object
Class Inheritance
Imports
org.bouncycastle.util.Pack, org.bouncycastle.util.encoders.Hex

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static long

Returns:

derived key-id
keyIdFromFingerprint
(int
version of the key
keyVersion
,
byte[]
fingerprint of the key
fingerprint
)

Derive a key-id from the given key fingerprint.

public static long

Returns:

key-id
keyIdFromLibrePgpFingerprint
(byte[]
32 byte fingerprint
v5Fingerprint
)

Derive a 64 bit key-id from a version 5 LibrePGP fingerprint.

public static long

Returns:

key-id
keyIdFromV4Fingerprint
(byte[]
20 byte fingerprint
v4Fingerprint
)

Derive a 64 bit key-id from a version 4 OpenPGP fingerprint.

public static long

Returns:

key-id
keyIdFromV6Fingerprint
(byte[]
32 byte fingerprint
v6Fingerprint
)

Derive a 64 bit key-id from a version 6 OpenPGP fingerprint.

public static long

Returns:

long
longFromLeftMostBytes
(byte[]
bytes
bytes
)

Convert the left-most 8 bytes from the given array to a long.

public static long

Returns:

long
longFromRightMostBytes
(byte[]
bytes
bytes
)

Convert the right-most 8 bytes from the given array to a long.

public static String
prettifyFingerprint(byte[] fingerprint)

public static long

Returns:

key-ID
readKeyID
(byte[]
byte array
bytes
)

Read a key-ID from the first 8 octets of the given byte array.

public static long

Returns:

key-ID
readKeyID
(byte[]
byte array
bytes
,
int
offset
offset
)

Read a key-ID from 8 octets of the given byte array starting at offset.

public static void
writeKeyID(long
keyID
keyID
,
byte[]
byte array
bytes
,
int
starting offset
offset
)

Write the key-ID encoded as 8 octets to the given byte array, starting at index offset.

public static void
writeKeyID(long
keyID
keyID
,
byte[]
byte array
bytes
)

Write the key-ID to the first 8 octets of the given byte array.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

FingerprintUtilback to summary
public FingerprintUtil()

Method Detail

keyIdFromFingerprintback to summary
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:int

version of the key

fingerprint:byte[]

fingerprint of the key

Returns:long

derived key-id

keyIdFromLibrePgpFingerprintback to summary
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:byte[]

32 byte fingerprint

Returns:long

key-id

keyIdFromV4Fingerprintback to summary
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:byte[]

20 byte fingerprint

Returns:long

key-id

keyIdFromV6Fingerprintback to summary
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:byte[]

32 byte fingerprint

Returns:long

key-id

longFromLeftMostBytesback to summary
public static long longFromLeftMostBytes(byte[] bytes)

Convert the left-most 8 bytes from the given array to a long.

Parameters
bytes:byte[]

bytes

Returns:long

long

longFromRightMostBytesback to summary
public static long longFromRightMostBytes(byte[] bytes)

Convert the right-most 8 bytes from the given array to a long.

Parameters
bytes:byte[]

bytes

Returns:long

long

prettifyFingerprintback to summary
public static String prettifyFingerprint(byte[] fingerprint)
readKeyIDback to summary
public static long readKeyID(byte[] bytes)

Read a key-ID from the first 8 octets of the given byte array.

Parameters
bytes:byte[]

byte array

Returns:long

key-ID

readKeyIDback to summary
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[]

byte array

offset:int

offset

Returns:long

key-ID

writeKeyIDback to summary
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:long

keyID

bytes:byte[]

byte array

offset:int

starting offset

writeKeyIDback to summary
public static void writeKeyID(long keyID, byte[] bytes)

Write the key-ID to the first 8 octets of the given byte array.

Parameters
keyID:long

keyID

bytes:byte[]

byte array