Skip to content

Commit

Permalink
Properly parse and set PreferredAEADCipherSuites subpacket
Browse files Browse the repository at this point in the history
  • Loading branch information
vanitasvitae committed Aug 26, 2024
1 parent 7324d9a commit 813419f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.bouncycastle.bcpg.sig.KeyFlags;
import org.bouncycastle.bcpg.sig.NotationData;
import org.bouncycastle.bcpg.sig.PolicyURI;
import org.bouncycastle.bcpg.sig.PreferredAEADCiphersuites;
import org.bouncycastle.bcpg.sig.PreferredAlgorithms;
import org.bouncycastle.bcpg.sig.PrimaryUserID;
import org.bouncycastle.bcpg.sig.RegularExpression;
Expand Down Expand Up @@ -196,10 +197,9 @@ public void setPreferredCompressionAlgorithms(boolean isCritical, int[] algorith
* @param isCritical true if should be treated as critical, false otherwise.
* @param algorithms array of algorithms in descending preference
*/
public void setPreferredAEADAlgorithms(boolean isCritical, int[] algorithms)
public void setPreferredAEADAlgorithms(boolean isCritical, PreferredAEADCiphersuites.Combination[] algorithms)
{
packets.add(new PreferredAlgorithms(SignatureSubpacketTags.PREFERRED_AEAD_ALGORITHMS, isCritical,
algorithms));
packets.add(new PreferredAEADCiphersuites(isCritical, algorithms));
}

public void addPolicyURI(boolean isCritical, String policyUri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.bouncycastle.bcpg.sig.KeyFlags;
import org.bouncycastle.bcpg.sig.NotationData;
import org.bouncycastle.bcpg.sig.PolicyURI;
import org.bouncycastle.bcpg.sig.PreferredAEADCiphersuites;
import org.bouncycastle.bcpg.sig.PreferredAlgorithms;
import org.bouncycastle.bcpg.sig.PrimaryUserID;
import org.bouncycastle.bcpg.sig.RegularExpression;
Expand Down Expand Up @@ -285,7 +286,7 @@ public int[] getPreferredCompressionAlgorithms()
return ((PreferredAlgorithms)p).getPreferences();
}

public int[] getPreferredAEADAlgorithms()
public PreferredAEADCiphersuites getPreferredAEADAlgorithms()
{
SignatureSubpacket p = this.getSubpacket(SignatureSubpacketTags.PREFERRED_AEAD_ALGORITHMS);

Expand All @@ -294,7 +295,8 @@ public int[] getPreferredAEADAlgorithms()
return null;
}

return ((PreferredAlgorithms)p).getPreferences();
PreferredAEADCiphersuites packet = (PreferredAEADCiphersuites) p;
return new PreferredAEADCiphersuites(packet.isCritical(), packet.getRawAlgorithms());
}

public int getKeyFlags()
Expand Down

0 comments on commit 813419f

Please sign in to comment.