Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse Booleans methods in Revocable signature subpacket
Browse files Browse the repository at this point in the history
vanitasvitae committed Jan 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent cb1f989 commit ce31e73
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions pg/src/main/java/org/bouncycastle/bcpg/sig/Revocable.java
Original file line number Diff line number Diff line change
@@ -2,29 +2,14 @@

import org.bouncycastle.bcpg.SignatureSubpacket;
import org.bouncycastle.bcpg.SignatureSubpacketTags;
import org.bouncycastle.util.Booleans;

/**
* Signature subpacket indicating, whether the carrying signature can be revoked.
*/
public class Revocable
extends SignatureSubpacket
{
private static byte[] booleanToByteArray(
boolean value)
{
byte[] data = new byte[1];

if (value)
{
data[0] = 1;
return data;
}
else
{
return data;
}
}

{
public Revocable(
boolean critical,
boolean isLongLength,
@@ -37,11 +22,11 @@ public Revocable(
boolean critical,
boolean isRevocable)
{
super(SignatureSubpacketTags.REVOCABLE, critical, false, booleanToByteArray(isRevocable));
super(SignatureSubpacketTags.REVOCABLE, critical, false, Booleans.toByteArray(isRevocable));
}

public boolean isRevocable()
{
return data[0] != 0;
return Booleans.fromByteArray(data);
}
}

0 comments on commit ce31e73

Please sign in to comment.