Skip to content

Commit

Permalink
Reuse Booleans methods in Exportable signature subpacket
Browse files Browse the repository at this point in the history
  • Loading branch information
vanitasvitae committed Jan 27, 2024
1 parent d84673c commit cd4efec
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions pg/src/main/java/org/bouncycastle/bcpg/sig/Exportable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 is intended to be exportable.
*/
public class Exportable
extends SignatureSubpacket
{
private static byte[] booleanToByteArray(
boolean value)
{
byte[] data = new byte[1];

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

{
public Exportable(
boolean critical,
boolean isLongLength,
Expand All @@ -37,11 +22,11 @@ public Exportable(
boolean critical,
boolean isExportable)
{
super(SignatureSubpacketTags.EXPORTABLE, critical, false, booleanToByteArray(isExportable));
super(SignatureSubpacketTags.EXPORTABLE, critical, false, Booleans.toByteArray(isExportable));
}

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

0 comments on commit cd4efec

Please sign in to comment.