@@ -10,25 +10,40 @@ namespace Org.BouncyCastle.Bcpg.Sig
10
10
public class Features
11
11
: SignatureSubpacket
12
12
{
13
- /** Identifier for the modification detection feature */
14
- public static readonly byte FEATURE_MODIFICATION_DETECTION = 1 ;
13
+ /** Identifier for the Modification Detection (packets 18 and 19) */
14
+ public static readonly byte FEATURE_MODIFICATION_DETECTION = 0x01 ;
15
+ /** Identifier for the AEAD Encrypted Data Packet (packet 20) and version 5
16
+ Symmetric-Key Encrypted Session Key Packets (packet 3) */
17
+ public static readonly byte FEATURE_AEAD_ENCRYPTED_DATA = 0x02 ;
18
+ /** Identifier for the Version 5 Public-Key Packet format and corresponding new
19
+ fingerprint format */
20
+ public static readonly byte FEATURE_VERSION_5_PUBLIC_KEY = 0x04 ;
15
21
16
- private static byte [ ] FeatureToByteArray ( byte feature )
22
+ private static byte [ ] featureToByteArray ( byte feature )
17
23
{
18
- return new byte [ ] { feature } ;
24
+ byte [ ] data = new byte [ 1 ] ;
25
+ data [ 0 ] = feature ;
26
+ return data ;
19
27
}
20
28
21
29
public Features (
22
- bool critical ,
23
- bool isLongLength ,
24
- byte [ ] data )
25
- : base ( SignatureSubpacketTag . Features , critical , isLongLength , data )
30
+ bool critical ,
31
+ bool isLongLength ,
32
+ byte [ ] data ) : base ( SignatureSubpacketTag . Features , critical , isLongLength , data )
26
33
{
34
+
35
+ }
36
+
37
+
38
+ public Features ( bool critical , byte features ) : this ( critical , false , featureToByteArray ( features ) )
39
+ {
40
+
27
41
}
42
+
28
43
29
- public Features ( bool critical , byte feature )
30
- : base ( SignatureSubpacketTag . Features , critical , false , FeatureToByteArray ( feature ) )
44
+ public Features ( bool critical , int features ) : this ( critical , false , featureToByteArray ( ( byte ) features ) )
31
45
{
46
+
32
47
}
33
48
34
49
/**
@@ -44,32 +59,7 @@ public bool SupportsModificationDetection
44
59
*/
45
60
public bool SupportsFeature ( byte feature )
46
61
{
47
- return Array . IndexOf ( data , feature ) >= 0 ;
48
- }
49
-
50
- /**
51
- * Sets support for a particular feature.
52
- */
53
- private void SetSupportsFeature ( byte feature , bool support )
54
- {
55
- if ( feature == 0 )
56
- throw new ArgumentException ( "cannot be 0" , "feature" ) ;
57
-
58
- int i = Array . IndexOf ( data , feature ) ;
59
- if ( ( i >= 0 ) == support )
60
- return ;
61
-
62
- if ( support )
63
- {
64
- data = Arrays . Append ( data , feature ) ;
65
- }
66
- else
67
- {
68
- byte [ ] temp = new byte [ data . Length - 1 ] ;
69
- Array . Copy ( data , 0 , temp , 0 , i ) ;
70
- Array . Copy ( data , i + 1 , temp , i , temp . Length - i ) ;
71
- data = temp ;
72
- }
62
+ return ( data [ 0 ] & feature ) != 0 ;
73
63
}
74
64
}
75
65
}
0 commit comments