Issues (81)

src/Constants.php (2 issues)

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