org.spongycastle.bcpg.sig.IssuerKeyID Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pg Show documentation
Show all versions of pg Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle
intended for the Android platform. Android unfortunately ships with a stripped-down version of
Bouncy Castle, which prevents easy upgrades - Spongy Castle overcomes this and provides a full,
up-to-date version of the Bouncy Castle cryptographic libs.
The newest version!
package org.spongycastle.bcpg.sig;
import org.spongycastle.bcpg.SignatureSubpacket;
import org.spongycastle.bcpg.SignatureSubpacketTags;
/**
* packet giving signature creation time.
*/
public class IssuerKeyID
extends SignatureSubpacket
{
protected static byte[] keyIDToBytes(
long keyId)
{
byte[] data = new byte[8];
data[0] = (byte)(keyId >> 56);
data[1] = (byte)(keyId >> 48);
data[2] = (byte)(keyId >> 40);
data[3] = (byte)(keyId >> 32);
data[4] = (byte)(keyId >> 24);
data[5] = (byte)(keyId >> 16);
data[6] = (byte)(keyId >> 8);
data[7] = (byte)keyId;
return data;
}
public IssuerKeyID(
boolean critical,
boolean isLongLength,
byte[] data)
{
super(SignatureSubpacketTags.ISSUER_KEY_ID, critical, isLongLength, data);
}
public IssuerKeyID(
boolean critical,
long keyID)
{
super(SignatureSubpacketTags.ISSUER_KEY_ID, critical, false, keyIDToBytes(keyID));
}
public long getKeyID()
{
long keyID = ((long)(data[0] & 0xff) << 56) | ((long)(data[1] & 0xff) << 48) | ((long)(data[2] & 0xff) << 40) | ((long)(data[3] & 0xff) << 32)
| ((long)(data[4] & 0xff) << 24) | ((data[5] & 0xff) << 16) | ((data[6] & 0xff) << 8) | (data[7] & 0xff);
return keyID;
}
}