diff --git a/crypto/src/bcpg/sig/Features.cs b/crypto/src/bcpg/sig/Features.cs
index 29584239a..135d7f54e 100644
--- a/crypto/src/bcpg/sig/Features.cs
+++ b/crypto/src/bcpg/sig/Features.cs
@@ -10,25 +10,40 @@ namespace Org.BouncyCastle.Bcpg.Sig
public class Features
: SignatureSubpacket
{
- /** Identifier for the modification detection feature */
- public static readonly byte FEATURE_MODIFICATION_DETECTION = 1;
+ /** Identifier for the Modification Detection (packets 18 and 19) */
+ public static readonly byte FEATURE_MODIFICATION_DETECTION = 0x01;
+ /** Identifier for the AEAD Encrypted Data Packet (packet 20) and version 5
+ Symmetric-Key Encrypted Session Key Packets (packet 3) */
+ public static readonly byte FEATURE_AEAD_ENCRYPTED_DATA = 0x02;
+ /** Identifier for the Version 5 Public-Key Packet format and corresponding new
+ fingerprint format */
+ public static readonly byte FEATURE_VERSION_5_PUBLIC_KEY = 0x04;
- private static byte[] FeatureToByteArray(byte feature)
+ private static byte[] featureToByteArray(byte feature)
{
- return new byte[]{ feature };
+ byte[] data = new byte[1];
+ data[0] = feature;
+ return data;
}
public Features(
- bool critical,
- bool isLongLength,
- byte[] data)
- : base(SignatureSubpacketTag.Features, critical, isLongLength, data)
+ bool critical,
+ bool isLongLength,
+ byte[] data): base(SignatureSubpacketTag.Features, critical, isLongLength, data)
{
+
+ }
+
+
+ public Features(bool critical, byte features): this(critical, false, featureToByteArray(features))
+ {
+
}
+
- public Features(bool critical, byte feature)
- : base(SignatureSubpacketTag.Features, critical, false, FeatureToByteArray(feature))
+ public Features(bool critical, int features): this(critical, false, featureToByteArray((byte)features))
{
+
}
/**
@@ -44,32 +59,7 @@ namespace Org.BouncyCastle.Bcpg.Sig
*/
public bool SupportsFeature(byte feature)
{
- return Array.IndexOf(data, feature) >= 0;
- }
-
- /**
- * Sets support for a particular feature.
- */
- private void SetSupportsFeature(byte feature, bool support)
- {
- if (feature == 0)
- throw new ArgumentException("cannot be 0", "feature");
-
- int i = Array.IndexOf(data, feature);
- if ((i >= 0) == support)
- return;
-
- if (support)
- {
- data = Arrays.Append(data, feature);
- }
- else
- {
- byte[] temp = new byte[data.Length - 1];
- Array.Copy(data, 0, temp, 0, i);
- Array.Copy(data, i + 1, temp, i, temp.Length - i);
- data = temp;
- }
+ return (data[0] & feature) != 0;
}
}
}
|