Issues (85)

src/Constants.php (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity;
6
7
/**
8
 * A collection of constants used in this library, as defined by the XMLSec set of recommendations.
9
 *
10
 * @package simplesamlphp/xml-security
11
 */
12
class Constants extends \SimpleSAML\XML\Constants
13
{
14
    /**
15
     * Symmetric key wrap algorithms
16
     */
17
    public const KEY_WRAP_3DES = 'http://www.w3.org/2001/04/xmlenc#kw-tripledes';
18
19
    public const KEY_WRAP_AES128 = 'http://www.w3.org/2001/04/xmlenc#kw-aes128';
20
21
    public const KEY_WRAP_AES192 = 'http://www.w3.org/2001/04/xmlenc#kw-aes192';
22
23
    public const KEY_WRAP_AES256 = 'http://www.w3.org/2001/04/xmlenc#kw-aes256';
24
25
    /**
26
     * Key derivation algorithms
27
     */
28
    public const KEY_DERIVATION_CONCATKDF = 'http://www.w3.org/2009/xmlenc11#ConcatKDF';
29
30
    public const KEY_DERIVATION_PBKDF2 = 'http://www.w3.org/2009/xmlenc11#pbkdf2';
31
32
    /**
33
     * Key agreement algorithms
34
     */
35
    public const KEY_AGREEMENT_ECDH_ES = 'http://www.w3.org/2009/xmlenc11#ECDH-ES';
36
37
    public const KEY_AGREEMENT_DH = 'http://www.w3.org/2001/04/xmlenc#dh';
38
39
    public const KEY_AGREEMENT_DH_ES = 'http://www.w3.org/2009/xmlenc11#dh-es';
40
41
    /**
42
     * Message digest algorithms
43
     */
44
    public const DIGEST_SHA1 = 'http://www.w3.org/2000/09/xmldsig#sha1';
45
46
    public const DIGEST_SHA224 = 'http://www.w3.org/2001/04/xmldsig-more#sha224';
47
48
    public const DIGEST_SHA256 = 'http://www.w3.org/2001/04/xmlenc#sha256';
49
50
    public const DIGEST_SHA384 = 'http://www.w3.org/2001/04/xmldsig-more#sha384';
51
52
    public const DIGEST_SHA512 = 'http://www.w3.org/2001/04/xmlenc#sha512';
53
54
    public const DIGEST_RIPEMD160 = 'http://www.w3.org/2001/04/xmlenc#ripemd160';
55
56
    /**
57
     * Padding schemas
58
     */
59
    public const PADDING_PKCS1 = "PKCS1";
60
61
    public const PADDING_PKCS1_OAEP = "OAEP";
62
63
    /**
64
     * Block encryption algorithms
65
     */
66
    public const BLOCK_ENC_3DES = 'http://www.w3.org/2001/04/xmlenc#tripledes-cbc';
67
68
    public const BLOCK_ENC_AES128 = 'http://www.w3.org/2001/04/xmlenc#aes128-cbc';
69
70
    public const BLOCK_ENC_AES192 = 'http://www.w3.org/2001/04/xmlenc#aes192-cbc';
71
72
    public const BLOCK_ENC_AES256 = 'http://www.w3.org/2001/04/xmlenc#aes256-cbc';
73
74
    public const BLOCK_ENC_AES128_GCM = 'http://www.w3.org/2009/xmlenc11#aes128-gcm';
75
76
    public const BLOCK_ENC_AES192_GCM = 'http://www.w3.org/2009/xmlenc11#aes192-gcm';
77
78
    public const BLOCK_ENC_AES256_GCM = 'http://www.w3.org/2009xmlenc11#aes256-gcm';
79
80
    /**
81
     * Key transport algorithms
82
     */
83
    public const KEY_TRANSPORT_RSA_1_5 = 'http://www.w3.org/2001/04/xmlenc#rsa-1_5';
84
85
    public const KEY_TRANSPORT_OAEP = 'http://www.w3.org/2009/xmlenc11#rsa-oaep';
86
87
    public const KEY_TRANSPORT_OAEP_MGF1P = 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p';
88
89
    /**
90
     * Canonicalization algorithms
91
     */
92
    public const C14N_INCLUSIVE_WITH_COMMENTS = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments';
93
94
    public const C14N_INCLUSIVE_WITHOUT_COMMENTS = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315';
95
96
    public const C14N_EXCLUSIVE_WITH_COMMENTS = 'http://www.w3.org/2001/10/xml-exc-c14n#WithComments';
97
98
    public const C14N_EXCLUSIVE_WITHOUT_COMMENTS = 'http://www.w3.org/2001/10/xml-exc-c14n#';
99
100
    public const C14N11_INCLUSIVE_WITH_COMMENTS = 'http://www.w3.org/2006/12/xml-c14n11';
101
102
    public const C14N11_INCLUSIVE_WITHOUT_COMMENTS = 'http://www.w3.org/2006/12/xml-c14n11#WithComments';
103
104
    /**
105
     * Signature algorithms
106
     */
107
    public const SIG_RSA_SHA1 = 'http://www.w3.org/2000/09/xmldsig#rsa-sha1';
108
109
    public const SIG_RSA_SHA224 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha224';
110
111
    public const SIG_RSA_SHA256 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256';
112
113
    public const SIG_RSA_SHA384 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha384';
114
115
    public const SIG_RSA_SHA512 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha512';
116
117
    public const SIG_RSA_RIPEMD160 = 'http://www.w3.org/2001/04/xmldsig-more#rsa-ripemd160';
118
119
    public const SIG_HMAC_SHA1 = 'http://www.w3.org/2000/09/xmldsig#hmac-sha1';
120
121
    public const SIG_HMAC_SHA224 = 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha224';
122
123
    public const SIG_HMAC_SHA256 = 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256';
124
125
    public const SIG_HMAC_SHA384 = 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha384';
126
127
    public const SIG_HMAC_SHA512 = 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha512';
128
129
    public const SIG_HMAC_RIPEMD160 = 'http://www.w3.org/2001/04/xmldsig-more#hmac-ripemd160';
130
131
    /**
132
     * Encoding algorithms
133
     */
134
    public const ENCODING_BASE64 = 'http://www.w3.org/2000/09/xmldsig#base64';
135
136
    /**
137
     * Transforms algorithms
138
     */
139
    public const TRANSFORMS_BASE64 = 'http://www.w3.org/2000/09/xmldsig#base64';
140
141
    /**
142
     * XML & XPath namespaces and identifiers
143
     */
144
    public const NS_XDSIG = 'http://www.w3.org/2000/09/xmldsig#';
145
146
    public const NS_XDSIG11 = 'http://www.w3.org/2009/xmldsig11#';
147
148
    public const XMLDSIG_ENVELOPED = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature';
149
150
    public const XMLDSIG_MANIFEST = 'http://www.w3.org/2000/09/xmldsig#Manifest';
151
152
    public const XMLDSIG11_DER_ENCODED_KEY_VALUE = 'https://www.w3.org/2009/xmldsig11#DEREncodedKeyValue';
153
154
    public const NS_XENC = 'http://www.w3.org/2001/04/xmlenc#';
155
156
    public const NS_XENC11 = 'http://www.w3.org/2009/xmlenc11#';
157
158
    public const XMLENC_CONTENT = 'http://www.w3.org/2001/04/xmlenc#Content';
159
160
    public const XMLENC_ELEMENT = 'http://www.w3.org/2001/04/xmlenc#Element';
161
162
    public const XMLENC_ENCRYPTEDKEY = 'http://www.w3.org/2001/04/xmlenc#EncryptedKey';
163
164
    public const XMLENC_EXI = 'http://www.w3.org/2009/xmlenc11#EXI';
165
166
167
    /** @var string[] */
168
    public static array $KEY_WRAP_ALGORITHMS = [
169
        self::KEY_WRAP_3DES,
170
        self::KEY_WRAP_AES128,
171
        self::KEY_WRAP_AES192,
172
        self::KEY_WRAP_AES256,
173
    ];
174
175
    /** @var string[] */
176
    public static array $KEY_DERIVATION_ALGORITHMS = [
177
        self::KEY_DERIVATION_CONCATKDF,
178
        self::KEY_DERIVATION_PBKDF2,
179
    ];
180
181
    /** @var string[] */
182
    public static array $KEY_AGREEMENT_ALGORITHMS = [
183
        self::KEY_AGREEMENT_ECDH_ES,
184
        self::KEY_AGREEMENT_DH,
185
        self::KEY_AGREEMENT_DH_ES,
186
    ];
187
188
    /** @var array<string, string> */
189
    public static array $DIGEST_ALGORITHMS = [
190
        self::DIGEST_SHA1 => 'sha1',
191
        self::DIGEST_SHA224 => 'sha224',
192
        self::DIGEST_SHA256 => 'sha256',
193
        self::DIGEST_SHA384 => 'sha384',
194
        self::DIGEST_SHA512 => 'sha512',
195
        self::DIGEST_RIPEMD160 => 'ripemd160',
196
    ];
197
198
    /** @var array<string, string> */
199
    public static array $BLOCK_CIPHER_ALGORITHMS = [
200
        self::BLOCK_ENC_3DES => 'des-ede3-cbc',
201
        self::BLOCK_ENC_AES128 => 'aes-128-cbc',
202
        self::BLOCK_ENC_AES192 => 'aes-192-cbc',
203
        self::BLOCK_ENC_AES256 => 'aes-256-cbc',
204
        self::BLOCK_ENC_AES128_GCM => 'aes-128-gcm',
205
        self::BLOCK_ENC_AES192_GCM => 'aes-192-gcm',
206
        self::BLOCK_ENC_AES256_GCM => 'aes-256-gcm',
207
    ];
208
209
    /** @var array<string, positive-int> */
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<string, positive-int> at position 4 could not be parsed: Unknown type name 'positive-int' at position 4 in array<string, positive-int>.
Loading history...
210
    public static array $BLOCK_SIZES = [
211
        self::BLOCK_ENC_3DES => 8,
212
        self::BLOCK_ENC_AES128 => 16,
213
        self::BLOCK_ENC_AES192 => 16,
214
        self::BLOCK_ENC_AES256 => 16,
215
        self::BLOCK_ENC_AES128_GCM => 16,
216
        self::BLOCK_ENC_AES192_GCM => 16,
217
        self::BLOCK_ENC_AES256_GCM => 16,
218
    ];
219
220
    /** @var array<string, string> */
221
    public static array $RSA_DIGESTS = [
222
        self::SIG_RSA_SHA1 => self::DIGEST_SHA1,
223
        self::SIG_RSA_SHA224 => self::DIGEST_SHA224,
224
        self::SIG_RSA_SHA256 => self::DIGEST_SHA256,
225
        self::SIG_RSA_SHA384 => self::DIGEST_SHA384,
226
        self::SIG_RSA_SHA512 => self::DIGEST_SHA512,
227
        self::SIG_RSA_RIPEMD160 => self::DIGEST_RIPEMD160,
228
    ];
229
230
    /** @var array<string, string> */
231
    public static array $HMAC_DIGESTS = [
232
        self::SIG_HMAC_SHA1 => self::DIGEST_SHA1,
233
        self::SIG_HMAC_SHA224 => self::DIGEST_SHA224,
234
        self::SIG_HMAC_SHA256 => self::DIGEST_SHA256,
235
        self::SIG_HMAC_SHA384 => self::DIGEST_SHA384,
236
        self::SIG_HMAC_SHA512 => self::DIGEST_SHA512,
237
        self::SIG_HMAC_RIPEMD160 => self::DIGEST_RIPEMD160,
238
    ];
239
240
    /** @var string[] */
241
    public static array $KEY_TRANSPORT_ALGORITHMS = [
242
        self::KEY_TRANSPORT_RSA_1_5,
243
        self::KEY_TRANSPORT_OAEP,
244
        self::KEY_TRANSPORT_OAEP_MGF1P,
245
    ];
246
247
    /** @var string[] */
248
    public static array $CANONICALIZATION_ALGORITHMS = [
249
        self::C14N_INCLUSIVE_WITH_COMMENTS,
250
        self::C14N_INCLUSIVE_WITHOUT_COMMENTS,
251
        self::C14N_EXCLUSIVE_WITH_COMMENTS,
252
        self::C14N_EXCLUSIVE_WITHOUT_COMMENTS,
253
        self::C14N11_INCLUSIVE_WITH_COMMENTS,
254
        self::C14N11_INCLUSIVE_WITHOUT_COMMENTS,
255
    ];
256
}
257