
org.spongycastle.bcpg.sig.RevocationReason 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;
import org.spongycastle.util.Strings;
/**
* Represents revocation reason OpenPGP signature sub packet.
*/
public class RevocationReason extends SignatureSubpacket
{
public RevocationReason(boolean isCritical, boolean isLongLength, byte[] data)
{
super(SignatureSubpacketTags.REVOCATION_REASON, isCritical, isLongLength, data);
}
public RevocationReason(boolean isCritical, byte reason, String description)
{
super(SignatureSubpacketTags.REVOCATION_REASON, isCritical, false, createData(reason, description));
}
private static byte[] createData(byte reason, String description)
{
byte[] descriptionBytes = Strings.toUTF8ByteArray(description);
byte[] data = new byte[1 + descriptionBytes.length];
data[0] = reason;
System.arraycopy(descriptionBytes, 0, data, 1, descriptionBytes.length);
return data;
}
public byte getRevocationReason()
{
return getData()[0];
}
public String getRevocationDescription()
{
byte[] data = getData();
if (data.length == 1)
{
return "";
}
byte[] description = new byte[data.length - 1];
System.arraycopy(data, 1, description, 0, description.length);
return Strings.fromUTF8ByteArray(description);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy