Skip to content

Commit 58c4293

Browse files
authored
Merge pull request #18 from PHPCompatibility/feature/compatibility-with-sodium-compat-1.11.1-1.12.0
Update for compatibility with sodium_compat v 1.12.0
2 parents 94b2388 + a9e808f commit 58c4293

2 files changed

Lines changed: 72 additions & 12 deletions

File tree

PHPCompatibilityParagonieSodiumCompat/ruleset.xml

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,26 @@
2020
<exclude name="PHPCompatibility.Classes.NewClasses.sodiumexceptionFound"/>
2121

2222
<!-- https://github.com/paragonie/sodium_compat/blob/master/lib/php72compat.php -->
23-
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_keybytesFound"/>
24-
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_nsecbytesFound"/>
25-
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_npubbytesFound"/>
26-
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_abytesFound"/>
23+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_base64_variant_originalFound"/>
24+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_base64_variant_original_no_paddingFound"/>
25+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_base64_variant_urlsafeFound"/>
26+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_base64_variant_urlsafe_no_paddingFound"/>
2727
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_aes256gcm_keybytesFound"/>
2828
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_aes256gcm_nsecbytesFound"/>
2929
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_aes256gcm_npubbytesFound"/>
3030
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_aes256gcm_abytesFound"/>
31+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_keybytesFound"/>
32+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_nsecbytesFound"/>
33+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_npubbytesFound"/>
34+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_abytesFound"/>
3135
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_ietf_keybytesFound"/>
3236
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_ietf_nsecbytesFound"/>
3337
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_ietf_npubbytesFound"/>
3438
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_chacha20poly1305_ietf_abytesFound"/>
39+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_xchacha20poly1305_ietf_keybytesFound"/>
40+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_xchacha20poly1305_ietf_nsecbytesFound"/>
41+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_xchacha20poly1305_ietf_npubbytesFound"/>
42+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_aead_xchacha20poly1305_ietf_abytesFound"/>
3543
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_auth_bytesFound"/>
3644
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_auth_keybytesFound"/>
3745
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_sealbytesFound"/>
@@ -41,10 +49,16 @@
4149
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_macbytesFound"/>
4250
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_noncebytesFound"/>
4351
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_box_seedbytesFound"/>
52+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kdf_bytes_minFound"/>
53+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kdf_bytes_maxFound"/>
54+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kdf_contextbytesFound"/>
55+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kdf_keybytesFound"/>
4456
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_bytesFound"/>
57+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_keypairbytesFound"/>
4558
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_publickeybytesFound"/>
4659
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_secretkeybytesFound"/>
4760
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_seedbytesFound"/>
61+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_kx_sessionkeybytesFound"/>
4862
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_generichash_bytesFound"/>
4963
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_generichash_bytes_minFound"/>
5064
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_generichash_bytes_maxFound"/>
@@ -61,8 +75,21 @@
6175
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_opslimit_moderateFound"/>
6276
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_memlimit_sensitiveFound"/>
6377
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_opslimit_sensitiveFound"/>
78+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_scryptsalsa208sha256_saltbytesFound"/>
79+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_scryptsalsa208sha256_strprefixFound"/>
80+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_scryptsalsa208sha256_opslimit_interactiveFound"/>
81+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_scryptsalsa208sha256_memlimit_interactiveFound"/>
82+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_scryptsalsa208sha256_opslimit_sensitiveFound"/>
83+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_pwhash_scryptsalsa208sha256_memlimit_sensitiveFound"/>
6484
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_scalarmult_bytesFound"/>
6585
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_scalarmult_scalarbytesFound"/>
86+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretstream_xchacha20poly1305_abytesFound"/>
87+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretstream_xchacha20poly1305_headerbytesFound"/>
88+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretstream_xchacha20poly1305_keybytesFound"/>
89+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretstream_xchacha20poly1305_messagebytes_maxFound"/>
90+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretstream_xchacha20poly1305_tag_pushFound"/>
91+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretstream_xchacha20poly1305_tag_rekeyFound"/>
92+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretstream_xchacha20poly1305_tag_finalFound"/>
6693
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_shorthash_bytesFound"/>
6794
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_shorthash_keybytesFound"/>
6895
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_secretbox_keybytesFound"/>
@@ -75,8 +102,9 @@
75102
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_sign_keypairbytesFound"/>
76103
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_stream_keybytesFound"/>
77104
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_crypto_stream_noncebytesFound"/>
78-
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_library_version_majorFound"/>
79-
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_library_version_minorFound"/>
105+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_library_versionFound"/>
106+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_library_major_versionFound"/>
107+
<exclude name="PHPCompatibility.Constants.NewConstants.sodium_library_minor_versionFound"/>
80108
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_addFound"/>
81109
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_base642binFound"/>
82110
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_bin2base64Found"/>
@@ -157,6 +185,7 @@
157185
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_crypto_stream_xorFound"/>
158186
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_hex2binFound"/>
159187
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_incrementFound"/>
188+
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_library_versionFound"/>
160189
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_library_version_majorFound"/>
161190
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_library_version_minorFound"/>
162191
<exclude name="PHPCompatibility.FunctionUse.NewFunctions.sodium_version_stringFound"/>
@@ -169,6 +198,9 @@
169198
</rule>
170199

171200
<!-- Prevent false positives being thrown when run over the code of sodium_compat itself. -->
201+
<rule ref="PHPCompatibility.FunctionUse.NewFunctionParameters.assert_descriptionFound">
202+
<exclude-pattern>/sodium_compat/autoload\.php$</exclude-pattern>
203+
</rule>
172204
<rule ref="PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__debuginfoFound">
173205
<exclude-pattern>/sodium_compat/src/Core(32)?/Curve25519/Fe\.php$</exclude-pattern>
174206
</rule>

Test/ParagonieSodiumCompatTest.php

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,26 @@
1414

1515
function SodiumExceptionTypeHint( SodiumException $a ) {}
1616

17-
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES;
18-
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES;
19-
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES;
20-
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_ABYTES;
17+
echo SODIUM_BASE64_VARIANT_ORIGINAL;
18+
echo SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING;
19+
echo SODIUM_BASE64_VARIANT_URLSAFE;
20+
echo SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING;
2121
echo SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES;
2222
echo SODIUM_CRYPTO_AEAD_AES256GCM_NSECBYTES;
2323
echo SODIUM_CRYPTO_AEAD_AES256GCM_NPUBBYTES;
2424
echo SODIUM_CRYPTO_AEAD_AES256GCM_ABYTES;
25+
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES;
26+
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES;
27+
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES;
28+
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_ABYTES;
2529
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES;
2630
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES;
2731
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES;
2832
echo SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES;
33+
echo SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES;
34+
echo SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES;
35+
echo SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES;
36+
echo SODIUM_CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES;
2937
echo SODIUM_CRYPTO_AUTH_BYTES;
3038
echo SODIUM_CRYPTO_AUTH_KEYBYTES;
3139
echo SODIUM_CRYPTO_BOX_SEALBYTES;
@@ -35,10 +43,16 @@ function SodiumExceptionTypeHint( SodiumException $a ) {}
3543
echo SODIUM_CRYPTO_BOX_MACBYTES;
3644
echo SODIUM_CRYPTO_BOX_NONCEBYTES;
3745
echo SODIUM_CRYPTO_BOX_SEEDBYTES;
46+
echo SODIUM_CRYPTO_KDF_BYTES_MIN;
47+
echo SODIUM_CRYPTO_KDF_BYTES_MAX;
48+
echo SODIUM_CRYPTO_KDF_CONTEXTBYTES;
49+
echo SODIUM_CRYPTO_KDF_KEYBYTES;
3850
echo SODIUM_CRYPTO_KX_BYTES;
51+
echo SODIUM_CRYPTO_KX_KEYPAIRBYTES;
3952
echo SODIUM_CRYPTO_KX_PUBLICKEYBYTES;
4053
echo SODIUM_CRYPTO_KX_SECRETKEYBYTES;
4154
echo SODIUM_CRYPTO_KX_SEEDBYTES;
55+
echo SODIUM_CRYPTO_KX_SESSIONKEYBYTES;
4256
echo SODIUM_CRYPTO_GENERICHASH_BYTES;
4357
echo SODIUM_CRYPTO_GENERICHASH_BYTES_MIN;
4458
echo SODIUM_CRYPTO_GENERICHASH_BYTES_MAX;
@@ -55,8 +69,21 @@ function SodiumExceptionTypeHint( SodiumException $a ) {}
5569
echo SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE;
5670
echo SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE;
5771
echo SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE;
72+
echo SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES;
73+
echo SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX;
74+
echo SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE;
75+
echo SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE;
76+
echo SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE;
77+
echo SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE;
5878
echo SODIUM_CRYPTO_SCALARMULT_BYTES;
5979
echo SODIUM_CRYPTO_SCALARMULT_SCALARBYTES;
80+
echo SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES;
81+
echo SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES;
82+
echo SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES;
83+
echo SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX;
84+
echo SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PUSH;
85+
echo SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY;
86+
echo SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL;
6087
echo SODIUM_CRYPTO_SHORTHASH_BYTES;
6188
echo SODIUM_CRYPTO_SHORTHASH_KEYBYTES;
6289
echo SODIUM_CRYPTO_SECRETBOX_KEYBYTES;
@@ -69,8 +96,9 @@ function SodiumExceptionTypeHint( SodiumException $a ) {}
6996
echo SODIUM_CRYPTO_SIGN_KEYPAIRBYTES;
7097
echo SODIUM_CRYPTO_STREAM_KEYBYTES;
7198
echo SODIUM_CRYPTO_STREAM_NONCEBYTES;
72-
echo SODIUM_LIBRARY_VERSION_MAJOR;
73-
echo SODIUM_LIBRARY_VERSION_MINOR;
99+
echo SODIUM_LIBRARY_MAJOR_VERSION;
100+
echo SODIUM_LIBRARY_MINOR_VERSION;
101+
echo SODIUM_LIBRARY_VERSION;
74102

75103
sodium_add();
76104
sodium_base642bin();

0 commit comments

Comments
 (0)