Wordfence Security – Firewall & Malware Scan - Version 7.2.4

Version Description

  • March 26, 2019 =
  • Improvement: Updated vulnerability database integration.
  • Improvement: Better messaging when a WAF rule update fails to better indicate the cause.
  • Fix: Removed a double slash that could occur in an image path.
  • Fix: Adjusted timeouts to improve reliability of WAF rule updates on slower servers.
  • Fix: Improved connection process with Wordfence Central for better reliability on servers with non-standard paths.
  • Fix: Switched to autoloader with fastMult enabled on sodum_compat to minimize connection issues.
Download this release

Release Info

Developer wfryan
Plugin Icon 128x128 Wordfence Security – Firewall & Malware Scan
Version 7.2.4
Comparing to
See all releases

Code changes from version 7.2.3 to 7.2.4

Files changed (96) hide show
  1. css/{activity-report-widget.1551370846.css → activity-report-widget.1553617391.css} +0 -0
  2. css/{diff.1551370846.css → diff.1553617391.css} +0 -0
  3. css/{dt_table.1551370846.css → dt_table.1553617391.css} +0 -0
  4. css/{fullLog.1551370846.css → fullLog.1553617391.css} +0 -0
  5. css/{iptraf.1551370846.css → iptraf.1553617391.css} +0 -0
  6. css/{jquery-ui-timepicker-addon.1551370846.css → jquery-ui-timepicker-addon.1553617391.css} +0 -0
  7. css/{jquery-ui.min.1551370846.css → jquery-ui.min.1553617391.css} +0 -0
  8. css/{jquery-ui.structure.min.1551370846.css → jquery-ui.structure.min.1553617391.css} +0 -0
  9. css/{jquery-ui.theme.min.1551370846.css → jquery-ui.theme.min.1553617391.css} +0 -0
  10. css/{main.1551370846.css → main.1553617391.css} +0 -0
  11. css/{phpinfo.1551370846.css → phpinfo.1553617391.css} +0 -0
  12. css/{wf-adminbar.1551370846.css → wf-adminbar.1553617391.css} +0 -0
  13. css/{wf-colorbox.1551370846.css → wf-colorbox.1553617391.css} +0 -0
  14. css/{wf-font-awesome.1551370846.css → wf-font-awesome.1553617391.css} +0 -0
  15. css/{wf-global.1551370846.css → wf-global.1553617391.css} +0 -0
  16. css/{wf-ionicons.1551370846.css → wf-ionicons.1553617391.css} +0 -0
  17. css/{wf-onboarding.1551370846.css → wf-onboarding.1553617391.css} +0 -0
  18. css/{wf-roboto-font.1551370846.css → wf-roboto-font.1553617391.css} +0 -0
  19. css/{wfselect2.min.1551370846.css → wfselect2.min.1553617391.css} +0 -0
  20. css/{wordfenceBox.1551370846.css → wordfenceBox.1553617391.css} +0 -0
  21. js/{Chart.bundle.min.1551370846.js → Chart.bundle.min.1553617391.js} +0 -0
  22. js/{admin.1551370846.js → admin.1553617391.js} +9 -1
  23. js/{admin.ajaxWatcher.1551370846.js → admin.ajaxWatcher.1553617391.js} +0 -0
  24. js/{admin.liveTraffic.1551370846.js → admin.liveTraffic.1553617391.js} +0 -0
  25. js/{date.1551370846.js → date.1553617391.js} +0 -0
  26. js/{jquery-ui-timepicker-addon.1551370846.js → jquery-ui-timepicker-addon.1553617391.js} +0 -0
  27. js/{jquery.colorbox-min.1551370846.js → jquery.colorbox-min.1553617391.js} +0 -0
  28. js/{jquery.colorbox.1551370846.js → jquery.colorbox.1553617391.js} +0 -0
  29. js/{jquery.dataTables.min.1551370846.js → jquery.dataTables.min.1553617391.js} +0 -0
  30. js/{jquery.qrcode.min.1551370846.js → jquery.qrcode.min.1553617391.js} +0 -0
  31. js/{jquery.tmpl.min.1551370846.js → jquery.tmpl.min.1553617391.js} +0 -0
  32. js/{jquery.tools.min.1551370846.js → jquery.tools.min.1553617391.js} +0 -0
  33. js/{knockout-3.3.0.1551370846.js → knockout-3.3.0.1553617391.js} +0 -0
  34. js/{perf.1551370846.js → perf.1553617391.js} +0 -0
  35. js/{wfdashboard.1551370846.js → wfdashboard.1553617391.js} +0 -0
  36. js/{wfdropdown.1551370846.js → wfdropdown.1553617391.js} +0 -0
  37. js/wfglobal.1551370846.js +0 -160
  38. js/wfglobal.1553617391.js +234 -0
  39. js/{wfpopover.1551370846.js → wfpopover.1553617391.js} +0 -0
  40. js/{wfselect2.min.1551370846.js → wfselect2.min.1553617391.js} +0 -0
  41. lib/dashboard/widget_notifications.php +1 -1
  42. lib/menu_wordfence_central.php +1 -1
  43. lib/rest-api/wfRESTAuthenticationController.php +3 -2
  44. lib/rest-api/wfRESTConfigController.php +2 -1
  45. lib/wfCentralAPI.php +1 -1
  46. lib/wfConfig.php +12 -4
  47. lib/wfOnboardingController.php +3 -3
  48. lib/wordfenceClass.php +24 -4
  49. models/firewall/wfFirewall.php +4 -0
  50. readme.txt +9 -1
  51. vendor/autoload.php +1 -1
  52. vendor/composer/autoload_files.php +0 -1
  53. vendor/composer/autoload_real.php +18 -0
  54. vendor/composer/autoload_static.php +4 -0
  55. vendor/composer/installed.json +149 -0
  56. vendor/paragonie/random_compat/lib/byte_safe_strings.php +0 -181
  57. vendor/paragonie/random_compat/lib/cast_to_int.php +0 -75
  58. vendor/paragonie/random_compat/lib/error_polyfill.php +0 -49
  59. vendor/paragonie/random_compat/lib/random.php +4 -197
  60. vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php +0 -88
  61. vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php +0 -167
  62. vendor/paragonie/random_compat/lib/random_bytes_libsodium.php +0 -88
  63. vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php +0 -92
  64. vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php +0 -77
  65. vendor/paragonie/random_compat/lib/random_int.php +0 -190
  66. vendor/paragonie/sodium_compat/lib/php72compat.php +10 -5
  67. vendor/paragonie/sodium_compat/src/Compat.php +214 -97
  68. vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php +32 -20
  69. vendor/paragonie/sodium_compat/src/Core/ChaCha20/Ctx.php +1 -1
  70. vendor/paragonie/sodium_compat/src/Core/Curve25519.php +250 -226
  71. vendor/paragonie/sodium_compat/src/Core/Curve25519/Fe.php +1 -10
  72. vendor/paragonie/sodium_compat/src/Core/Ed25519.php +1 -0
  73. vendor/paragonie/sodium_compat/src/Core/Poly1305/State.php +25 -25
  74. vendor/paragonie/sodium_compat/src/Core/SipHash.php +8 -8
  75. vendor/paragonie/sodium_compat/src/Core/Util.php +2 -2
  76. vendor/paragonie/sodium_compat/src/Core32/BLAKE2b.php +20 -11
  77. vendor/paragonie/sodium_compat/src/Core32/ChaCha20/Ctx.php +1 -1
  78. vendor/paragonie/sodium_compat/src/Core32/Curve25519.php +342 -689
  79. vendor/paragonie/sodium_compat/src/Core32/Curve25519/Fe.php +2 -38
  80. vendor/paragonie/sodium_compat/src/Core32/Ed25519.php +1 -0
  81. vendor/paragonie/sodium_compat/src/Core32/Int32.php +120 -35
  82. vendor/paragonie/sodium_compat/src/Core32/Int64.php +235 -55
  83. vendor/paragonie/sodium_compat/src/Core32/Poly1305/State.php +36 -36
  84. vendor/paragonie/sodium_compat/src/Core32/SipHash.php +0 -1
  85. vendor/paragonie/sodium_compat/src/Core32/X25519.php +7 -1
  86. vendor/paragonie/sodium_compat/src/Crypto.php +12 -5
  87. vendor/paragonie/sodium_compat/src/Crypto32.php +10 -3
  88. vendor/paragonie/sodium_compat/src/File.php +38 -4
  89. vendor/wordfence/wf-waf/src/lib/http.php +32 -8
  90. vendor/wordfence/wf-waf/src/lib/waf.php +6 -2
  91. views/common/block-navigation-option.php +1 -1
  92. views/dashboard/options-group-general.php +1 -1
  93. views/onboarding/fresh-install.php +1 -1
  94. views/onboarding/modal-final-attempt.php +1 -1
  95. views/onboarding/plugin-header.php +1 -1
  96. wordfence.php +3 -3
css/{activity-report-widget.1551370846.css → activity-report-widget.1553617391.css} RENAMED
File without changes
css/{diff.1551370846.css → diff.1553617391.css} RENAMED
File without changes
css/{dt_table.1551370846.css → dt_table.1553617391.css} RENAMED
File without changes
css/{fullLog.1551370846.css → fullLog.1553617391.css} RENAMED
File without changes
css/{iptraf.1551370846.css → iptraf.1553617391.css} RENAMED
File without changes
css/{jquery-ui-timepicker-addon.1551370846.css → jquery-ui-timepicker-addon.1553617391.css} RENAMED
File without changes
css/{jquery-ui.min.1551370846.css → jquery-ui.min.1553617391.css} RENAMED
File without changes
css/{jquery-ui.structure.min.1551370846.css → jquery-ui.structure.min.1553617391.css} RENAMED
File without changes
css/{jquery-ui.theme.min.1551370846.css → jquery-ui.theme.min.1553617391.css} RENAMED
File without changes
css/{main.1551370846.css → main.1553617391.css} RENAMED
File without changes
css/{phpinfo.1551370846.css → phpinfo.1553617391.css} RENAMED
File without changes
css/{wf-adminbar.1551370846.css → wf-adminbar.1553617391.css} RENAMED
File without changes
css/{wf-colorbox.1551370846.css → wf-colorbox.1553617391.css} RENAMED
File without changes
css/{wf-font-awesome.1551370846.css → wf-font-awesome.1553617391.css} RENAMED
File without changes
css/{wf-global.1551370846.css → wf-global.1553617391.css} RENAMED
File without changes
css/{wf-ionicons.1551370846.css → wf-ionicons.1553617391.css} RENAMED
File without changes
css/{wf-onboarding.1551370846.css → wf-onboarding.1553617391.css} RENAMED
File without changes
css/{wf-roboto-font.1551370846.css → wf-roboto-font.1553617391.css} RENAMED
File without changes
css/{wfselect2.min.1551370846.css → wfselect2.min.1553617391.css} RENAMED
File without changes
css/{wordfenceBox.1551370846.css → wordfenceBox.1553617391.css} RENAMED
File without changes
js/{Chart.bundle.min.1551370846.js → Chart.bundle.min.1553617391.js} RENAMED
File without changes
js/{admin.1551370846.js → admin.1553617391.js} RENAMED
@@ -3294,7 +3294,15 @@
3294
  }
3295
  }
3296
  else {
3297
- self.colorboxModal((self.isSmallScreen ? '300px' : '400px'), 'Rule Update Failed', 'No rules were updated. Please verify you have permissions to write to the /wp-content/wflogs directory.');
 
 
 
 
 
 
 
 
3298
  }
3299
  if (typeof onSuccess === 'function') {
3300
  return onSuccess.apply(this, arguments);
3294
  }
3295
  }
3296
  else {
3297
+ if (self.wafData['failure'] == 'ratelimit') {
3298
+ self.colorboxModal((self.isSmallScreen ? '300px' : '400px'), 'Rule Update Failed', 'No rules were updated. Your website has reached the maximum number of rule update requests. Please try again later.');
3299
+ }
3300
+ else if (self.wafData['failure'] == 'unreachable') {
3301
+ self.colorboxModal((self.isSmallScreen ? '300px' : '400px'), 'Rule Update Failed', 'No rules were updated. Please verify your website can reach the Wordfence servers.');
3302
+ }
3303
+ else {
3304
+ self.colorboxModal((self.isSmallScreen ? '300px' : '400px'), 'Rule Update Failed', 'No rules were updated. Please verify you have permissions to write to the /wp-content/wflogs directory.');
3305
+ }
3306
  }
3307
  if (typeof onSuccess === 'function') {
3308
  return onSuccess.apply(this, arguments);
js/{admin.ajaxWatcher.1551370846.js → admin.ajaxWatcher.1553617391.js} RENAMED
File without changes
js/{admin.liveTraffic.1551370846.js → admin.liveTraffic.1553617391.js} RENAMED
File without changes
js/{date.1551370846.js → date.1553617391.js} RENAMED
File without changes
js/{jquery-ui-timepicker-addon.1551370846.js → jquery-ui-timepicker-addon.1553617391.js} RENAMED
File without changes
js/{jquery.colorbox-min.1551370846.js → jquery.colorbox-min.1553617391.js} RENAMED
File without changes
js/{jquery.colorbox.1551370846.js → jquery.colorbox.1553617391.js} RENAMED
File without changes
js/{jquery.dataTables.min.1551370846.js → jquery.dataTables.min.1553617391.js} RENAMED
File without changes
js/{jquery.qrcode.min.1551370846.js → jquery.qrcode.min.1553617391.js} RENAMED
File without changes
js/{jquery.tmpl.min.1551370846.js → jquery.tmpl.min.1553617391.js} RENAMED
File without changes
js/{jquery.tools.min.1551370846.js → jquery.tools.min.1553617391.js} RENAMED
File without changes
js/{knockout-3.3.0.1551370846.js → knockout-3.3.0.1553617391.js} RENAMED
File without changes
js/{perf.1551370846.js → perf.1553617391.js} RENAMED
File without changes
js/{wfdashboard.1551370846.js → wfdashboard.1553617391.js} RENAMED
File without changes
js/{wfdropdown.1551370846.js → wfdropdown.1553617391.js} RENAMED
File without changes
js/wfglobal.1551370846.js DELETED
@@ -1,160 +0,0 @@
1
- (function($) {
2
- if (!window['wordfenceExt']) {
3
- window['wordfenceExt'] = {
4
- nonce: false,
5
- loadingCount: 0,
6
- isSmallScreen: false,
7
- init: function(){
8
- this.nonce = WordfenceAdminVars.firstNonce;
9
- this.isSmallScreen = window.matchMedia("only screen and (max-width: 500px)").matches;
10
- },
11
- showLoading: function(){
12
- this.loadingCount++;
13
- if (this.loadingCount == 1) {
14
- jQuery('<div id="wordfenceWorking">Wordfence is working...</div>').appendTo('body');
15
- }
16
- },
17
- removeLoading: function(){
18
- this.loadingCount--;
19
- if(this.loadingCount == 0){
20
- jQuery('#wordfenceWorking').remove();
21
- }
22
- },
23
- autoUpdateChoice: function(choice){
24
- this.ajax('wordfence_autoUpdateChoice', {
25
- choice: choice
26
- },
27
- function(res){ jQuery('#wordfenceAutoUpdateChoice').fadeOut(); },
28
- function(){ jQuery('#wordfenceAutoUpdateChoice').fadeOut(); }
29
- );
30
- },
31
- misconfiguredHowGetIPsChoice : function(choice) {
32
- this.ajax('wordfence_misconfiguredHowGetIPsChoice', {
33
- choice: choice
34
- },
35
- function(res){ jQuery('#wordfenceMisconfiguredHowGetIPsNotice').fadeOut(); },
36
- function(){ jQuery('#wordfenceMisconfiguredHowGetIPsNotice').fadeOut(); }
37
- );
38
- },
39
- switchLiveTrafficSecurityOnlyChoice: function(choice) {
40
- this.ajax('wordfence_switchLiveTrafficSecurityOnlyChoice', {
41
- choice: choice
42
- },
43
- function(res){ jQuery('#switchLiveTrafficSecurityOnlyChoice').fadeOut(); },
44
- function(){ jQuery('#switchLiveTrafficSecurityOnlyChoice').fadeOut(); }
45
- );
46
- },
47
- dismissAdminNotice: function(nid) {
48
- this.ajax('wordfence_dismissAdminNotice', {
49
- id: nid
50
- },
51
- function(res){ jQuery('.wf-admin-notice[data-notice-id="' + nid + '"]').fadeOut(); },
52
- function(){ jQuery('.wf-admin-notice[data-notice-id="' + nid + '"]').fadeOut(); }
53
- );
54
- },
55
- setOption: function(key, value, successCallback) {
56
- var changes = {};
57
- changes[key] = value;
58
- this.ajax('wordfence_saveOptions', {changes: JSON.stringify(changes)}, function(res) {
59
- if (res.success) {
60
- typeof successCallback == 'function' && successCallback(res);
61
- }
62
- });
63
- },
64
- ajax: function(action, data, cb, cbErr, noLoading){
65
- if(typeof(data) == 'string'){
66
- if(data.length > 0){
67
- data += '&';
68
- }
69
- data += 'action=' + action + '&nonce=' + this.nonce;
70
- } else if(typeof(data) == 'object'){
71
- data['action'] = action;
72
- data['nonce'] = this.nonce;
73
- }
74
- if(! cbErr){
75
- cbErr = function(){};
76
- }
77
- var self = this;
78
- if(! noLoading){
79
- this.showLoading();
80
- }
81
- jQuery.ajax({
82
- type: 'POST',
83
- url: WordfenceAdminVars.ajaxURL,
84
- dataType: "json",
85
- data: data,
86
- success: function(json){
87
- if(! noLoading){
88
- self.removeLoading();
89
- }
90
- if(json && json.nonce){
91
- self.nonce = json.nonce;
92
- }
93
- cb(json);
94
- },
95
- error: function(){
96
- if(! noLoading){
97
- self.removeLoading();
98
- }
99
- cbErr();
100
- }
101
- });
102
- },
103
- parseEmails: function(raw) {
104
- var emails = [];
105
- if (typeof raw !== 'string') {
106
- return emails;
107
- }
108
-
109
- var rawEmails = raw.replace(/\s/g, '').split(',');
110
- for (var i = 0; i < rawEmails.length; i++) {
111
- //From https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address
112
- if (/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(rawEmails[i])) {
113
- emails.push(rawEmails[i]);
114
- }
115
- }
116
- return emails;
117
- },
118
- onboardingProcessEmails: function(emails, subscribe, touppAgreed) {
119
- var subscribe = !!subscribe;
120
- wordfenceExt.setOption('alertEmails', emails.join(', '));
121
-
122
- if (touppAgreed) {
123
- this.ajax('wordfence_recordTOUPP', {}, function(res) {
124
- //Do nothing
125
- });
126
- }
127
-
128
- if (subscribe) {
129
- this.ajax('wordfence_mailingSignup', {emails: JSON.stringify(emails)}, function(res) {
130
- //Do nothing
131
- });
132
- }
133
- },
134
- onboardingInstallLicense: function(license, successCallback, errorCallback) {
135
- this.ajax('wordfence_installLicense', {license: license}, function(res) {
136
- if (res.success) {
137
- typeof successCallback == 'function' && successCallback(res);
138
- }
139
- else if (res.error) {
140
- typeof errorCallback == 'function' && errorCallback(res);
141
- }
142
- });
143
- }
144
- };
145
- }
146
-
147
- $(function() {
148
- wordfenceExt.init();
149
-
150
- $('.wf-dismiss-link').on('click', function() {
151
- $('#wf-extended-protection-notice').css({
152
- opacity: .75
153
- });
154
- $.get(this.href, function() {
155
- $('#wf-extended-protection-notice').fadeOut(1000);
156
- });
157
- return false;
158
- });
159
- });
160
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/wfglobal.1553617391.js ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+ if (!window['wordfenceExt']) {
3
+ window['wordfenceExt'] = {
4
+ nonce: false,
5
+ loadingCount: 0,
6
+ isSmallScreen: false,
7
+ init: function(){
8
+ this.nonce = WordfenceAdminVars.firstNonce;
9
+ this.isSmallScreen = window.matchMedia("only screen and (max-width: 500px)").matches;
10
+ },
11
+ showLoading: function(){
12
+ this.loadingCount++;
13
+ if (this.loadingCount == 1) {
14
+ jQuery('<div id="wordfenceWorking">Wordfence is working...</div>').appendTo('body');
15
+ }
16
+ },
17
+ removeLoading: function(){
18
+ this.loadingCount--;
19
+ if(this.loadingCount == 0){
20
+ jQuery('#wordfenceWorking').remove();
21
+ }
22
+ },
23
+ autoUpdateChoice: function(choice){
24
+ this.ajax('wordfence_autoUpdateChoice', {
25
+ choice: choice
26
+ },
27
+ function(res){ jQuery('#wordfenceAutoUpdateChoice').fadeOut(); },
28
+ function(){ jQuery('#wordfenceAutoUpdateChoice').fadeOut(); }
29
+ );
30
+ },
31
+ misconfiguredHowGetIPsChoice : function(choice) {
32
+ this.ajax('wordfence_misconfiguredHowGetIPsChoice', {
33
+ choice: choice
34
+ },
35
+ function(res){ jQuery('#wordfenceMisconfiguredHowGetIPsNotice').fadeOut(); },
36
+ function(){ jQuery('#wordfenceMisconfiguredHowGetIPsNotice').fadeOut(); }
37
+ );
38
+ },
39
+ switchLiveTrafficSecurityOnlyChoice: function(choice) {
40
+ this.ajax('wordfence_switchLiveTrafficSecurityOnlyChoice', {
41
+ choice: choice
42
+ },
43
+ function(res){ jQuery('#switchLiveTrafficSecurityOnlyChoice').fadeOut(); },
44
+ function(){ jQuery('#switchLiveTrafficSecurityOnlyChoice').fadeOut(); }
45
+ );
46
+ },
47
+ dismissAdminNotice: function(nid) {
48
+ this.ajax('wordfence_dismissAdminNotice', {
49
+ id: nid
50
+ },
51
+ function(res){ jQuery('.wf-admin-notice[data-notice-id="' + nid + '"]').fadeOut(); },
52
+ function(){ jQuery('.wf-admin-notice[data-notice-id="' + nid + '"]').fadeOut(); }
53
+ );
54
+ },
55
+ setOption: function(key, value, successCallback) {
56
+ var changes = {};
57
+ changes[key] = value;
58
+ this.ajax('wordfence_saveOptions', {changes: JSON.stringify(changes)}, function(res) {
59
+ if (res.success) {
60
+ typeof successCallback == 'function' && successCallback(res);
61
+ }
62
+ });
63
+ },
64
+ ajax: function(action, data, cb, cbErr, noLoading){
65
+ if(typeof(data) == 'string'){
66
+ if(data.length > 0){
67
+ data += '&';
68
+ }
69
+ data += 'action=' + action + '&nonce=' + this.nonce;
70
+ } else if(typeof(data) == 'object'){
71
+ data['action'] = action;
72
+ data['nonce'] = this.nonce;
73
+ }
74
+ if(! cbErr){
75
+ cbErr = function(){};
76
+ }
77
+ var self = this;
78
+ if(! noLoading){
79
+ this.showLoading();
80
+ }
81
+ jQuery.ajax({
82
+ type: 'POST',
83
+ url: WordfenceAdminVars.ajaxURL,
84
+ dataType: "json",
85
+ data: data,
86
+ success: function(json){
87
+ if(! noLoading){
88
+ self.removeLoading();
89
+ }
90
+ if(json && json.nonce){
91
+ self.nonce = json.nonce;
92
+ }
93
+ cb(json);
94
+ },
95
+ error: function(){
96
+ if(! noLoading){
97
+ self.removeLoading();
98
+ }
99
+ cbErr();
100
+ }
101
+ });
102
+ },
103
+ hashSHA256: function(s) {
104
+ return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(s))
105
+ },
106
+ isEmailBlacklisted: function(email) {
107
+ var hash = this.hashSHA256(email);
108
+ for (var i = 0; i < WordfenceAdminVars.alertEmailBlacklist.length; i++) {
109
+ if (hash === WordfenceAdminVars.alertEmailBlacklist[i]) {
110
+ return true;
111
+ }
112
+ }
113
+ return false;
114
+ },
115
+ parseEmails: function(raw) {
116
+ var emails = [];
117
+ if (typeof raw !== 'string') {
118
+ return emails;
119
+ }
120
+
121
+ var rawEmails = raw.replace(/\s/g, '').split(',');
122
+ for (var i = 0; i < rawEmails.length; i++) {
123
+ //From https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address
124
+ if (/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(rawEmails[i]) && !this.isEmailBlacklisted(rawEmails[i])) {
125
+ emails.push(rawEmails[i]);
126
+ }
127
+ }
128
+ return emails;
129
+ },
130
+ onboardingProcessEmails: function(emails, subscribe, touppAgreed) {
131
+ var subscribe = !!subscribe;
132
+ wordfenceExt.setOption('alertEmails', emails.join(', '));
133
+
134
+ if (touppAgreed) {
135
+ this.ajax('wordfence_recordTOUPP', {}, function(res) {
136
+ //Do nothing
137
+ });
138
+ }
139
+
140
+ if (subscribe) {
141
+ this.ajax('wordfence_mailingSignup', {emails: JSON.stringify(emails)}, function(res) {
142
+ //Do nothing
143
+ });
144
+ }
145
+ },
146
+ onboardingInstallLicense: function(license, successCallback, errorCallback) {
147
+ this.ajax('wordfence_installLicense', {license: license}, function(res) {
148
+ if (res.success) {
149
+ typeof successCallback == 'function' && successCallback(res);
150
+ }
151
+ else if (res.error) {
152
+ typeof errorCallback == 'function' && errorCallback(res);
153
+ }
154
+ });
155
+ }
156
+ };
157
+ }
158
+
159
+ $(function() {
160
+ wordfenceExt.init();
161
+
162
+ $('.wf-dismiss-link').on('click', function() {
163
+ $('#wf-extended-protection-notice').css({
164
+ opacity: .75
165
+ });
166
+ $.get(this.href, function() {
167
+ $('#wf-extended-protection-notice').fadeOut(1000);
168
+ });
169
+ return false;
170
+ });
171
+ });
172
+ })(jQuery);
173
+
174
+ //Stanford Javascript Crypto Library: https://bitwiseshiftleft.github.io/sjcl/
175
+ "use strict";var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}};
176
+ sjcl.cipher.aes=function(a){this.s[0][0][0]||this.O();var b,c,d,e,f=this.s[0][4],g=this.s[1];b=a.length;var h=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid("invalid aes key size");this.b=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(0===a%b||8===b&&4===a%b)c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));d[a]=d[a-b]^c}for(b=0;a;b++,a--)c=d[b&3?a:a-4],e[b]=4>=a||4>b?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^g[3][f[c&
177
+ 255]]};
178
+ sjcl.cipher.aes.prototype={encrypt:function(a){return t(this,a,0)},decrypt:function(a){return t(this,a,1)},s:[[[],[],[],[],[]],[[],[],[],[],[]]],O:function(){var a=this.s[0],b=this.s[1],c=a[4],d=b[4],e,f,g,h=[],k=[],l,n,m,p;for(e=0;0x100>e;e++)k[(h[e]=e<<1^283*(e>>7))^e]=e;for(f=g=0;!c[f];f^=l||1,g=k[g]||1)for(m=g^g<<1^g<<2^g<<3^g<<4,m=m>>8^m&255^99,c[f]=m,d[m]=f,n=h[e=h[l=h[f]]],p=0x1010101*n^0x10001*e^0x101*l^0x1010100*f,n=0x101*h[m]^0x1010100*m,e=0;4>e;e++)a[e][f]=n=n<<24^n>>>8,b[e][m]=p=p<<24^p>>>8;for(e=
179
+ 0;5>e;e++)a[e]=a[e].slice(0),b[e]=b[e].slice(0)}};
180
+ function t(a,b,c){if(4!==b.length)throw new sjcl.exception.invalid("invalid aes block size");var d=a.b[c],e=b[0]^d[0],f=b[c?3:1]^d[1],g=b[2]^d[2];b=b[c?1:3]^d[3];var h,k,l,n=d.length/4-2,m,p=4,r=[0,0,0,0];h=a.s[c];a=h[0];var q=h[1],v=h[2],w=h[3],x=h[4];for(m=0;m<n;m++)h=a[e>>>24]^q[f>>16&255]^v[g>>8&255]^w[b&255]^d[p],k=a[f>>>24]^q[g>>16&255]^v[b>>8&255]^w[e&255]^d[p+1],l=a[g>>>24]^q[b>>16&255]^v[e>>8&255]^w[f&255]^d[p+2],b=a[b>>>24]^q[e>>16&255]^v[f>>8&255]^w[g&255]^d[p+3],p+=4,e=h,f=k,g=l;for(m=
181
+ 0;4>m;m++)r[c?3&-m:m]=x[e>>>24]<<24^x[f>>16&255]<<16^x[g>>8&255]<<8^x[b&255]^d[p++],h=e,e=f,f=g,g=b,b=h;return r}
182
+ sjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.$(a.slice(b/32),32-(b&31)).slice(1);return void 0===c?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var d=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-d^a[b/32+1|0]>>>d:a[b/32|0]>>>d)&(1<<c)-1},concat:function(a,b){if(0===a.length||0===b.length)return a.concat(b);var c=a[a.length-1],d=sjcl.bitArray.getPartial(c);return 32===d?a.concat(b):sjcl.bitArray.$(b,d,c|0,a.slice(0,a.length-1))},bitLength:function(a){var b=a.length;return 0===
183
+ b?0:32*(b-1)+sjcl.bitArray.getPartial(a[b-1])},clamp:function(a,b){if(32*a.length<b)return a;a=a.slice(0,Math.ceil(b/32));var c=a.length;b=b&31;0<c&&b&&(a[c-1]=sjcl.bitArray.partial(b,a[c-1]&2147483648>>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+0x10000000000*a},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return!1;var c=0,d;for(d=0;d<a.length;d++)c|=a[d]^b[d];return 0===
184
+ c},$:function(a,b,c,d){var e;e=0;for(void 0===d&&(d=[]);32<=b;b-=32)d.push(c),c=0;if(0===b)return d.concat(a);for(e=0;e<a.length;e++)d.push(c|a[e]>>>b),c=a[e]<<32-b;e=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(e);d.push(sjcl.bitArray.partial(b+a&31,32<b+a?c:d.pop(),1));return d},i:function(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],a[3]^b[3]]},byteswapM:function(a){var b,c;for(b=0;b<a.length;++b)c=a[b],a[b]=c>>>24|c>>>8&0xff00|(c&0xff00)<<8|c<<24;return a}};
185
+ sjcl.codec.utf8String={fromBits:function(a){var b="",c=sjcl.bitArray.bitLength(a),d,e;for(d=0;d<c/8;d++)0===(d&3)&&(e=a[d/4]),b+=String.fromCharCode(e>>>8>>>8>>>8),e<<=8;return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,d=0;for(c=0;c<a.length;c++)d=d<<8|a.charCodeAt(c),3===(c&3)&&(b.push(d),d=0);c&3&&b.push(sjcl.bitArray.partial(8*(c&3),d));return b}};
186
+ sjcl.codec.hex={fromBits:function(a){var b="",c;for(c=0;c<a.length;c++)b+=((a[c]|0)+0xf00000000000).toString(16).substr(4);return b.substr(0,sjcl.bitArray.bitLength(a)/4)},toBits:function(a){var b,c=[],d;a=a.replace(/\s|0x/g,"");d=a.length;a=a+"00000000";for(b=0;b<a.length;b+=8)c.push(parseInt(a.substr(b,8),16)^0);return sjcl.bitArray.clamp(c,4*d)}};
187
+ sjcl.codec.base32={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",X:"0123456789ABCDEFGHIJKLMNOPQRSTUV",BITS:32,BASE:5,REMAINING:27,fromBits:function(a,b,c){var d=sjcl.codec.base32.BASE,e=sjcl.codec.base32.REMAINING,f="",g=0,h=sjcl.codec.base32.B,k=0,l=sjcl.bitArray.bitLength(a);c&&(h=sjcl.codec.base32.X);for(c=0;f.length*d<l;)f+=h.charAt((k^a[c]>>>g)>>>e),g<d?(k=a[c]<<d-g,g+=e,c++):(k<<=d,g-=d);for(;f.length&7&&!b;)f+="=";return f},toBits:function(a,b){a=a.replace(/\s|=/g,"").toUpperCase();var c=sjcl.codec.base32.BITS,
188
+ d=sjcl.codec.base32.BASE,e=sjcl.codec.base32.REMAINING,f=[],g,h=0,k=sjcl.codec.base32.B,l=0,n,m="base32";b&&(k=sjcl.codec.base32.X,m="base32hex");for(g=0;g<a.length;g++){n=k.indexOf(a.charAt(g));if(0>n){if(!b)try{return sjcl.codec.base32hex.toBits(a)}catch(p){}throw new sjcl.exception.invalid("this isn't "+m+"!");}h>e?(h-=e,f.push(l^n>>>h),l=n<<c-h):(h+=d,l^=n<<c-h)}h&56&&f.push(sjcl.bitArray.partial(h&56,l,1));return f}};
189
+ sjcl.codec.base32hex={fromBits:function(a,b){return sjcl.codec.base32.fromBits(a,b,1)},toBits:function(a){return sjcl.codec.base32.toBits(a,1)}};
190
+ sjcl.codec.base64={B:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(a,b,c){var d="",e=0,f=sjcl.codec.base64.B,g=0,h=sjcl.bitArray.bitLength(a);c&&(f=f.substr(0,62)+"-_");for(c=0;6*d.length<h;)d+=f.charAt((g^a[c]>>>e)>>>26),6>e?(g=a[c]<<6-e,e+=26,c++):(g<<=6,e-=6);for(;d.length&3&&!b;)d+="=";return d},toBits:function(a,b){a=a.replace(/\s|=/g,"");var c=[],d,e=0,f=sjcl.codec.base64.B,g=0,h;b&&(f=f.substr(0,62)+"-_");for(d=0;d<a.length;d++){h=f.indexOf(a.charAt(d));
191
+ if(0>h)throw new sjcl.exception.invalid("this isn't base64!");26<e?(e-=26,c.push(g^h>>>e),g=h<<32-e):(e+=6,g^=h<<32-e)}e&56&&c.push(sjcl.bitArray.partial(e&56,g,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}};sjcl.hash.sha256=function(a){this.b[0]||this.O();a?(this.F=a.F.slice(0),this.A=a.A.slice(0),this.l=a.l):this.reset()};sjcl.hash.sha256.hash=function(a){return(new sjcl.hash.sha256).update(a).finalize()};
192
+ sjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.F=this.Y.slice(0);this.A=[];this.l=0;return this},update:function(a){"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));var b,c=this.A=sjcl.bitArray.concat(this.A,a);b=this.l;a=this.l=b+sjcl.bitArray.bitLength(a);if(0x1fffffffffffff<a)throw new sjcl.exception.invalid("Cannot hash more than 2^53 - 1 bits");if("undefined"!==typeof Uint32Array){var d=new Uint32Array(c),e=0;for(b=512+b-(512+b&0x1ff);b<=a;b+=512)u(this,d.subarray(16*e,
193
+ 16*(e+1))),e+=1;c.splice(0,16*e)}else for(b=512+b-(512+b&0x1ff);b<=a;b+=512)u(this,c.splice(0,16));return this},finalize:function(){var a,b=this.A,c=this.F,b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this.l/0x100000000));for(b.push(this.l|0);b.length;)u(this,b.splice(0,16));this.reset();return c},Y:[],b:[],O:function(){function a(a){return 0x100000000*(a-Math.floor(a))|0}for(var b=0,c=2,d,e;64>b;c++){e=!0;for(d=2;d*d<=c;d++)if(0===c%d){e=
194
+ !1;break}e&&(8>b&&(this.Y[b]=a(Math.pow(c,.5))),this.b[b]=a(Math.pow(c,1/3)),b++)}}};
195
+ function u(a,b){var c,d,e,f=a.F,g=a.b,h=f[0],k=f[1],l=f[2],n=f[3],m=f[4],p=f[5],r=f[6],q=f[7];for(c=0;64>c;c++)16>c?d=b[c]:(d=b[c+1&15],e=b[c+14&15],d=b[c&15]=(d>>>7^d>>>18^d>>>3^d<<25^d<<14)+(e>>>17^e>>>19^e>>>10^e<<15^e<<13)+b[c&15]+b[c+9&15]|0),d=d+q+(m>>>6^m>>>11^m>>>25^m<<26^m<<21^m<<7)+(r^m&(p^r))+g[c],q=r,r=p,p=m,m=n+d|0,n=l,l=k,k=h,h=d+(k&l^n&(k^l))+(k>>>2^k>>>13^k>>>22^k<<30^k<<19^k<<10)|0;f[0]=f[0]+h|0;f[1]=f[1]+k|0;f[2]=f[2]+l|0;f[3]=f[3]+n|0;f[4]=f[4]+m|0;f[5]=f[5]+p|0;f[6]=f[6]+r|0;f[7]=
196
+ f[7]+q|0}
197
+ sjcl.mode.ccm={name:"ccm",G:[],listenProgress:function(a){sjcl.mode.ccm.G.push(a)},unListenProgress:function(a){a=sjcl.mode.ccm.G.indexOf(a);-1<a&&sjcl.mode.ccm.G.splice(a,1)},fa:function(a){var b=sjcl.mode.ccm.G.slice(),c;for(c=0;c<b.length;c+=1)b[c](a)},encrypt:function(a,b,c,d,e){var f,g=b.slice(0),h=sjcl.bitArray,k=h.bitLength(c)/8,l=h.bitLength(g)/8;e=e||64;d=d||[];if(7>k)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(f=2;4>f&&l>>>8*f;f++);f<15-k&&(f=15-k);c=h.clamp(c,
198
+ 8*(15-f));b=sjcl.mode.ccm.V(a,b,c,d,e,f);g=sjcl.mode.ccm.C(a,g,c,b,e,f);return h.concat(g.data,g.tag)},decrypt:function(a,b,c,d,e){e=e||64;d=d||[];var f=sjcl.bitArray,g=f.bitLength(c)/8,h=f.bitLength(b),k=f.clamp(b,h-e),l=f.bitSlice(b,h-e),h=(h-e)/8;if(7>g)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(b=2;4>b&&h>>>8*b;b++);b<15-g&&(b=15-g);c=f.clamp(c,8*(15-b));k=sjcl.mode.ccm.C(a,k,c,l,e,b);a=sjcl.mode.ccm.V(a,k.data,c,d,e,b);if(!f.equal(k.tag,a))throw new sjcl.exception.corrupt("ccm: tag doesn't match");
199
+ return k.data},na:function(a,b,c,d,e,f){var g=[],h=sjcl.bitArray,k=h.i;d=[h.partial(8,(b.length?64:0)|d-2<<2|f-1)];d=h.concat(d,c);d[3]|=e;d=a.encrypt(d);if(b.length)for(c=h.bitLength(b)/8,65279>=c?g=[h.partial(16,c)]:0xffffffff>=c&&(g=h.concat([h.partial(16,65534)],[c])),g=h.concat(g,b),b=0;b<g.length;b+=4)d=a.encrypt(k(d,g.slice(b,b+4).concat([0,0,0])));return d},V:function(a,b,c,d,e,f){var g=sjcl.bitArray,h=g.i;e/=8;if(e%2||4>e||16<e)throw new sjcl.exception.invalid("ccm: invalid tag length");
200
+ if(0xffffffff<d.length||0xffffffff<b.length)throw new sjcl.exception.bug("ccm: can't deal with 4GiB or more data");c=sjcl.mode.ccm.na(a,d,c,e,g.bitLength(b)/8,f);for(d=0;d<b.length;d+=4)c=a.encrypt(h(c,b.slice(d,d+4).concat([0,0,0])));return g.clamp(c,8*e)},C:function(a,b,c,d,e,f){var g,h=sjcl.bitArray;g=h.i;var k=b.length,l=h.bitLength(b),n=k/50,m=n;c=h.concat([h.partial(8,f-1)],c).concat([0,0,0]).slice(0,4);d=h.bitSlice(g(d,a.encrypt(c)),0,e);if(!k)return{tag:d,data:[]};for(g=0;g<k;g+=4)g>n&&(sjcl.mode.ccm.fa(g/
201
+ k),n+=m),c[3]++,e=a.encrypt(c),b[g]^=e[0],b[g+1]^=e[1],b[g+2]^=e[2],b[g+3]^=e[3];return{tag:d,data:h.clamp(b,l)}}};
202
+ sjcl.mode.ocb2={name:"ocb2",encrypt:function(a,b,c,d,e,f){if(128!==sjcl.bitArray.bitLength(c))throw new sjcl.exception.invalid("ocb iv must be 128 bits");var g,h=sjcl.mode.ocb2.S,k=sjcl.bitArray,l=k.i,n=[0,0,0,0];c=h(a.encrypt(c));var m,p=[];d=d||[];e=e||64;for(g=0;g+4<b.length;g+=4)m=b.slice(g,g+4),n=l(n,m),p=p.concat(l(c,a.encrypt(l(c,m)))),c=h(c);m=b.slice(g);b=k.bitLength(m);g=a.encrypt(l(c,[0,0,0,b]));m=k.clamp(l(m.concat([0,0,0]),g),b);n=l(n,l(m.concat([0,0,0]),g));n=a.encrypt(l(n,l(c,h(c))));
203
+ d.length&&(n=l(n,f?d:sjcl.mode.ocb2.pmac(a,d)));return p.concat(k.concat(m,k.clamp(n,e)))},decrypt:function(a,b,c,d,e,f){if(128!==sjcl.bitArray.bitLength(c))throw new sjcl.exception.invalid("ocb iv must be 128 bits");e=e||64;var g=sjcl.mode.ocb2.S,h=sjcl.bitArray,k=h.i,l=[0,0,0,0],n=g(a.encrypt(c)),m,p,r=sjcl.bitArray.bitLength(b)-e,q=[];d=d||[];for(c=0;c+4<r/32;c+=4)m=k(n,a.decrypt(k(n,b.slice(c,c+4)))),l=k(l,m),q=q.concat(m),n=g(n);p=r-32*c;m=a.encrypt(k(n,[0,0,0,p]));m=k(m,h.clamp(b.slice(c),p).concat([0,
204
+ 0,0]));l=k(l,m);l=a.encrypt(k(l,k(n,g(n))));d.length&&(l=k(l,f?d:sjcl.mode.ocb2.pmac(a,d)));if(!h.equal(h.clamp(l,e),h.bitSlice(b,r)))throw new sjcl.exception.corrupt("ocb: tag doesn't match");return q.concat(h.clamp(m,p))},pmac:function(a,b){var c,d=sjcl.mode.ocb2.S,e=sjcl.bitArray,f=e.i,g=[0,0,0,0],h=a.encrypt([0,0,0,0]),h=f(h,d(d(h)));for(c=0;c+4<b.length;c+=4)h=d(h),g=f(g,a.encrypt(f(h,b.slice(c,c+4))));c=b.slice(c);128>e.bitLength(c)&&(h=f(h,d(h)),c=e.concat(c,[-2147483648,0,0,0]));g=f(g,c);
205
+ return a.encrypt(f(d(f(h,d(h))),g))},S:function(a){return[a[0]<<1^a[1]>>>31,a[1]<<1^a[2]>>>31,a[2]<<1^a[3]>>>31,a[3]<<1^135*(a[0]>>>31)]}};
206
+ sjcl.mode.gcm={name:"gcm",encrypt:function(a,b,c,d,e){var f=b.slice(0);b=sjcl.bitArray;d=d||[];a=sjcl.mode.gcm.C(!0,a,f,d,c,e||128);return b.concat(a.data,a.tag)},decrypt:function(a,b,c,d,e){var f=b.slice(0),g=sjcl.bitArray,h=g.bitLength(f);e=e||128;d=d||[];e<=h?(b=g.bitSlice(f,h-e),f=g.bitSlice(f,0,h-e)):(b=f,f=[]);a=sjcl.mode.gcm.C(!1,a,f,d,c,e);if(!g.equal(a.tag,b))throw new sjcl.exception.corrupt("gcm: tag doesn't match");return a.data},ka:function(a,b){var c,d,e,f,g,h=sjcl.bitArray.i;e=[0,0,
207
+ 0,0];f=b.slice(0);for(c=0;128>c;c++){(d=0!==(a[Math.floor(c/32)]&1<<31-c%32))&&(e=h(e,f));g=0!==(f[3]&1);for(d=3;0<d;d--)f[d]=f[d]>>>1|(f[d-1]&1)<<31;f[0]>>>=1;g&&(f[0]^=-0x1f000000)}return e},j:function(a,b,c){var d,e=c.length;b=b.slice(0);for(d=0;d<e;d+=4)b[0]^=0xffffffff&c[d],b[1]^=0xffffffff&c[d+1],b[2]^=0xffffffff&c[d+2],b[3]^=0xffffffff&c[d+3],b=sjcl.mode.gcm.ka(b,a);return b},C:function(a,b,c,d,e,f){var g,h,k,l,n,m,p,r,q=sjcl.bitArray;m=c.length;p=q.bitLength(c);r=q.bitLength(d);h=q.bitLength(e);
208
+ g=b.encrypt([0,0,0,0]);96===h?(e=e.slice(0),e=q.concat(e,[1])):(e=sjcl.mode.gcm.j(g,[0,0,0,0],e),e=sjcl.mode.gcm.j(g,e,[0,0,Math.floor(h/0x100000000),h&0xffffffff]));h=sjcl.mode.gcm.j(g,[0,0,0,0],d);n=e.slice(0);d=h.slice(0);a||(d=sjcl.mode.gcm.j(g,h,c));for(l=0;l<m;l+=4)n[3]++,k=b.encrypt(n),c[l]^=k[0],c[l+1]^=k[1],c[l+2]^=k[2],c[l+3]^=k[3];c=q.clamp(c,p);a&&(d=sjcl.mode.gcm.j(g,h,c));a=[Math.floor(r/0x100000000),r&0xffffffff,Math.floor(p/0x100000000),p&0xffffffff];d=sjcl.mode.gcm.j(g,d,a);k=b.encrypt(e);
209
+ d[0]^=k[0];d[1]^=k[1];d[2]^=k[2];d[3]^=k[3];return{tag:q.bitSlice(d,0,f),data:c}}};sjcl.misc.hmac=function(a,b){this.W=b=b||sjcl.hash.sha256;var c=[[],[]],d,e=b.prototype.blockSize/32;this.w=[new b,new b];a.length>e&&(a=b.hash(a));for(d=0;d<e;d++)c[0][d]=a[d]^909522486,c[1][d]=a[d]^1549556828;this.w[0].update(c[0]);this.w[1].update(c[1]);this.R=new b(this.w[0])};
210
+ sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(a){if(this.aa)throw new sjcl.exception.invalid("encrypt on already updated hmac called!");this.update(a);return this.digest(a)};sjcl.misc.hmac.prototype.reset=function(){this.R=new this.W(this.w[0]);this.aa=!1};sjcl.misc.hmac.prototype.update=function(a){this.aa=!0;this.R.update(a)};sjcl.misc.hmac.prototype.digest=function(){var a=this.R.finalize(),a=(new this.W(this.w[1])).update(a).finalize();this.reset();return a};
211
+ sjcl.misc.pbkdf2=function(a,b,c,d,e){c=c||1E4;if(0>d||0>c)throw new sjcl.exception.invalid("invalid params to pbkdf2");"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));e=e||sjcl.misc.hmac;a=new e(a);var f,g,h,k,l=[],n=sjcl.bitArray;for(k=1;32*l.length<(d||1);k++){e=f=a.encrypt(n.concat(b,[k]));for(g=1;g<c;g++)for(f=a.encrypt(f),h=0;h<f.length;h++)e[h]^=f[h];l=l.concat(e)}d&&(l=n.clamp(l,d));return l};
212
+ sjcl.prng=function(a){this.c=[new sjcl.hash.sha256];this.m=[0];this.P=0;this.H={};this.N=0;this.U={};this.Z=this.f=this.o=this.ha=0;this.b=[0,0,0,0,0,0,0,0];this.h=[0,0,0,0];this.L=void 0;this.M=a;this.D=!1;this.K={progress:{},seeded:{}};this.u=this.ga=0;this.I=1;this.J=2;this.ca=0x10000;this.T=[0,48,64,96,128,192,0x100,384,512,768,1024];this.da=3E4;this.ba=80};
213
+ sjcl.prng.prototype={randomWords:function(a,b){var c=[],d;d=this.isReady(b);var e;if(d===this.u)throw new sjcl.exception.notReady("generator isn't seeded");if(d&this.J){d=!(d&this.I);e=[];var f=0,g;this.Z=e[0]=(new Date).valueOf()+this.da;for(g=0;16>g;g++)e.push(0x100000000*Math.random()|0);for(g=0;g<this.c.length&&(e=e.concat(this.c[g].finalize()),f+=this.m[g],this.m[g]=0,d||!(this.P&1<<g));g++);this.P>=1<<this.c.length&&(this.c.push(new sjcl.hash.sha256),this.m.push(0));this.f-=f;f>this.o&&(this.o=
214
+ f);this.P++;this.b=sjcl.hash.sha256.hash(this.b.concat(e));this.L=new sjcl.cipher.aes(this.b);for(d=0;4>d&&(this.h[d]=this.h[d]+1|0,!this.h[d]);d++);}for(d=0;d<a;d+=4)0===(d+1)%this.ca&&y(this),e=z(this),c.push(e[0],e[1],e[2],e[3]);y(this);return c.slice(0,a)},setDefaultParanoia:function(a,b){if(0===a&&"Setting paranoia=0 will ruin your security; use it only for testing"!==b)throw new sjcl.exception.invalid("Setting paranoia=0 will ruin your security; use it only for testing");this.M=a},addEntropy:function(a,
215
+ b,c){c=c||"user";var d,e,f=(new Date).valueOf(),g=this.H[c],h=this.isReady(),k=0;d=this.U[c];void 0===d&&(d=this.U[c]=this.ha++);void 0===g&&(g=this.H[c]=0);this.H[c]=(this.H[c]+1)%this.c.length;switch(typeof a){case "number":void 0===b&&(b=1);this.c[g].update([d,this.N++,1,b,f,1,a|0]);break;case "object":c=Object.prototype.toString.call(a);if("[object Uint32Array]"===c){e=[];for(c=0;c<a.length;c++)e.push(a[c]);a=e}else for("[object Array]"!==c&&(k=1),c=0;c<a.length&&!k;c++)"number"!==typeof a[c]&&
216
+ (k=1);if(!k){if(void 0===b)for(c=b=0;c<a.length;c++)for(e=a[c];0<e;)b++,e=e>>>1;this.c[g].update([d,this.N++,2,b,f,a.length].concat(a))}break;case "string":void 0===b&&(b=a.length);this.c[g].update([d,this.N++,3,b,f,a.length]);this.c[g].update(a);break;default:k=1}if(k)throw new sjcl.exception.bug("random: addEntropy only supports number, array of numbers or string");this.m[g]+=b;this.f+=b;h===this.u&&(this.isReady()!==this.u&&A("seeded",Math.max(this.o,this.f)),A("progress",this.getProgress()))},
217
+ isReady:function(a){a=this.T[void 0!==a?a:this.M];return this.o&&this.o>=a?this.m[0]>this.ba&&(new Date).valueOf()>this.Z?this.J|this.I:this.I:this.f>=a?this.J|this.u:this.u},getProgress:function(a){a=this.T[a?a:this.M];return this.o>=a?1:this.f>a?1:this.f/a},startCollectors:function(){if(!this.D){this.a={loadTimeCollector:B(this,this.ma),mouseCollector:B(this,this.oa),keyboardCollector:B(this,this.la),accelerometerCollector:B(this,this.ea),touchCollector:B(this,this.qa)};if(window.addEventListener)window.addEventListener("load",
218
+ this.a.loadTimeCollector,!1),window.addEventListener("mousemove",this.a.mouseCollector,!1),window.addEventListener("keypress",this.a.keyboardCollector,!1),window.addEventListener("devicemotion",this.a.accelerometerCollector,!1),window.addEventListener("touchmove",this.a.touchCollector,!1);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new sjcl.exception.bug("can't attach event");
219
+ this.D=!0}},stopCollectors:function(){this.D&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,!1),window.removeEventListener("mousemove",this.a.mouseCollector,!1),window.removeEventListener("keypress",this.a.keyboardCollector,!1),window.removeEventListener("devicemotion",this.a.accelerometerCollector,!1),window.removeEventListener("touchmove",this.a.touchCollector,!1)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",
220
+ this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.D=!1)},addEventListener:function(a,b){this.K[a][this.ga++]=b},removeEventListener:function(a,b){var c,d,e=this.K[a],f=[];for(d in e)e.hasOwnProperty(d)&&e[d]===b&&f.push(d);for(c=0;c<f.length;c++)d=f[c],delete e[d]},la:function(){C(this,1)},oa:function(a){var b,c;try{b=a.x||a.clientX||a.offsetX||0,c=a.y||a.clientY||a.offsetY||0}catch(d){c=b=0}0!=b&&0!=c&&this.addEntropy([b,c],2,"mouse");C(this,0)},qa:function(a){a=
221
+ a.touches[0]||a.changedTouches[0];this.addEntropy([a.pageX||a.clientX,a.pageY||a.clientY],1,"touch");C(this,0)},ma:function(){C(this,2)},ea:function(a){a=a.accelerationIncludingGravity.x||a.accelerationIncludingGravity.y||a.accelerationIncludingGravity.z;if(window.orientation){var b=window.orientation;"number"===typeof b&&this.addEntropy(b,1,"accelerometer")}a&&this.addEntropy(a,2,"accelerometer");C(this,0)}};
222
+ function A(a,b){var c,d=sjcl.random.K[a],e=[];for(c in d)d.hasOwnProperty(c)&&e.push(d[c]);for(c=0;c<e.length;c++)e[c](b)}function C(a,b){"undefined"!==typeof window&&window.performance&&"function"===typeof window.performance.now?a.addEntropy(window.performance.now(),b,"loadtime"):a.addEntropy((new Date).valueOf(),b,"loadtime")}function y(a){a.b=z(a).concat(z(a));a.L=new sjcl.cipher.aes(a.b)}function z(a){for(var b=0;4>b&&(a.h[b]=a.h[b]+1|0,!a.h[b]);b++);return a.L.encrypt(a.h)}
223
+ function B(a,b){return function(){b.apply(a,arguments)}}sjcl.random=new sjcl.prng(6);
224
+ a:try{var D,E,F,G;if(G="undefined"!==typeof module&&module.exports){var H;try{H=require("crypto")}catch(a){H=null}G=E=H}if(G&&E.randomBytes)D=E.randomBytes(128),D=new Uint32Array((new Uint8Array(D)).buffer),sjcl.random.addEntropy(D,1024,"crypto['randomBytes']");else if("undefined"!==typeof window&&"undefined"!==typeof Uint32Array){F=new Uint32Array(32);if(window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues(F);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues(F);
225
+ else break a;sjcl.random.addEntropy(F,1024,"crypto['getRandomValues']")}}catch(a){"undefined"!==typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(a))}
226
+ sjcl.json={defaults:{v:1,iter:1E4,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},ja:function(a,b,c,d){c=c||{};d=d||{};var e=sjcl.json,f=e.g({iv:sjcl.random.randomWords(4,0)},e.defaults),g;e.g(f,c);c=f.adata;"string"===typeof f.salt&&(f.salt=sjcl.codec.base64.toBits(f.salt));"string"===typeof f.iv&&(f.iv=sjcl.codec.base64.toBits(f.iv));if(!sjcl.mode[f.mode]||!sjcl.cipher[f.cipher]||"string"===typeof a&&100>=f.iter||64!==f.ts&&96!==f.ts&&128!==f.ts||128!==f.ks&&192!==f.ks&&0x100!==f.ks||2>f.iv.length||
227
+ 4<f.iv.length)throw new sjcl.exception.invalid("json encrypt: invalid parameters");"string"===typeof a?(g=sjcl.misc.cachedPbkdf2(a,f),a=g.key.slice(0,f.ks/32),f.salt=g.salt):sjcl.ecc&&a instanceof sjcl.ecc.elGamal.publicKey&&(g=a.kem(),f.kemtag=g.tag,a=g.key.slice(0,f.ks/32));"string"===typeof b&&(b=sjcl.codec.utf8String.toBits(b));"string"===typeof c&&(f.adata=c=sjcl.codec.utf8String.toBits(c));g=new sjcl.cipher[f.cipher](a);e.g(d,f);d.key=a;f.ct="ccm"===f.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&
228
+ b instanceof ArrayBuffer?sjcl.arrayBuffer.ccm.encrypt(g,b,f.iv,c,f.ts):sjcl.mode[f.mode].encrypt(g,b,f.iv,c,f.ts);return f},encrypt:function(a,b,c,d){var e=sjcl.json,f=e.ja.apply(e,arguments);return e.encode(f)},ia:function(a,b,c,d){c=c||{};d=d||{};var e=sjcl.json;b=e.g(e.g(e.g({},e.defaults),b),c,!0);var f,g;f=b.adata;"string"===typeof b.salt&&(b.salt=sjcl.codec.base64.toBits(b.salt));"string"===typeof b.iv&&(b.iv=sjcl.codec.base64.toBits(b.iv));if(!sjcl.mode[b.mode]||!sjcl.cipher[b.cipher]||"string"===
229
+ typeof a&&100>=b.iter||64!==b.ts&&96!==b.ts&&128!==b.ts||128!==b.ks&&192!==b.ks&&0x100!==b.ks||!b.iv||2>b.iv.length||4<b.iv.length)throw new sjcl.exception.invalid("json decrypt: invalid parameters");"string"===typeof a?(g=sjcl.misc.cachedPbkdf2(a,b),a=g.key.slice(0,b.ks/32),b.salt=g.salt):sjcl.ecc&&a instanceof sjcl.ecc.elGamal.secretKey&&(a=a.unkem(sjcl.codec.base64.toBits(b.kemtag)).slice(0,b.ks/32));"string"===typeof f&&(f=sjcl.codec.utf8String.toBits(f));g=new sjcl.cipher[b.cipher](a);f="ccm"===
230
+ b.mode&&sjcl.arrayBuffer&&sjcl.arrayBuffer.ccm&&b.ct instanceof ArrayBuffer?sjcl.arrayBuffer.ccm.decrypt(g,b.ct,b.iv,b.tag,f,b.ts):sjcl.mode[b.mode].decrypt(g,b.ct,b.iv,f,b.ts);e.g(d,b);d.key=a;return 1===c.raw?f:sjcl.codec.utf8String.fromBits(f)},decrypt:function(a,b,c,d){var e=sjcl.json;return e.ia(a,e.decode(b),c,d)},encode:function(a){var b,c="{",d="";for(b in a)if(a.hasOwnProperty(b)){if(!b.match(/^[a-z0-9]+$/i))throw new sjcl.exception.invalid("json encode: invalid property name");c+=d+'"'+
231
+ b+'":';d=",";switch(typeof a[b]){case "number":case "boolean":c+=a[b];break;case "string":c+='"'+escape(a[b])+'"';break;case "object":c+='"'+sjcl.codec.base64.fromBits(a[b],0)+'"';break;default:throw new sjcl.exception.bug("json encode: unsupported type");}}return c+"}"},decode:function(a){a=a.replace(/\s/g,"");if(!a.match(/^\{.*\}$/))throw new sjcl.exception.invalid("json decode: this isn't json!");a=a.replace(/^\{|\}$/g,"").split(/,/);var b={},c,d;for(c=0;c<a.length;c++){if(!(d=a[c].match(/^\s*(?:(["']?)([a-z][a-z0-9]*)\1)\s*:\s*(?:(-?\d+)|"([a-z0-9+\/%*_.@=\-]*)"|(true|false))$/i)))throw new sjcl.exception.invalid("json decode: this isn't json!");
232
+ null!=d[3]?b[d[2]]=parseInt(d[3],10):null!=d[4]?b[d[2]]=d[2].match(/^(ct|adata|salt|iv)$/)?sjcl.codec.base64.toBits(d[4]):unescape(d[4]):null!=d[5]&&(b[d[2]]="true"===d[5])}return b},g:function(a,b,c){void 0===a&&(a={});if(void 0===b)return a;for(var d in b)if(b.hasOwnProperty(d)){if(c&&void 0!==a[d]&&a[d]!==b[d])throw new sjcl.exception.invalid("required parameter overridden");a[d]=b[d]}return a},sa:function(a,b){var c={},d;for(d in a)a.hasOwnProperty(d)&&a[d]!==b[d]&&(c[d]=a[d]);return c},ra:function(a,
233
+ b){var c={},d;for(d=0;d<b.length;d++)void 0!==a[b[d]]&&(c[b[d]]=a[b[d]]);return c}};sjcl.encrypt=sjcl.json.encrypt;sjcl.decrypt=sjcl.json.decrypt;sjcl.misc.pa={};sjcl.misc.cachedPbkdf2=function(a,b){var c=sjcl.misc.pa,d;b=b||{};d=b.iter||1E3;c=c[a]=c[a]||{};d=c[d]=c[d]||{firstSalt:b.salt&&b.salt.length?b.salt.slice(0):sjcl.random.randomWords(2,0)};c=void 0===b.salt?d.firstSalt:b.salt;d[c]=d[c]||sjcl.misc.pbkdf2(a,c,b.iter);return{key:d[c].slice(0),salt:c.slice(0)}};
234
+ "undefined"!==typeof module&&module.exports&&(module.exports=sjcl);"function"===typeof define&&define([],function(){return sjcl});
js/{wfpopover.1551370846.js → wfpopover.1553617391.js} RENAMED
File without changes
js/{wfselect2.min.1551370846.js → wfselect2.min.1553617391.js} RENAMED
File without changes
lib/dashboard/widget_notifications.php CHANGED
@@ -32,7 +32,7 @@
32
  <div class="wf-flex-col-xs-100 wf-flex-col-lg-50 wf-col-lg-half-padding-left wf-dashboard-item-flex-wrapper wf-central-connected">
33
  <div class="wf-dashboard-item active wf-flex-row-1">
34
  <div class="wf-central-dashboard">
35
- <img class="wf-central-dashboard-logo" src="<?php echo wfUtils::getBaseURL() ?>/images/wf-central-logo.svg" alt="Wordfence Central">
36
  <div class="wf-central-dashboard-copy">
37
  <p><strong><?php _e('Wordfence Central Status', 'wordfence') ?></strong></p>
38
  <p><?php
32
  <div class="wf-flex-col-xs-100 wf-flex-col-lg-50 wf-col-lg-half-padding-left wf-dashboard-item-flex-wrapper wf-central-connected">
33
  <div class="wf-dashboard-item active wf-flex-row-1">
34
  <div class="wf-central-dashboard">
35
+ <img class="wf-central-dashboard-logo" src="<?php echo wfUtils::getBaseURL() ?>images/wf-central-logo.svg" alt="Wordfence Central">
36
  <div class="wf-central-dashboard-copy">
37
  <p><strong><?php _e('Wordfence Central Status', 'wordfence') ?></strong></p>
38
  <p><?php
lib/menu_wordfence_central.php CHANGED
@@ -52,7 +52,7 @@ else {
52
  <div class="wf-flex-row wf-flex-grow-all">
53
  <div class="wf-flex-row-1 wf-block wf-active">
54
  <div class="wf-central-dashboard">
55
- <img class="wf-central-dashboard-logo" src="<?php echo wfUtils::getBaseURL() ?>/images/wf-central-logo.svg" alt="Wordfence Central">
56
  <div class="wf-central-dashboard-copy">
57
  <p><strong><?php _e('Wordfence Central', 'wordfence') ?></strong></p>
58
  <p><?php _e('Wordfence Central allows you to manage Wordfence on multiple sites from one location. It makes security monitoring and configuring Wordfence easier.', 'wordfence') ?></p>
52
  <div class="wf-flex-row wf-flex-grow-all">
53
  <div class="wf-flex-row-1 wf-block wf-active">
54
  <div class="wf-central-dashboard">
55
+ <img class="wf-central-dashboard-logo" src="<?php echo wfUtils::getBaseURL() ?>images/wf-central-logo.svg" alt="Wordfence Central">
56
  <div class="wf-central-dashboard-copy">
57
  <p><strong><?php _e('Wordfence Central', 'wordfence') ?></strong></p>
58
  <p><?php _e('Wordfence Central allows you to manage Wordfence on multiple sites from one location. It makes security monitoring and configuring Wordfence easier.', 'wordfence') ?></p>
lib/rest-api/wfRESTAuthenticationController.php CHANGED
@@ -46,6 +46,7 @@ class wfRESTAuthenticationController {
46
  public function nonce($request) {
47
  $response = rest_ensure_response(array(
48
  'nonce' => self::generateNonce(),
 
49
  ));
50
  return $response;
51
  }
@@ -55,7 +56,7 @@ class wfRESTAuthenticationController {
55
  * @return mixed|WP_REST_Response
56
  */
57
  public function authenticate($request) {
58
- require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload.php';
59
 
60
  $siteID = wfConfig::get('wordfenceCentralSiteID');
61
  if (!$siteID) {
@@ -116,7 +117,7 @@ class wfRESTAuthenticationController {
116
  * @return mixed|WP_REST_Response
117
  */
118
  public function authenticatePremium($request) {
119
- require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload.php';
120
 
121
  // verify signature.
122
  $data = $request->get_param('data');
46
  public function nonce($request) {
47
  $response = rest_ensure_response(array(
48
  'nonce' => self::generateNonce(),
49
+ 'admin_url' => network_admin_url(),
50
  ));
51
  return $response;
52
  }
56
  * @return mixed|WP_REST_Response
57
  */
58
  public function authenticate($request) {
59
+ require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload-fast.php';
60
 
61
  $siteID = wfConfig::get('wordfenceCentralSiteID');
62
  if (!$siteID) {
117
  * @return mixed|WP_REST_Response
118
  */
119
  public function authenticatePremium($request) {
120
+ require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload-fast.php';
121
 
122
  // verify signature.
123
  $data = $request->get_param('data');
lib/rest-api/wfRESTConfigController.php CHANGED
@@ -146,6 +146,7 @@ class wfRESTConfigController extends wfRESTBaseController {
146
  $systemInfo['output_buffering'] = ini_get('output_buffering');
147
  $systemInfo['ip'] = wfUtils::getIPAndServerVariable();
148
  $systemInfo['detected_ips'] = wfUtils::getAllServerVariableIPs();
 
149
 
150
  $response = rest_ensure_response(array(
151
  'config' => $config,
@@ -217,7 +218,7 @@ class wfRESTConfigController extends wfRESTBaseController {
217
  * @return mixed|WP_REST_Response
218
  */
219
  public function premiumConnect($request) {
220
- require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload.php';
221
 
222
  // Store values sent by Central.
223
  $wordfenceCentralPK = $request['public-key'];
146
  $systemInfo['output_buffering'] = ini_get('output_buffering');
147
  $systemInfo['ip'] = wfUtils::getIPAndServerVariable();
148
  $systemInfo['detected_ips'] = wfUtils::getAllServerVariableIPs();
149
+ $systemInfo['admin_url'] = network_admin_url();
150
 
151
  $response = rest_ensure_response(array(
152
  'config' => $config,
218
  * @return mixed|WP_REST_Response
219
  */
220
  public function premiumConnect($request) {
221
+ require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload-fast.php';
222
 
223
  // Store values sent by Central.
224
  $wordfenceCentralPK = $request['public-key'];
lib/wfCentralAPI.php CHANGED
@@ -253,7 +253,7 @@ class wfCentralAuthenticatedAPIRequest extends wfCentralAPIRequest {
253
  }
254
 
255
  public function fetchToken() {
256
- require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload.php';
257
 
258
  $defaultArgs = array(
259
  'timeout' => 6,
253
  }
254
 
255
  public function fetchToken() {
256
+ require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload-fast.php';
257
 
258
  $defaultArgs = array(
259
  'timeout' => 6,
lib/wfConfig.php CHANGED
@@ -843,12 +843,20 @@ class wfConfig {
843
  $emails = self::getAlertEmails();
844
  return sizeof($emails) > 0 ? true : false;
845
  }
846
- public static function getAlertEmails(){
 
 
 
 
847
  $dat = explode(',', self::get('alertEmails'));
848
  $emails = array();
849
- foreach($dat as $email){
850
- if(preg_match('/\@/', $email)){
851
- $emails[] = trim($email);
 
 
 
 
852
  }
853
  }
854
  return $emails;
843
  $emails = self::getAlertEmails();
844
  return sizeof($emails) > 0 ? true : false;
845
  }
846
+ public static function alertEmailBlacklist() {
847
+ return array('3c4aa9bd643bd9bb9873014227151a85b24ab8d72fe02cc5799b0edc56eabb67', 'aa06081e3962a3c17a85a06ddf9e418ca1ba8fead3f9b7a20beaf51848a1fd75', 'a25a360bded101e25ebabe5643161ddbb6c3fa33838bbe9a123c2ec0cda8d370', '36e8407dfa80d64cfe42ede4d9d5ce2d4840a5e4781b5f8a7b3b8eacec86fcad');
848
+ }
849
+ public static function getAlertEmails() {
850
+ $blacklist = self::alertEmailBlacklist();
851
  $dat = explode(',', self::get('alertEmails'));
852
  $emails = array();
853
+ foreach ($dat as $email) {
854
+ $email = trim($email);
855
+ if (preg_match('/\@/', $email)) {
856
+ $hash = hash('sha256', $email);
857
+ if (!in_array($hash, $blacklist)) {
858
+ $emails[] = $email;
859
+ }
860
  }
861
  }
862
  return $emails;
lib/wfOnboardingController.php CHANGED
@@ -22,7 +22,7 @@ class wfOnboardingController {
22
  * Sets the appropriate initial settings for an existing install so it's not forced through onboarding.
23
  */
24
  public static function migrateOnboarding() {
25
- $alertEmails = wfConfig::get('alertEmails');
26
  $onboardingAttempt1 = wfConfig::get('onboardingAttempt1');
27
  if (!empty($alertEmails) && empty($onboardingAttempt1)) {
28
  wfConfig::set('onboardingAttempt1', self::ONBOARDING_FIRST_LICENSE); //Mark onboarding as done
@@ -128,14 +128,14 @@ class wfOnboardingController {
128
  return false;
129
  }
130
 
131
- $alertEmails = wfConfig::get('alertEmails');
132
  $show = !wfConfig::get('onboardingAttempt2') && empty($alertEmails); //Unset defaults to true, all others false
133
  return $show;
134
  }
135
 
136
  public static function shouldShowAttempt3() {
137
  if (isset($_GET['page']) && preg_match('/^Wordfence/', $_GET['page'])) {
138
- $alertEmails = wfConfig::get('alertEmails');
139
  return empty($alertEmails);
140
  }
141
 
22
  * Sets the appropriate initial settings for an existing install so it's not forced through onboarding.
23
  */
24
  public static function migrateOnboarding() {
25
+ $alertEmails = wfConfig::getAlertEmails();
26
  $onboardingAttempt1 = wfConfig::get('onboardingAttempt1');
27
  if (!empty($alertEmails) && empty($onboardingAttempt1)) {
28
  wfConfig::set('onboardingAttempt1', self::ONBOARDING_FIRST_LICENSE); //Mark onboarding as done
128
  return false;
129
  }
130
 
131
+ $alertEmails = wfConfig::getAlertEmails();
132
  $show = !wfConfig::get('onboardingAttempt2') && empty($alertEmails); //Unset defaults to true, all others false
133
  return $show;
134
  }
135
 
136
  public static function shouldShowAttempt3() {
137
  if (isset($_GET['page']) && preg_match('/^Wordfence/', $_GET['page'])) {
138
+ $alertEmails = wfConfig::getAlertEmails();
139
  return empty($alertEmails);
140
  }
141
 
lib/wordfenceClass.php CHANGED
@@ -4651,7 +4651,7 @@ HTACCESS;
4651
  }
4652
  public static function ajax_updateAlertEmail_callback(){
4653
  $email = trim($_POST['email']);
4654
- if(! preg_match('/[^\@]+\@[^\.]+\.[^\.]+/', $email)){
4655
  return array( 'err' => "Invalid email address given.");
4656
  }
4657
  wfConfig::set('alertEmails', $email);
@@ -5668,6 +5668,7 @@ HTML;
5668
  'modalTemplate' => wfView::create('common/modal-prompt', array('title' => '${title}', 'message' => '${message}', 'primaryButton' => array('id' => 'wf-generic-modal-close', 'label' => __('Close', 'wordfence'), 'link' => '#')))->render(),
5669
  'tokenInvalidTemplate' => wfView::create('common/modal-prompt', array('title' => '${title}', 'message' => '${message}', 'primaryButton' => array('id' => 'wf-token-invalid-modal-reload', 'label' => __('Reload', 'wordfence'), 'link' => '#')))->render(),
5670
  'modalHTMLTemplate' => wfView::create('common/modal-prompt', array('title' => '${title}', 'message' => '{{html message}}', 'primaryButton' => array('id' => 'wf-generic-modal-close', 'label' => __('Close', 'wordfence'), 'link' => '#')))->render(),
 
5671
  ));
5672
  }
5673
  public static function showTOUPPOverlay($classList) {
@@ -6813,8 +6814,24 @@ to your httpd.conf if using Apache, or find documentation on how to disable dire
6813
  $event = new wfWAFCronFetchRulesEvent(time() - 2);
6814
  $event->setWaf(wfWAF::getInstance());
6815
  $success = $event->fire();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6816
 
6817
- return self::_getWAFData($success);
6818
  }
6819
  catch (Exception $e) {
6820
  $wafData = array(
@@ -7065,7 +7082,7 @@ to your httpd.conf if using Apache, or find documentation on how to disable dire
7065
  $waf->getStorageEngine()->setConfig('whitelistedURLParams', $whitelist, 'livewaf');
7066
  }
7067
 
7068
- private static function _getWAFData($updated = null) {
7069
  $data['learningMode'] = wfWAF::getInstance()->isInLearningMode();
7070
  $data['rules'] = wfWAF::getInstance()->getRules();
7071
  /** @var wfWAFRule $rule */
@@ -7111,6 +7128,9 @@ to your httpd.conf if using Apache, or find documentation on how to disable dire
7111
  $data['isPaid'] = (bool) wfConfig::get('isPaid', 0);
7112
  if ($updated !== null) {
7113
  $data['updated'] = (bool) $updated;
 
 
 
7114
  }
7115
  return $data;
7116
  }
@@ -8255,7 +8275,7 @@ if (file_exists(%1$s)) {
8255
  // Step 2: Makes POST request to `/central/api/wf/site/<guid>` endpoint passing in the new public key.
8256
  // Uses JWT from auth grant endpoint as auth.
8257
 
8258
- require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload.php';
8259
 
8260
  $accessToken = wfConfig::get('wordfenceCentralAccessToken');
8261
  if (!$accessToken) {
4651
  }
4652
  public static function ajax_updateAlertEmail_callback(){
4653
  $email = trim($_POST['email']);
4654
+ if(! preg_match('/[^\@]+\@[^\.]+\.[^\.]+/', $email) || in_array(hash('sha256', $email), wfConfig::alertEmailBlacklist())){
4655
  return array( 'err' => "Invalid email address given.");
4656
  }
4657
  wfConfig::set('alertEmails', $email);
5668
  'modalTemplate' => wfView::create('common/modal-prompt', array('title' => '${title}', 'message' => '${message}', 'primaryButton' => array('id' => 'wf-generic-modal-close', 'label' => __('Close', 'wordfence'), 'link' => '#')))->render(),
5669
  'tokenInvalidTemplate' => wfView::create('common/modal-prompt', array('title' => '${title}', 'message' => '${message}', 'primaryButton' => array('id' => 'wf-token-invalid-modal-reload', 'label' => __('Reload', 'wordfence'), 'link' => '#')))->render(),
5670
  'modalHTMLTemplate' => wfView::create('common/modal-prompt', array('title' => '${title}', 'message' => '{{html message}}', 'primaryButton' => array('id' => 'wf-generic-modal-close', 'label' => __('Close', 'wordfence'), 'link' => '#')))->render(),
5671
+ 'alertEmailBlacklist' => wfConfig::alertEmailBlacklist(),
5672
  ));
5673
  }
5674
  public static function showTOUPPOverlay($classList) {
6814
  $event = new wfWAFCronFetchRulesEvent(time() - 2);
6815
  $event->setWaf(wfWAF::getInstance());
6816
  $success = $event->fire();
6817
+ $failureReason = false;
6818
+ if (!$success && method_exists($event, 'getResponse')) {
6819
+ $response = $event->getResponse();
6820
+ if ($response === false) {
6821
+ $failureReason = wfFirewall::UPDATE_FAILURE_UNREACHABLE;
6822
+ }
6823
+ else {
6824
+ $jsonData = @json_decode($response->getBody(), true);
6825
+ if (isset($jsonData['errorMessage']) && strpos($jsonData['errorMessage'], 'rate limit') !== false) {
6826
+ $failureReason = wfFirewall::UPDATE_FAILURE_RATELIMIT;
6827
+ }
6828
+ else if (isset($jsonData['data']['signature'])) {
6829
+ $failureReason = wfFirewall::UPDATE_FAILURE_FILESYSTEM;
6830
+ }
6831
+ }
6832
+ }
6833
 
6834
+ return self::_getWAFData($success, $failureReason);
6835
  }
6836
  catch (Exception $e) {
6837
  $wafData = array(
7082
  $waf->getStorageEngine()->setConfig('whitelistedURLParams', $whitelist, 'livewaf');
7083
  }
7084
 
7085
+ private static function _getWAFData($updated = null, $failureReason = false) {
7086
  $data['learningMode'] = wfWAF::getInstance()->isInLearningMode();
7087
  $data['rules'] = wfWAF::getInstance()->getRules();
7088
  /** @var wfWAFRule $rule */
7128
  $data['isPaid'] = (bool) wfConfig::get('isPaid', 0);
7129
  if ($updated !== null) {
7130
  $data['updated'] = (bool) $updated;
7131
+ if (!$updated) {
7132
+ $data['failure'] = $failureReason;
7133
+ }
7134
  }
7135
  return $data;
7136
  }
8275
  // Step 2: Makes POST request to `/central/api/wf/site/<guid>` endpoint passing in the new public key.
8276
  // Uses JWT from auth grant endpoint as auth.
8277
 
8278
+ require_once WORDFENCE_PATH . '/vendor/paragonie/sodium_compat/autoload-fast.php';
8279
 
8280
  $accessToken = wfConfig::get('wordfenceCentralAccessToken');
8281
  if (!$accessToken) {
models/firewall/wfFirewall.php CHANGED
@@ -15,6 +15,10 @@ class wfFirewall
15
  const BLACKLIST_MODE_DISABLED = 'disabled';
16
  const BLACKLIST_MODE_ENABLED = 'enabled';
17
 
 
 
 
 
18
  /**
19
  * Returns a string suitable for display of the firewall status.
20
  *
15
  const BLACKLIST_MODE_DISABLED = 'disabled';
16
  const BLACKLIST_MODE_ENABLED = 'enabled';
17
 
18
+ const UPDATE_FAILURE_RATELIMIT = 'ratelimit';
19
+ const UPDATE_FAILURE_UNREACHABLE = 'unreachable';
20
+ const UPDATE_FAILURE_FILESYSTEM = 'filesystem';
21
+
22
  /**
23
  * Returns a string suitable for display of the firewall status.
24
  *
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: security, firewall, malware scanner, web application firewall, antivirus,
4
  Requires at least: 3.9
5
  Requires PHP: 5.3
6
  Tested up to: 5.1
7
- Stable tag: 7.2.3
8
 
9
  Secure your website with the most comprehensive WordPress security plugin. Firewall, malware scan, blocking, live traffic, login security & more.
10
 
@@ -177,6 +177,14 @@ Secure your website with Wordfence.
177
 
178
  == Changelog ==
179
 
 
 
 
 
 
 
 
 
180
  = 7.2.3 - February 28, 2019 =
181
  * Improvement: Country names are now shown instead of two letter codes where appropriate.
182
  * Improvement: Updated the service whitelist to reflect additions to the Facebook IP ranges.
4
  Requires at least: 3.9
5
  Requires PHP: 5.3
6
  Tested up to: 5.1
7
+ Stable tag: 7.2.4
8
 
9
  Secure your website with the most comprehensive WordPress security plugin. Firewall, malware scan, blocking, live traffic, login security & more.
10
 
177
 
178
  == Changelog ==
179
 
180
+ = 7.2.4 - March 26, 2019 =
181
+ * Improvement: Updated vulnerability database integration.
182
+ * Improvement: Better messaging when a WAF rule update fails to better indicate the cause.
183
+ * Fix: Removed a double slash that could occur in an image path.
184
+ * Fix: Adjusted timeouts to improve reliability of WAF rule updates on slower servers.
185
+ * Fix: Improved connection process with Wordfence Central for better reliability on servers with non-standard paths.
186
+ * Fix: Switched to autoloader with fastMult enabled on sodum_compat to minimize connection issues.
187
+
188
  = 7.2.3 - February 28, 2019 =
189
  * Improvement: Country names are now shown instead of two letter codes where appropriate.
190
  * Improvement: Updated the service whitelist to reflect additions to the Facebook IP ranges.
vendor/autoload.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload.php @generated by Composer
4
 
5
- if (!class_exists('ComposerAutoloaderInit6d00a11c4faa7bdc4bb08ac266cdf951')) { //Added to generated file to compensate for instances where the WAF loads from a different instance
6
  require_once __DIR__ . '/composer/autoload_real.php';
7
  }
8
 
2
 
3
  // autoload.php @generated by Composer
4
 
5
+ if (!class_exists('ComposerAutoloaderInit6d00a11c4faa7bdc4bb08ac266cdf951')) {
6
  require_once __DIR__ . '/composer/autoload_real.php';
7
  }
8
 
vendor/composer/autoload_files.php CHANGED
@@ -6,6 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
- '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
10
  '3109cb1a231dcd04bee1f9f620d46975' => $vendorDir . '/paragonie/sodium_compat/autoload.php',
11
  );
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
 
9
  '3109cb1a231dcd04bee1f9f620d46975' => $vendorDir . '/paragonie/sodium_compat/autoload.php',
10
  );
vendor/composer/autoload_real.php CHANGED
@@ -47,6 +47,24 @@ class ComposerAutoloaderInit6d00a11c4faa7bdc4bb08ac266cdf951
47
 
48
  $loader->register(true);
49
 
 
 
 
 
 
 
 
 
 
50
  return $loader;
51
  }
52
  }
 
 
 
 
 
 
 
 
 
47
 
48
  $loader->register(true);
49
 
50
+ if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit6d00a11c4faa7bdc4bb08ac266cdf951::$files;
52
+ } else {
53
+ $includeFiles = require __DIR__ . '/autoload_files.php';
54
+ }
55
+ foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire6d00a11c4faa7bdc4bb08ac266cdf951($fileIdentifier, $file);
57
+ }
58
+
59
  return $loader;
60
  }
61
  }
62
+
63
+ function composerRequire6d00a11c4faa7bdc4bb08ac266cdf951($fileIdentifier, $file)
64
+ {
65
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
+ require $file;
67
+
68
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
69
+ }
70
+ }
vendor/composer/autoload_static.php CHANGED
@@ -6,6 +6,10 @@ namespace Composer\Autoload;
6
 
7
  class ComposerStaticInit6d00a11c4faa7bdc4bb08ac266cdf951
8
  {
 
 
 
 
9
  public static $prefixLengthsPsr4 = array (
10
  'M' =>
11
  array (
6
 
7
  class ComposerStaticInit6d00a11c4faa7bdc4bb08ac266cdf951
8
  {
9
+ public static $files = array (
10
+ '3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php',
11
+ );
12
+
13
  public static $prefixLengthsPsr4 = array (
14
  'M' =>
15
  array (
vendor/composer/installed.json CHANGED
@@ -217,5 +217,154 @@
217
  ],
218
  "description": "Internal MaxMind Web Service API",
219
  "homepage": "https://github.com/maxmind/web-service-common-php"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  }
221
  ]
217
  ],
218
  "description": "Internal MaxMind Web Service API",
219
  "homepage": "https://github.com/maxmind/web-service-common-php"
220
+ },
221
+ {
222
+ "name": "paragonie/random_compat",
223
+ "version": "v9.99.99",
224
+ "version_normalized": "9.99.99.0",
225
+ "source": {
226
+ "type": "git",
227
+ "url": "https://github.com/paragonie/random_compat.git",
228
+ "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95"
229
+ },
230
+ "dist": {
231
+ "type": "zip",
232
+ "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
233
+ "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
234
+ "shasum": ""
235
+ },
236
+ "require": {
237
+ "php": "^7"
238
+ },
239
+ "require-dev": {
240
+ "phpunit/phpunit": "4.*|5.*",
241
+ "vimeo/psalm": "^1"
242
+ },
243
+ "suggest": {
244
+ "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
245
+ },
246
+ "time": "2018-07-02T15:55:56+00:00",
247
+ "type": "library",
248
+ "installation-source": "dist",
249
+ "notification-url": "https://packagist.org/downloads/",
250
+ "license": [
251
+ "MIT"
252
+ ],
253
+ "authors": [
254
+ {
255
+ "name": "Paragon Initiative Enterprises",
256
+ "email": "security@paragonie.com",
257
+ "homepage": "https://paragonie.com"
258
+ }
259
+ ],
260
+ "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
261
+ "keywords": [
262
+ "csprng",
263
+ "polyfill",
264
+ "pseudorandom",
265
+ "random"
266
+ ]
267
+ },
268
+ {
269
+ "name": "paragonie/sodium_compat",
270
+ "version": "v1.9.1",
271
+ "version_normalized": "1.9.1.0",
272
+ "source": {
273
+ "type": "git",
274
+ "url": "https://github.com/paragonie/sodium_compat.git",
275
+ "reference": "87125d5b265f98c4d1b8d83a1f0726607c229421"
276
+ },
277
+ "dist": {
278
+ "type": "zip",
279
+ "url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/87125d5b265f98c4d1b8d83a1f0726607c229421",
280
+ "reference": "87125d5b265f98c4d1b8d83a1f0726607c229421",
281
+ "shasum": ""
282
+ },
283
+ "require": {
284
+ "paragonie/random_compat": ">=1",
285
+ "php": "^5.2.4|^5.3|^5.4|^5.5|^5.6|^7|^8"
286
+ },
287
+ "require-dev": {
288
+ "phpunit/phpunit": "^3|^4|^5"
289
+ },
290
+ "suggest": {
291
+ "ext-libsodium": "PHP < 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security.",
292
+ "ext-sodium": "PHP >= 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security."
293
+ },
294
+ "time": "2019-03-20T17:19:05+00:00",
295
+ "type": "library",
296
+ "installation-source": "dist",
297
+ "autoload": {
298
+ "files": [
299
+ "autoload.php"
300
+ ]
301
+ },
302
+ "notification-url": "https://packagist.org/downloads/",
303
+ "license": [
304
+ "ISC"
305
+ ],
306
+ "authors": [
307
+ {
308
+ "name": "Paragon Initiative Enterprises",
309
+ "email": "security@paragonie.com"
310
+ },
311
+ {
312
+ "name": "Frank Denis",
313
+ "email": "jedisct1@pureftpd.org"
314
+ }
315
+ ],
316
+ "description": "Pure PHP implementation of libsodium; uses the PHP extension if it exists",
317
+ "keywords": [
318
+ "Authentication",
319
+ "BLAKE2b",
320
+ "ChaCha20",
321
+ "ChaCha20-Poly1305",
322
+ "Chapoly",
323
+ "Curve25519",
324
+ "Ed25519",
325
+ "EdDSA",
326
+ "Edwards-curve Digital Signature Algorithm",
327
+ "Elliptic Curve Diffie-Hellman",
328
+ "Poly1305",
329
+ "Pure-PHP cryptography",
330
+ "RFC 7748",
331
+ "RFC 8032",
332
+ "Salpoly",
333
+ "Salsa20",
334
+ "X25519",
335
+ "XChaCha20-Poly1305",
336
+ "XSalsa20-Poly1305",
337
+ "Xchacha20",
338
+ "Xsalsa20",
339
+ "aead",
340
+ "cryptography",
341
+ "ecdh",
342
+ "elliptic curve",
343
+ "elliptic curve cryptography",
344
+ "encryption",
345
+ "libsodium",
346
+ "php",
347
+ "public-key cryptography",
348
+ "secret-key cryptography",
349
+ "side-channel resistant"
350
+ ]
351
+ },
352
+ {
353
+ "name": "wordfence/wf-waf",
354
+ "version": "1.0.0",
355
+ "version_normalized": "1.0.0.0",
356
+ "source": {
357
+ "type": "git",
358
+ "url": "https://github.com/wordfence/wf-waf.git",
359
+ "reference": "origin/master"
360
+ },
361
+ "dist": {
362
+ "type": "zip",
363
+ "url": "https://github.com/wordfence/wf-waf/zipball/master",
364
+ "reference": "origin/master",
365
+ "shasum": null
366
+ },
367
+ "type": "library",
368
+ "installation-source": "source"
369
  }
370
  ]
vendor/paragonie/random_compat/lib/byte_safe_strings.php DELETED
@@ -1,181 +0,0 @@
1
- <?php
2
- /**
3
- * Random_* Compatibility Library
4
- * for using the new PHP 7 random_* API in PHP 5 projects
5
- *
6
- * The MIT License (MIT)
7
- *
8
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in
18
- * all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- * SOFTWARE.
27
- */
28
-
29
- if (!is_callable('RandomCompat_strlen')) {
30
- if (
31
- defined('MB_OVERLOAD_STRING') &&
32
- ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
33
- ) {
34
- /**
35
- * strlen() implementation that isn't brittle to mbstring.func_overload
36
- *
37
- * This version uses mb_strlen() in '8bit' mode to treat strings as raw
38
- * binary rather than UTF-8, ISO-8859-1, etc
39
- *
40
- * @param string $binary_string
41
- *
42
- * @throws TypeError
43
- *
44
- * @return int
45
- */
46
- function RandomCompat_strlen($binary_string)
47
- {
48
- if (!is_string($binary_string)) {
49
- throw new TypeError(
50
- 'RandomCompat_strlen() expects a string'
51
- );
52
- }
53
-
54
- return (int) mb_strlen($binary_string, '8bit');
55
- }
56
-
57
- } else {
58
- /**
59
- * strlen() implementation that isn't brittle to mbstring.func_overload
60
- *
61
- * This version just used the default strlen()
62
- *
63
- * @param string $binary_string
64
- *
65
- * @throws TypeError
66
- *
67
- * @return int
68
- */
69
- function RandomCompat_strlen($binary_string)
70
- {
71
- if (!is_string($binary_string)) {
72
- throw new TypeError(
73
- 'RandomCompat_strlen() expects a string'
74
- );
75
- }
76
- return (int) strlen($binary_string);
77
- }
78
- }
79
- }
80
-
81
- if (!is_callable('RandomCompat_substr')) {
82
-
83
- if (
84
- defined('MB_OVERLOAD_STRING')
85
- &&
86
- ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
87
- ) {
88
- /**
89
- * substr() implementation that isn't brittle to mbstring.func_overload
90
- *
91
- * This version uses mb_substr() in '8bit' mode to treat strings as raw
92
- * binary rather than UTF-8, ISO-8859-1, etc
93
- *
94
- * @param string $binary_string
95
- * @param int $start
96
- * @param int $length (optional)
97
- *
98
- * @throws TypeError
99
- *
100
- * @return string
101
- */
102
- function RandomCompat_substr($binary_string, $start, $length = null)
103
- {
104
- if (!is_string($binary_string)) {
105
- throw new TypeError(
106
- 'RandomCompat_substr(): First argument should be a string'
107
- );
108
- }
109
-
110
- if (!is_int($start)) {
111
- throw new TypeError(
112
- 'RandomCompat_substr(): Second argument should be an integer'
113
- );
114
- }
115
-
116
- if ($length === null) {
117
- /**
118
- * mb_substr($str, 0, NULL, '8bit') returns an empty string on
119
- * PHP 5.3, so we have to find the length ourselves.
120
- */
121
- $length = RandomCompat_strlen($binary_string) - $start;
122
- } elseif (!is_int($length)) {
123
- throw new TypeError(
124
- 'RandomCompat_substr(): Third argument should be an integer, or omitted'
125
- );
126
- }
127
-
128
- // Consistency with PHP's behavior
129
- if ($start === RandomCompat_strlen($binary_string) && $length === 0) {
130
- return '';
131
- }
132
- if ($start > RandomCompat_strlen($binary_string)) {
133
- return '';
134
- }
135
-
136
- return (string) mb_substr($binary_string, $start, $length, '8bit');
137
- }
138
-
139
- } else {
140
-
141
- /**
142
- * substr() implementation that isn't brittle to mbstring.func_overload
143
- *
144
- * This version just uses the default substr()
145
- *
146
- * @param string $binary_string
147
- * @param int $start
148
- * @param int $length (optional)
149
- *
150
- * @throws TypeError
151
- *
152
- * @return string
153
- */
154
- function RandomCompat_substr($binary_string, $start, $length = null)
155
- {
156
- if (!is_string($binary_string)) {
157
- throw new TypeError(
158
- 'RandomCompat_substr(): First argument should be a string'
159
- );
160
- }
161
-
162
- if (!is_int($start)) {
163
- throw new TypeError(
164
- 'RandomCompat_substr(): Second argument should be an integer'
165
- );
166
- }
167
-
168
- if ($length !== null) {
169
- if (!is_int($length)) {
170
- throw new TypeError(
171
- 'RandomCompat_substr(): Third argument should be an integer, or omitted'
172
- );
173
- }
174
-
175
- return (string) substr($binary_string, $start, $length);
176
- }
177
-
178
- return (string) substr($binary_string, $start);
179
- }
180
- }
181
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/random_compat/lib/cast_to_int.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
- /**
3
- * Random_* Compatibility Library
4
- * for using the new PHP 7 random_* API in PHP 5 projects
5
- *
6
- * The MIT License (MIT)
7
- *
8
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in
18
- * all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- * SOFTWARE.
27
- */
28
-
29
- if (!is_callable('RandomCompat_intval')) {
30
-
31
- /**
32
- * Cast to an integer if we can, safely.
33
- *
34
- * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)
35
- * (non-inclusive), it will sanely cast it to an int. If you it's equal to
36
- * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats
37
- * lose precision, so the <= and => operators might accidentally let a float
38
- * through.
39
- *
40
- * @param int|float $number The number we want to convert to an int
41
- * @param bool $fail_open Set to true to not throw an exception
42
- *
43
- * @return float|int
44
- * @psalm-suppress InvalidReturnType
45
- *
46
- * @throws TypeError
47
- */
48
- function RandomCompat_intval($number, $fail_open = false)
49
- {
50
- if (is_int($number) || is_float($number)) {
51
- $number += 0;
52
- } elseif (is_numeric($number)) {
53
- $number += 0;
54
- }
55
-
56
- if (
57
- is_float($number)
58
- &&
59
- $number > ~PHP_INT_MAX
60
- &&
61
- $number < PHP_INT_MAX
62
- ) {
63
- $number = (int) $number;
64
- }
65
-
66
- if (is_int($number)) {
67
- return (int) $number;
68
- } elseif (!$fail_open) {
69
- throw new TypeError(
70
- 'Expected an integer.'
71
- );
72
- }
73
- return $number;
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/random_compat/lib/error_polyfill.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Random_* Compatibility Library
4
- * for using the new PHP 7 random_* API in PHP 5 projects
5
- *
6
- * The MIT License (MIT)
7
- *
8
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in
18
- * all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- * SOFTWARE.
27
- */
28
-
29
- if (!class_exists('Error', false)) {
30
- // We can't really avoid making this extend Exception in PHP 5.
31
- class Error extends Exception
32
- {
33
-
34
- }
35
- }
36
-
37
- if (!class_exists('TypeError', false)) {
38
- if (is_subclass_of('Error', 'Exception')) {
39
- class TypeError extends Error
40
- {
41
-
42
- }
43
- } else {
44
- class TypeError extends Exception
45
- {
46
-
47
- }
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/random_compat/lib/random.php CHANGED
@@ -3,12 +3,12 @@
3
  * Random_* Compatibility Library
4
  * for using the new PHP 7 random_* API in PHP 5 projects
5
  *
6
- * @version 2.0.10
7
- * @released 2017-03-13
8
  *
9
  * The MIT License (MIT)
10
  *
11
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
12
  *
13
  * Permission is hereby granted, free of charge, to any person obtaining a copy
14
  * of this software and associated documentation files (the "Software"), to deal
@@ -29,197 +29,4 @@
29
  * SOFTWARE.
30
  */
31
 
32
- if (!defined('PHP_VERSION_ID')) {
33
- // This constant was introduced in PHP 5.2.7
34
- $RandomCompatversion = array_map('intval', explode('.', PHP_VERSION));
35
- define(
36
- 'PHP_VERSION_ID',
37
- $RandomCompatversion[0] * 10000
38
- + $RandomCompatversion[1] * 100
39
- + $RandomCompatversion[2]
40
- );
41
- $RandomCompatversion = null;
42
- }
43
-
44
- /**
45
- * PHP 7.0.0 and newer have these functions natively.
46
- */
47
- if (PHP_VERSION_ID >= 70000) {
48
- return;
49
- }
50
-
51
- if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
52
- define('RANDOM_COMPAT_READ_BUFFER', 8);
53
- }
54
-
55
- $RandomCompatDIR = dirname(__FILE__);
56
-
57
- require_once $RandomCompatDIR . '/byte_safe_strings.php';
58
- require_once $RandomCompatDIR . '/cast_to_int.php';
59
- require_once $RandomCompatDIR . '/error_polyfill.php';
60
-
61
- if (!is_callable('random_bytes')) {
62
- /**
63
- * PHP 5.2.0 - 5.6.x way to implement random_bytes()
64
- *
65
- * We use conditional statements here to define the function in accordance
66
- * to the operating environment. It's a micro-optimization.
67
- *
68
- * In order of preference:
69
- * 1. Use libsodium if available.
70
- * 2. fread() /dev/urandom if available (never on Windows)
71
- * 3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM)
72
- * 4. COM('CAPICOM.Utilities.1')->GetRandom()
73
- *
74
- * See RATIONALE.md for our reasoning behind this particular order
75
- */
76
- if (extension_loaded('libsodium')) {
77
- // See random_bytes_libsodium.php
78
- if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) {
79
- require_once $RandomCompatDIR . '/random_bytes_libsodium.php';
80
- } elseif (method_exists('Sodium', 'randombytes_buf')) {
81
- require_once $RandomCompatDIR . '/random_bytes_libsodium_legacy.php';
82
- }
83
- }
84
-
85
- /**
86
- * Reading directly from /dev/urandom:
87
- */
88
- if (DIRECTORY_SEPARATOR === '/') {
89
- // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast
90
- // way to exclude Windows.
91
- $RandomCompatUrandom = true;
92
- $RandomCompat_basedir = ini_get('open_basedir');
93
-
94
- if (!empty($RandomCompat_basedir)) {
95
- $RandomCompat_open_basedir = explode(
96
- PATH_SEPARATOR,
97
- strtolower($RandomCompat_basedir)
98
- );
99
- $RandomCompatUrandom = (array() !== array_intersect(
100
- array('/dev', '/dev/', '/dev/urandom'),
101
- $RandomCompat_open_basedir
102
- ));
103
- $RandomCompat_open_basedir = null;
104
- }
105
-
106
- if (
107
- !is_callable('random_bytes')
108
- &&
109
- $RandomCompatUrandom
110
- &&
111
- @is_readable('/dev/urandom')
112
- ) {
113
- // Error suppression on is_readable() in case of an open_basedir
114
- // or safe_mode failure. All we care about is whether or not we
115
- // can read it at this point. If the PHP environment is going to
116
- // panic over trying to see if the file can be read in the first
117
- // place, that is not helpful to us here.
118
-
119
- // See random_bytes_dev_urandom.php
120
- require_once $RandomCompatDIR . '/random_bytes_dev_urandom.php';
121
- }
122
- // Unset variables after use
123
- $RandomCompat_basedir = null;
124
- } else {
125
- $RandomCompatUrandom = false;
126
- }
127
-
128
- /**
129
- * mcrypt_create_iv()
130
- *
131
- * We only want to use mcypt_create_iv() if:
132
- *
133
- * - random_bytes() hasn't already been defined
134
- * - the mcrypt extensions is loaded
135
- * - One of these two conditions is true:
136
- * - We're on Windows (DIRECTORY_SEPARATOR !== '/')
137
- * - We're not on Windows and /dev/urandom is readabale
138
- * (i.e. we're not in a chroot jail)
139
- * - Special case:
140
- * - If we're not on Windows, but the PHP version is between
141
- * 5.6.10 and 5.6.12, we don't want to use mcrypt. It will
142
- * hang indefinitely. This is bad.
143
- * - If we're on Windows, we want to use PHP >= 5.3.7 or else
144
- * we get insufficient entropy errors.
145
- */
146
- if (
147
- !is_callable('random_bytes')
148
- &&
149
- // Windows on PHP < 5.3.7 is broken, but non-Windows is not known to be.
150
- (DIRECTORY_SEPARATOR === '/' || PHP_VERSION_ID >= 50307)
151
- &&
152
- // Prevent this code from hanging indefinitely on non-Windows;
153
- // see https://bugs.php.net/bug.php?id=69833
154
- (
155
- DIRECTORY_SEPARATOR !== '/' ||
156
- (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613)
157
- )
158
- &&
159
- extension_loaded('mcrypt')
160
- ) {
161
- // See random_bytes_mcrypt.php
162
- require_once $RandomCompatDIR . '/random_bytes_mcrypt.php';
163
- }
164
- $RandomCompatUrandom = null;
165
-
166
- /**
167
- * This is a Windows-specific fallback, for when the mcrypt extension
168
- * isn't loaded.
169
- */
170
- if (
171
- !is_callable('random_bytes')
172
- &&
173
- extension_loaded('com_dotnet')
174
- &&
175
- class_exists('COM')
176
- ) {
177
- $RandomCompat_disabled_classes = preg_split(
178
- '#\s*,\s*#',
179
- strtolower(ini_get('disable_classes'))
180
- );
181
-
182
- if (!in_array('com', $RandomCompat_disabled_classes)) {
183
- try {
184
- $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
185
- if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
186
- // See random_bytes_com_dotnet.php
187
- require_once $RandomCompatDIR . '/random_bytes_com_dotnet.php';
188
- }
189
- } catch (com_exception $e) {
190
- // Don't try to use it.
191
- }
192
- }
193
- $RandomCompat_disabled_classes = null;
194
- $RandomCompatCOMtest = null;
195
- }
196
-
197
- /**
198
- * throw new Exception
199
- */
200
- if (!is_callable('random_bytes')) {
201
- /**
202
- * We don't have any more options, so let's throw an exception right now
203
- * and hope the developer won't let it fail silently.
204
- *
205
- * @param mixed $length
206
- * @psalm-suppress MissingReturnType
207
- * @throws Exception
208
- * @return string
209
- */
210
- function random_bytes($length)
211
- {
212
- unset($length); // Suppress "variable not used" warnings.
213
- throw new Exception(
214
- 'There is no suitable CSPRNG installed on your system'
215
- );
216
- return '';
217
- }
218
- }
219
- }
220
-
221
- if (!is_callable('random_int')) {
222
- require_once $RandomCompatDIR . '/random_int.php';
223
- }
224
-
225
- $RandomCompatDIR = null;
3
  * Random_* Compatibility Library
4
  * for using the new PHP 7 random_* API in PHP 5 projects
5
  *
6
+ * @version 2.99.99
7
+ * @released 2018-06-06
8
  *
9
  * The MIT License (MIT)
10
  *
11
+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
12
  *
13
  * Permission is hereby granted, free of charge, to any person obtaining a copy
14
  * of this software and associated documentation files (the "Software"), to deal
29
  * SOFTWARE.
30
  */
31
 
32
+ // NOP
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/random_compat/lib/random_bytes_com_dotnet.php DELETED
@@ -1,88 +0,0 @@
1
- <?php
2
- /**
3
- * Random_* Compatibility Library
4
- * for using the new PHP 7 random_* API in PHP 5 projects
5
- *
6
- * The MIT License (MIT)
7
- *
8
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in
18
- * all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- * SOFTWARE.
27
- */
28
-
29
- if (!is_callable('random_bytes')) {
30
- /**
31
- * Windows with PHP < 5.3.0 will not have the function
32
- * openssl_random_pseudo_bytes() available, so let's use
33
- * CAPICOM to work around this deficiency.
34
- *
35
- * @param int $bytes
36
- *
37
- * @throws Exception
38
- *
39
- * @return string
40
- */
41
- function random_bytes($bytes)
42
- {
43
- try {
44
- $bytes = RandomCompat_intval($bytes);
45
- } catch (TypeError $ex) {
46
- throw new TypeError(
47
- 'random_bytes(): $bytes must be an integer'
48
- );
49
- }
50
-
51
- if ($bytes < 1) {
52
- throw new Error(
53
- 'Length must be greater than 0'
54
- );
55
- }
56
-
57
- $buf = '';
58
- if (!class_exists('COM')) {
59
- throw new Error(
60
- 'COM does not exist'
61
- );
62
- }
63
- $util = new COM('CAPICOM.Utilities.1');
64
- $execCount = 0;
65
-
66
- /**
67
- * Let's not let it loop forever. If we run N times and fail to
68
- * get N bytes of random data, then CAPICOM has failed us.
69
- */
70
- do {
71
- $buf .= base64_decode($util->GetRandom($bytes, 0));
72
- if (RandomCompat_strlen($buf) >= $bytes) {
73
- /**
74
- * Return our random entropy buffer here:
75
- */
76
- return RandomCompat_substr($buf, 0, $bytes);
77
- }
78
- ++$execCount;
79
- } while ($execCount < $bytes);
80
-
81
- /**
82
- * If we reach here, PHP has failed us.
83
- */
84
- throw new Exception(
85
- 'Could not gather sufficient random data'
86
- );
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/random_compat/lib/random_bytes_dev_urandom.php DELETED
@@ -1,167 +0,0 @@
1
- <?php
2
- /**
3
- * Random_* Compatibility Library
4
- * for using the new PHP 7 random_* API in PHP 5 projects
5
- *
6
- * The MIT License (MIT)
7
- *
8
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in
18
- * all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- * SOFTWARE.
27
- */
28
-
29
- if (!defined('RANDOM_COMPAT_READ_BUFFER')) {
30
- define('RANDOM_COMPAT_READ_BUFFER', 8);
31
- }
32
-
33
- if (!is_callable('random_bytes')) {
34
- /**
35
- * Unless open_basedir is enabled, use /dev/urandom for
36
- * random numbers in accordance with best practices
37
- *
38
- * Why we use /dev/urandom and not /dev/random
39
- * @ref http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers
40
- *
41
- * @param int $bytes
42
- *
43
- * @throws Exception
44
- *
45
- * @return string
46
- */
47
- function random_bytes($bytes)
48
- {
49
- static $fp = null;
50
- /**
51
- * This block should only be run once
52
- */
53
- if (empty($fp)) {
54
- /**
55
- * We use /dev/urandom if it is a char device.
56
- * We never fall back to /dev/random
57
- */
58
- $fp = fopen('/dev/urandom', 'rb');
59
- if (!empty($fp)) {
60
- $st = fstat($fp);
61
- if (($st['mode'] & 0170000) !== 020000) {
62
- fclose($fp);
63
- $fp = false;
64
- }
65
- }
66
-
67
- if (!empty($fp)) {
68
- /**
69
- * stream_set_read_buffer() does not exist in HHVM
70
- *
71
- * If we don't set the stream's read buffer to 0, PHP will
72
- * internally buffer 8192 bytes, which can waste entropy
73
- *
74
- * stream_set_read_buffer returns 0 on success
75
- */
76
- if (is_callable('stream_set_read_buffer')) {
77
- stream_set_read_buffer($fp, RANDOM_COMPAT_READ_BUFFER);
78
- }
79
- if (is_callable('stream_set_chunk_size')) {
80
- stream_set_chunk_size($fp, RANDOM_COMPAT_READ_BUFFER);
81
- }
82
- }
83
- }
84
-
85
- try {
86
- $bytes = RandomCompat_intval($bytes);
87
- } catch (TypeError $ex) {
88
- throw new TypeError(
89
- 'random_bytes(): $bytes must be an integer'
90
- );
91
- }
92
-
93
- if ($bytes < 1) {
94
- throw new Error(
95
- 'Length must be greater than 0'
96
- );
97
- }
98
-
99
- /**
100
- * This if() block only runs if we managed to open a file handle
101
- *
102
- * It does not belong in an else {} block, because the above
103
- * if (empty($fp)) line is logic that should only be run once per
104
- * page load.
105
- */
106
- if (!empty($fp)) {
107
- /**
108
- * @var int
109
- */
110
- $remaining = $bytes;
111
-
112
- /**
113
- * @var string|bool
114
- */
115
- $buf = '';
116
-
117
- /**
118
- * We use fread() in a loop to protect against partial reads
119
- */
120
- do {
121
- /**
122
- * @var string|bool
123
- */
124
- $read = fread($fp, $remaining);
125
- if (!is_string($read)) {
126
- if ($read === false) {
127
- /**
128
- * We cannot safely read from the file. Exit the
129
- * do-while loop and trigger the exception condition
130
- *
131
- * @var string|bool
132
- */
133
- $buf = false;
134
- break;
135
- }
136
- }
137
- /**
138
- * Decrease the number of bytes returned from remaining
139
- */
140
- $remaining -= RandomCompat_strlen($read);
141
- /**
142
- * @var string|bool
143
- */
144
- $buf = $buf . $read;
145
- } while ($remaining > 0);
146
-
147
- /**
148
- * Is our result valid?
149
- */
150
- if (is_string($buf)) {
151
- if (RandomCompat_strlen($buf) === $bytes) {
152
- /**
153
- * Return our random entropy buffer here:
154
- */
155
- return $buf;
156
- }
157
- }
158
- }
159
-
160
- /**
161
- * If we reach here, PHP has failed us.
162
- */
163
- throw new Exception(
164
- 'Error reading from source device'
165
- );
166
- }
167
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/random_compat/lib/random_bytes_libsodium.php DELETED
@@ -1,88 +0,0 @@
1
- <?php
2
- /**
3
- * Random_* Compatibility Library
4
- * for using the new PHP 7 random_* API in PHP 5 projects
5
- *
6
- * The MIT License (MIT)
7
- *
8
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in
18
- * all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- * SOFTWARE.
27
- */
28
-
29
- if (!is_callable('random_bytes')) {
30
- /**
31
- * If the libsodium PHP extension is loaded, we'll use it above any other
32
- * solution.
33
- *
34
- * libsodium-php project:
35
- * @ref https://github.com/jedisct1/libsodium-php
36
- *
37
- * @param int $bytes
38
- *
39
- * @throws Exception
40
- *
41
- * @return string
42
- */
43
- function random_bytes($bytes)
44
- {
45
- try {
46
- $bytes = RandomCompat_intval($bytes);
47
- } catch (TypeError $ex) {
48
- throw new TypeError(
49
- 'random_bytes(): $bytes must be an integer'
50
- );
51
- }
52
-
53
- if ($bytes < 1) {
54
- throw new Error(
55
- 'Length must be greater than 0'
56
- );
57
- }
58
-
59
- /**
60
- * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
61
- * generated in one invocation.
62
- */
63
- if ($bytes > 2147483647) {
64
- $buf = '';
65
- for ($i = 0; $i < $bytes; $i += 1073741824) {
66
- $n = ($bytes - $i) > 1073741824
67
- ? 1073741824
68
- : $bytes - $i;
69
- $buf .= \Sodium\randombytes_buf($n);
70
- }
71
- } else {
72
- $buf = \Sodium\randombytes_buf($bytes);
73
- }
74
-
75
- if ($buf !== false) {
76
- if (RandomCompat_strlen($buf) === $bytes) {
77
- return $buf;
78
- }
79
- }
80
-
81
- /**
82
- * If we reach here, PHP has failed us.
83
- */
84
- throw new Exception(
85
- 'Could not gather sufficient random data'
86
- );
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/random_compat/lib/random_bytes_libsodium_legacy.php DELETED
@@ -1,92 +0,0 @@
1
- <?php
2
- /**
3
- * Random_* Compatibility Library
4
- * for using the new PHP 7 random_* API in PHP 5 projects
5
- *
6
- * The MIT License (MIT)
7
- *
8
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in
18
- * all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- * SOFTWARE.
27
- */
28
-
29
- if (!is_callable('random_bytes')) {
30
- /**
31
- * If the libsodium PHP extension is loaded, we'll use it above any other
32
- * solution.
33
- *
34
- * libsodium-php project:
35
- * @ref https://github.com/jedisct1/libsodium-php
36
- *
37
- * @param int $bytes
38
- *
39
- * @throws Exception
40
- *
41
- * @return string
42
- */
43
- function random_bytes($bytes)
44
- {
45
- try {
46
- $bytes = RandomCompat_intval($bytes);
47
- } catch (TypeError $ex) {
48
- throw new TypeError(
49
- 'random_bytes(): $bytes must be an integer'
50
- );
51
- }
52
-
53
- if ($bytes < 1) {
54
- throw new Error(
55
- 'Length must be greater than 0'
56
- );
57
- }
58
-
59
- /**
60
- * @var string
61
- */
62
- $buf = '';
63
-
64
- /**
65
- * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
66
- * generated in one invocation.
67
- */
68
- if ($bytes > 2147483647) {
69
- for ($i = 0; $i < $bytes; $i += 1073741824) {
70
- $n = ($bytes - $i) > 1073741824
71
- ? 1073741824
72
- : $bytes - $i;
73
- $buf .= Sodium::randombytes_buf((int) $n);
74
- }
75
- } else {
76
- $buf .= Sodium::randombytes_buf((int) $bytes);
77
- }
78
-
79
- if (is_string($buf)) {
80
- if (RandomCompat_strlen($buf) === $bytes) {
81
- return $buf;
82
- }
83
- }
84
-
85
- /**
86
- * If we reach here, PHP has failed us.
87
- */
88
- throw new Exception(
89
- 'Could not gather sufficient random data'
90
- );
91
- }
92
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/random_compat/lib/random_bytes_mcrypt.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
- /**
3
- * Random_* Compatibility Library
4
- * for using the new PHP 7 random_* API in PHP 5 projects
5
- *
6
- * The MIT License (MIT)
7
- *
8
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy
11
- * of this software and associated documentation files (the "Software"), to deal
12
- * in the Software without restriction, including without limitation the rights
13
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- * copies of the Software, and to permit persons to whom the Software is
15
- * furnished to do so, subject to the following conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be included in
18
- * all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- * SOFTWARE.
27
- */
28
-
29
- if (!is_callable('random_bytes')) {
30
- /**
31
- * Powered by ext/mcrypt (and thankfully NOT libmcrypt)
32
- *
33
- * @ref https://bugs.php.net/bug.php?id=55169
34
- * @ref https://github.com/php/php-src/blob/c568ffe5171d942161fc8dda066bce844bdef676/ext/mcrypt/mcrypt.c#L1321-L1386
35
- *
36
- * @param int $bytes
37
- *
38
- * @throws Exception
39
- *
40
- * @return string
41
- */
42
- function random_bytes($bytes)
43
- {
44
- try {
45
- $bytes = RandomCompat_intval($bytes);
46
- } catch (TypeError $ex) {
47
- throw new TypeError(
48
- 'random_bytes(): $bytes must be an integer'
49
- );
50
- }
51
-
52
- if ($bytes < 1) {
53
- throw new Error(
54
- 'Length must be greater than 0'
55
- );
56
- }
57
-
58
- $buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
59
- if (
60
- $buf !== false
61
- &&
62
- RandomCompat_strlen($buf) === $bytes
63
- ) {
64
- /**
65
- * Return our random entropy buffer here:
66
- */
67
- return $buf;
68
- }
69
-
70
- /**
71
- * If we reach here, PHP has failed us.
72
- */
73
- throw new Exception(
74
- 'Could not gather sufficient random data'
75
- );
76
- }
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/random_compat/lib/random_int.php DELETED
@@ -1,190 +0,0 @@
1
- <?php
2
-
3
- if (!is_callable('random_int')) {
4
- /**
5
- * Random_* Compatibility Library
6
- * for using the new PHP 7 random_* API in PHP 5 projects
7
- *
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in
20
- * all copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * Fetch a random integer between $min and $max inclusive
33
- *
34
- * @param int $min
35
- * @param int $max
36
- *
37
- * @throws Exception
38
- *
39
- * @return int
40
- */
41
- function random_int($min, $max)
42
- {
43
- /**
44
- * Type and input logic checks
45
- *
46
- * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)
47
- * (non-inclusive), it will sanely cast it to an int. If you it's equal to
48
- * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats
49
- * lose precision, so the <= and => operators might accidentally let a float
50
- * through.
51
- */
52
-
53
- try {
54
- $min = RandomCompat_intval($min);
55
- } catch (TypeError $ex) {
56
- throw new TypeError(
57
- 'random_int(): $min must be an integer'
58
- );
59
- }
60
-
61
- try {
62
- $max = RandomCompat_intval($max);
63
- } catch (TypeError $ex) {
64
- throw new TypeError(
65
- 'random_int(): $max must be an integer'
66
- );
67
- }
68
-
69
- /**
70
- * Now that we've verified our weak typing system has given us an integer,
71
- * let's validate the logic then we can move forward with generating random
72
- * integers along a given range.
73
- */
74
- if ($min > $max) {
75
- throw new Error(
76
- 'Minimum value must be less than or equal to the maximum value'
77
- );
78
- }
79
-
80
- if ($max === $min) {
81
- return (int) $min;
82
- }
83
-
84
- /**
85
- * Initialize variables to 0
86
- *
87
- * We want to store:
88
- * $bytes => the number of random bytes we need
89
- * $mask => an integer bitmask (for use with the &) operator
90
- * so we can minimize the number of discards
91
- */
92
- $attempts = $bits = $bytes = $mask = $valueShift = 0;
93
-
94
- /**
95
- * At this point, $range is a positive number greater than 0. It might
96
- * overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to
97
- * a float and we will lose some precision.
98
- */
99
- $range = $max - $min;
100
-
101
- /**
102
- * Test for integer overflow:
103
- */
104
- if (!is_int($range)) {
105
-
106
- /**
107
- * Still safely calculate wider ranges.
108
- * Provided by @CodesInChaos, @oittaa
109
- *
110
- * @ref https://gist.github.com/CodesInChaos/03f9ea0b58e8b2b8d435
111
- *
112
- * We use ~0 as a mask in this case because it generates all 1s
113
- *
114
- * @ref https://eval.in/400356 (32-bit)
115
- * @ref http://3v4l.org/XX9r5 (64-bit)
116
- */
117
- $bytes = PHP_INT_SIZE;
118
- $mask = ~0;
119
-
120
- } else {
121
-
122
- /**
123
- * $bits is effectively ceil(log($range, 2)) without dealing with
124
- * type juggling
125
- */
126
- while ($range > 0) {
127
- if ($bits % 8 === 0) {
128
- ++$bytes;
129
- }
130
- ++$bits;
131
- $range >>= 1;
132
- $mask = $mask << 1 | 1;
133
- }
134
- $valueShift = $min;
135
- }
136
-
137
- $val = 0;
138
- /**
139
- * Now that we have our parameters set up, let's begin generating
140
- * random integers until one falls between $min and $max
141
- */
142
- do {
143
- /**
144
- * The rejection probability is at most 0.5, so this corresponds
145
- * to a failure probability of 2^-128 for a working RNG
146
- */
147
- if ($attempts > 128) {
148
- throw new Exception(
149
- 'random_int: RNG is broken - too many rejections'
150
- );
151
- }
152
-
153
- /**
154
- * Let's grab the necessary number of random bytes
155
- */
156
- $randomByteString = random_bytes($bytes);
157
-
158
- /**
159
- * Let's turn $randomByteString into an integer
160
- *
161
- * This uses bitwise operators (<< and |) to build an integer
162
- * out of the values extracted from ord()
163
- *
164
- * Example: [9F] | [6D] | [32] | [0C] =>
165
- * 159 + 27904 + 3276800 + 201326592 =>
166
- * 204631455
167
- */
168
- $val &= 0;
169
- for ($i = 0; $i < $bytes; ++$i) {
170
- $val |= ord($randomByteString[$i]) << ($i * 8);
171
- }
172
-
173
- /**
174
- * Apply mask
175
- */
176
- $val &= $mask;
177
- $val += $valueShift;
178
-
179
- ++$attempts;
180
- /**
181
- * If $val overflows to a floating point number,
182
- * ... or is larger than $max,
183
- * ... or smaller than $min,
184
- * then try again.
185
- */
186
- } while (!is_int($val) || $val > $max || $val < $min);
187
-
188
- return (int) $val;
189
- }
190
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/sodium_compat/lib/php72compat.php CHANGED
@@ -63,6 +63,9 @@ foreach (array(
63
  'CRYPTO_SIGN_KEYPAIRBYTES',
64
  'CRYPTO_STREAM_KEYBYTES',
65
  'CRYPTO_STREAM_NONCEBYTES',
 
 
 
66
  ) as $constant
67
  ) {
68
  if (!defined("SODIUM_$constant")) {
@@ -247,7 +250,7 @@ if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) {
247
  function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key)
248
  {
249
  try {
250
- return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key);
251
  } catch (Error $ex) {
252
  return false;
253
  } catch (Exception $ex) {
@@ -268,7 +271,7 @@ if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) {
268
  */
269
  function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key)
270
  {
271
- return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key);
272
  }
273
  }
274
  if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_keygen')) {
@@ -426,14 +429,16 @@ if (!is_callable('sodium_crypto_box_seal_open')) {
426
  * @param string $message
427
  * @param string $kp
428
  * @return string|bool
 
429
  */
430
  function sodium_crypto_box_seal_open($message, $kp)
431
  {
432
  try {
433
  return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp);
434
- } catch (Error $ex) {
435
- return false;
436
- } catch (Exception $ex) {
 
437
  return false;
438
  }
439
  }
63
  'CRYPTO_SIGN_KEYPAIRBYTES',
64
  'CRYPTO_STREAM_KEYBYTES',
65
  'CRYPTO_STREAM_NONCEBYTES',
66
+ 'LIBRARY_VERSION_MAJOR',
67
+ 'LIBRARY_VERSION_MINOR',
68
+ 'VERSION_STRING'
69
  ) as $constant
70
  ) {
71
  if (!defined("SODIUM_$constant")) {
250
  function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key)
251
  {
252
  try {
253
+ return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key, true);
254
  } catch (Error $ex) {
255
  return false;
256
  } catch (Exception $ex) {
271
  */
272
  function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key)
273
  {
274
+ return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key, true);
275
  }
276
  }
277
  if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_keygen')) {
429
  * @param string $message
430
  * @param string $kp
431
  * @return string|bool
432
+ * @throws SodiumException
433
  */
434
  function sodium_crypto_box_seal_open($message, $kp)
435
  {
436
  try {
437
  return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp);
438
+ } catch (SodiumException $ex) {
439
+ if ($ex->getMessage() === 'Argument 2 must be CRYPTO_BOX_KEYPAIRBYTES long.') {
440
+ throw $ex;
441
+ }
442
  return false;
443
  }
444
  }
vendor/paragonie/sodium_compat/src/Compat.php CHANGED
@@ -129,7 +129,7 @@ class ParagonIE_Sodium_Compat
129
  /* Type checks: */
130
  ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1);
131
 
132
- if (self::isPhp72OrGreater()) {
133
  return (string) sodium_bin2hex($string);
134
  }
135
  if (self::use_fallback('bin2hex')) {
@@ -142,7 +142,7 @@ class ParagonIE_Sodium_Compat
142
  * Compare two strings, in constant-time.
143
  * Compared to memcmp(), compare() is more useful for sorting.
144
  *
145
- * @param string $left The left operand; must be a string
146
  * @param string $right The right operand; must be a string
147
  * @return int < 0 if the left operand is less than the right
148
  * = 0 if both strings are equal
@@ -157,7 +157,7 @@ class ParagonIE_Sodium_Compat
157
  ParagonIE_Sodium_Core_Util::declareScalarType($left, 'string', 1);
158
  ParagonIE_Sodium_Core_Util::declareScalarType($right, 'string', 2);
159
 
160
- if (self::isPhp72OrGreater()) {
161
  return (int) sodium_compare($left, $right);
162
  }
163
  if (self::use_fallback('compare')) {
@@ -176,7 +176,7 @@ class ParagonIE_Sodium_Compat
176
  */
177
  public static function crypto_aead_aes256gcm_is_available()
178
  {
179
- if (self::isPhp72OrGreater()) {
180
  return sodium_crypto_aead_aes256gcm_is_available();
181
  }
182
  if (self::use_fallback('crypto_aead_aes256gcm_is_available')) {
@@ -238,11 +238,13 @@ class ParagonIE_Sodium_Compat
238
  if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_AEAD_AES256GCM_ABYTES) {
239
  throw new SodiumException('Message must be at least CRYPTO_AEAD_AES256GCM_ABYTES long');
240
  }
241
-
242
- if (!self::crypto_aead_aes256gcm_is_available()) {
243
- throw new SodiumException('AES-256-GCM is not available');
244
  }
 
 
245
  $ctext = ParagonIE_Sodium_Core_Util::substr($ciphertext, 0, -self::CRYPTO_AEAD_AES256GCM_ABYTES);
 
246
  $authTag = ParagonIE_Sodium_Core_Util::substr($ciphertext, -self::CRYPTO_AEAD_AES256GCM_ABYTES, 16);
247
  return openssl_decrypt(
248
  $ctext,
@@ -293,6 +295,11 @@ class ParagonIE_Sodium_Compat
293
  if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_AES256GCM_KEYBYTES) {
294
  throw new SodiumException('Key must be CRYPTO_AEAD_AES256GCM_KEYBYTES long');
295
  }
 
 
 
 
 
296
  $authTag = '';
297
  $ciphertext = openssl_encrypt(
298
  $plaintext,
@@ -311,6 +318,8 @@ class ParagonIE_Sodium_Compat
311
  * symmetric AEAD interface.
312
  *
313
  * @return string
 
 
314
  */
315
  public static function crypto_aead_aes256gcm_keygen()
316
  {
@@ -327,9 +336,9 @@ class ParagonIE_Sodium_Compat
327
  * IETF mode uses a 96-bit random nonce with a 32-bit counter.
328
  *
329
  * @param string $ciphertext Encrypted message (with Poly1305 MAC appended)
330
- * @param string $assocData Authenticated Associated Data (unencrypted)
331
- * @param string $nonce Number to be used only Once; must be 8 bytes
332
- * @param string $key Encryption key
333
  *
334
  * @return string The original plaintext message
335
  * @throws SodiumException
@@ -361,7 +370,7 @@ class ParagonIE_Sodium_Compat
361
  throw new SodiumException('Message must be at least CRYPTO_AEAD_CHACHA20POLY1305_ABYTES long');
362
  }
363
 
364
- if (self::isPhp72OrGreater()) {
365
  /**
366
  * @psalm-suppress InvalidReturnStatement
367
  * @psalm-suppress FalsableReturnStatement
@@ -409,8 +418,8 @@ class ParagonIE_Sodium_Compat
409
  *
410
  * @param string $plaintext Message to be encrypted
411
  * @param string $assocData Authenticated Associated Data (unencrypted)
412
- * @param string $nonce Number to be used only Once; must be 8 bytes
413
- * @param string $key Encryption key
414
  *
415
  * @return string Ciphertext with a 16-byte Poly1305 message
416
  * authentication code appended
@@ -438,7 +447,7 @@ class ParagonIE_Sodium_Compat
438
  throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
439
  }
440
 
441
- if (self::isPhp72OrGreater()) {
442
  return (string) sodium_crypto_aead_chacha20poly1305_encrypt(
443
  $plaintext,
444
  $assocData,
@@ -481,9 +490,9 @@ class ParagonIE_Sodium_Compat
481
  * Regular mode uses a 64-bit random nonce with a 64-bit counter.
482
  *
483
  * @param string $ciphertext Encrypted message (with Poly1305 MAC appended)
484
- * @param string $assocData Authenticated Associated Data (unencrypted)
485
- * @param string $nonce Number to be used only Once; must be 12 bytes
486
- * @param string $key Encryption key
487
  *
488
  * @return string The original plaintext message
489
  * @throws SodiumException
@@ -515,7 +524,7 @@ class ParagonIE_Sodium_Compat
515
  throw new SodiumException('Message must be at least CRYPTO_AEAD_CHACHA20POLY1305_ABYTES long');
516
  }
517
 
518
- if (self::isPhp72OrGreater()) {
519
  /**
520
  * @psalm-suppress InvalidReturnStatement
521
  * @psalm-suppress FalsableReturnStatement
@@ -557,6 +566,8 @@ class ParagonIE_Sodium_Compat
557
  * symmetric AEAD interface.
558
  *
559
  * @return string
 
 
560
  */
561
  public static function crypto_aead_chacha20poly1305_keygen()
562
  {
@@ -603,7 +614,7 @@ class ParagonIE_Sodium_Compat
603
  throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
604
  }
605
 
606
- if (self::isPhp72OrGreater()) {
607
  return (string) sodium_crypto_aead_chacha20poly1305_ietf_encrypt(
608
  $plaintext,
609
  $assocData,
@@ -641,6 +652,8 @@ class ParagonIE_Sodium_Compat
641
  * symmetric AEAD interface. (IETF version)
642
  *
643
  * @return string
 
 
644
  */
645
  public static function crypto_aead_chacha20poly1305_ietf_keygen()
646
  {
@@ -656,10 +669,11 @@ class ParagonIE_Sodium_Compat
656
  * This mode uses a 64-bit random nonce with a 64-bit counter.
657
  * IETF mode uses a 96-bit random nonce with a 32-bit counter.
658
  *
659
- * @param string $ciphertext Encrypted message (with Poly1305 MAC appended)
660
- * @param string $assocData Authenticated Associated Data (unencrypted)
661
- * @param string $nonce Number to be used only Once; must be 8 bytes
662
- * @param string $key Encryption key
 
663
  *
664
  * @return string The original plaintext message
665
  * @throws SodiumException
@@ -670,7 +684,8 @@ class ParagonIE_Sodium_Compat
670
  $ciphertext = '',
671
  $assocData = '',
672
  $nonce = '',
673
- $key = ''
 
674
  ) {
675
  /* Type checks: */
676
  ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1);
@@ -688,6 +703,16 @@ class ParagonIE_Sodium_Compat
688
  if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES) {
689
  throw new SodiumException('Message must be at least CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES long');
690
  }
 
 
 
 
 
 
 
 
 
 
691
 
692
  if (PHP_INT_SIZE === 4) {
693
  return ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_decrypt(
@@ -714,10 +739,11 @@ class ParagonIE_Sodium_Compat
714
  * This mode uses a 64-bit random nonce with a 64-bit counter.
715
  * IETF mode uses a 96-bit random nonce with a 32-bit counter.
716
  *
717
- * @param string $plaintext Message to be encrypted
718
- * @param string $assocData Authenticated Associated Data (unencrypted)
719
- * @param string $nonce Number to be used only Once; must be 8 bytes
720
- * @param string $key Encryption key
 
721
  *
722
  * @return string Ciphertext with a 16-byte Poly1305 message
723
  * authentication code appended
@@ -729,7 +755,8 @@ class ParagonIE_Sodium_Compat
729
  $plaintext = '',
730
  $assocData = '',
731
  $nonce = '',
732
- $key = ''
 
733
  ) {
734
  /* Type checks: */
735
  ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1);
@@ -744,6 +771,16 @@ class ParagonIE_Sodium_Compat
744
  if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES) {
745
  throw new SodiumException('Key must be CRYPTO_AEAD_XCHACHA20POLY1305_KEYBYTES long');
746
  }
 
 
 
 
 
 
 
 
 
 
747
 
748
  if (PHP_INT_SIZE === 4) {
749
  return ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_encrypt(
@@ -766,6 +803,8 @@ class ParagonIE_Sodium_Compat
766
  * symmetric AEAD interface.
767
  *
768
  * @return string
 
 
769
  */
770
  public static function crypto_aead_xchacha20poly1305_ietf_keygen()
771
  {
@@ -800,7 +839,7 @@ class ParagonIE_Sodium_Compat
800
  throw new SodiumException('Argument 2 must be CRYPTO_AUTH_KEYBYTES long.');
801
  }
802
 
803
- if (self::isPhp72OrGreater()) {
804
  return (string) sodium_crypto_auth($message, $key);
805
  }
806
  if (self::use_fallback('crypto_auth')) {
@@ -814,6 +853,8 @@ class ParagonIE_Sodium_Compat
814
 
815
  /**
816
  * @return string
 
 
817
  */
818
  public static function crypto_auth_keygen()
819
  {
@@ -847,7 +888,7 @@ class ParagonIE_Sodium_Compat
847
  throw new SodiumException('Argument 3 must be CRYPTO_AUTH_KEYBYTES long.');
848
  }
849
 
850
- if (self::isPhp72OrGreater()) {
851
  return (bool) sodium_crypto_auth_verify($mac, $message, $key);
852
  }
853
  if (self::use_fallback('crypto_auth_verify')) {
@@ -891,7 +932,7 @@ class ParagonIE_Sodium_Compat
891
  throw new SodiumException('Argument 3 must be CRYPTO_BOX_KEYPAIRBYTES long.');
892
  }
893
 
894
- if (self::isPhp72OrGreater()) {
895
  return (string) sodium_crypto_box($plaintext, $nonce, $keypair);
896
  }
897
  if (self::use_fallback('crypto_box')) {
@@ -931,7 +972,7 @@ class ParagonIE_Sodium_Compat
931
  throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
932
  }
933
 
934
- if (self::isPhp72OrGreater()) {
935
  return (string) sodium_crypto_box_seal($plaintext, $publicKey);
936
  }
937
  if (self::use_fallback('crypto_box_seal')) {
@@ -969,7 +1010,7 @@ class ParagonIE_Sodium_Compat
969
  throw new SodiumException('Argument 2 must be CRYPTO_BOX_KEYPAIRBYTES long.');
970
  }
971
 
972
- if (self::isPhp72OrGreater()) {
973
  /**
974
  * @psalm-suppress InvalidReturnStatement
975
  * @psalm-suppress FalsableReturnStatement
@@ -998,12 +1039,15 @@ class ParagonIE_Sodium_Compat
998
  */
999
  public static function crypto_box_keypair()
1000
  {
1001
- if (self::isPhp72OrGreater()) {
1002
  return (string) sodium_crypto_box_keypair();
1003
  }
1004
  if (self::use_fallback('crypto_box_keypair')) {
1005
  return (string) call_user_func('\\Sodium\\crypto_box_keypair');
1006
  }
 
 
 
1007
  return ParagonIE_Sodium_Crypto::box_keypair();
1008
  }
1009
 
@@ -1032,7 +1076,7 @@ class ParagonIE_Sodium_Compat
1032
  throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
1033
  }
1034
 
1035
- if (self::isPhp72OrGreater()) {
1036
  return (string) sodium_crypto_box_keypair_from_secretkey_and_publickey($secretKey, $publicKey);
1037
  }
1038
  if (self::use_fallback('crypto_box_keypair_from_secretkey_and_publickey')) {
@@ -1075,7 +1119,7 @@ class ParagonIE_Sodium_Compat
1075
  throw new SodiumException('Argument 3 must be CRYPTO_BOX_KEYPAIRBYTES long.');
1076
  }
1077
 
1078
- if (self::isPhp72OrGreater()) {
1079
  /**
1080
  * @psalm-suppress InvalidReturnStatement
1081
  * @psalm-suppress FalsableReturnStatement
@@ -1094,7 +1138,7 @@ class ParagonIE_Sodium_Compat
1094
  /**
1095
  * Extract the public key from a crypto_box keypair.
1096
  *
1097
- * @param string $keypair
1098
  * @return string Your crypto_box public key
1099
  * @throws SodiumException
1100
  * @throws TypeError
@@ -1110,7 +1154,7 @@ class ParagonIE_Sodium_Compat
1110
  throw new SodiumException('Argument 1 must be CRYPTO_BOX_KEYPAIRBYTES long.');
1111
  }
1112
 
1113
- if (self::isPhp72OrGreater()) {
1114
  return (string) sodium_crypto_box_publickey($keypair);
1115
  }
1116
  if (self::use_fallback('crypto_box_publickey')) {
@@ -1126,7 +1170,7 @@ class ParagonIE_Sodium_Compat
1126
  * Calculate the X25519 public key from a given X25519 secret key.
1127
  *
1128
  * @param string $secretKey Any X25519 secret key
1129
- * @return string The corresponding X25519 public key
1130
  * @throws SodiumException
1131
  * @throws TypeError
1132
  * @psalm-suppress MixedArgument
@@ -1141,7 +1185,7 @@ class ParagonIE_Sodium_Compat
1141
  throw new SodiumException('Argument 1 must be CRYPTO_BOX_SECRETKEYBYTES long.');
1142
  }
1143
 
1144
- if (self::isPhp72OrGreater()) {
1145
  return (string) sodium_crypto_box_publickey_from_secretkey($secretKey);
1146
  }
1147
  if (self::use_fallback('crypto_box_publickey_from_secretkey')) {
@@ -1172,7 +1216,7 @@ class ParagonIE_Sodium_Compat
1172
  throw new SodiumException('Argument 1 must be CRYPTO_BOX_KEYPAIRBYTES long.');
1173
  }
1174
 
1175
- if (self::isPhp72OrGreater()) {
1176
  return (string) sodium_crypto_box_secretkey($keypair);
1177
  }
1178
  if (self::use_fallback('crypto_box_secretkey')) {
@@ -1199,7 +1243,7 @@ class ParagonIE_Sodium_Compat
1199
  /* Type checks: */
1200
  ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1);
1201
 
1202
- if (self::isPhp72OrGreater()) {
1203
  return (string) sodium_crypto_box_seed_keypair($seed);
1204
  }
1205
  if (self::use_fallback('crypto_box_seed_keypair')) {
@@ -1244,7 +1288,7 @@ class ParagonIE_Sodium_Compat
1244
  }
1245
  }
1246
 
1247
- if (self::isPhp72OrGreater()) {
1248
  return (string) sodium_crypto_generichash($message, $key, $length);
1249
  }
1250
  if (self::use_fallback('crypto_generichash')) {
@@ -1260,7 +1304,7 @@ class ParagonIE_Sodium_Compat
1260
  * Get the final BLAKE2b hash output for a given context.
1261
  *
1262
  * @param string &$ctx BLAKE2 hashing context. Generated by crypto_generichash_init().
1263
- * @param int $length Hash output size.
1264
  * @return string Final BLAKE2b hash.
1265
  * @throws SodiumException
1266
  * @throws TypeError
@@ -1272,7 +1316,7 @@ class ParagonIE_Sodium_Compat
1272
  ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1);
1273
  ParagonIE_Sodium_Core_Util::declareScalarType($length, 'int', 2);
1274
 
1275
- if (self::isPhp72OrGreater()) {
1276
  return sodium_crypto_generichash_final($ctx, $length);
1277
  }
1278
  if (self::use_fallback('crypto_generichash_final')) {
@@ -1322,7 +1366,7 @@ class ParagonIE_Sodium_Compat
1322
  }
1323
  }
1324
 
1325
- if (self::isPhp72OrGreater()) {
1326
  return sodium_crypto_generichash_init($key, $length);
1327
  }
1328
  if (self::use_fallback('crypto_generichash_init')) {
@@ -1337,7 +1381,7 @@ class ParagonIE_Sodium_Compat
1337
  /**
1338
  * Update a BLAKE2b hashing context with additional data.
1339
  *
1340
- * @param string &$ctx BLAKE2 hashing context. Generated by crypto_generichash_init().
1341
  * $ctx is passed by reference and gets updated in-place.
1342
  * @param string $message The message to append to the existing hash state.
1343
  * @return void
@@ -1351,7 +1395,7 @@ class ParagonIE_Sodium_Compat
1351
  ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1);
1352
  ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 2);
1353
 
1354
- if (self::isPhp72OrGreater()) {
1355
  sodium_crypto_generichash_update($ctx, $message);
1356
  return;
1357
  }
@@ -1369,6 +1413,8 @@ class ParagonIE_Sodium_Compat
1369
 
1370
  /**
1371
  * @return string
 
 
1372
  */
1373
  public static function crypto_generichash_keygen()
1374
  {
@@ -1426,7 +1472,7 @@ class ParagonIE_Sodium_Compat
1426
  throw new SodiumException('Argument 4 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
1427
  }
1428
 
1429
- if (self::isPhp72OrGreater()) {
1430
  if (is_callable('sodium_crypto_kx')) {
1431
  return (string) sodium_crypto_kx(
1432
  $my_secret,
@@ -1481,7 +1527,7 @@ class ParagonIE_Sodium_Compat
1481
  ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4);
1482
  ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5);
1483
 
1484
- if (self::isPhp72OrGreater()) {
1485
  if (!is_null($alg)) {
1486
  ParagonIE_Sodium_Core_Util::declareScalarType($alg, 'int', 6);
1487
  return sodium_crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $alg);
@@ -1507,7 +1553,7 @@ class ParagonIE_Sodium_Compat
1507
  */
1508
  public static function crypto_pwhash_is_available()
1509
  {
1510
- if (self::isPhp72OrGreater()) {
1511
  return true;
1512
  }
1513
  if (self::use_fallback('crypto_pwhash')) {
@@ -1531,7 +1577,7 @@ class ParagonIE_Sodium_Compat
1531
  ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2);
1532
  ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3);
1533
 
1534
- if (self::isPhp72OrGreater()) {
1535
  return sodium_crypto_pwhash_str($passwd, $opslimit, $memlimit);
1536
  }
1537
  if (self::use_fallback('crypto_pwhash_str')) {
@@ -1556,7 +1602,7 @@ class ParagonIE_Sodium_Compat
1556
  ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1);
1557
  ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2);
1558
 
1559
- if (self::isPhp72OrGreater()) {
1560
  return (bool) sodium_crypto_pwhash_str_verify($passwd, $hash);
1561
  }
1562
  if (self::use_fallback('crypto_pwhash_str_verify')) {
@@ -1586,11 +1632,24 @@ class ParagonIE_Sodium_Compat
1586
  ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4);
1587
  ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5);
1588
 
1589
- if (self::isPhp72OrGreater()) {
1590
- return (string) sodium_crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit);
 
 
 
 
 
 
1591
  }
1592
  if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256')) {
1593
- return (string) call_user_func('\\Sodium\\crypto_pwhash_scryptsalsa208sha256', $outlen, $passwd, $salt, $opslimit, $memlimit);
 
 
 
 
 
 
 
1594
  }
1595
  // This is the best we can do.
1596
  throw new SodiumException(
@@ -1608,7 +1667,7 @@ class ParagonIE_Sodium_Compat
1608
  */
1609
  public static function crypto_pwhash_scryptsalsa208sha256_is_available()
1610
  {
1611
- if (self::isPhp72OrGreater()) {
1612
  return true;
1613
  }
1614
  if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256')) {
@@ -1631,11 +1690,20 @@ class ParagonIE_Sodium_Compat
1631
  ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2);
1632
  ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3);
1633
 
1634
- if (self::isPhp72OrGreater()) {
1635
- return (string) sodium_crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit);
 
 
 
 
1636
  }
1637
  if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str')) {
1638
- return (string) call_user_func('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str', $passwd, $opslimit, $memlimit);
 
 
 
 
 
1639
  }
1640
  // This is the best we can do.
1641
  throw new SodiumException(
@@ -1655,11 +1723,18 @@ class ParagonIE_Sodium_Compat
1655
  ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1);
1656
  ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2);
1657
 
1658
- if (self::isPhp72OrGreater()) {
1659
- return (bool) sodium_crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash);
 
 
 
1660
  }
1661
  if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str_verify')) {
1662
- return (bool) call_user_func('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify', $passwd, $hash);
 
 
 
 
1663
  }
1664
  // This is the best we can do.
1665
  throw new SodiumException(
@@ -1694,7 +1769,7 @@ class ParagonIE_Sodium_Compat
1694
  throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
1695
  }
1696
 
1697
- if (self::isPhp72OrGreater()) {
1698
  return sodium_crypto_scalarmult($secretKey, $publicKey);
1699
  }
1700
  if (self::use_fallback('crypto_scalarmult')) {
@@ -1734,7 +1809,7 @@ class ParagonIE_Sodium_Compat
1734
  throw new SodiumException('Argument 1 must be CRYPTO_BOX_SECRETKEYBYTES long.');
1735
  }
1736
 
1737
- if (self::isPhp72OrGreater()) {
1738
  return sodium_crypto_scalarmult_base($secretKey);
1739
  }
1740
  if (self::use_fallback('crypto_scalarmult_base')) {
@@ -1777,7 +1852,7 @@ class ParagonIE_Sodium_Compat
1777
  throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
1778
  }
1779
 
1780
- if (self::isPhp72OrGreater()) {
1781
  return sodium_crypto_secretbox($plaintext, $nonce, $key);
1782
  }
1783
  if (self::use_fallback('crypto_secretbox')) {
@@ -1817,7 +1892,7 @@ class ParagonIE_Sodium_Compat
1817
  throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
1818
  }
1819
 
1820
- if (self::isPhp72OrGreater()) {
1821
  /**
1822
  * @psalm-suppress InvalidReturnStatement
1823
  * @psalm-suppress FalsableReturnStatement
@@ -1837,6 +1912,8 @@ class ParagonIE_Sodium_Compat
1837
  * Return a secure random key for use with crypto_secretbox
1838
  *
1839
  * @return string
 
 
1840
  */
1841
  public static function crypto_secretbox_keygen()
1842
  {
@@ -1930,7 +2007,7 @@ class ParagonIE_Sodium_Compat
1930
  throw new SodiumException('Argument 2 must be CRYPTO_SHORTHASH_KEYBYTES long.');
1931
  }
1932
 
1933
- if (self::isPhp72OrGreater()) {
1934
  return sodium_crypto_shorthash($message, $key);
1935
  }
1936
  if (self::use_fallback('crypto_shorthash')) {
@@ -1946,6 +2023,8 @@ class ParagonIE_Sodium_Compat
1946
  * Return a secure random key for use with crypto_shorthash
1947
  *
1948
  * @return string
 
 
1949
  */
1950
  public static function crypto_shorthash_keygen()
1951
  {
@@ -1978,7 +2057,7 @@ class ParagonIE_Sodium_Compat
1978
  throw new SodiumException('Argument 2 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
1979
  }
1980
 
1981
- if (self::isPhp72OrGreater()) {
1982
  return sodium_crypto_sign($message, $secretKey);
1983
  }
1984
  if (self::use_fallback('crypto_sign')) {
@@ -2017,7 +2096,7 @@ class ParagonIE_Sodium_Compat
2017
  throw new SodiumException('Argument 2 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
2018
  }
2019
 
2020
- if (self::isPhp72OrGreater()) {
2021
  /**
2022
  * @psalm-suppress InvalidReturnStatement
2023
  * @psalm-suppress FalsableReturnStatement
@@ -2042,7 +2121,7 @@ class ParagonIE_Sodium_Compat
2042
  */
2043
  public static function crypto_sign_keypair()
2044
  {
2045
- if (self::isPhp72OrGreater()) {
2046
  return sodium_crypto_sign_keypair();
2047
  }
2048
  if (self::use_fallback('crypto_sign_keypair')) {
@@ -2067,7 +2146,7 @@ class ParagonIE_Sodium_Compat
2067
  {
2068
  ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1);
2069
 
2070
- if (self::isPhp72OrGreater()) {
2071
  return sodium_crypto_sign_seed_keypair($seed);
2072
  }
2073
  if (self::use_fallback('crypto_sign_keypair')) {
@@ -2102,7 +2181,7 @@ class ParagonIE_Sodium_Compat
2102
  throw new SodiumException('Argument 1 must be CRYPTO_SIGN_KEYPAIRBYTES long.');
2103
  }
2104
 
2105
- if (self::isPhp72OrGreater()) {
2106
  return sodium_crypto_sign_publickey($keypair);
2107
  }
2108
  if (self::use_fallback('crypto_sign_publickey')) {
@@ -2133,7 +2212,7 @@ class ParagonIE_Sodium_Compat
2133
  throw new SodiumException('Argument 1 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
2134
  }
2135
 
2136
- if (self::isPhp72OrGreater()) {
2137
  return sodium_crypto_sign_publickey_from_secretkey($secretKey);
2138
  }
2139
  if (self::use_fallback('crypto_sign_publickey_from_secretkey')) {
@@ -2164,7 +2243,7 @@ class ParagonIE_Sodium_Compat
2164
  throw new SodiumException('Argument 1 must be CRYPTO_SIGN_KEYPAIRBYTES long.');
2165
  }
2166
 
2167
- if (self::isPhp72OrGreater()) {
2168
  return sodium_crypto_sign_secretkey($keypair);
2169
  }
2170
  if (self::use_fallback('crypto_sign_secretkey')) {
@@ -2199,7 +2278,7 @@ class ParagonIE_Sodium_Compat
2199
  throw new SodiumException('Argument 2 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
2200
  }
2201
 
2202
- if (self::isPhp72OrGreater()) {
2203
  return sodium_crypto_sign_detached($message, $secretKey);
2204
  }
2205
  if (self::use_fallback('crypto_sign_detached')) {
@@ -2238,11 +2317,16 @@ class ParagonIE_Sodium_Compat
2238
  throw new SodiumException('Argument 3 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
2239
  }
2240
 
2241
- if (self::isPhp72OrGreater()) {
2242
  return sodium_crypto_sign_verify_detached($signature, $message, $publicKey);
2243
  }
2244
  if (self::use_fallback('crypto_sign_verify_detached')) {
2245
- return (bool) call_user_func('\\Sodium\\crypto_sign_verify_detached', $signature, $message, $publicKey);
 
 
 
 
 
2246
  }
2247
  if (PHP_INT_SIZE === 4) {
2248
  return ParagonIE_Sodium_Crypto32::sign_verify_detached($signature, $message, $publicKey);
@@ -2268,7 +2352,7 @@ class ParagonIE_Sodium_Compat
2268
  if (ParagonIE_Sodium_Core_Util::strlen($pk) < self::CRYPTO_SIGN_PUBLICKEYBYTES) {
2269
  throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_PUBLICKEYBYTES long.');
2270
  }
2271
- if (self::isPhp72OrGreater()) {
2272
  if (is_callable('crypto_sign_ed25519_pk_to_curve25519')) {
2273
  return (string) sodium_crypto_sign_ed25519_pk_to_curve25519($pk);
2274
  }
@@ -2300,7 +2384,7 @@ class ParagonIE_Sodium_Compat
2300
  if (ParagonIE_Sodium_Core_Util::strlen($sk) < self::CRYPTO_SIGN_SEEDBYTES) {
2301
  throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_SEEDBYTES long.');
2302
  }
2303
- if (self::isPhp72OrGreater()) {
2304
  if (is_callable('crypto_sign_ed25519_sk_to_curve25519')) {
2305
  return sodium_crypto_sign_ed25519_sk_to_curve25519($sk);
2306
  }
@@ -2348,7 +2432,7 @@ class ParagonIE_Sodium_Compat
2348
  throw new SodiumException('Argument 3 must be CRYPTO_STREAM_KEYBYTES long.');
2349
  }
2350
 
2351
- if (self::isPhp72OrGreater()) {
2352
  return sodium_crypto_stream($len, $nonce, $key);
2353
  }
2354
  if (self::use_fallback('crypto_stream')) {
@@ -2395,7 +2479,7 @@ class ParagonIE_Sodium_Compat
2395
  throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
2396
  }
2397
 
2398
- if (self::isPhp72OrGreater()) {
2399
  return sodium_crypto_stream_xor($message, $nonce, $key);
2400
  }
2401
  if (self::use_fallback('crypto_stream_xor')) {
@@ -2411,6 +2495,8 @@ class ParagonIE_Sodium_Compat
2411
  * Return a secure random key for use with crypto_stream
2412
  *
2413
  * @return string
 
 
2414
  */
2415
  public static function crypto_stream_keygen()
2416
  {
@@ -2432,7 +2518,7 @@ class ParagonIE_Sodium_Compat
2432
  /* Type checks: */
2433
  ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1);
2434
 
2435
- if (self::isPhp72OrGreater()) {
2436
  if (is_callable('sodium_hex2bin')) {
2437
  return (string) sodium_hex2bin($string);
2438
  }
@@ -2458,12 +2544,13 @@ class ParagonIE_Sodium_Compat
2458
  /* Type checks: */
2459
  ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1);
2460
 
2461
- if (self::isPhp72OrGreater()) {
2462
  sodium_increment($var);
2463
  return;
2464
  }
2465
  if (self::use_fallback('increment')) {
2466
- @call_user_func('\\Sodium\\increment', $var);
 
2467
  return;
2468
  }
2469
 
@@ -2490,7 +2577,7 @@ class ParagonIE_Sodium_Compat
2490
  */
2491
  public static function library_version_major()
2492
  {
2493
- if (self::isPhp72OrGreater()) {
2494
  return sodium_library_version_major();
2495
  }
2496
  if (self::use_fallback('library_version_major')) {
@@ -2509,7 +2596,7 @@ class ParagonIE_Sodium_Compat
2509
  */
2510
  public static function library_version_minor()
2511
  {
2512
- if (self::isPhp72OrGreater()) {
2513
  return sodium_library_version_minor();
2514
  }
2515
  if (self::use_fallback('library_version_minor')) {
@@ -2558,13 +2645,16 @@ class ParagonIE_Sodium_Compat
2558
  /* Type checks: */
2559
  ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1);
2560
 
2561
- if (self::isPhp72OrGreater()) {
2562
  sodium_memzero($var);
2563
  return;
2564
  }
2565
  if (self::use_fallback('memzero')) {
2566
- @call_user_func('\\Sodium\\memzero', $var);
2567
- return;
 
 
 
2568
  }
2569
  // This is the best we can do.
2570
  throw new SodiumException(
@@ -2573,12 +2663,29 @@ class ParagonIE_Sodium_Compat
2573
  );
2574
  }
2575
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2576
  /**
2577
  * Generate a string of bytes from the kernel's CSPRNG.
2578
  * Proudly uses /dev/urandom (if getrandom(2) is not available).
2579
  *
2580
  * @param int $numBytes
2581
  * @return string
 
2582
  * @throws TypeError
2583
  */
2584
  public static function randombytes_buf($numBytes)
@@ -2588,7 +2695,9 @@ class ParagonIE_Sodium_Compat
2588
  if (is_numeric($numBytes)) {
2589
  $numBytes = (int) $numBytes;
2590
  } else {
2591
- throw new TypeError('Argument 1 must be an integer, ' . gettype($numBytes) . ' given.');
 
 
2592
  }
2593
  }
2594
  if (self::use_fallback('randombytes_buf')) {
@@ -2602,6 +2711,8 @@ class ParagonIE_Sodium_Compat
2602
  *
2603
  * @param int $range
2604
  * @return int
 
 
2605
  * @throws TypeError
2606
  */
2607
  public static function randombytes_uniform($range)
@@ -2609,9 +2720,11 @@ class ParagonIE_Sodium_Compat
2609
  /* Type checks: */
2610
  if (!is_int($range)) {
2611
  if (is_numeric($range)) {
2612
- $range = (int)$range;
2613
  } else {
2614
- throw new TypeError('Argument 1 must be an integer, ' . gettype($range) . ' given.');
 
 
2615
  }
2616
  }
2617
  if (self::use_fallback('randombytes_uniform')) {
@@ -2624,6 +2737,9 @@ class ParagonIE_Sodium_Compat
2624
  * Generate a random 16-bit integer.
2625
  *
2626
  * @return int
 
 
 
2627
  */
2628
  public static function randombytes_random16()
2629
  {
@@ -2643,7 +2759,7 @@ class ParagonIE_Sodium_Compat
2643
  */
2644
  public static function version_string()
2645
  {
2646
- if (self::isPhp72OrGreater()) {
2647
  return (string) sodium_version_string();
2648
  }
2649
  if (self::use_fallback('version_string')) {
@@ -2686,15 +2802,16 @@ class ParagonIE_Sodium_Compat
2686
 
2687
  /**
2688
  * Libsodium as implemented in PHP 7.2
 
2689
  *
2690
  * @ref https://wiki.php.net/rfc/libsodium
2691
  * @return bool
2692
  */
2693
- protected static function isPhp72OrGreater()
2694
  {
2695
  static $res = null;
2696
  if ($res === null) {
2697
- $res = PHP_VERSION_ID >= 70200 && extension_loaded('sodium');
2698
  }
2699
  if (self::$disableFallbackForUnitTests) {
2700
  // Don't fallback. Use the PHP implementation.
129
  /* Type checks: */
130
  ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1);
131
 
132
+ if (self::useNewSodiumAPI()) {
133
  return (string) sodium_bin2hex($string);
134
  }
135
  if (self::use_fallback('bin2hex')) {
142
  * Compare two strings, in constant-time.
143
  * Compared to memcmp(), compare() is more useful for sorting.
144
  *
145
+ * @param string $left The left operand; must be a string
146
  * @param string $right The right operand; must be a string
147
  * @return int < 0 if the left operand is less than the right
148
  * = 0 if both strings are equal
157
  ParagonIE_Sodium_Core_Util::declareScalarType($left, 'string', 1);
158
  ParagonIE_Sodium_Core_Util::declareScalarType($right, 'string', 2);
159
 
160
+ if (self::useNewSodiumAPI()) {
161
  return (int) sodium_compare($left, $right);
162
  }
163
  if (self::use_fallback('compare')) {
176
  */
177
  public static function crypto_aead_aes256gcm_is_available()
178
  {
179
+ if (self::useNewSodiumAPI()) {
180
  return sodium_crypto_aead_aes256gcm_is_available();
181
  }
182
  if (self::use_fallback('crypto_aead_aes256gcm_is_available')) {
238
  if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_AEAD_AES256GCM_ABYTES) {
239
  throw new SodiumException('Message must be at least CRYPTO_AEAD_AES256GCM_ABYTES long');
240
  }
241
+ if (!is_callable('openssl_decrypt')) {
242
+ throw new SodiumException('The OpenSSL extension is not installed, or openssl_decrypt() is not available');
 
243
  }
244
+
245
+ /** @var string $ctext */
246
  $ctext = ParagonIE_Sodium_Core_Util::substr($ciphertext, 0, -self::CRYPTO_AEAD_AES256GCM_ABYTES);
247
+ /** @var string $authTag */
248
  $authTag = ParagonIE_Sodium_Core_Util::substr($ciphertext, -self::CRYPTO_AEAD_AES256GCM_ABYTES, 16);
249
  return openssl_decrypt(
250
  $ctext,
295
  if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_AES256GCM_KEYBYTES) {
296
  throw new SodiumException('Key must be CRYPTO_AEAD_AES256GCM_KEYBYTES long');
297
  }
298
+
299
+ if (!is_callable('openssl_encrypt')) {
300
+ throw new SodiumException('The OpenSSL extension is not installed, or openssl_encrypt() is not available');
301
+ }
302
+
303
  $authTag = '';
304
  $ciphertext = openssl_encrypt(
305
  $plaintext,
318
  * symmetric AEAD interface.
319
  *
320
  * @return string
321
+ * @throws Exception
322
+ * @throws Error
323
  */
324
  public static function crypto_aead_aes256gcm_keygen()
325
  {
336
  * IETF mode uses a 96-bit random nonce with a 32-bit counter.
337
  *
338
  * @param string $ciphertext Encrypted message (with Poly1305 MAC appended)
339
+ * @param string $assocData Authenticated Associated Data (unencrypted)
340
+ * @param string $nonce Number to be used only Once; must be 8 bytes
341
+ * @param string $key Encryption key
342
  *
343
  * @return string The original plaintext message
344
  * @throws SodiumException
370
  throw new SodiumException('Message must be at least CRYPTO_AEAD_CHACHA20POLY1305_ABYTES long');
371
  }
372
 
373
+ if (self::useNewSodiumAPI()) {
374
  /**
375
  * @psalm-suppress InvalidReturnStatement
376
  * @psalm-suppress FalsableReturnStatement
418
  *
419
  * @param string $plaintext Message to be encrypted
420
  * @param string $assocData Authenticated Associated Data (unencrypted)
421
+ * @param string $nonce Number to be used only Once; must be 8 bytes
422
+ * @param string $key Encryption key
423
  *
424
  * @return string Ciphertext with a 16-byte Poly1305 message
425
  * authentication code appended
447
  throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
448
  }
449
 
450
+ if (self::useNewSodiumAPI()) {
451
  return (string) sodium_crypto_aead_chacha20poly1305_encrypt(
452
  $plaintext,
453
  $assocData,
490
  * Regular mode uses a 64-bit random nonce with a 64-bit counter.
491
  *
492
  * @param string $ciphertext Encrypted message (with Poly1305 MAC appended)
493
+ * @param string $assocData Authenticated Associated Data (unencrypted)
494
+ * @param string $nonce Number to be used only Once; must be 12 bytes
495
+ * @param string $key Encryption key
496
  *
497
  * @return string The original plaintext message
498
  * @throws SodiumException
524
  throw new SodiumException('Message must be at least CRYPTO_AEAD_CHACHA20POLY1305_ABYTES long');
525
  }
526
 
527
+ if (self::useNewSodiumAPI()) {
528
  /**
529
  * @psalm-suppress InvalidReturnStatement
530
  * @psalm-suppress FalsableReturnStatement
566
  * symmetric AEAD interface.
567
  *
568
  * @return string
569
+ * @throws Exception
570
+ * @throws Error
571
  */
572
  public static function crypto_aead_chacha20poly1305_keygen()
573
  {
614
  throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
615
  }
616
 
617
+ if (self::useNewSodiumAPI()) {
618
  return (string) sodium_crypto_aead_chacha20poly1305_ietf_encrypt(
619
  $plaintext,
620
  $assocData,
652
  * symmetric AEAD interface. (IETF version)
653
  *
654
  * @return string
655
+ * @throws Exception
656
+ * @throws Error
657
  */
658
  public static function crypto_aead_chacha20poly1305_ietf_keygen()
659
  {
669
  * This mode uses a 64-bit random nonce with a 64-bit counter.
670
  * IETF mode uses a 96-bit random nonce with a 32-bit counter.
671
  *
672
+ * @param string $ciphertext Encrypted message (with Poly1305 MAC appended)
673
+ * @param string $assocData Authenticated Associated Data (unencrypted)
674
+ * @param string $nonce Number to be used only Once; must be 8 bytes
675
+ * @param string $key Encryption key
676
+ * @param bool $dontFallback Don't fallback to ext/sodium
677
  *
678
  * @return string The original plaintext message
679
  * @throws SodiumException
684
  $ciphertext = '',
685
  $assocData = '',
686
  $nonce = '',
687
+ $key = '',
688
+ $dontFallback = false
689
  ) {
690
  /* Type checks: */
691
  ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1);
703
  if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES) {
704
  throw new SodiumException('Message must be at least CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES long');
705
  }
706
+ if (self::useNewSodiumAPI() && !$dontFallback) {
707
+ if (is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) {
708
+ return sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(
709
+ $ciphertext,
710
+ $assocData,
711
+ $nonce,
712
+ $key
713
+ );
714
+ }
715
+ }
716
 
717
  if (PHP_INT_SIZE === 4) {
718
  return ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_decrypt(
739
  * This mode uses a 64-bit random nonce with a 64-bit counter.
740
  * IETF mode uses a 96-bit random nonce with a 32-bit counter.
741
  *
742
+ * @param string $plaintext Message to be encrypted
743
+ * @param string $assocData Authenticated Associated Data (unencrypted)
744
+ * @param string $nonce Number to be used only Once; must be 8 bytes
745
+ * @param string $key Encryption key
746
+ * @param bool $dontFallback Don't fallback to ext/sodium
747
  *
748
  * @return string Ciphertext with a 16-byte Poly1305 message
749
  * authentication code appended
755
  $plaintext = '',
756
  $assocData = '',
757
  $nonce = '',
758
+ $key = '',
759
+ $dontFallback = false
760
  ) {
761
  /* Type checks: */
762
  ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1);
771
  if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES) {
772
  throw new SodiumException('Key must be CRYPTO_AEAD_XCHACHA20POLY1305_KEYBYTES long');
773
  }
774
+ if (self::useNewSodiumAPI() && !$dontFallback) {
775
+ if (is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) {
776
+ return sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(
777
+ $plaintext,
778
+ $assocData,
779
+ $nonce,
780
+ $key
781
+ );
782
+ }
783
+ }
784
 
785
  if (PHP_INT_SIZE === 4) {
786
  return ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_encrypt(
803
  * symmetric AEAD interface.
804
  *
805
  * @return string
806
+ * @throws Exception
807
+ * @throws Error
808
  */
809
  public static function crypto_aead_xchacha20poly1305_ietf_keygen()
810
  {
839
  throw new SodiumException('Argument 2 must be CRYPTO_AUTH_KEYBYTES long.');
840
  }
841
 
842
+ if (self::useNewSodiumAPI()) {
843
  return (string) sodium_crypto_auth($message, $key);
844
  }
845
  if (self::use_fallback('crypto_auth')) {
853
 
854
  /**
855
  * @return string
856
+ * @throws Exception
857
+ * @throws Error
858
  */
859
  public static function crypto_auth_keygen()
860
  {
888
  throw new SodiumException('Argument 3 must be CRYPTO_AUTH_KEYBYTES long.');
889
  }
890
 
891
+ if (self::useNewSodiumAPI()) {
892
  return (bool) sodium_crypto_auth_verify($mac, $message, $key);
893
  }
894
  if (self::use_fallback('crypto_auth_verify')) {
932
  throw new SodiumException('Argument 3 must be CRYPTO_BOX_KEYPAIRBYTES long.');
933
  }
934
 
935
+ if (self::useNewSodiumAPI()) {
936
  return (string) sodium_crypto_box($plaintext, $nonce, $keypair);
937
  }
938
  if (self::use_fallback('crypto_box')) {
972
  throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
973
  }
974
 
975
+ if (self::useNewSodiumAPI()) {
976
  return (string) sodium_crypto_box_seal($plaintext, $publicKey);
977
  }
978
  if (self::use_fallback('crypto_box_seal')) {
1010
  throw new SodiumException('Argument 2 must be CRYPTO_BOX_KEYPAIRBYTES long.');
1011
  }
1012
 
1013
+ if (self::useNewSodiumAPI()) {
1014
  /**
1015
  * @psalm-suppress InvalidReturnStatement
1016
  * @psalm-suppress FalsableReturnStatement
1039
  */
1040
  public static function crypto_box_keypair()
1041
  {
1042
+ if (self::useNewSodiumAPI()) {
1043
  return (string) sodium_crypto_box_keypair();
1044
  }
1045
  if (self::use_fallback('crypto_box_keypair')) {
1046
  return (string) call_user_func('\\Sodium\\crypto_box_keypair');
1047
  }
1048
+ if (PHP_INT_SIZE === 4) {
1049
+ return ParagonIE_Sodium_Crypto32::box_keypair();
1050
+ }
1051
  return ParagonIE_Sodium_Crypto::box_keypair();
1052
  }
1053
 
1076
  throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
1077
  }
1078
 
1079
+ if (self::useNewSodiumAPI()) {
1080
  return (string) sodium_crypto_box_keypair_from_secretkey_and_publickey($secretKey, $publicKey);
1081
  }
1082
  if (self::use_fallback('crypto_box_keypair_from_secretkey_and_publickey')) {
1119
  throw new SodiumException('Argument 3 must be CRYPTO_BOX_KEYPAIRBYTES long.');
1120
  }
1121
 
1122
+ if (self::useNewSodiumAPI()) {
1123
  /**
1124
  * @psalm-suppress InvalidReturnStatement
1125
  * @psalm-suppress FalsableReturnStatement
1138
  /**
1139
  * Extract the public key from a crypto_box keypair.
1140
  *
1141
+ * @param string $keypair Keypair containing secret and public key
1142
  * @return string Your crypto_box public key
1143
  * @throws SodiumException
1144
  * @throws TypeError
1154
  throw new SodiumException('Argument 1 must be CRYPTO_BOX_KEYPAIRBYTES long.');
1155
  }
1156
 
1157
+ if (self::useNewSodiumAPI()) {
1158
  return (string) sodium_crypto_box_publickey($keypair);
1159
  }
1160
  if (self::use_fallback('crypto_box_publickey')) {
1170
  * Calculate the X25519 public key from a given X25519 secret key.
1171
  *
1172
  * @param string $secretKey Any X25519 secret key
1173
+ * @return string The corresponding X25519 public key
1174
  * @throws SodiumException
1175
  * @throws TypeError
1176
  * @psalm-suppress MixedArgument
1185
  throw new SodiumException('Argument 1 must be CRYPTO_BOX_SECRETKEYBYTES long.');
1186
  }
1187
 
1188
+ if (self::useNewSodiumAPI()) {
1189
  return (string) sodium_crypto_box_publickey_from_secretkey($secretKey);
1190
  }
1191
  if (self::use_fallback('crypto_box_publickey_from_secretkey')) {
1216
  throw new SodiumException('Argument 1 must be CRYPTO_BOX_KEYPAIRBYTES long.');
1217
  }
1218
 
1219
+ if (self::useNewSodiumAPI()) {
1220
  return (string) sodium_crypto_box_secretkey($keypair);
1221
  }
1222
  if (self::use_fallback('crypto_box_secretkey')) {
1243
  /* Type checks: */
1244
  ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1);
1245
 
1246
+ if (self::useNewSodiumAPI()) {
1247
  return (string) sodium_crypto_box_seed_keypair($seed);
1248
  }
1249
  if (self::use_fallback('crypto_box_seed_keypair')) {
1288
  }
1289
  }
1290
 
1291
+ if (self::useNewSodiumAPI()) {
1292
  return (string) sodium_crypto_generichash($message, $key, $length);
1293
  }
1294
  if (self::use_fallback('crypto_generichash')) {
1304
  * Get the final BLAKE2b hash output for a given context.
1305
  *
1306
  * @param string &$ctx BLAKE2 hashing context. Generated by crypto_generichash_init().
1307
+ * @param int $length Hash output size.
1308
  * @return string Final BLAKE2b hash.
1309
  * @throws SodiumException
1310
  * @throws TypeError
1316
  ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1);
1317
  ParagonIE_Sodium_Core_Util::declareScalarType($length, 'int', 2);
1318
 
1319
+ if (self::useNewSodiumAPI()) {
1320
  return sodium_crypto_generichash_final($ctx, $length);
1321
  }
1322
  if (self::use_fallback('crypto_generichash_final')) {
1366
  }
1367
  }
1368
 
1369
+ if (self::useNewSodiumAPI()) {
1370
  return sodium_crypto_generichash_init($key, $length);
1371
  }
1372
  if (self::use_fallback('crypto_generichash_init')) {
1381
  /**
1382
  * Update a BLAKE2b hashing context with additional data.
1383
  *
1384
+ * @param string &$ctx BLAKE2 hashing context. Generated by crypto_generichash_init().
1385
  * $ctx is passed by reference and gets updated in-place.
1386
  * @param string $message The message to append to the existing hash state.
1387
  * @return void
1395
  ParagonIE_Sodium_Core_Util::declareScalarType($ctx, 'string', 1);
1396
  ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 2);
1397
 
1398
+ if (self::useNewSodiumAPI()) {
1399
  sodium_crypto_generichash_update($ctx, $message);
1400
  return;
1401
  }
1413
 
1414
  /**
1415
  * @return string
1416
+ * @throws Exception
1417
+ * @throws Error
1418
  */
1419
  public static function crypto_generichash_keygen()
1420
  {
1472
  throw new SodiumException('Argument 4 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
1473
  }
1474
 
1475
+ if (self::useNewSodiumAPI()) {
1476
  if (is_callable('sodium_crypto_kx')) {
1477
  return (string) sodium_crypto_kx(
1478
  $my_secret,
1527
  ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4);
1528
  ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5);
1529
 
1530
+ if (self::useNewSodiumAPI()) {
1531
  if (!is_null($alg)) {
1532
  ParagonIE_Sodium_Core_Util::declareScalarType($alg, 'int', 6);
1533
  return sodium_crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $alg);
1553
  */
1554
  public static function crypto_pwhash_is_available()
1555
  {
1556
+ if (self::useNewSodiumAPI()) {
1557
  return true;
1558
  }
1559
  if (self::use_fallback('crypto_pwhash')) {
1577
  ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2);
1578
  ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3);
1579
 
1580
+ if (self::useNewSodiumAPI()) {
1581
  return sodium_crypto_pwhash_str($passwd, $opslimit, $memlimit);
1582
  }
1583
  if (self::use_fallback('crypto_pwhash_str')) {
1602
  ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1);
1603
  ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2);
1604
 
1605
+ if (self::useNewSodiumAPI()) {
1606
  return (bool) sodium_crypto_pwhash_str_verify($passwd, $hash);
1607
  }
1608
  if (self::use_fallback('crypto_pwhash_str_verify')) {
1632
  ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4);
1633
  ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5);
1634
 
1635
+ if (self::useNewSodiumAPI()) {
1636
+ return (string) sodium_crypto_pwhash_scryptsalsa208sha256(
1637
+ (int) $outlen,
1638
+ (string) $passwd,
1639
+ (string) $salt,
1640
+ (int) $opslimit,
1641
+ (int) $memlimit
1642
+ );
1643
  }
1644
  if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256')) {
1645
+ return (string) call_user_func(
1646
+ '\\Sodium\\crypto_pwhash_scryptsalsa208sha256',
1647
+ (int) $outlen,
1648
+ (string) $passwd,
1649
+ (string) $salt,
1650
+ (int) $opslimit,
1651
+ (int) $memlimit
1652
+ );
1653
  }
1654
  // This is the best we can do.
1655
  throw new SodiumException(
1667
  */
1668
  public static function crypto_pwhash_scryptsalsa208sha256_is_available()
1669
  {
1670
+ if (self::useNewSodiumAPI()) {
1671
  return true;
1672
  }
1673
  if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256')) {
1690
  ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2);
1691
  ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3);
1692
 
1693
+ if (self::useNewSodiumAPI()) {
1694
+ return (string) sodium_crypto_pwhash_scryptsalsa208sha256_str(
1695
+ (string) $passwd,
1696
+ (int) $opslimit,
1697
+ (int) $memlimit
1698
+ );
1699
  }
1700
  if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str')) {
1701
+ return (string) call_user_func(
1702
+ '\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str',
1703
+ (string) $passwd,
1704
+ (int) $opslimit,
1705
+ (int) $memlimit
1706
+ );
1707
  }
1708
  // This is the best we can do.
1709
  throw new SodiumException(
1723
  ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1);
1724
  ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2);
1725
 
1726
+ if (self::useNewSodiumAPI()) {
1727
+ return (bool) sodium_crypto_pwhash_scryptsalsa208sha256_str_verify(
1728
+ (string) $passwd,
1729
+ (string) $hash
1730
+ );
1731
  }
1732
  if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str_verify')) {
1733
+ return (bool) call_user_func(
1734
+ '\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify',
1735
+ (string) $passwd,
1736
+ (string) $hash
1737
+ );
1738
  }
1739
  // This is the best we can do.
1740
  throw new SodiumException(
1769
  throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
1770
  }
1771
 
1772
+ if (self::useNewSodiumAPI()) {
1773
  return sodium_crypto_scalarmult($secretKey, $publicKey);
1774
  }
1775
  if (self::use_fallback('crypto_scalarmult')) {
1809
  throw new SodiumException('Argument 1 must be CRYPTO_BOX_SECRETKEYBYTES long.');
1810
  }
1811
 
1812
+ if (self::useNewSodiumAPI()) {
1813
  return sodium_crypto_scalarmult_base($secretKey);
1814
  }
1815
  if (self::use_fallback('crypto_scalarmult_base')) {
1852
  throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
1853
  }
1854
 
1855
+ if (self::useNewSodiumAPI()) {
1856
  return sodium_crypto_secretbox($plaintext, $nonce, $key);
1857
  }
1858
  if (self::use_fallback('crypto_secretbox')) {
1892
  throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
1893
  }
1894
 
1895
+ if (self::useNewSodiumAPI()) {
1896
  /**
1897
  * @psalm-suppress InvalidReturnStatement
1898
  * @psalm-suppress FalsableReturnStatement
1912
  * Return a secure random key for use with crypto_secretbox
1913
  *
1914
  * @return string
1915
+ * @throws Exception
1916
+ * @throws Error
1917
  */
1918
  public static function crypto_secretbox_keygen()
1919
  {
2007
  throw new SodiumException('Argument 2 must be CRYPTO_SHORTHASH_KEYBYTES long.');
2008
  }
2009
 
2010
+ if (self::useNewSodiumAPI()) {
2011
  return sodium_crypto_shorthash($message, $key);
2012
  }
2013
  if (self::use_fallback('crypto_shorthash')) {
2023
  * Return a secure random key for use with crypto_shorthash
2024
  *
2025
  * @return string
2026
+ * @throws Exception
2027
+ * @throws Error
2028
  */
2029
  public static function crypto_shorthash_keygen()
2030
  {
2057
  throw new SodiumException('Argument 2 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
2058
  }
2059
 
2060
+ if (self::useNewSodiumAPI()) {
2061
  return sodium_crypto_sign($message, $secretKey);
2062
  }
2063
  if (self::use_fallback('crypto_sign')) {
2096
  throw new SodiumException('Argument 2 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
2097
  }
2098
 
2099
+ if (self::useNewSodiumAPI()) {
2100
  /**
2101
  * @psalm-suppress InvalidReturnStatement
2102
  * @psalm-suppress FalsableReturnStatement
2121
  */
2122
  public static function crypto_sign_keypair()
2123
  {
2124
+ if (self::useNewSodiumAPI()) {
2125
  return sodium_crypto_sign_keypair();
2126
  }
2127
  if (self::use_fallback('crypto_sign_keypair')) {
2146
  {
2147
  ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1);
2148
 
2149
+ if (self::useNewSodiumAPI()) {
2150
  return sodium_crypto_sign_seed_keypair($seed);
2151
  }
2152
  if (self::use_fallback('crypto_sign_keypair')) {
2181
  throw new SodiumException('Argument 1 must be CRYPTO_SIGN_KEYPAIRBYTES long.');
2182
  }
2183
 
2184
+ if (self::useNewSodiumAPI()) {
2185
  return sodium_crypto_sign_publickey($keypair);
2186
  }
2187
  if (self::use_fallback('crypto_sign_publickey')) {
2212
  throw new SodiumException('Argument 1 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
2213
  }
2214
 
2215
+ if (self::useNewSodiumAPI()) {
2216
  return sodium_crypto_sign_publickey_from_secretkey($secretKey);
2217
  }
2218
  if (self::use_fallback('crypto_sign_publickey_from_secretkey')) {
2243
  throw new SodiumException('Argument 1 must be CRYPTO_SIGN_KEYPAIRBYTES long.');
2244
  }
2245
 
2246
+ if (self::useNewSodiumAPI()) {
2247
  return sodium_crypto_sign_secretkey($keypair);
2248
  }
2249
  if (self::use_fallback('crypto_sign_secretkey')) {
2278
  throw new SodiumException('Argument 2 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
2279
  }
2280
 
2281
+ if (self::useNewSodiumAPI()) {
2282
  return sodium_crypto_sign_detached($message, $secretKey);
2283
  }
2284
  if (self::use_fallback('crypto_sign_detached')) {
2317
  throw new SodiumException('Argument 3 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
2318
  }
2319
 
2320
+ if (self::useNewSodiumAPI()) {
2321
  return sodium_crypto_sign_verify_detached($signature, $message, $publicKey);
2322
  }
2323
  if (self::use_fallback('crypto_sign_verify_detached')) {
2324
+ return (bool) call_user_func(
2325
+ '\\Sodium\\crypto_sign_verify_detached',
2326
+ $signature,
2327
+ $message,
2328
+ $publicKey
2329
+ );
2330
  }
2331
  if (PHP_INT_SIZE === 4) {
2332
  return ParagonIE_Sodium_Crypto32::sign_verify_detached($signature, $message, $publicKey);
2352
  if (ParagonIE_Sodium_Core_Util::strlen($pk) < self::CRYPTO_SIGN_PUBLICKEYBYTES) {
2353
  throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_PUBLICKEYBYTES long.');
2354
  }
2355
+ if (self::useNewSodiumAPI()) {
2356
  if (is_callable('crypto_sign_ed25519_pk_to_curve25519')) {
2357
  return (string) sodium_crypto_sign_ed25519_pk_to_curve25519($pk);
2358
  }
2384
  if (ParagonIE_Sodium_Core_Util::strlen($sk) < self::CRYPTO_SIGN_SEEDBYTES) {
2385
  throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_SEEDBYTES long.');
2386
  }
2387
+ if (self::useNewSodiumAPI()) {
2388
  if (is_callable('crypto_sign_ed25519_sk_to_curve25519')) {
2389
  return sodium_crypto_sign_ed25519_sk_to_curve25519($sk);
2390
  }
2432
  throw new SodiumException('Argument 3 must be CRYPTO_STREAM_KEYBYTES long.');
2433
  }
2434
 
2435
+ if (self::useNewSodiumAPI()) {
2436
  return sodium_crypto_stream($len, $nonce, $key);
2437
  }
2438
  if (self::use_fallback('crypto_stream')) {
2479
  throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
2480
  }
2481
 
2482
+ if (self::useNewSodiumAPI()) {
2483
  return sodium_crypto_stream_xor($message, $nonce, $key);
2484
  }
2485
  if (self::use_fallback('crypto_stream_xor')) {
2495
  * Return a secure random key for use with crypto_stream
2496
  *
2497
  * @return string
2498
+ * @throws Exception
2499
+ * @throws Error
2500
  */
2501
  public static function crypto_stream_keygen()
2502
  {
2518
  /* Type checks: */
2519
  ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1);
2520
 
2521
+ if (self::useNewSodiumAPI()) {
2522
  if (is_callable('sodium_hex2bin')) {
2523
  return (string) sodium_hex2bin($string);
2524
  }
2544
  /* Type checks: */
2545
  ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1);
2546
 
2547
+ if (self::useNewSodiumAPI()) {
2548
  sodium_increment($var);
2549
  return;
2550
  }
2551
  if (self::use_fallback('increment')) {
2552
+ $func = '\\Sodium\\increment';
2553
+ $func($var);
2554
  return;
2555
  }
2556
 
2577
  */
2578
  public static function library_version_major()
2579
  {
2580
+ if (self::useNewSodiumAPI()) {
2581
  return sodium_library_version_major();
2582
  }
2583
  if (self::use_fallback('library_version_major')) {
2596
  */
2597
  public static function library_version_minor()
2598
  {
2599
+ if (self::useNewSodiumAPI()) {
2600
  return sodium_library_version_minor();
2601
  }
2602
  if (self::use_fallback('library_version_minor')) {
2645
  /* Type checks: */
2646
  ParagonIE_Sodium_Core_Util::declareScalarType($var, 'string', 1);
2647
 
2648
+ if (self::useNewSodiumAPI()) {
2649
  sodium_memzero($var);
2650
  return;
2651
  }
2652
  if (self::use_fallback('memzero')) {
2653
+ $func = '\\Sodium\\memzero';
2654
+ $func($var);
2655
+ if ($var === null) {
2656
+ return;
2657
+ }
2658
  }
2659
  // This is the best we can do.
2660
  throw new SodiumException(
2663
  );
2664
  }
2665
 
2666
+ /**
2667
+ * Will sodium_compat run fast on the current hardware and PHP configuration?
2668
+ *
2669
+ * @return bool
2670
+ */
2671
+ public static function polyfill_is_fast()
2672
+ {
2673
+ if (extension_loaded('sodium')) {
2674
+ return true;
2675
+ }
2676
+ if (extension_loaded('libsodium')) {
2677
+ return true;
2678
+ }
2679
+ return PHP_INT_SIZE === 8;
2680
+ }
2681
+
2682
  /**
2683
  * Generate a string of bytes from the kernel's CSPRNG.
2684
  * Proudly uses /dev/urandom (if getrandom(2) is not available).
2685
  *
2686
  * @param int $numBytes
2687
  * @return string
2688
+ * @throws Exception
2689
  * @throws TypeError
2690
  */
2691
  public static function randombytes_buf($numBytes)
2695
  if (is_numeric($numBytes)) {
2696
  $numBytes = (int) $numBytes;
2697
  } else {
2698
+ throw new TypeError(
2699
+ 'Argument 1 must be an integer, ' . gettype($numBytes) . ' given.'
2700
+ );
2701
  }
2702
  }
2703
  if (self::use_fallback('randombytes_buf')) {
2711
  *
2712
  * @param int $range
2713
  * @return int
2714
+ * @throws Exception
2715
+ * @throws Error
2716
  * @throws TypeError
2717
  */
2718
  public static function randombytes_uniform($range)
2720
  /* Type checks: */
2721
  if (!is_int($range)) {
2722
  if (is_numeric($range)) {
2723
+ $range = (int) $range;
2724
  } else {
2725
+ throw new TypeError(
2726
+ 'Argument 1 must be an integer, ' . gettype($range) . ' given.'
2727
+ );
2728
  }
2729
  }
2730
  if (self::use_fallback('randombytes_uniform')) {
2737
  * Generate a random 16-bit integer.
2738
  *
2739
  * @return int
2740
+ * @throws Exception
2741
+ * @throws Error
2742
+ * @throws TypeError
2743
  */
2744
  public static function randombytes_random16()
2745
  {
2759
  */
2760
  public static function version_string()
2761
  {
2762
+ if (self::useNewSodiumAPI()) {
2763
  return (string) sodium_version_string();
2764
  }
2765
  if (self::use_fallback('version_string')) {
2802
 
2803
  /**
2804
  * Libsodium as implemented in PHP 7.2
2805
+ * and/or ext/sodium (via PECL)
2806
  *
2807
  * @ref https://wiki.php.net/rfc/libsodium
2808
  * @return bool
2809
  */
2810
+ protected static function useNewSodiumAPI()
2811
  {
2812
  static $res = null;
2813
  if ($res === null) {
2814
+ $res = PHP_VERSION_ID >= 70000 && extension_loaded('sodium');
2815
  }
2816
  if (self::$disableFallbackForUnitTests) {
2817
  // Don't fallback. Use the PHP implementation.
vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php CHANGED
@@ -131,7 +131,10 @@ abstract class ParagonIE_Sodium_Core_BLAKE2b extends ParagonIE_Sodium_Core_Util
131
  if (!is_numeric($y[1])) {
132
  throw new SodiumException('y[1] is not an integer');
133
  }
134
- return self::new64($x[0] ^ $y[0], $x[1] ^ $y[1]);
 
 
 
135
  }
136
 
137
  /**
@@ -163,18 +166,18 @@ abstract class ParagonIE_Sodium_Core_BLAKE2b extends ParagonIE_Sodium_Core_Util
163
 
164
  if ($c < 32) {
165
  /** @var int $h0 */
166
- $h0 = ($x[0] << $c) | (
167
  (
168
- $x[1] & ((1 << $c) - 1)
169
  <<
170
  (32 - $c)
171
  ) >> (32 - $c)
172
  );
173
  /** @var int $l0 */
174
- $l0 = $x[1] << $c;
175
  } else {
176
  /** @var int $h0 */
177
- $h0 = $x[1] << ($c - 32);
178
  }
179
 
180
  $h1 = 0;
@@ -182,12 +185,12 @@ abstract class ParagonIE_Sodium_Core_BLAKE2b extends ParagonIE_Sodium_Core_Util
182
 
183
  if ($c1 < 32) {
184
  /** @var int $h1 */
185
- $h1 = $x[0] >> $c1;
186
  /** @var int $l1 */
187
- $l1 = ($x[1] >> $c1) | ($x[0] & ((1 << $c1) - 1)) << (32 - $c1);
188
  } else {
189
  /** @var int $l1 */
190
- $l1 = $x[0] >> ($c1 - 32);
191
  }
192
 
193
  return self::new64($h0 | $h1, $l0 | $l1);
@@ -217,9 +220,15 @@ abstract class ParagonIE_Sodium_Core_BLAKE2b extends ParagonIE_Sodium_Core_Util
217
  protected static function load64(SplFixedArray $x, $i)
218
  {
219
  /** @var int $l */
220
- $l = $x[$i] | ($x[$i+1]<<8) | ($x[$i+2]<<16) | ($x[$i+3]<<24);
 
 
 
221
  /** @var int $h */
222
- $h = $x[$i+4] | ($x[$i+5]<<8) | ($x[$i+6]<<16) | ($x[$i+7]<<24);
 
 
 
223
  return self::new64($h, $l);
224
  }
225
 
@@ -243,7 +252,7 @@ abstract class ParagonIE_Sodium_Core_BLAKE2b extends ParagonIE_Sodium_Core_Util
243
  */
244
  /** @var int $uIdx */
245
  $uIdx = ((7 - $j) & 4) >> 2;
246
- $x[$i] = ($u[$uIdx] & 0xff);
247
  if (++$i > $maxLength) {
248
  return;
249
  }
@@ -622,7 +631,7 @@ abstract class ParagonIE_Sodium_Core_BLAKE2b extends ParagonIE_Sodium_Core_Util
622
  public static function SplFixedArrayToString(SplFixedArray $a)
623
  {
624
  /**
625
- * @var array<mixed, int>
626
  */
627
  $arr = $a->toArray();
628
  $c = $a->count();
@@ -668,16 +677,19 @@ abstract class ParagonIE_Sodium_Core_BLAKE2b extends ParagonIE_Sodium_Core_Util
668
  # uint8_t buf[2 * 128];
669
  $str .= self::SplFixedArrayToString($ctx[3]);
670
 
 
 
 
671
  # size_t buflen;
672
  $str .= implode('', array(
673
- self::intToChr($ctx[4] & 0xff),
674
- self::intToChr(($ctx[4] >> 8) & 0xff),
675
- self::intToChr(($ctx[4] >> 16) & 0xff),
676
- self::intToChr(($ctx[4] >> 24) & 0xff),
677
- self::intToChr(($ctx[4] >> 32) & 0xff),
678
- self::intToChr(($ctx[4] >> 40) & 0xff),
679
- self::intToChr(($ctx[4] >> 48) & 0xff),
680
- self::intToChr(($ctx[4] >> 56) & 0xff)
681
  ));
682
  # uint8_t last_node;
683
  return $str . "\x00";
131
  if (!is_numeric($y[1])) {
132
  throw new SodiumException('y[1] is not an integer');
133
  }
134
+ return self::new64(
135
+ (int) ($x[0] ^ $y[0]),
136
+ (int) ($x[1] ^ $y[1])
137
+ );
138
  }
139
 
140
  /**
166
 
167
  if ($c < 32) {
168
  /** @var int $h0 */
169
+ $h0 = ((int) ($x[0]) << $c) | (
170
  (
171
+ (int) ($x[1]) & ((1 << $c) - 1)
172
  <<
173
  (32 - $c)
174
  ) >> (32 - $c)
175
  );
176
  /** @var int $l0 */
177
+ $l0 = (int) ($x[1]) << $c;
178
  } else {
179
  /** @var int $h0 */
180
+ $h0 = (int) ($x[1]) << ($c - 32);
181
  }
182
 
183
  $h1 = 0;
185
 
186
  if ($c1 < 32) {
187
  /** @var int $h1 */
188
+ $h1 = (int) ($x[0]) >> $c1;
189
  /** @var int $l1 */
190
+ $l1 = ((int) ($x[1]) >> $c1) | ((int) ($x[0]) & ((1 << $c1) - 1)) << (32 - $c1);
191
  } else {
192
  /** @var int $l1 */
193
+ $l1 = (int) ($x[0]) >> ($c1 - 32);
194
  }
195
 
196
  return self::new64($h0 | $h1, $l0 | $l1);
220
  protected static function load64(SplFixedArray $x, $i)
221
  {
222
  /** @var int $l */
223
+ $l = (int) ($x[$i])
224
+ | ((int) ($x[$i+1]) << 8)
225
+ | ((int) ($x[$i+2]) << 16)
226
+ | ((int) ($x[$i+3]) << 24);
227
  /** @var int $h */
228
+ $h = (int) ($x[$i+4])
229
+ | ((int) ($x[$i+5]) << 8)
230
+ | ((int) ($x[$i+6]) << 16)
231
+ | ((int) ($x[$i+7]) << 24);
232
  return self::new64($h, $l);
233
  }
234
 
252
  */
253
  /** @var int $uIdx */
254
  $uIdx = ((7 - $j) & 4) >> 2;
255
+ $x[$i] = ((int) ($u[$uIdx]) & 0xff);
256
  if (++$i > $maxLength) {
257
  return;
258
  }
631
  public static function SplFixedArrayToString(SplFixedArray $a)
632
  {
633
  /**
634
+ * @var array<int, int|string> $arr
635
  */
636
  $arr = $a->toArray();
637
  $c = $a->count();
677
  # uint8_t buf[2 * 128];
678
  $str .= self::SplFixedArrayToString($ctx[3]);
679
 
680
+ /** @var int $ctx4 */
681
+ $ctx4 = (int) $ctx[4];
682
+
683
  # size_t buflen;
684
  $str .= implode('', array(
685
+ self::intToChr($ctx4 & 0xff),
686
+ self::intToChr(($ctx4 >> 8) & 0xff),
687
+ self::intToChr(($ctx4 >> 16) & 0xff),
688
+ self::intToChr(($ctx4 >> 24) & 0xff),
689
+ self::intToChr(($ctx4 >> 32) & 0xff),
690
+ self::intToChr(($ctx4 >> 40) & 0xff),
691
+ self::intToChr(($ctx4 >> 48) & 0xff),
692
+ self::intToChr(($ctx4 >> 56) & 0xff)
693
  ));
694
  # uint8_t last_node;
695
  return $str . "\x00";
vendor/paragonie/sodium_compat/src/Core/ChaCha20/Ctx.php CHANGED
@@ -10,7 +10,7 @@ if (class_exists('ParagonIE_Sodium_Core_ChaCha20_Ctx', false)) {
10
  class ParagonIE_Sodium_Core_ChaCha20_Ctx extends ParagonIE_Sodium_Core_Util implements ArrayAccess
11
  {
12
  /**
13
- * @var SplFixedArray<int, int>
14
  */
15
  protected $container;
16
 
10
  class ParagonIE_Sodium_Core_ChaCha20_Ctx extends ParagonIE_Sodium_Core_Util implements ArrayAccess
11
  {
12
  /**
13
+ * @var SplFixedArray internally, <int, int>
14
  */
15
  protected $container;
16
 
vendor/paragonie/sodium_compat/src/Core/Curve25519.php CHANGED
@@ -88,7 +88,7 @@ abstract class ParagonIE_Sodium_Core_Curve25519 extends ParagonIE_Sodium_Core_Cu
88
  for ($i = 0; $i < 10; ++$i) {
89
  /** @var int $x */
90
  $x = (($f[$i] ^ $g[$i]) & $b);
91
- $h[$i] = (int) ($f[$i] ^ $x);
92
  }
93
  return ParagonIE_Sodium_Core_Curve25519_Fe::fromArray($h);
94
  }
@@ -453,106 +453,106 @@ abstract class ParagonIE_Sodium_Core_Curve25519 extends ParagonIE_Sodium_Core_Cu
453
  $f7_2 = $f7 << 1;
454
  /** @var int $f9_2 */
455
  $f9_2 = $f9 << 1;
456
- $f0g0 = self::mul($f0, $g0, 27);
457
- $f0g1 = self::mul($f0, $g1, 26);
458
- $f0g2 = self::mul($f0, $g2, 27);
459
- $f0g3 = self::mul($f0, $g3, 26);
460
- $f0g4 = self::mul($f0, $g4, 27);
461
- $f0g5 = self::mul($f0, $g5, 26);
462
- $f0g6 = self::mul($f0, $g6, 27);
463
- $f0g7 = self::mul($f0, $g7, 26);
464
- $f0g8 = self::mul($f0, $g8, 27);
465
- $f0g9 = self::mul($f0, $g9, 27);
466
- $f1g0 = self::mul($f1, $g0, 27);
467
- $f1g1_2 = self::mul($f1_2, $g1, 26);
468
- $f1g2 = self::mul($f1, $g2, 27);
469
- $f1g3_2 = self::mul($f1_2, $g3, 26);
470
- $f1g4 = self::mul($f1, $g4, 27);
471
- $f1g5_2 = self::mul($f1_2, $g5, 26);
472
- $f1g6 = self::mul($f1, $g6, 27);
473
- $f1g7_2 = self::mul($f1_2, $g7, 26);
474
- $f1g8 = self::mul($f1, $g8, 27);
475
- $f1g9_38 = self::mul($g9_19, $f1_2, 27);
476
- $f2g0 = self::mul($f2, $g0, 27);
477
- $f2g1 = self::mul($f2, $g1, 26);
478
- $f2g2 = self::mul($f2, $g2, 27);
479
- $f2g3 = self::mul($f2, $g3, 26);
480
- $f2g4 = self::mul($f2, $g4, 27);
481
- $f2g5 = self::mul($f2, $g5, 26);
482
- $f2g6 = self::mul($f2, $g6, 27);
483
- $f2g7 = self::mul($f2, $g7, 26);
484
- $f2g8_19 = self::mul($g8_19, $f2, 27);
485
- $f2g9_19 = self::mul($g9_19, $f2, 27);
486
- $f3g0 = self::mul($f3, $g0, 27);
487
- $f3g1_2 = self::mul($f3_2, $g1, 26);
488
- $f3g2 = self::mul($f3, $g2, 27);
489
- $f3g3_2 = self::mul($f3_2, $g3, 26);
490
- $f3g4 = self::mul($f3, $g4, 27);
491
- $f3g5_2 = self::mul($f3_2, $g5, 26);
492
- $f3g6 = self::mul($f3, $g6, 27);
493
- $f3g7_38 = self::mul($g7_19, $f3_2, 27);
494
- $f3g8_19 = self::mul($g8_19, $f3, 27);
495
- $f3g9_38 = self::mul($g9_19, $f3_2, 27);
496
- $f4g0 = self::mul($f4, $g0, 27);
497
- $f4g1 = self::mul($f4, $g1, 26);
498
- $f4g2 = self::mul($f4, $g2, 27);
499
- $f4g3 = self::mul($f4, $g3, 26);
500
- $f4g4 = self::mul($f4, $g4, 27);
501
- $f4g5 = self::mul($f4, $g5, 26);
502
- $f4g6_19 = self::mul($g6_19, $f4, 27);
503
- $f4g7_19 = self::mul($g7_19, $f4, 27);
504
- $f4g8_19 = self::mul($g8_19, $f4, 27);
505
- $f4g9_19 = self::mul($g9_19, $f4, 27);
506
- $f5g0 = self::mul($f5, $g0, 27);
507
- $f5g1_2 = self::mul($f5_2, $g1, 26);
508
- $f5g2 = self::mul($f5, $g2, 27);
509
- $f5g3_2 = self::mul($f5_2, $g3, 26);
510
- $f5g4 = self::mul($f5, $g4, 27);
511
- $f5g5_38 = self::mul($g5_19, $f5_2, 27);
512
- $f5g6_19 = self::mul($g6_19, $f5, 26);
513
- $f5g7_38 = self::mul($g7_19, $f5_2, 27);
514
- $f5g8_19 = self::mul($g8_19, $f5, 26);
515
- $f5g9_38 = self::mul($g9_19, $f5_2, 27);
516
- $f6g0 = self::mul($f6, $g0, 27);
517
- $f6g1 = self::mul($f6, $g1, 26);
518
- $f6g2 = self::mul($f6, $g2, 27);
519
- $f6g3 = self::mul($f6, $g3, 26);
520
- $f6g4_19 = self::mul($g4_19, $f6, 27);
521
- $f6g5_19 = self::mul($g5_19, $f6, 27);
522
- $f6g6_19 = self::mul($g6_19, $f6, 27);
523
- $f6g7_19 = self::mul($g7_19, $f6, 27);
524
- $f6g8_19 = self::mul($g8_19, $f6, 27);
525
- $f6g9_19 = self::mul($g9_19, $f6, 27);
526
- $f7g0 = self::mul($f7, $g0, 27);
527
- $f7g1_2 = self::mul($f7_2, $g1, 26);
528
- $f7g2 = self::mul($f7, $g2, 27);
529
- $f7g3_38 = self::mul($g3_19, $f7_2, 27);
530
- $f7g4_19 = self::mul($g4_19, $f7, 27);
531
- $f7g5_38 = self::mul($g5_19, $f7_2, 27);
532
- $f7g6_19 = self::mul($g6_19, $f7, 27);
533
- $f7g7_38 = self::mul($g7_19, $f7_2, 27);
534
- $f7g8_19 = self::mul($g8_19, $f7, 27);
535
- $f7g9_38 = self::mul($g9_19,$f7_2, 27);
536
- $f8g0 = self::mul($f8, $g0, 27);
537
- $f8g1 = self::mul($f8, $g1, 26);
538
- $f8g2_19 = self::mul($g2_19, $f8, 27);
539
- $f8g3_19 = self::mul($g3_19, $f8, 27);
540
- $f8g4_19 = self::mul($g4_19, $f8, 27);
541
- $f8g5_19 = self::mul($g5_19, $f8, 27);
542
- $f8g6_19 = self::mul($g6_19, $f8, 27);
543
- $f8g7_19 = self::mul($g7_19, $f8, 27);
544
- $f8g8_19 = self::mul($g8_19, $f8, 27);
545
- $f8g9_19 = self::mul($g9_19, $f8, 27);
546
- $f9g0 = self::mul($f9, $g0, 27);
547
- $f9g1_38 = self::mul($g1_19, $f9_2, 27);
548
- $f9g2_19 = self::mul($g2_19, $f9, 27);
549
- $f9g3_38 = self::mul($g3_19, $f9_2, 27);
550
- $f9g4_19 = self::mul($g4_19, $f9, 27);
551
- $f9g5_38 = self::mul($g5_19, $f9_2, 27);
552
- $f9g6_19 = self::mul($g6_19, $f9, 27);
553
- $f9g7_38 = self::mul($g7_19, $f9_2, 27);
554
- $f9g8_19 = self::mul($g8_19, $f9, 27);
555
- $f9g9_38 = self::mul($g9_19, $f9_2, 27);
556
  $h0 = $f0g0 + $f1g9_38 + $f2g8_19 + $f3g7_38 + $f4g6_19 + $f5g5_38 + $f6g4_19 + $f7g3_38 + $f8g2_19 + $f9g1_38;
557
  $h1 = $f0g1 + $f1g0 + $f2g9_19 + $f3g8_19 + $f4g7_19 + $f5g6_19 + $f6g5_19 + $f7g4_19 + $f8g3_19 + $f9g2_19;
558
  $h2 = $f0g2 + $f1g1_2 + $f2g0 + $f3g9_38 + $f4g8_19 + $f5g7_38 + $f6g6_19 + $f7g5_38 + $f8g4_19 + $f9g3_38;
@@ -699,61 +699,61 @@ abstract class ParagonIE_Sodium_Core_Curve25519 extends ParagonIE_Sodium_Core_Cu
699
  $f7_38 = self::mul($f7, 38, 6);
700
  $f8_19 = self::mul($f8, 19, 5);
701
  $f9_38 = self::mul($f9, 38, 6);
702
- $f0f0 = self::mul($f0, $f0, 26);
703
- $f0f1_2 = self::mul($f0_2, $f1, 26);
704
- $f0f2_2 = self::mul($f0_2, $f2, 26);
705
- $f0f3_2 = self::mul($f0_2, $f3, 26);
706
- $f0f4_2 = self::mul($f0_2, $f4, 26);
707
- $f0f5_2 = self::mul($f0_2, $f5, 26);
708
- $f0f6_2 = self::mul($f0_2, $f6, 26);
709
- $f0f7_2 = self::mul($f0_2, $f7, 26);
710
- $f0f8_2 = self::mul($f0_2, $f8, 26);
711
- $f0f9_2 = self::mul($f0_2, $f9, 26);
712
- $f1f1_2 = self::mul($f1_2, $f1, 26);
713
- $f1f2_2 = self::mul($f1_2, $f2, 26);
714
- $f1f3_4 = self::mul($f1_2, $f3_2, 26);
715
- $f1f4_2 = self::mul($f1_2, $f4, 26);
716
- $f1f5_4 = self::mul($f1_2, $f5_2, 27);
717
- $f1f6_2 = self::mul($f1_2, $f6, 26);
718
- $f1f7_4 = self::mul($f1_2, $f7_2, 26);
719
- $f1f8_2 = self::mul($f1_2, $f8, 26);
720
- $f1f9_76 = self::mul($f9_38, $f1_2, 26);
721
- $f2f2 = self::mul($f2, $f2, 26);
722
- $f2f3_2 = self::mul($f2_2, $f3, 26);
723
- $f2f4_2 = self::mul($f2_2, $f4, 26);
724
- $f2f5_2 = self::mul($f2_2, $f5, 26);
725
- $f2f6_2 = self::mul($f2_2, $f6, 26);
726
- $f2f7_2 = self::mul($f2_2, $f7, 26);
727
- $f2f8_38 = self::mul($f8_19, $f2_2, 27);
728
- $f2f9_38 = self::mul($f9_38, $f2, 26);
729
- $f3f3_2 = self::mul($f3_2, $f3, 26);
730
- $f3f4_2 = self::mul($f3_2, $f4, 26);
731
- $f3f5_4 = self::mul($f3_2, $f5_2, 27);
732
- $f3f6_2 = self::mul($f3_2, $f6, 26);
733
- $f3f7_76 = self::mul($f7_38, $f3_2, 26);
734
- $f3f8_38 = self::mul($f8_19, $f3_2, 26);
735
- $f3f9_76 = self::mul($f9_38, $f3_2, 26);
736
- $f4f4 = self::mul($f4, $f4, 26);
737
- $f4f5_2 = self::mul($f4_2, $f5, 26);
738
- $f4f6_38 = self::mul($f6_19, $f4_2, 27);
739
- $f4f7_38 = self::mul($f7_38, $f4, 26);
740
- $f4f8_38 = self::mul($f8_19, $f4_2, 27);
741
- $f4f9_38 = self::mul($f9_38, $f4, 26);
742
- $f5f5_38 = self::mul($f5_38, $f5, 26);
743
- $f5f6_38 = self::mul($f6_19, $f5_2, 27);
744
- $f5f7_76 = self::mul($f7_38, $f5_2, 27);
745
- $f5f8_38 = self::mul($f8_19, $f5_2, 27);
746
- $f5f9_76 = self::mul($f9_38, $f5_2, 27);
747
- $f6f6_19 = self::mul($f6_19, $f6, 26);
748
- $f6f7_38 = self::mul($f7_38, $f6, 26);
749
- $f6f8_38 = self::mul($f8_19, $f6_2, 27);
750
- $f6f9_38 = self::mul($f9_38, $f6, 26);
751
- $f7f7_38 = self::mul($f7_38, $f7, 26);
752
- $f7f8_38 = self::mul($f8_19, $f7_2, 27);
753
- $f7f9_76 = self::mul($f9_38, $f7_2, 27);
754
- $f8f8_19 = self::mul($f8_19, $f8, 26);
755
- $f8f9_38 = self::mul($f9_38, $f8, 26);
756
- $f9f9_38 = self::mul($f9_38, $f9, 27);
757
  $h0 = $f0f0 + $f1f9_76 + $f2f8_38 + $f3f7_76 + $f4f6_38 + $f5f5_38;
758
  $h1 = $f0f1_2 + $f2f9_38 + $f3f8_38 + $f4f7_38 + $f5f6_38;
759
  $h2 = $f0f2_2 + $f1f1_2 + $f3f9_76 + $f4f8_38 + $f5f7_76 + $f6f6_19;
@@ -881,61 +881,61 @@ abstract class ParagonIE_Sodium_Core_Curve25519 extends ParagonIE_Sodium_Core_Cu
881
  $f7_38 = self::mul($f7, 38, 6); /* 1.959375*2^30 */
882
  $f8_19 = self::mul($f8, 19, 5); /* 1.959375*2^30 */
883
  $f9_38 = self::mul($f9, 38, 6); /* 1.959375*2^30 */
884
- $f0f0 = self::mul($f0, $f0, 26);
885
- $f0f1_2 = self::mul($f0_2, $f1, 26);
886
- $f0f2_2 = self::mul($f0_2, $f2, 26);
887
- $f0f3_2 = self::mul($f0_2, $f3, 26);
888
- $f0f4_2 = self::mul($f0_2, $f4, 26);
889
- $f0f5_2 = self::mul($f0_2, $f5, 26);
890
- $f0f6_2 = self::mul($f0_2, $f6, 26);
891
- $f0f7_2 = self::mul($f0_2, $f7, 26);
892
- $f0f8_2 = self::mul($f0_2, $f8, 26);
893
- $f0f9_2 = self::mul($f0_2, $f9, 26);
894
- $f1f1_2 = self::mul($f1_2, $f1, 26);
895
- $f1f2_2 = self::mul($f1_2, $f2, 26);
896
- $f1f3_4 = self::mul($f1_2, $f3_2, 27);
897
- $f1f4_2 = self::mul($f1_2, $f4, 26);
898
- $f1f5_4 = self::mul($f1_2, $f5_2, 27);
899
- $f1f6_2 = self::mul($f1_2, $f6, 26);
900
- $f1f7_4 = self::mul($f1_2, $f7_2, 27);
901
- $f1f8_2 = self::mul($f1_2, $f8, 26);
902
- $f1f9_76 = self::mul($f9_38, $f1_2, 27);
903
- $f2f2 = self::mul($f2, $f2, 26);
904
- $f2f3_2 = self::mul($f2_2, $f3, 26);
905
- $f2f4_2 = self::mul($f2_2, $f4, 26);
906
- $f2f5_2 = self::mul($f2_2, $f5, 26);
907
- $f2f6_2 = self::mul($f2_2, $f6, 26);
908
- $f2f7_2 = self::mul($f2_2, $f7, 26);
909
- $f2f8_38 = self::mul($f8_19, $f2_2, 27);
910
- $f2f9_38 = self::mul($f9_38, $f2, 26);
911
- $f3f3_2 = self::mul($f3_2, $f3, 26);
912
- $f3f4_2 = self::mul($f3_2, $f4, 26);
913
- $f3f5_4 = self::mul($f3_2, $f5_2, 27);
914
- $f3f6_2 = self::mul($f3_2, $f6, 27);
915
- $f3f7_76 = self::mul($f7_38, $f3_2, 27);
916
- $f3f8_38 = self::mul($f8_19, $f3_2, 27);
917
- $f3f9_76 = self::mul($f9_38, $f3_2, 27);
918
- $f4f4 = self::mul($f4, $f4, 26);
919
- $f4f5_2 = self::mul($f4_2, $f5, 26);
920
- $f4f6_38 = self::mul($f6_19, $f4_2, 27);
921
- $f4f7_38 = self::mul($f7_38, $f4, 27);
922
- $f4f8_38 = self::mul($f8_19, $f4_2, 27);
923
- $f4f9_38 = self::mul($f9_38, $f4, 27);
924
- $f5f5_38 = self::mul($f5_38, $f5, 26);
925
- $f5f6_38 = self::mul($f6_19, $f5_2, 27);
926
- $f5f7_76 = self::mul($f7_38, $f5_2, 27);
927
- $f5f8_38 = self::mul($f8_19, $f5_2, 27);
928
- $f5f9_76 = self::mul($f9_38, $f5_2, 27);
929
- $f6f6_19 = self::mul($f6_19, $f6, 26);
930
- $f6f7_38 = self::mul($f7_38, $f6, 26);
931
- $f6f8_38 = self::mul($f8_19, $f6_2, 27);
932
- $f6f9_38 = self::mul($f9_38, $f6, 26);
933
- $f7f7_38 = self::mul($f7_38, $f7, 26);
934
- $f7f8_38 = self::mul($f8_19, $f7_2, 27);
935
- $f7f9_76 = self::mul($f9_38, $f7_2, 27);
936
- $f8f8_19 = self::mul($f8_19, $f8, 26);
937
- $f8f9_38 = self::mul($f9_38, $f8, 26);
938
- $f9f9_38 = self::mul($f9_38, $f9, 27);
939
 
940
  /** @var int $h0 */
941
  $h0 = (int) ($f0f0 + $f1f9_76 + $f2f8_38 + $f3f7_76 + $f4f6_38 + $f5f5_38) << 1;
@@ -1840,7 +1840,9 @@ abstract class ParagonIE_Sodium_Core_Curve25519 extends ParagonIE_Sodium_Core_Cu
1840
 
1841
  # slide(aslide,a);
1842
  # slide(bslide,b);
 
1843
  $aslide = self::slide($a);
 
1844
  $bslide = self::slide($b);
1845
 
1846
  # ge_p3_to_cached(&Ai[0],A);
@@ -2080,21 +2082,43 @@ abstract class ParagonIE_Sodium_Core_Curve25519 extends ParagonIE_Sodium_Core_Cu
2080
  $s1 = $c1 + self::mul($a0, $b1, 24) + self::mul($a1, $b0, 24);
2081
  $s2 = $c2 + self::mul($a0, $b2, 24) + self::mul($a1, $b1, 24) + self::mul($a2, $b0, 24);
2082
  $s3 = $c3 + self::mul($a0, $b3, 24) + self::mul($a1, $b2, 24) + self::mul($a2, $b1, 24) + self::mul($a3, $b0, 24);
2083
- $s4 = $c4 + self::mul($a0, $b4, 24) + self::mul($a1, $b3, 24) + self::mul($a2, $b2, 24) + self::mul($a3, $b1, 24) + self::mul($a4, $b0, 24);
2084
- $s5 = $c5 + self::mul($a0, $b5, 24) + self::mul($a1, $b4, 24) + self::mul($a2, $b3, 24) + self::mul($a3, $b2, 24) + self::mul($a4, $b1, 24) + self::mul($a5, $b0, 24);
2085
- $s6 = $c6 + self::mul($a0, $b6, 24) + self::mul($a1, $b5, 24) + self::mul($a2, $b4, 24) + self::mul($a3, $b3, 24) + self::mul($a4, $b2, 24) + self::mul($a5, $b1, 24) + self::mul($a6, $b0, 24);
2086
- $s7 = $c7 + self::mul($a0, $b7, 24) + self::mul($a1, $b6, 24) + self::mul($a2, $b5, 24) + self::mul($a3, $b4, 24) + self::mul($a4, $b3, 24) + self::mul($a5, $b2, 24) + self::mul($a6, $b1, 24) + self::mul($a7, $b0, 24);
2087
- $s8 = $c8 + self::mul($a0, $b8, 24) + self::mul($a1, $b7, 24) + self::mul($a2, $b6, 24) + self::mul($a3, $b5, 24) + self::mul($a4, $b4, 24) + self::mul($a5, $b3, 24) + self::mul($a6, $b2, 24) + self::mul($a7, $b1, 24) + self::mul($a8, $b0, 24);
2088
- $s9 = $c9 + self::mul($a0, $b9, 24) + self::mul($a1, $b8, 24) + self::mul($a2, $b7, 24) + self::mul($a3, $b6, 24) + self::mul($a4, $b5, 24) + self::mul($a5, $b4, 24) + self::mul($a6, $b3, 24) + self::mul($a7, $b2, 24) + self::mul($a8, $b1, 24) + self::mul($a9, $b0, 24);
2089
- $s10 = $c10 + self::mul($a0, $b10, 24) + self::mul($a1, $b9, 24) + self::mul($a2, $b8, 24) + self::mul($a3, $b7, 24) + self::mul($a4, $b6, 24) + self::mul($a5, $b5, 24) + self::mul($a6, $b4, 24) + self::mul($a7, $b3, 24) + self::mul($a8, $b2, 24) + self::mul($a9, $b1, 24) + self::mul($a10, $b0, 24);
2090
- $s11 = $c11 + self::mul($a0, $b11, 24) + self::mul($a1, $b10, 24) + self::mul($a2, $b9, 24) + self::mul($a3, $b8, 24) + self::mul($a4, $b7, 24) + self::mul($a5, $b6, 24) + self::mul($a6, $b5, 24) + self::mul($a7, $b4, 24) + self::mul($a8, $b3, 24) + self::mul($a9, $b2, 24) + self::mul($a10, $b1, 24) + self::mul($a11, $b0, 24);
2091
- $s12 = self::mul($a1, $b11, 24) + self::mul($a2, $b10, 24) + self::mul($a3, $b9, 24) + self::mul($a4, $b8, 24) + self::mul($a5, $b7, 24) + self::mul($a6, $b6, 24) + self::mul($a7, $b5, 24) + self::mul($a8, $b4, 24) + self::mul($a9, $b3, 24) + self::mul($a10, $b2, 24) + self::mul($a11, $b1, 24);
2092
- $s13 = self::mul($a2, $b11, 24) + self::mul($a3, $b10, 24) + self::mul($a4, $b9, 24) + self::mul($a5, $b8, 24) + self::mul($a6, $b7, 24) + self::mul($a7, $b6, 24) + self::mul($a8, $b5, 24) + self::mul($a9, $b4, 24) + self::mul($a10, $b3, 24) + self::mul($a11, $b2, 24);
2093
- $s14 = self::mul($a3, $b11, 24) + self::mul($a4, $b10, 24) + self::mul($a5, $b9, 24) + self::mul($a6, $b8, 24) + self::mul($a7, $b7, 24) + self::mul($a8, $b6, 24) + self::mul($a9, $b5, 24) + self::mul($a10, $b4, 24) + self::mul($a11, $b3, 24);
2094
- $s15 = self::mul($a4, $b11, 24) + self::mul($a5, $b10, 24) + self::mul($a6, $b9, 24) + self::mul($a7, $b8, 24) + self::mul($a8, $b7, 24) + self::mul($a9, $b6, 24) + self::mul($a10, $b5, 24) + self::mul($a11, $b4, 24);
2095
- $s16 = self::mul($a5, $b11, 24) + self::mul($a6, $b10, 24) + self::mul($a7, $b9, 24) + self::mul($a8, $b8, 24) + self::mul($a9, $b7, 24) + self::mul($a10, $b6, 24) + self::mul($a11, $b5, 24);
2096
- $s17 = self::mul($a6, $b11, 24) + self::mul($a7, $b10, 24) + self::mul($a8, $b9, 24) + self::mul($a9, $b8, 24) + self::mul($a10, $b7, 24) + self::mul($a11, $b6, 24);
2097
- $s18 = self::mul($a7, $b11, 24) + self::mul($a8, $b10, 24) + self::mul($a9, $b9, 24) + self::mul($a10, $b8, 24) + self::mul($a11, $b7, 24);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2098
  $s19 = self::mul($a8, $b11, 24) + self::mul($a9, $b10, 24) + self::mul($a10, $b9, 24) + self::mul($a11, $b8, 24);
2099
  $s20 = self::mul($a9, $b11, 24) + self::mul($a10, $b10, 24) + self::mul($a11, $b9, 24);
2100
  $s21 = self::mul($a10, $b11, 24) + self::mul($a11, $b10, 24);
88
  for ($i = 0; $i < 10; ++$i) {
89
  /** @var int $x */
90
  $x = (($f[$i] ^ $g[$i]) & $b);
91
+ $h[$i] = (int) ((int) ($f[$i]) ^ $x);
92
  }
93
  return ParagonIE_Sodium_Core_Curve25519_Fe::fromArray($h);
94
  }
453
  $f7_2 = $f7 << 1;
454
  /** @var int $f9_2 */
455
  $f9_2 = $f9 << 1;
456
+ $f0g0 = self::mul($f0, $g0, 26);
457
+ $f0g1 = self::mul($f0, $g1, 25);
458
+ $f0g2 = self::mul($f0, $g2, 26);
459
+ $f0g3 = self::mul($f0, $g3, 25);
460
+ $f0g4 = self::mul($f0, $g4, 26);
461
+ $f0g5 = self::mul($f0, $g5, 25);
462
+ $f0g6 = self::mul($f0, $g6, 26);
463
+ $f0g7 = self::mul($f0, $g7, 25);
464
+ $f0g8 = self::mul($f0, $g8, 26);
465
+ $f0g9 = self::mul($f0, $g9, 26);
466
+ $f1g0 = self::mul($f1, $g0, 26);
467
+ $f1g1_2 = self::mul($f1_2, $g1, 25);
468
+ $f1g2 = self::mul($f1, $g2, 26);
469
+ $f1g3_2 = self::mul($f1_2, $g3, 25);
470
+ $f1g4 = self::mul($f1, $g4, 26);
471
+ $f1g5_2 = self::mul($f1_2, $g5, 25);
472
+ $f1g6 = self::mul($f1, $g6, 26);
473
+ $f1g7_2 = self::mul($f1_2, $g7, 25);
474
+ $f1g8 = self::mul($f1, $g8, 26);
475
+ $f1g9_38 = self::mul($g9_19, $f1_2, 26);
476
+ $f2g0 = self::mul($f2, $g0, 26);
477
+ $f2g1 = self::mul($f2, $g1, 25);
478
+ $f2g2 = self::mul($f2, $g2, 26);
479
+ $f2g3 = self::mul($f2, $g3, 25);
480
+ $f2g4 = self::mul($f2, $g4, 26);
481
+ $f2g5 = self::mul($f2, $g5, 25);
482
+ $f2g6 = self::mul($f2, $g6, 26);
483
+ $f2g7 = self::mul($f2, $g7, 25);
484
+ $f2g8_19 = self::mul($g8_19, $f2, 26);
485
+ $f2g9_19 = self::mul($g9_19, $f2, 26);
486
+ $f3g0 = self::mul($f3, $g0, 26);
487
+ $f3g1_2 = self::mul($f3_2, $g1, 25);
488
+ $f3g2 = self::mul($f3, $g2, 26);
489
+ $f3g3_2 = self::mul($f3_2, $g3, 25);
490
+ $f3g4 = self::mul($f3, $g4, 26);
491
+ $f3g5_2 = self::mul($f3_2, $g5, 25);
492
+ $f3g6 = self::mul($f3, $g6, 26);
493
+ $f3g7_38 = self::mul($g7_19, $f3_2, 26);
494
+ $f3g8_19 = self::mul($g8_19, $f3, 25);
495
+ $f3g9_38 = self::mul($g9_19, $f3_2, 26);
496
+ $f4g0 = self::mul($f4, $g0, 26);
497
+ $f4g1 = self::mul($f4, $g1, 25);
498
+ $f4g2 = self::mul($f4, $g2, 26);
499
+ $f4g3 = self::mul($f4, $g3, 25);
500
+ $f4g4 = self::mul($f4, $g4, 26);
501
+ $f4g5 = self::mul($f4, $g5, 25);
502
+ $f4g6_19 = self::mul($g6_19, $f4, 26);
503
+ $f4g7_19 = self::mul($g7_19, $f4, 26);
504
+ $f4g8_19 = self::mul($g8_19, $f4, 26);
505
+ $f4g9_19 = self::mul($g9_19, $f4, 26);
506
+ $f5g0 = self::mul($f5, $g0, 26);
507
+ $f5g1_2 = self::mul($f5_2, $g1, 25);
508
+ $f5g2 = self::mul($f5, $g2, 26);
509
+ $f5g3_2 = self::mul($f5_2, $g3, 25);
510
+ $f5g4 = self::mul($f5, $g4, 26);
511
+ $f5g5_38 = self::mul($g5_19, $f5_2, 26);
512
+ $f5g6_19 = self::mul($g6_19, $f5, 25);
513
+ $f5g7_38 = self::mul($g7_19, $f5_2, 26);
514
+ $f5g8_19 = self::mul($g8_19, $f5, 25);
515
+ $f5g9_38 = self::mul($g9_19, $f5_2, 26);
516
+ $f6g0 = self::mul($f6, $g0, 26);
517
+ $f6g1 = self::mul($f6, $g1, 25);
518
+ $f6g2 = self::mul($f6, $g2, 26);
519
+ $f6g3 = self::mul($f6, $g3, 25);
520
+ $f6g4_19 = self::mul($g4_19, $f6, 26);
521
+ $f6g5_19 = self::mul($g5_19, $f6, 26);
522
+ $f6g6_19 = self::mul($g6_19, $f6, 26);
523
+ $f6g7_19 = self::mul($g7_19, $f6, 26);
524
+ $f6g8_19 = self::mul($g8_19, $f6, 26);
525
+ $f6g9_19 = self::mul($g9_19, $f6, 26);
526
+ $f7g0 = self::mul($f7, $g0, 26);
527
+ $f7g1_2 = self::mul($f7_2, $g1, 25);
528
+ $f7g2 = self::mul($f7, $g2, 26);
529
+ $f7g3_38 = self::mul($g3_19, $f7_2, 26);
530
+ $f7g4_19 = self::mul($g4_19, $f7, 26);
531
+ $f7g5_38 = self::mul($g5_19, $f7_2, 26);
532
+ $f7g6_19 = self::mul($g6_19, $f7, 25);
533
+ $f7g7_38 = self::mul($g7_19, $f7_2, 26);
534
+ $f7g8_19 = self::mul($g8_19, $f7, 25);
535
+ $f7g9_38 = self::mul($g9_19,$f7_2, 26);
536
+ $f8g0 = self::mul($f8, $g0, 26);
537
+ $f8g1 = self::mul($f8, $g1, 25);
538
+ $f8g2_19 = self::mul($g2_19, $f8, 26);
539
+ $f8g3_19 = self::mul($g3_19, $f8, 26);
540
+ $f8g4_19 = self::mul($g4_19, $f8, 26);
541
+ $f8g5_19 = self::mul($g5_19, $f8, 26);
542
+ $f8g6_19 = self::mul($g6_19, $f8, 26);
543
+ $f8g7_19 = self::mul($g7_19, $f8, 26);
544
+ $f8g8_19 = self::mul($g8_19, $f8, 26);
545
+ $f8g9_19 = self::mul($g9_19, $f8, 26);
546
+ $f9g0 = self::mul($f9, $g0, 26);
547
+ $f9g1_38 = self::mul($g1_19, $f9_2, 26);
548
+ $f9g2_19 = self::mul($g2_19, $f9, 25);
549
+ $f9g3_38 = self::mul($g3_19, $f9_2, 26);
550
+ $f9g4_19 = self::mul($g4_19, $f9, 25);
551
+ $f9g5_38 = self::mul($g5_19, $f9_2, 26);
552
+ $f9g6_19 = self::mul($g6_19, $f9, 25);
553
+ $f9g7_38 = self::mul($g7_19, $f9_2, 26);
554
+ $f9g8_19 = self::mul($g8_19, $f9, 25);
555
+ $f9g9_38 = self::mul($g9_19, $f9_2, 26);
556
  $h0 = $f0g0 + $f1g9_38 + $f2g8_19 + $f3g7_38 + $f4g6_19 + $f5g5_38 + $f6g4_19 + $f7g3_38 + $f8g2_19 + $f9g1_38;
557
  $h1 = $f0g1 + $f1g0 + $f2g9_19 + $f3g8_19 + $f4g7_19 + $f5g6_19 + $f6g5_19 + $f7g4_19 + $f8g3_19 + $f9g2_19;
558
  $h2 = $f0g2 + $f1g1_2 + $f2g0 + $f3g9_38 + $f4g8_19 + $f5g7_38 + $f6g6_19 + $f7g5_38 + $f8g4_19 + $f9g3_38;
699
  $f7_38 = self::mul($f7, 38, 6);
700
  $f8_19 = self::mul($f8, 19, 5);
701
  $f9_38 = self::mul($f9, 38, 6);
702
+ $f0f0 = self::mul($f0, $f0, 25);
703
+ $f0f1_2 = self::mul($f0_2, $f1, 24);
704
+ $f0f2_2 = self::mul($f0_2, $f2, 25);
705
+ $f0f3_2 = self::mul($f0_2, $f3, 24);
706
+ $f0f4_2 = self::mul($f0_2, $f4, 25);
707
+ $f0f5_2 = self::mul($f0_2, $f5, 25);
708
+ $f0f6_2 = self::mul($f0_2, $f6, 25);
709
+ $f0f7_2 = self::mul($f0_2, $f7, 24);
710
+ $f0f8_2 = self::mul($f0_2, $f8, 25);
711
+ $f0f9_2 = self::mul($f0_2, $f9, 25);
712
+ $f1f1_2 = self::mul($f1_2, $f1, 24);
713
+ $f1f2_2 = self::mul($f1_2, $f2, 25);
714
+ $f1f3_4 = self::mul($f1_2, $f3_2, 25);
715
+ $f1f4_2 = self::mul($f1_2, $f4, 25);
716
+ $f1f5_4 = self::mul($f1_2, $f5_2, 26);
717
+ $f1f6_2 = self::mul($f1_2, $f6, 25);
718
+ $f1f7_4 = self::mul($f1_2, $f7_2, 25);
719
+ $f1f8_2 = self::mul($f1_2, $f8, 25);
720
+ $f1f9_76 = self::mul($f9_38, $f1_2, 25);
721
+ $f2f2 = self::mul($f2, $f2, 25);
722
+ $f2f3_2 = self::mul($f2_2, $f3, 24);
723
+ $f2f4_2 = self::mul($f2_2, $f4, 25);
724
+ $f2f5_2 = self::mul($f2_2, $f5, 25);
725
+ $f2f6_2 = self::mul($f2_2, $f6, 25);
726
+ $f2f7_2 = self::mul($f2_2, $f7, 24);
727
+ $f2f8_38 = self::mul($f8_19, $f2_2, 26);
728
+ $f2f9_38 = self::mul($f9_38, $f2, 25);
729
+ $f3f3_2 = self::mul($f3_2, $f3, 24);
730
+ $f3f4_2 = self::mul($f3_2, $f4, 25);
731
+ $f3f5_4 = self::mul($f3_2, $f5_2, 26);
732
+ $f3f6_2 = self::mul($f3_2, $f6, 25);
733
+ $f3f7_76 = self::mul($f7_38, $f3_2, 25);
734
+ $f3f8_38 = self::mul($f8_19, $f3_2, 25);
735
+ $f3f9_76 = self::mul($f9_38, $f3_2, 25);
736
+ $f4f4 = self::mul($f4, $f4, 25);
737
+ $f4f5_2 = self::mul($f4_2, $f5, 25);
738
+ $f4f6_38 = self::mul($f6_19, $f4_2, 26);
739
+ $f4f7_38 = self::mul($f7_38, $f4, 25);
740
+ $f4f8_38 = self::mul($f8_19, $f4_2, 26);
741
+ $f4f9_38 = self::mul($f9_38, $f4, 25);
742
+ $f5f5_38 = self::mul($f5_38, $f5, 25);
743
+ $f5f6_38 = self::mul($f6_19, $f5_2, 26);
744
+ $f5f7_76 = self::mul($f7_38, $f5_2, 26);
745
+ $f5f8_38 = self::mul($f8_19, $f5_2, 26);
746
+ $f5f9_76 = self::mul($f9_38, $f5_2, 26);
747
+ $f6f6_19 = self::mul($f6_19, $f6, 25);
748
+ $f6f7_38 = self::mul($f7_38, $f6, 25);
749
+ $f6f8_38 = self::mul($f8_19, $f6_2, 26);
750
+ $f6f9_38 = self::mul($f9_38, $f6, 25);
751
+ $f7f7_38 = self::mul($f7_38, $f7, 24);
752
+ $f7f8_38 = self::mul($f8_19, $f7_2, 25);
753
+ $f7f9_76 = self::mul($f9_38, $f7_2, 25);
754
+ $f8f8_19 = self::mul($f8_19, $f8, 25);
755
+ $f8f9_38 = self::mul($f9_38, $f8, 25);
756
+ $f9f9_38 = self::mul($f9_38, $f9, 25);
757
  $h0 = $f0f0 + $f1f9_76 + $f2f8_38 + $f3f7_76 + $f4f6_38 + $f5f5_38;
758
  $h1 = $f0f1_2 + $f2f9_38 + $f3f8_38 + $f4f7_38 + $f5f6_38;
759
  $h2 = $f0f2_2 + $f1f1_2 + $f3f9_76 + $f4f8_38 + $f5f7_76 + $f6f6_19;
881
  $f7_38 = self::mul($f7, 38, 6); /* 1.959375*2^30 */
882
  $f8_19 = self::mul($f8, 19, 5); /* 1.959375*2^30 */
883
  $f9_38 = self::mul($f9, 38, 6); /* 1.959375*2^30 */
884
+ $f0f0 = self::mul($f0, $f0, 24);
885
+ $f0f1_2 = self::mul($f0_2, $f1, 24);
886
+ $f0f2_2 = self::mul($f0_2, $f2, 24);
887
+ $f0f3_2 = self::mul($f0_2, $f3, 24);
888
+ $f0f4_2 = self::mul($f0_2, $f4, 24);
889
+ $f0f5_2 = self::mul($f0_2, $f5, 24);
890
+ $f0f6_2 = self::mul($f0_2, $f6, 24);
891
+ $f0f7_2 = self::mul($f0_2, $f7, 24);
892
+ $f0f8_2 = self::mul($f0_2, $f8, 24);
893
+ $f0f9_2 = self::mul($f0_2, $f9, 24);
894
+ $f1f1_2 = self::mul($f1_2, $f1, 24);
895
+ $f1f2_2 = self::mul($f1_2, $f2, 24);
896
+ $f1f3_4 = self::mul($f1_2, $f3_2, 24);
897
+ $f1f4_2 = self::mul($f1_2, $f4, 24);
898
+ $f1f5_4 = self::mul($f1_2, $f5_2, 24);
899
+ $f1f6_2 = self::mul($f1_2, $f6, 24);
900
+ $f1f7_4 = self::mul($f1_2, $f7_2, 24);
901
+ $f1f8_2 = self::mul($f1_2, $f8, 24);
902
+ $f1f9_76 = self::mul($f9_38, $f1_2, 24);
903
+ $f2f2 = self::mul($f2, $f2, 24);
904
+ $f2f3_2 = self::mul($f2_2, $f3, 24);
905
+ $f2f4_2 = self::mul($f2_2, $f4, 24);
906
+ $f2f5_2 = self::mul($f2_2, $f5, 24);
907
+ $f2f6_2 = self::mul($f2_2, $f6, 24);
908
+ $f2f7_2 = self::mul($f2_2, $f7, 24);
909
+ $f2f8_38 = self::mul($f8_19, $f2_2, 25);
910
+ $f2f9_38 = self::mul($f9_38, $f2, 24);
911
+ $f3f3_2 = self::mul($f3_2, $f3, 24);
912
+ $f3f4_2 = self::mul($f3_2, $f4, 24);
913
+ $f3f5_4 = self::mul($f3_2, $f5_2, 24);
914
+ $f3f6_2 = self::mul($f3_2, $f6, 24);
915
+ $f3f7_76 = self::mul($f7_38, $f3_2, 24);
916
+ $f3f8_38 = self::mul($f8_19, $f3_2, 24);
917
+ $f3f9_76 = self::mul($f9_38, $f3_2, 24);
918
+ $f4f4 = self::mul($f4, $f4, 24);
919
+ $f4f5_2 = self::mul($f4_2, $f5, 24);
920
+ $f4f6_38 = self::mul($f6_19, $f4_2, 25);
921
+ $f4f7_38 = self::mul($f7_38, $f4, 24);
922
+ $f4f8_38 = self::mul($f8_19, $f4_2, 25);
923
+ $f4f9_38 = self::mul($f9_38, $f4, 24);
924
+ $f5f5_38 = self::mul($f5_38, $f5, 24);
925
+ $f5f6_38 = self::mul($f6_19, $f5_2, 24);
926
+ $f5f7_76 = self::mul($f7_38, $f5_2, 24);
927
+ $f5f8_38 = self::mul($f8_19, $f5_2, 24);
928
+ $f5f9_76 = self::mul($f9_38, $f5_2, 24);
929
+ $f6f6_19 = self::mul($f6_19, $f6, 24);
930
+ $f6f7_38 = self::mul($f7_38, $f6, 24);
931
+ $f6f8_38 = self::mul($f8_19, $f6_2, 25);
932
+ $f6f9_38 = self::mul($f9_38, $f6, 24);
933
+ $f7f7_38 = self::mul($f7_38, $f7, 24);
934
+ $f7f8_38 = self::mul($f8_19, $f7_2, 24);
935
+ $f7f9_76 = self::mul($f9_38, $f7_2, 24);
936
+ $f8f8_19 = self::mul($f8_19, $f8, 24);
937
+ $f8f9_38 = self::mul($f9_38, $f8, 24);
938
+ $f9f9_38 = self::mul($f9_38, $f9, 24);
939
 
940
  /** @var int $h0 */
941
  $h0 = (int) ($f0f0 + $f1f9_76 + $f2f8_38 + $f3f7_76 + $f4f6_38 + $f5f5_38) << 1;
1840
 
1841
  # slide(aslide,a);
1842
  # slide(bslide,b);
1843
+ /** @var array<int, int> $aslide */
1844
  $aslide = self::slide($a);
1845
+ /** @var array<int, int> $bslide */
1846
  $bslide = self::slide($b);
1847
 
1848
  # ge_p3_to_cached(&Ai[0],A);
2082
  $s1 = $c1 + self::mul($a0, $b1, 24) + self::mul($a1, $b0, 24);
2083
  $s2 = $c2 + self::mul($a0, $b2, 24) + self::mul($a1, $b1, 24) + self::mul($a2, $b0, 24);
2084
  $s3 = $c3 + self::mul($a0, $b3, 24) + self::mul($a1, $b2, 24) + self::mul($a2, $b1, 24) + self::mul($a3, $b0, 24);
2085
+ $s4 = $c4 + self::mul($a0, $b4, 24) + self::mul($a1, $b3, 24) + self::mul($a2, $b2, 24) + self::mul($a3, $b1, 24) +
2086
+ self::mul($a4, $b0, 24);
2087
+ $s5 = $c5 + self::mul($a0, $b5, 24) + self::mul($a1, $b4, 24) + self::mul($a2, $b3, 24) + self::mul($a3, $b2, 24) +
2088
+ self::mul($a4, $b1, 24) + self::mul($a5, $b0, 24);
2089
+ $s6 = $c6 + self::mul($a0, $b6, 24) + self::mul($a1, $b5, 24) + self::mul($a2, $b4, 24) + self::mul($a3, $b3, 24) +
2090
+ self::mul($a4, $b2, 24) + self::mul($a5, $b1, 24) + self::mul($a6, $b0, 24);
2091
+ $s7 = $c7 + self::mul($a0, $b7, 24) + self::mul($a1, $b6, 24) + self::mul($a2, $b5, 24) + self::mul($a3, $b4, 24) +
2092
+ self::mul($a4, $b3, 24) + self::mul($a5, $b2, 24) + self::mul($a6, $b1, 24) + self::mul($a7, $b0, 24);
2093
+ $s8 = $c8 + self::mul($a0, $b8, 24) + self::mul($a1, $b7, 24) + self::mul($a2, $b6, 24) + self::mul($a3, $b5, 24) +
2094
+ self::mul($a4, $b4, 24) + self::mul($a5, $b3, 24) + self::mul($a6, $b2, 24) + self::mul($a7, $b1, 24) +
2095
+ self::mul($a8, $b0, 24);
2096
+ $s9 = $c9 + self::mul($a0, $b9, 24) + self::mul($a1, $b8, 24) + self::mul($a2, $b7, 24) + self::mul($a3, $b6, 24) +
2097
+ self::mul($a4, $b5, 24) + self::mul($a5, $b4, 24) + self::mul($a6, $b3, 24) + self::mul($a7, $b2, 24) +
2098
+ self::mul($a8, $b1, 24) + self::mul($a9, $b0, 24);
2099
+ $s10 = $c10 + self::mul($a0, $b10, 24) + self::mul($a1, $b9, 24) + self::mul($a2, $b8, 24) + self::mul($a3, $b7, 24) +
2100
+ self::mul($a4, $b6, 24) + self::mul($a5, $b5, 24) + self::mul($a6, $b4, 24) + self::mul($a7, $b3, 24) +
2101
+ self::mul($a8, $b2, 24) + self::mul($a9, $b1, 24) + self::mul($a10, $b0, 24);
2102
+ $s11 = $c11 + self::mul($a0, $b11, 24) + self::mul($a1, $b10, 24) + self::mul($a2, $b9, 24) + self::mul($a3, $b8, 24) +
2103
+ self::mul($a4, $b7, 24) + self::mul($a5, $b6, 24) + self::mul($a6, $b5, 24) + self::mul($a7, $b4, 24) +
2104
+ self::mul($a8, $b3, 24) + self::mul($a9, $b2, 24) + self::mul($a10, $b1, 24) + self::mul($a11, $b0, 24);
2105
+ $s12 = self::mul($a1, $b11, 24) + self::mul($a2, $b10, 24) + self::mul($a3, $b9, 24) + self::mul($a4, $b8, 24) +
2106
+ self::mul($a5, $b7, 24) + self::mul($a6, $b6, 24) + self::mul($a7, $b5, 24) + self::mul($a8, $b4, 24) +
2107
+ self::mul($a9, $b3, 24) + self::mul($a10, $b2, 24) + self::mul($a11, $b1, 24);
2108
+ $s13 = self::mul($a2, $b11, 24) + self::mul($a3, $b10, 24) + self::mul($a4, $b9, 24) + self::mul($a5, $b8, 24) +
2109
+ self::mul($a6, $b7, 24) + self::mul($a7, $b6, 24) + self::mul($a8, $b5, 24) + self::mul($a9, $b4, 24) +
2110
+ self::mul($a10, $b3, 24) + self::mul($a11, $b2, 24);
2111
+ $s14 = self::mul($a3, $b11, 24) + self::mul($a4, $b10, 24) + self::mul($a5, $b9, 24) + self::mul($a6, $b8, 24) +
2112
+ self::mul($a7, $b7, 24) + self::mul($a8, $b6, 24) + self::mul($a9, $b5, 24) + self::mul($a10, $b4, 24) +
2113
+ self::mul($a11, $b3, 24);
2114
+ $s15 = self::mul($a4, $b11, 24) + self::mul($a5, $b10, 24) + self::mul($a6, $b9, 24) + self::mul($a7, $b8, 24) +
2115
+ self::mul($a8, $b7, 24) + self::mul($a9, $b6, 24) + self::mul($a10, $b5, 24) + self::mul($a11, $b4, 24);
2116
+ $s16 = self::mul($a5, $b11, 24) + self::mul($a6, $b10, 24) + self::mul($a7, $b9, 24) + self::mul($a8, $b8, 24) +
2117
+ self::mul($a9, $b7, 24) + self::mul($a10, $b6, 24) + self::mul($a11, $b5, 24);
2118
+ $s17 = self::mul($a6, $b11, 24) + self::mul($a7, $b10, 24) + self::mul($a8, $b9, 24) + self::mul($a9, $b8, 24) +
2119
+ self::mul($a10, $b7, 24) + self::mul($a11, $b6, 24);
2120
+ $s18 = self::mul($a7, $b11, 24) + self::mul($a8, $b10, 24) + self::mul($a9, $b9, 24) + self::mul($a10, $b8, 24) +
2121
+ self::mul($a11, $b7, 24);
2122
  $s19 = self::mul($a8, $b11, 24) + self::mul($a9, $b10, 24) + self::mul($a10, $b9, 24) + self::mul($a11, $b8, 24);
2123
  $s20 = self::mul($a9, $b11, 24) + self::mul($a10, $b10, 24) + self::mul($a11, $b9, 24);
2124
  $s21 = self::mul($a10, $b11, 24) + self::mul($a11, $b10, 24);
vendor/paragonie/sodium_compat/src/Core/Curve25519/Fe.php CHANGED
@@ -21,15 +21,6 @@ class ParagonIE_Sodium_Core_Curve25519_Fe implements ArrayAccess
21
  */
22
  protected $size = 10;
23
 
24
- /**
25
- * ParagonIE_Sodium_Core_Curve25519_Fe constructor.
26
- * @param int $size
27
- */
28
- public function __construct($size = 10)
29
- {
30
- $this->size = 10;
31
- }
32
-
33
  /**
34
  * @internal You should not use this directly from another application
35
  *
@@ -47,7 +38,7 @@ class ParagonIE_Sodium_Core_Curve25519_Fe implements ArrayAccess
47
  }
48
  $array = array_values($array);
49
 
50
- $obj = new ParagonIE_Sodium_Core_Curve25519_Fe($count);
51
  if ($save_indexes) {
52
  for ($i = 0; $i < $count; ++$i) {
53
  $obj->offsetSet($keys[$i], $array[$i]);
21
  */
22
  protected $size = 10;
23
 
 
 
 
 
 
 
 
 
 
24
  /**
25
  * @internal You should not use this directly from another application
26
  *
38
  }
39
  $array = array_values($array);
40
 
41
+ $obj = new ParagonIE_Sodium_Core_Curve25519_Fe();
42
  if ($save_indexes) {
43
  for ($i = 0; $i < $count; ++$i) {
44
  $obj->offsetSet($keys[$i], $array[$i]);
vendor/paragonie/sodium_compat/src/Core/Ed25519.php CHANGED
@@ -16,6 +16,7 @@ abstract class ParagonIE_Sodium_Core_Ed25519 extends ParagonIE_Sodium_Core_Curve
16
  * @internal You should not use this directly from another application
17
  *
18
  * @return string (96 bytes)
 
19
  * @throws SodiumException
20
  * @throws TypeError
21
  */
16
  * @internal You should not use this directly from another application
17
  *
18
  * @return string (96 bytes)
19
+ * @throws Exception
20
  * @throws SodiumException
21
  * @throws TypeError
22
  */
vendor/paragonie/sodium_compat/src/Core/Poly1305/State.php CHANGED
@@ -184,43 +184,43 @@ class ParagonIE_Sodium_Core_Poly1305_State extends ParagonIE_Sodium_Core_Util
184
 
185
  /* h *= r */
186
  $d0 = (
187
- self::mul($h0, $r0, 31) +
188
- self::mul($h1, $s4, 31) +
189
- self::mul($h2, $s3, 31) +
190
- self::mul($h3, $s2, 31) +
191
- self::mul($h4, $s1, 31)
192
  );
193
 
194
  $d1 = (
195
- self::mul($h0, $r1, 31) +
196
- self::mul($h1, $r0, 31) +
197
- self::mul($h2, $s4, 31) +
198
- self::mul($h3, $s3, 31) +
199
- self::mul($h4, $s2, 31)
200
  );
201
 
202
  $d2 = (
203
- self::mul($h0, $r2, 31) +
204
- self::mul($h1, $r1, 31) +
205
- self::mul($h2, $r0, 31) +
206
- self::mul($h3, $s4, 31) +
207
- self::mul($h4, $s3, 31)
208
  );
209
 
210
  $d3 = (
211
- self::mul($h0, $r3, 31) +
212
- self::mul($h1, $r2, 31) +
213
- self::mul($h2, $r1, 31) +
214
- self::mul($h3, $r0, 31) +
215
- self::mul($h4, $s4, 31)
216
  );
217
 
218
  $d4 = (
219
- self::mul($h0, $r4, 31) +
220
- self::mul($h1, $r3, 31) +
221
- self::mul($h2, $r2, 31) +
222
- self::mul($h3, $r1, 31) +
223
- self::mul($h4, $r0, 31)
224
  );
225
 
226
  /* (partial) h %= p */
184
 
185
  /* h *= r */
186
  $d0 = (
187
+ self::mul($h0, $r0, 25) +
188
+ self::mul($s4, $h1, 26) +
189
+ self::mul($s3, $h2, 26) +
190
+ self::mul($s2, $h3, 26) +
191
+ self::mul($s1, $h4, 26)
192
  );
193
 
194
  $d1 = (
195
+ self::mul($h0, $r1, 25) +
196
+ self::mul($h1, $r0, 25) +
197
+ self::mul($s4, $h2, 26) +
198
+ self::mul($s3, $h3, 26) +
199
+ self::mul($s2, $h4, 26)
200
  );
201
 
202
  $d2 = (
203
+ self::mul($h0, $r2, 25) +
204
+ self::mul($h1, $r1, 25) +
205
+ self::mul($h2, $r0, 25) +
206
+ self::mul($s4, $h3, 26) +
207
+ self::mul($s3, $h4, 26)
208
  );
209
 
210
  $d3 = (
211
+ self::mul($h0, $r3, 25) +
212
+ self::mul($h1, $r2, 25) +
213
+ self::mul($h2, $r1, 25) +
214
+ self::mul($h3, $r0, 25) +
215
+ self::mul($s4, $h4, 26)
216
  );
217
 
218
  $d4 = (
219
+ self::mul($h0, $r4, 25) +
220
+ self::mul($h1, $r3, 25) +
221
+ self::mul($h2, $r2, 25) +
222
+ self::mul($h3, $r1, 25) +
223
+ self::mul($h4, $r0, 25)
224
  );
225
 
226
  /* (partial) h %= p */
vendor/paragonie/sodium_compat/src/Core/SipHash.php CHANGED
@@ -33,7 +33,7 @@ class ParagonIE_Sodium_Core_SipHash extends ParagonIE_Sodium_Core_Util
33
  $v[3] ^= $v[1];
34
 
35
  # v0=ROTL(v0,32);
36
- list($v[0], $v[1]) = self::rotl_64($v[0], $v[1], 32);
37
 
38
  # v2 += v3;
39
  list($v[4], $v[5]) = self::add(
@@ -50,12 +50,12 @@ class ParagonIE_Sodium_Core_SipHash extends ParagonIE_Sodium_Core_Util
50
 
51
  # v0 += v3;
52
  list($v[0], $v[1]) = self::add(
53
- array($v[0], $v[1]),
54
- array($v[6], $v[7])
55
  );
56
 
57
  # v3=ROTL(v3,21);
58
- list($v[6], $v[7]) = self::rotl_64($v[6], $v[7], 21);
59
 
60
  # v3 ^= v0;
61
  $v[6] ^= $v[0];
@@ -63,19 +63,19 @@ class ParagonIE_Sodium_Core_SipHash extends ParagonIE_Sodium_Core_Util
63
 
64
  # v2 += v1;
65
  list($v[4], $v[5]) = self::add(
66
- array($v[4], $v[5]),
67
- array($v[2], $v[3])
68
  );
69
 
70
  # v1=ROTL(v1,17);
71
- list($v[2], $v[3]) = self::rotl_64($v[2], $v[3], 17);
72
 
73
  # v1 ^= v2;;
74
  $v[2] ^= $v[4];
75
  $v[3] ^= $v[5];
76
 
77
  # v2=ROTL(v2,32)
78
- list($v[4], $v[5]) = self::rotl_64($v[4], $v[5], 32);
79
 
80
  return $v;
81
  }
33
  $v[3] ^= $v[1];
34
 
35
  # v0=ROTL(v0,32);
36
+ list($v[0], $v[1]) = self::rotl_64((int) $v[0], (int) $v[1], 32);
37
 
38
  # v2 += v3;
39
  list($v[4], $v[5]) = self::add(
50
 
51
  # v0 += v3;
52
  list($v[0], $v[1]) = self::add(
53
+ array((int) $v[0], (int) $v[1]),
54
+ array((int) $v[6], (int) $v[7])
55
  );
56
 
57
  # v3=ROTL(v3,21);
58
+ list($v[6], $v[7]) = self::rotl_64((int) $v[6], (int) $v[7], 21);
59
 
60
  # v3 ^= v0;
61
  $v[6] ^= $v[0];
63
 
64
  # v2 += v1;
65
  list($v[4], $v[5]) = self::add(
66
+ array((int) $v[4], (int) $v[5]),
67
+ array((int) $v[2], (int) $v[3])
68
  );
69
 
70
  # v1=ROTL(v1,17);
71
+ list($v[2], $v[3]) = self::rotl_64((int) $v[2], (int) $v[3], 17);
72
 
73
  # v1 ^= v2;;
74
  $v[2] ^= $v[4];
75
  $v[3] ^= $v[5];
76
 
77
  # v2=ROTL(v2,32)
78
+ list($v[4], $v[5]) = self::rotl_64((int) $v[4], (int) $v[5], 32);
79
 
80
  return $v;
81
  }
vendor/paragonie/sodium_compat/src/Core/Util.php CHANGED
@@ -549,7 +549,7 @@ abstract class ParagonIE_Sodium_Core_Util
549
  *
550
  * @var int
551
  */
552
- $mask = -(($b >> $defaultSize) & 1);
553
 
554
  /**
555
  * Ensure $b is a positive integer, without creating
@@ -912,7 +912,7 @@ abstract class ParagonIE_Sodium_Core_Util
912
  if ($mbstring === null) {
913
  $mbstring = extension_loaded('mbstring')
914
  &&
915
- (ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING);
916
  }
917
  /** @var bool $mbstring */
918
 
549
  *
550
  * @var int
551
  */
552
+ $mask = -(($b >> ((int) $defaultSize)) & 1);
553
 
554
  /**
555
  * Ensure $b is a positive integer, without creating
912
  if ($mbstring === null) {
913
  $mbstring = extension_loaded('mbstring')
914
  &&
915
+ ((int) (ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING);
916
  }
917
  /** @var bool $mbstring */
918
 
vendor/paragonie/sodium_compat/src/Core32/BLAKE2b.php CHANGED
@@ -138,9 +138,15 @@ abstract class ParagonIE_Sodium_Core32_BLAKE2b extends ParagonIE_Sodium_Core_Uti
138
  public static function load64($x, $i)
139
  {
140
  /** @var int $l */
141
- $l = $x[$i] | ($x[$i+1]<<8) | ($x[$i+2]<<16) | ($x[$i+3]<<24);
 
 
 
142
  /** @var int $h */
143
- $h = $x[$i+4] | ($x[$i+5]<<8) | ($x[$i+6]<<16) | ($x[$i+7]<<24);
 
 
 
144
  return self::new64($h, $l);
145
  }
146
 
@@ -557,7 +563,7 @@ abstract class ParagonIE_Sodium_Core32_BLAKE2b extends ParagonIE_Sodium_Core_Uti
557
  public static function SplFixedArrayToString(SplFixedArray $a)
558
  {
559
  /**
560
- * @var array<mixed, int>
561
  */
562
  $arr = $a->toArray();
563
  $c = $a->count();
@@ -609,16 +615,19 @@ abstract class ParagonIE_Sodium_Core32_BLAKE2b extends ParagonIE_Sodium_Core_Uti
609
  # uint8_t buf[2 * 128];
610
  $str .= self::SplFixedArrayToString($ctx[3]);
611
 
 
 
 
612
  # size_t buflen;
613
  $str .= implode('', array(
614
- self::intToChr($ctx[4] & 0xff),
615
- self::intToChr(($ctx[4] >> 8) & 0xff),
616
- self::intToChr(($ctx[4] >> 16) & 0xff),
617
- self::intToChr(($ctx[4] >> 24) & 0xff),
618
- self::intToChr(($ctx[4] >> 32) & 0xff),
619
- self::intToChr(($ctx[4] >> 40) & 0xff),
620
- self::intToChr(($ctx[4] >> 48) & 0xff),
621
- self::intToChr(($ctx[4] >> 56) & 0xff)
622
  ));
623
  # uint8_t last_node;
624
  return $str . "\x00";
138
  public static function load64($x, $i)
139
  {
140
  /** @var int $l */
141
+ $l = (int) ($x[$i])
142
+ | ((int) ($x[$i+1]) << 8)
143
+ | ((int) ($x[$i+2]) << 16)
144
+ | ((int) ($x[$i+3]) << 24);
145
  /** @var int $h */
146
+ $h = (int) ($x[$i+4])
147
+ | ((int) ($x[$i+5]) << 8)
148
+ | ((int) ($x[$i+6]) << 16)
149
+ | ((int) ($x[$i+7]) << 24);
150
  return self::new64($h, $l);
151
  }
152
 
563
  public static function SplFixedArrayToString(SplFixedArray $a)
564
  {
565
  /**
566
+ * @var array<int, string|int>
567
  */
568
  $arr = $a->toArray();
569
  $c = $a->count();
615
  # uint8_t buf[2 * 128];
616
  $str .= self::SplFixedArrayToString($ctx[3]);
617
 
618
+ /** @var int $ctx4 */
619
+ $ctx4 = $ctx[4];
620
+
621
  # size_t buflen;
622
  $str .= implode('', array(
623
+ self::intToChr($ctx4 & 0xff),
624
+ self::intToChr(($ctx4 >> 8) & 0xff),
625
+ self::intToChr(($ctx4 >> 16) & 0xff),
626
+ self::intToChr(($ctx4 >> 24) & 0xff),
627
+ self::intToChr(($ctx4 >> 32) & 0xff),
628
+ self::intToChr(($ctx4 >> 40) & 0xff),
629
+ self::intToChr(($ctx4 >> 48) & 0xff),
630
+ self::intToChr(($ctx4 >> 56) & 0xff)
631
  ));
632
  # uint8_t last_node;
633
  return $str . "\x00";
vendor/paragonie/sodium_compat/src/Core32/ChaCha20/Ctx.php CHANGED
@@ -10,7 +10,7 @@ if (class_exists('ParagonIE_Sodium_Core_ChaCha20_Ctx', false)) {
10
  class ParagonIE_Sodium_Core32_ChaCha20_Ctx extends ParagonIE_Sodium_Core32_Util implements ArrayAccess
11
  {
12
  /**
13
- * @var SplFixedArray<int, ParagonIE_Sodium_Core32_Int32>
14
  */
15
  protected $container;
16
 
10
  class ParagonIE_Sodium_Core32_ChaCha20_Ctx extends ParagonIE_Sodium_Core32_Util implements ArrayAccess
11
  {
12
  /**
13
+ * @var SplFixedArray internally, <int, ParagonIE_Sodium_Core32_Int32>
14
  */
15
  protected $container;
16
 
vendor/paragonie/sodium_compat/src/Core32/Curve25519.php CHANGED
@@ -103,6 +103,7 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
103
  * @param ParagonIE_Sodium_Core32_Curve25519_Fe $g
104
  * @param int $b
105
  * @return ParagonIE_Sodium_Core32_Curve25519_Fe
 
106
  * @throws TypeError
107
  * @psalm-suppress MixedAssignment
108
  * @psalm-suppress MixedMethodCall
@@ -506,106 +507,106 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
506
  $f7_2 = $f7->shiftLeft(1);
507
  /** @var ParagonIE_Sodium_Core32_Int64 $f9_2 */
508
  $f9_2 = $f9->shiftLeft(1);
509
- $f0g0 = $f0->mulInt64($g0, 31);
510
- $f0g1 = $f0->mulInt64($g1, 31);
511
- $f0g2 = $f0->mulInt64($g2, 31);
512
- $f0g3 = $f0->mulInt64($g3, 31);
513
- $f0g4 = $f0->mulInt64($g4, 31);
514
- $f0g5 = $f0->mulInt64($g5, 31);
515
- $f0g6 = $f0->mulInt64($g6, 31);
516
- $f0g7 = $f0->mulInt64($g7, 31);
517
- $f0g8 = $f0->mulInt64($g8, 31);
518
- $f0g9 = $f0->mulInt64($g9, 31);
519
- $f1g0 = $f1->mulInt64($g0, 31);
520
- $f1g1_2 = $f1_2->mulInt64($g1, 31);
521
- $f1g2 = $f1->mulInt64($g2, 31);
522
- $f1g3_2 = $f1_2->mulInt64($g3, 31);
523
- $f1g4 = $f1->mulInt64($g4, 31);
524
- $f1g5_2 = $f1_2->mulInt64($g5, 31);
525
- $f1g6 = $f1->mulInt64($g6, 31);
526
- $f1g7_2 = $f1_2->mulInt64($g7, 31);
527
- $f1g8 = $f1->mulInt64($g8, 31);
528
- $f1g9_38 = $g9_19->mulInt64($f1_2, 31);
529
- $f2g0 = $f2->mulInt64($g0, 31);
530
- $f2g1 = $f2->mulInt64($g1, 31);
531
- $f2g2 = $f2->mulInt64($g2, 31);
532
- $f2g3 = $f2->mulInt64($g3, 31);
533
- $f2g4 = $f2->mulInt64($g4, 31);
534
- $f2g5 = $f2->mulInt64($g5, 31);
535
- $f2g6 = $f2->mulInt64($g6, 31);
536
- $f2g7 = $f2->mulInt64($g7, 31);
537
- $f2g8_19 = $g8_19->mulInt64($f2, 31);
538
- $f2g9_19 = $g9_19->mulInt64($f2, 31);
539
- $f3g0 = $f3->mulInt64($g0, 31);
540
- $f3g1_2 = $f3_2->mulInt64($g1, 31);
541
- $f3g2 = $f3->mulInt64($g2, 31);
542
- $f3g3_2 = $f3_2->mulInt64($g3, 31);
543
- $f3g4 = $f3->mulInt64($g4, 31);
544
- $f3g5_2 = $f3_2->mulInt64($g5, 31);
545
- $f3g6 = $f3->mulInt64($g6, 31);
546
- $f3g7_38 = $g7_19->mulInt64($f3_2, 31);
547
- $f3g8_19 = $g8_19->mulInt64($f3, 31);
548
- $f3g9_38 = $g9_19->mulInt64($f3_2, 31);
549
- $f4g0 = $f4->mulInt64($g0, 31);
550
- $f4g1 = $f4->mulInt64($g1, 31);
551
- $f4g2 = $f4->mulInt64($g2, 31);
552
- $f4g3 = $f4->mulInt64($g3, 31);
553
- $f4g4 = $f4->mulInt64($g4, 31);
554
- $f4g5 = $f4->mulInt64($g5, 31);
555
- $f4g6_19 = $g6_19->mulInt64($f4, 31);
556
- $f4g7_19 = $g7_19->mulInt64($f4, 31);
557
- $f4g8_19 = $g8_19->mulInt64($f4, 31);
558
- $f4g9_19 = $g9_19->mulInt64($f4, 31);
559
- $f5g0 = $f5->mulInt64($g0, 31);
560
- $f5g1_2 = $f5_2->mulInt64($g1, 31);
561
- $f5g2 = $f5->mulInt64($g2, 31);
562
- $f5g3_2 = $f5_2->mulInt64($g3, 31);
563
- $f5g4 = $f5->mulInt64($g4, 31);
564
- $f5g5_38 = $g5_19->mulInt64($f5_2, 31);
565
- $f5g6_19 = $g6_19->mulInt64($f5, 31);
566
- $f5g7_38 = $g7_19->mulInt64($f5_2, 31);
567
- $f5g8_19 = $g8_19->mulInt64($f5, 31);
568
- $f5g9_38 = $g9_19->mulInt64($f5_2, 31);
569
- $f6g0 = $f6->mulInt64($g0, 31);
570
- $f6g1 = $f6->mulInt64($g1, 31);
571
- $f6g2 = $f6->mulInt64($g2, 31);
572
- $f6g3 = $f6->mulInt64($g3, 31);
573
- $f6g4_19 = $g4_19->mulInt64($f6, 31);
574
- $f6g5_19 = $g5_19->mulInt64($f6, 31);
575
- $f6g6_19 = $g6_19->mulInt64($f6, 31);
576
- $f6g7_19 = $g7_19->mulInt64($f6, 31);
577
- $f6g8_19 = $g8_19->mulInt64($f6, 31);
578
- $f6g9_19 = $g9_19->mulInt64($f6, 31);
579
- $f7g0 = $f7->mulInt64($g0, 31);
580
- $f7g1_2 = $g1->mulInt64($f7_2, 31);
581
- $f7g2 = $f7->mulInt64($g2, 31);
582
- $f7g3_38 = $g3_19->mulInt64($f7_2, 31);
583
- $f7g4_19 = $g4_19->mulInt64($f7, 31);
584
- $f7g5_38 = $g5_19->mulInt64($f7_2, 31);
585
- $f7g6_19 = $g6_19->mulInt64($f7, 31);
586
- $f7g7_38 = $g7_19->mulInt64($f7_2, 31);
587
- $f7g8_19 = $g8_19->mulInt64($f7, 31);
588
- $f7g9_38 = $g9_19->mulInt64($f7_2, 31);
589
- $f8g0 = $f8->mulInt64($g0, 31);
590
- $f8g1 = $f8->mulInt64($g1, 31);
591
- $f8g2_19 = $f8->mulInt64($g2_19, 31);
592
- $f8g3_19 = $f8->mulInt64($g3_19, 31);
593
- $f8g4_19 = $f8->mulInt64($g4_19, 31);
594
- $f8g5_19 = $f8->mulInt64($g5_19, 31);
595
- $f8g6_19 = $f8->mulInt64($g6_19, 31);
596
- $f8g7_19 = $f8->mulInt64($g7_19, 31);
597
- $f8g8_19 = $f8->mulInt64($g8_19, 31);
598
- $f8g9_19 = $f8->mulInt64($g9_19, 31);
599
- $f9g0 = $f9->mulInt64($g0, 31);
600
- $f9g1_38 = $f9_2->mulInt64($g1_19, 31);
601
- $f9g2_19 = $f9->mulInt64($g2_19, 31);
602
- $f9g3_38 = $f9_2->mulInt64($g3_19, 31);
603
- $f9g4_19 = $f9->mulInt64($g4_19, 31);
604
- $f9g5_38 = $f9_2->mulInt64($g5_19, 31);
605
- $f9g6_19 = $f9->mulInt64($g6_19, 31);
606
- $f9g7_38 = $f9_2->mulInt64($g7_19, 31);
607
- $f9g8_19 = $f9->mulInt64($g8_19, 31);
608
- $f9g9_38 = $f9_2->mulInt64($g9_19, 31);
609
 
610
  // $h0 = $f0g0 + $f1g9_38 + $f2g8_19 + $f3g7_38 + $f4g6_19 + $f5g5_38 + $f6g4_19 + $f7g3_38 + $f8g2_19 + $f9g1_38;
611
  $h0 = $f0g0->addInt64($f1g9_38)->addInt64($f2g8_19)->addInt64($f3g7_38)
@@ -715,7 +716,7 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
715
  $h8 = $h8->subInt64($carry8->shiftLeft(26));
716
 
717
  $carry9 = $h9->addInt(1 << 24)->shiftRight(25);
718
- $h0 = $h0->addInt64($carry9->mulInt(19));
719
  $h9 = $h9->subInt64($carry9->shiftLeft(25));
720
 
721
  $carry0 = $h0->addInt(1 << 25)->shiftRight(26);
@@ -810,70 +811,70 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
810
  $f8_19 = $f8->mulInt(19, 5);
811
  $f9_38 = $f9->mulInt(38, 6);
812
  /** @var ParagonIE_Sodium_Core32_Int64 $f0f0*/
813
- $f0f0 = $f0->mulInt64($f0, 31);
814
- $f0f1_2 = $f0_2->mulInt64($f1, 31);
815
- $f0f2_2 = $f0_2->mulInt64($f2, 31);
816
- $f0f3_2 = $f0_2->mulInt64($f3, 31);
817
- $f0f4_2 = $f0_2->mulInt64($f4, 31);
818
- $f0f5_2 = $f0_2->mulInt64($f5, 31);
819
- $f0f6_2 = $f0_2->mulInt64($f6, 31);
820
- $f0f7_2 = $f0_2->mulInt64($f7, 31);
821
- $f0f8_2 = $f0_2->mulInt64($f8, 31);
822
- $f0f9_2 = $f0_2->mulInt64($f9, 31);
823
-
824
- $f1f1_2 = $f1_2->mulInt64($f1, 31);
825
- $f1f2_2 = $f1_2->mulInt64($f2, 31);
826
- $f1f3_4 = $f1_2->mulInt64($f3_2, 31);
827
- $f1f4_2 = $f1_2->mulInt64($f4, 31);
828
- $f1f5_4 = $f1_2->mulInt64($f5_2, 31);
829
- $f1f6_2 = $f1_2->mulInt64($f6, 31);
830
- $f1f7_4 = $f1_2->mulInt64($f7_2, 31);
831
- $f1f8_2 = $f1_2->mulInt64($f8, 31);
832
- $f1f9_76 = $f1_2->mulInt64($f9_38, 31);
833
-
834
- $f2f2 = $f2->mulInt64($f2, 31);
835
- $f2f3_2 = $f2_2->mulInt64($f3, 31);
836
- $f2f4_2 = $f2_2->mulInt64($f4, 31);
837
- $f2f5_2 = $f2_2->mulInt64($f5, 31);
838
- $f2f6_2 = $f2_2->mulInt64($f6, 31);
839
- $f2f7_2 = $f2_2->mulInt64($f7, 31);
840
- $f2f8_38 = $f8_19->mulInt64($f2_2, 31);
841
- $f2f9_38 = $f9_38->mulInt64($f2, 31);
842
-
843
- $f3f3_2 = $f3_2->mulInt64($f3, 31);
844
- $f3f4_2 = $f3_2->mulInt64($f4, 31);
845
- $f3f5_4 = $f3_2->mulInt64($f5_2, 31);
846
- $f3f6_2 = $f3_2->mulInt64($f6, 31);
847
- $f3f7_76 = $f7_38->mulInt64($f3_2, 31);
848
- $f3f8_38 = $f8_19->mulInt64($f3_2, 31);
849
- $f3f9_76 = $f9_38->mulInt64($f3_2, 31);
850
-
851
- $f4f4 = $f4->mulInt64($f4, 31);
852
- $f4f5_2 = $f4_2->mulInt64($f5, 31);
853
- $f4f6_38 = $f4_2->mulInt64($f6_19, 31);
854
- $f4f7_38 = $f7_38->mulInt64($f4, 31);
855
- $f4f8_38 = $f8_19->mulInt64($f4_2, 31);
856
- $f4f9_38 = $f9_38->mulInt64($f4, 31);
857
-
858
- $f5f5_38 = $f5_38->mulInt64($f5, 31);
859
- $f5f6_38 = $f6_19->mulInt64($f5_2, 31);
860
- $f5f7_76 = $f7_38->mulInt64($f5_2, 31);
861
- $f5f8_38 = $f8_19->mulInt64($f5_2, 31);
862
- $f5f9_76 = $f9_38->mulInt64($f5_2, 31);
863
-
864
- $f6f6_19 = $f6_19->mulInt64($f6, 31);
865
- $f6f7_38 = $f7_38->mulInt64($f6, 31);
866
- $f6f8_38 = $f8_19->mulInt64($f6_2, 31);
867
- $f6f9_38 = $f6->mulInt64($f9_38, 31);
868
-
869
- $f7f7_38 = $f7->mulInt64($f7_38, 31);
870
- $f7f8_38 = $f7_2->mulInt64($f8_19, 31);
871
- $f7f9_76 = $f7_2->mulInt64($f9_38, 31);
872
-
873
- $f8f8_19 = $f8->mulInt64($f8_19, 31);
874
- $f8f9_38 = $f8->mulInt64($f9_38, 31);
875
-
876
- $f9f9_38 = $f9->mulInt64($f9_38, 31);
877
 
878
  $h0 = $f0f0->addInt64($f1f9_76)->addInt64($f2f8_38)->addInt64($f3f7_76)->addInt64($f4f6_38)->addInt64($f5f5_38);
879
  $h1 = $f0f1_2->addInt64($f2f9_38)->addInt64($f3f8_38)->addInt64($f4f7_38)->addInt64($f5f6_38);
@@ -940,7 +941,7 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
940
  $h8 = $h8->subInt64($carry8->shiftLeft(26));
941
 
942
  $carry9 = $h9->addInt(1 << 24)->shiftRight(25);
943
- $h0 = $h0->addInt64($carry9->mulInt(19));
944
  $h9 = $h9->subInt64($carry9->shiftLeft(25));
945
 
946
  $carry0 = $h0->addInt(1 << 25)->shiftRight(26);
@@ -1012,61 +1013,61 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
1012
  $f7_38 = $f7->mulInt(38, 6); /* 1.959375*2^30 */
1013
  $f8_19 = $f8->mulInt(19, 5); /* 1.959375*2^30 */
1014
  $f9_38 = $f9->mulInt(38, 6); /* 1.959375*2^30 */
1015
- $f0f0 = $f0->mulInt64($f0, 31);
1016
- $f0f1_2 = $f0_2->mulInt64($f1, 31);
1017
- $f0f2_2 = $f0_2->mulInt64($f2, 31);
1018
- $f0f3_2 = $f0_2->mulInt64($f3, 31);
1019
- $f0f4_2 = $f0_2->mulInt64($f4, 31);
1020
- $f0f5_2 = $f0_2->mulInt64($f5, 31);
1021
- $f0f6_2 = $f0_2->mulInt64($f6, 31);
1022
- $f0f7_2 = $f0_2->mulInt64($f7, 31);
1023
- $f0f8_2 = $f0_2->mulInt64($f8, 31);
1024
- $f0f9_2 = $f0_2->mulInt64($f9, 31);
1025
- $f1f1_2 = $f1_2->mulInt64($f1, 31);
1026
- $f1f2_2 = $f1_2->mulInt64($f2, 31);
1027
- $f1f3_4 = $f1_2->mulInt64($f3_2, 31);
1028
- $f1f4_2 = $f1_2->mulInt64($f4, 31);
1029
- $f1f5_4 = $f1_2->mulInt64($f5_2, 31);
1030
- $f1f6_2 = $f1_2->mulInt64($f6, 31);
1031
- $f1f7_4 = $f1_2->mulInt64($f7_2, 31);
1032
- $f1f8_2 = $f1_2->mulInt64($f8, 31);
1033
- $f1f9_76 = $f1_2->mulInt64($f9_38, 31);
1034
- $f2f2 = $f2->mulInt64($f2, 31);
1035
- $f2f3_2 = $f2_2->mulInt64($f3, 31);
1036
- $f2f4_2 = $f2_2->mulInt64($f4, 31);
1037
- $f2f5_2 = $f2_2->mulInt64($f5, 31);
1038
- $f2f6_2 = $f2_2->mulInt64($f6, 31);
1039
- $f2f7_2 = $f2_2->mulInt64($f7, 31);
1040
- $f2f8_38 = $f2_2->mulInt64($f8_19, 31);
1041
- $f2f9_38 = $f2->mulInt64($f9_38, 31);
1042
- $f3f3_2 = $f3_2->mulInt64($f3, 31);
1043
- $f3f4_2 = $f3_2->mulInt64($f4, 31);
1044
- $f3f5_4 = $f3_2->mulInt64($f5_2, 31);
1045
- $f3f6_2 = $f3_2->mulInt64($f6, 31);
1046
- $f3f7_76 = $f3_2->mulInt64($f7_38, 31);
1047
- $f3f8_38 = $f3_2->mulInt64($f8_19, 31);
1048
- $f3f9_76 = $f3_2->mulInt64($f9_38, 31);
1049
- $f4f4 = $f4->mulInt64($f4, 31);
1050
- $f4f5_2 = $f4_2->mulInt64($f5, 31);
1051
- $f4f6_38 = $f4_2->mulInt64($f6_19, 31);
1052
- $f4f7_38 = $f4->mulInt64($f7_38, 31);
1053
- $f4f8_38 = $f4_2->mulInt64($f8_19, 31);
1054
- $f4f9_38 = $f4->mulInt64($f9_38, 31);
1055
- $f5f5_38 = $f5->mulInt64($f5_38, 31);
1056
- $f5f6_38 = $f5_2->mulInt64($f6_19, 31);
1057
- $f5f7_76 = $f5_2->mulInt64($f7_38, 31);
1058
- $f5f8_38 = $f5_2->mulInt64($f8_19, 31);
1059
- $f5f9_76 = $f5_2->mulInt64($f9_38, 31);
1060
- $f6f6_19 = $f6->mulInt64($f6_19, 31);
1061
- $f6f7_38 = $f6->mulInt64($f7_38, 31);
1062
- $f6f8_38 = $f6_2->mulInt64($f8_19, 31);
1063
- $f6f9_38 = $f6->mulInt64($f9_38, 31);
1064
- $f7f7_38 = $f7->mulInt64($f7_38, 31);
1065
- $f7f8_38 = $f7_2->mulInt64($f8_19, 31);
1066
- $f7f9_76 = $f7_2->mulInt64($f9_38, 31);
1067
- $f8f8_19 = $f8->mulInt64($f8_19, 31);
1068
- $f8f9_38 = $f8->mulInt64($f9_38, 31);
1069
- $f9f9_38 = $f9->mulInt64($f9_38, 31);
1070
 
1071
  $h0 = $f0f0->addInt64($f1f9_76)->addInt64($f2f8_38)->addInt64($f3f7_76)->addInt64($f4f6_38)->addInt64($f5f5_38);
1072
  $h1 = $f0f1_2->addInt64($f2f9_38)->addInt64($f3f8_38)->addInt64($f4f7_38)->addInt64($f5f6_38);
@@ -1079,12 +1080,6 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
1079
  $h8 = $f0f8_2->addInt64($f1f7_4)->addInt64($f2f6_2)->addInt64($f3f5_4)->addInt64($f4f4)->addInt64($f9f9_38);
1080
  $h9 = $f0f9_2->addInt64($f1f8_2)->addInt64($f2f7_2)->addInt64($f3f6_2)->addInt64($f4f5_2);
1081
 
1082
- /*
1083
- $h6 = (int) ($f0f6_2 + $f1f5_4 + $f2f4_2 + $f3f3_2 + $f7f9_76 + $f8f8_19);
1084
- $h7 = (int) ($f0f7_2 + $f1f6_2 + $f2f5_2 + $f3f4_2 + $f8f9_38);
1085
- $h8 = (int) ($f0f8_2 + $f1f7_4 + $f2f6_2 + $f3f5_4 + $f4f4 + $f9f9_38);
1086
- */
1087
-
1088
  /**
1089
  * @var ParagonIE_Sodium_Core32_Int64 $h0
1090
  * @var ParagonIE_Sodium_Core32_Int64 $h1
@@ -1144,7 +1139,7 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
1144
  $h8 = $h8->subInt64($carry8->shiftLeft(26));
1145
 
1146
  $carry9 = $h9->addInt(1 << 24)->shiftRight(25);
1147
- $h0 = $h0->addInt64($carry9->mulInt(19));
1148
  $h9 = $h9->subInt64($carry9->shiftLeft(25));
1149
 
1150
  $carry0 = $h0->addInt(1 << 25)->shiftRight(26);
@@ -2116,7 +2111,9 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
2116
 
2117
  # slide(aslide,a);
2118
  # slide(bslide,b);
 
2119
  $aslide = self::slide($a);
 
2120
  $bslide = self::slide($b);
2121
 
2122
  # ge_p3_to_cached(&Ai[0],A);
@@ -2285,42 +2282,42 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
2285
  */
2286
  public static function sc_muladd($a, $b, $c)
2287
  {
2288
- $a0 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($a, 0, 3)))->toInt64();
2289
- $a1 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($a, 2, 4)) >> 5))->toInt64();
2290
- $a2 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($a, 5, 3)) >> 2))->toInt64();
2291
- $a3 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($a, 7, 4)) >> 7))->toInt64();
2292
- $a4 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($a, 10, 4)) >> 4))->toInt64();
2293
- $a5 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($a, 13, 3)) >> 1))->toInt64();
2294
- $a6 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($a, 15, 4)) >> 6))->toInt64();
2295
- $a7 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($a, 18, 3)) >> 3))->toInt64();
2296
- $a8 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($a, 21, 3)))->toInt64();
2297
- $a9 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($a, 23, 4)) >> 5))->toInt64();
2298
- $a10 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($a, 26, 3)) >> 2))->toInt64();
2299
- $a11 = ParagonIE_Sodium_Core32_Int32::fromInt(0x1fffffff & (self::load_4(self::substr($a, 28, 4)) >> 7))->toInt64();
2300
- $b0 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($b, 0, 3)))->toInt64();
2301
- $b1 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($b, 2, 4)) >> 5))->toInt64();
2302
- $b2 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($b, 5, 3)) >> 2))->toInt64();
2303
- $b3 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($b, 7, 4)) >> 7))->toInt64();
2304
- $b4 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($b, 10, 4)) >> 4))->toInt64();
2305
- $b5 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($b, 13, 3)) >> 1))->toInt64();
2306
- $b6 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($b, 15, 4)) >> 6))->toInt64();
2307
- $b7 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($b, 18, 3)) >> 3))->toInt64();
2308
- $b8 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($b, 21, 3)))->toInt64();
2309
- $b9 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($b, 23, 4)) >> 5))->toInt64();
2310
- $b10 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($b, 26, 3)) >> 2))->toInt64();
2311
- $b11 = ParagonIE_Sodium_Core32_Int32::fromInt(0x1fffffff & (self::load_4(self::substr($b, 28, 4)) >> 7))->toInt64();
2312
- $c0 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($c, 0, 3)))->toInt64();
2313
- $c1 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($c, 2, 4)) >> 5))->toInt64();
2314
- $c2 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($c, 5, 3)) >> 2))->toInt64();
2315
- $c3 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($c, 7, 4)) >> 7))->toInt64();
2316
- $c4 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($c, 10, 4)) >> 4))->toInt64();
2317
- $c5 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($c, 13, 3)) >> 1))->toInt64();
2318
- $c6 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($c, 15, 4)) >> 6))->toInt64();
2319
- $c7 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($c, 18, 3)) >> 3))->toInt64();
2320
- $c8 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($c, 21, 3)))->toInt64();
2321
- $c9 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($c, 23, 4)) >> 5))->toInt64();
2322
- $c10 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($c, 26, 3)) >> 2))->toInt64();
2323
- $c11 = ParagonIE_Sodium_Core32_Int32::fromInt(0x1fffffff & (self::load_4(self::substr($c, 28, 4)) >> 7))->toInt64();
2324
 
2325
  /* Can't really avoid the pyramid here: */
2326
  /**
@@ -2353,34 +2350,56 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
2353
  $s0 = $c0->addInt64($a0->mulInt64($b0, 24));
2354
  $s1 = $c1->addInt64($a0->mulInt64($b1, 24))->addInt64($a1->mulInt64($b0, 24));
2355
  $s2 = $c2->addInt64($a0->mulInt64($b2, 24))->addInt64($a1->mulInt64($b1, 24))->addInt64($a2->mulInt64($b0, 24));
2356
- $s3 = $c3->addInt64($a0->mulInt64($b3, 24))->addInt64($a1->mulInt64($b2, 24))->addInt64($a2->mulInt64($b1, 24))->addInt64($a3->mulInt64($b0, 24));
2357
- $s4 = $c4->addInt64($a0->mulInt64($b4, 24))->addInt64($a1->mulInt64($b3, 24))->addInt64($a2->mulInt64($b2, 24))->addInt64($a3->mulInt64($b1, 24))->addInt64($a4->mulInt64($b0, 24));
2358
- $s5 = $c5->addInt64($a0->mulInt64($b5, 24))->addInt64($a1->mulInt64($b4, 24))->addInt64($a2->mulInt64($b3, 24))->addInt64($a3->mulInt64($b2, 24))->addInt64($a4->mulInt64($b1, 24))->addInt64($a5->mulInt64($b0, 24));
2359
- $s6 = $c6->addInt64($a0->mulInt64($b6, 24))->addInt64($a1->mulInt64($b5, 24))->addInt64($a2->mulInt64($b4, 24))->addInt64($a3->mulInt64($b3, 24))->addInt64($a4->mulInt64($b2, 24))->addInt64($a5->mulInt64($b1, 24))
 
 
 
 
2360
  ->addInt64($a6->mulInt64($b0, 24));
2361
- $s7 = $c7->addInt64($a0->mulInt64($b7, 24))->addInt64($a1->mulInt64($b6, 24))->addInt64($a2->mulInt64($b5, 24))->addInt64($a3->mulInt64($b4, 24))->addInt64($a4->mulInt64($b3, 24))->addInt64($a5->mulInt64($b2, 24))
 
2362
  ->addInt64($a6->mulInt64($b1, 24))->addInt64($a7->mulInt64($b0, 24));
2363
- $s8 = $c8->addInt64($a0->mulInt64($b8, 24))->addInt64($a1->mulInt64($b7, 24))->addInt64($a2->mulInt64($b6, 24))->addInt64($a3->mulInt64($b5, 24))->addInt64($a4->mulInt64($b4, 24))->addInt64($a5->mulInt64($b3, 24))
 
2364
  ->addInt64($a6->mulInt64($b2, 24))->addInt64($a7->mulInt64($b1, 24))->addInt64($a8->mulInt64($b0, 24));
2365
- $s9 = $c9->addInt64($a0->mulInt64($b9, 24))->addInt64($a1->mulInt64($b8, 24))->addInt64($a2->mulInt64($b7, 24))->addInt64($a3->mulInt64($b6, 24))->addInt64($a4->mulInt64($b5, 24))->addInt64($a5->mulInt64($b4, 24))
2366
- ->addInt64($a6->mulInt64($b3, 24))->addInt64($a7->mulInt64($b2, 24))->addInt64($a8->mulInt64($b1, 24))->addInt64($a9->mulInt64($b0, 24));
2367
- $s10 = $c10->addInt64($a0->mulInt64($b10, 24))->addInt64($a1->mulInt64($b9, 24))->addInt64($a2->mulInt64($b8, 24))->addInt64($a3->mulInt64($b7, 24))->addInt64($a4->mulInt64($b6, 24))->addInt64($a5->mulInt64($b5, 24))
2368
- ->addInt64($a6->mulInt64($b4, 24))->addInt64($a7->mulInt64($b3, 24))->addInt64($a8->mulInt64($b2, 24))->addInt64($a9->mulInt64($b1, 24))->addInt64($a10->mulInt64($b0, 24));
2369
- $s11 = $c11->addInt64($a0->mulInt64($b11, 24))->addInt64($a1->mulInt64($b10, 24))->addInt64($a2->mulInt64($b9, 24))->addInt64($a3->mulInt64($b8, 24))->addInt64($a4->mulInt64($b7, 24))->addInt64($a5->mulInt64($b6, 24))
2370
- ->addInt64($a6->mulInt64($b5, 24))->addInt64($a7->mulInt64($b4, 24))->addInt64($a8->mulInt64($b3, 24))->addInt64($a9->mulInt64($b2, 24))->addInt64($a10->mulInt64($b1, 24))->addInt64($a11->mulInt64($b0, 24));
2371
- $s12 = $a1->mulInt64($b11, 24)->addInt64($a2->mulInt64($b10, 24))->addInt64($a3->mulInt64($b9, 24))->addInt64($a4->mulInt64($b8, 24))->addInt64($a5->mulInt64($b7, 24))->addInt64($a6->mulInt64($b6, 24))
2372
- ->addInt64($a7->mulInt64($b5, 24))->addInt64($a8->mulInt64($b4, 24))->addInt64($a9->mulInt64($b3, 24))->addInt64($a10->mulInt64($b2, 24))->addInt64($a11->mulInt64($b1, 24));
2373
- $s13 = $a2->mulInt64($b11, 24)->addInt64($a3->mulInt64($b10, 24))->addInt64($a4->mulInt64($b9, 24))->addInt64($a5->mulInt64($b8, 24))->addInt64($a6->mulInt64($b7, 24))->addInt64($a7->mulInt64($b6, 24))
2374
- ->addInt64($a8->mulInt64($b5, 24))->addInt64($a9->mulInt64($b4, 24))->addInt64($a10->mulInt64($b3, 24))->addInt64($a11->mulInt64($b2, 24));
2375
- $s14 = $a3->mulInt64($b11, 24)->addInt64($a4->mulInt64($b10, 24))->addInt64($a5->mulInt64($b9, 24))->addInt64($a6->mulInt64($b8, 24))->addInt64($a7->mulInt64($b7, 24))->addInt64($a8->mulInt64($b6, 24))
 
 
 
 
 
 
 
 
 
 
 
2376
  ->addInt64($a9->mulInt64($b5, 24))->addInt64($a10->mulInt64($b4, 24))->addInt64($a11->mulInt64($b3, 24));
2377
- $s15 = $a4->mulInt64($b11, 24)->addInt64($a5->mulInt64($b10, 24))->addInt64($a6->mulInt64($b9, 24))->addInt64($a7->mulInt64($b8, 24))->addInt64($a8->mulInt64($b7, 24))->addInt64($a9->mulInt64($b6, 24))
 
2378
  ->addInt64($a10->mulInt64($b5, 24))->addInt64($a11->mulInt64($b4, 24));
2379
- $s16 = $a5->mulInt64($b11, 24)->addInt64($a6->mulInt64($b10, 24))->addInt64($a7->mulInt64($b9, 24))->addInt64($a8->mulInt64($b8, 24))->addInt64($a9->mulInt64($b7, 24))->addInt64($a10->mulInt64($b6, 24))
2380
- ->addInt64($a11->mulInt64($b5, 24));
2381
- $s17 = $a6->mulInt64($b11, 24)->addInt64($a7->mulInt64($b10, 24))->addInt64($a8->mulInt64($b9, 24))->addInt64($a9->mulInt64($b8, 24))->addInt64($a10->mulInt64($b7, 24))->addInt64($a11->mulInt64($b6, 24));
2382
- $s18 = $a7->mulInt64($b11, 24)->addInt64($a8->mulInt64($b10, 24))->addInt64($a9->mulInt64($b9, 24))->addInt64($a10->mulInt64($b8, 24))->addInt64($a11->mulInt64($b7, 24));
2383
- $s19 = $a8->mulInt64($b11, 24)->addInt64($a9->mulInt64($b10, 24))->addInt64($a10->mulInt64($b9, 24))->addInt64($a11->mulInt64($b8, 24));
 
 
 
 
2384
  $s20 = $a9->mulInt64($b11, 24)->addInt64($a10->mulInt64($b10, 24))->addInt64($a11->mulInt64($b9, 24));
2385
  $s21 = $a10->mulInt64($b11, 24)->addInt64($a11->mulInt64($b10, 24));
2386
  $s22 = $a11->mulInt64($b11, 24);
@@ -2701,18 +2720,18 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
2701
  $s11 = $s11->addInt64($carry10);
2702
  $s10 = $s10->subInt64($carry10->shiftLeft(21));
2703
 
2704
- $S0 = $s0->toInt32()->toInt();
2705
- $S1 = $s1->toInt32()->toInt();
2706
- $S2 = $s2->toInt32()->toInt();
2707
- $S3 = $s3->toInt32()->toInt();
2708
- $S4 = $s4->toInt32()->toInt();
2709
- $S5 = $s5->toInt32()->toInt();
2710
- $S6 = $s6->toInt32()->toInt();
2711
- $S7 = $s7->toInt32()->toInt();
2712
- $S8 = $s8->toInt32()->toInt();
2713
- $S9 = $s9->toInt32()->toInt();
2714
- $S10 = $s10->toInt32()->toInt();
2715
- $S11 = $s11->toInt32()->toInt();
2716
 
2717
  /**
2718
  * @var array<int, int>
@@ -2790,30 +2809,30 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
2790
  * @var ParagonIE_Sodium_Core32_Int64 $s22
2791
  * @var ParagonIE_Sodium_Core32_Int64 $s23
2792
  */
2793
- $s0 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($s, 0, 3)))->toInt64();
2794
- $s1 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 2, 4)) >> 5))->toInt64();
2795
- $s2 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 5, 3)) >> 2))->toInt64();
2796
- $s3 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 7, 4)) >> 7))->toInt64();
2797
- $s4 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 10, 4)) >> 4))->toInt64();
2798
- $s5 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 13, 3)) >> 1))->toInt64();
2799
- $s6 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 15, 4)) >> 6))->toInt64();
2800
- $s7 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 18, 4)) >> 3))->toInt64();
2801
- $s8 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($s, 21, 3)))->toInt64();
2802
- $s9 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 23, 4)) >> 5))->toInt64();
2803
- $s10 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 26, 3)) >> 2))->toInt64();
2804
- $s11 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 28, 4)) >> 7))->toInt64();
2805
- $s12 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 31, 4)) >> 4))->toInt64();
2806
- $s13 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 34, 3)) >> 1))->toInt64();
2807
- $s14 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 36, 4)) >> 6))->toInt64();
2808
- $s15 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 39, 4)) >> 3))->toInt64();
2809
- $s16 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($s, 42, 3)))->toInt64();
2810
- $s17 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 44, 4)) >> 5))->toInt64();
2811
- $s18 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 47, 3)) >> 2))->toInt64();
2812
- $s19 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 49, 4)) >> 7))->toInt64();
2813
- $s20 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 52, 4)) >> 4))->toInt64();
2814
- $s21 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 55, 3)) >> 1))->toInt64();
2815
- $s22 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 57, 4)) >> 6))->toInt64();
2816
- $s23 = ParagonIE_Sodium_Core32_Int32::fromInt(0x1fffffff & (self::load_4(self::substr($s, 60, 4)) >> 3))->toInt64();
2817
 
2818
  $s11 = $s11->addInt64($s23->mulInt(666643, 20));
2819
  $s12 = $s12->addInt64($s23->mulInt(470296, 19));
@@ -3111,372 +3130,6 @@ abstract class ParagonIE_Sodium_Core32_Curve25519 extends ParagonIE_Sodium_Core3
3111
  return self::intArrayToString($arr);
3112
  }
3113
 
3114
- /**
3115
- * @internal You should not use this directly from another application
3116
- *
3117
- * @param string $s
3118
- * @return string
3119
- * @throws SodiumException
3120
- * @throws TypeError
3121
- */
3122
- public static function sc_reduce_old($s)
3123
- {
3124
- /**
3125
- * @var ParagonIE_Sodium_Core32_Int32 $s0
3126
- * @var ParagonIE_Sodium_Core32_Int32 $s1
3127
- * @var ParagonIE_Sodium_Core32_Int32 $s2
3128
- * @var ParagonIE_Sodium_Core32_Int32 $s3
3129
- * @var ParagonIE_Sodium_Core32_Int32 $s4
3130
- * @var ParagonIE_Sodium_Core32_Int32 $s5
3131
- * @var ParagonIE_Sodium_Core32_Int32 $s6
3132
- * @var ParagonIE_Sodium_Core32_Int32 $s7
3133
- * @var ParagonIE_Sodium_Core32_Int32 $s8
3134
- * @var ParagonIE_Sodium_Core32_Int32 $s9
3135
- * @var ParagonIE_Sodium_Core32_Int32 $s10
3136
- * @var ParagonIE_Sodium_Core32_Int32 $s11
3137
- * @var ParagonIE_Sodium_Core32_Int32 $s12
3138
- * @var ParagonIE_Sodium_Core32_Int32 $s13
3139
- * @var ParagonIE_Sodium_Core32_Int32 $s14
3140
- * @var ParagonIE_Sodium_Core32_Int32 $s15
3141
- * @var ParagonIE_Sodium_Core32_Int32 $s16
3142
- * @var ParagonIE_Sodium_Core32_Int32 $s17
3143
- * @var ParagonIE_Sodium_Core32_Int32 $s18
3144
- * @var ParagonIE_Sodium_Core32_Int32 $s19
3145
- * @var ParagonIE_Sodium_Core32_Int32 $s20
3146
- * @var ParagonIE_Sodium_Core32_Int32 $s21
3147
- * @var ParagonIE_Sodium_Core32_Int32 $s22
3148
- * @var ParagonIE_Sodium_Core32_Int32 $s23
3149
- */
3150
- $s0 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($s, 0, 3)));
3151
- $s1 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 2, 4)) >> 5));
3152
- $s2 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 5, 3)) >> 2));
3153
- $s3 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 7, 4)) >> 7));
3154
- $s4 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 10, 4)) >> 4));
3155
- $s5 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 13, 3)) >> 1));
3156
- $s6 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 15, 4)) >> 6));
3157
- $s7 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 18, 4)) >> 3));
3158
- $s8 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($s, 21, 3)));
3159
- $s9 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 23, 4)) >> 5));
3160
- $s10 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 26, 3)) >> 2));
3161
- $s11 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 28, 4)) >> 7));
3162
- $s12 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 31, 4)) >> 4));
3163
- $s13 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 34, 3)) >> 1));
3164
- $s14 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 36, 4)) >> 6));
3165
- $s15 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 39, 4)) >> 3));
3166
- $s16 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & self::load_3(self::substr($s, 42, 3)));
3167
- $s17 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 44, 4)) >> 5));
3168
- $s18 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 47, 3)) >> 2));
3169
- $s19 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 49, 4)) >> 7));
3170
- $s20 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 52, 4)) >> 4));
3171
- $s21 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_3(self::substr($s, 55, 3)) >> 1));
3172
- $s22 = ParagonIE_Sodium_Core32_Int32::fromInt(2097151 & (self::load_4(self::substr($s, 57, 4)) >> 6));
3173
- $s23 = ParagonIE_Sodium_Core32_Int32::fromInt(self::load_4(self::substr($s, 60, 4)) >> 3);
3174
-
3175
- $s11 = $s11->addInt32($s23->mulInt(666643, 20));
3176
- $s12 = $s12->addInt32($s23->mulInt(470296, 19));
3177
- $s13 = $s13->addInt32($s23->mulInt(654183, 20));
3178
- $s14 = $s14->subInt32($s23->mulInt(997805, 20));
3179
- $s15 = $s15->addInt32($s23->mulInt(136657, 18));
3180
- $s16 = $s16->subInt32($s23->mulInt(683901, 20));
3181
-
3182
- $s10 = $s10->addInt32($s22->mulInt(666643, 20));
3183
- $s11 = $s11->addInt32($s22->mulInt(470296, 19));
3184
- $s12 = $s12->addInt32($s22->mulInt(654183, 20));
3185
- $s13 = $s13->subInt32($s22->mulInt(997805, 20));
3186
- $s14 = $s14->addInt32($s22->mulInt(136657, 18));
3187
- $s15 = $s15->subInt32($s22->mulInt(683901, 20));
3188
-
3189
- $s9 = $s9->addInt32($s21->mulInt(666643, 20));
3190
- $s10 = $s10->addInt32($s21->mulInt(470296, 19));
3191
- $s11 = $s11->addInt32($s21->mulInt(654183, 20));
3192
- $s12 = $s12->subInt32($s21->mulInt(997805, 20));
3193
- $s13 = $s13->addInt32($s21->mulInt(136657, 18));
3194
- $s14 = $s14->subInt32($s21->mulInt(683901, 20));
3195
-
3196
- $s8 = $s8->addInt32($s20->mulInt(666643, 20));
3197
- $s9 = $s9->addInt32($s20->mulInt(470296, 19));
3198
- $s10 = $s10->addInt32($s20->mulInt(654183, 20));
3199
- $s11 = $s11->subInt32($s20->mulInt(997805, 20));
3200
- $s12 = $s12->addInt32($s20->mulInt(136657, 18));
3201
- $s13 = $s13->subInt32($s20->mulInt(683901, 20));
3202
-
3203
- $s7 = $s7->addInt32($s19->mulInt(666643, 20));
3204
- $s8 = $s8->addInt32($s19->mulInt(470296, 19));
3205
- $s9 = $s9->addInt32($s19->mulInt(654183, 20));
3206
- $s10 = $s10->subInt32($s19->mulInt(997805, 20));
3207
- $s11 = $s11->addInt32($s19->mulInt(136657, 18));
3208
- $s12 = $s12->subInt32($s19->mulInt(683901, 20));
3209
-
3210
- $s6 = $s6->addInt32($s18->mulInt(666643, 20));
3211
- $s7 = $s7->addInt32($s18->mulInt(470296, 19));
3212
- $s8 = $s8->addInt32($s18->mulInt(654183, 20));
3213
- $s9 = $s9->subInt32($s18->mulInt(997805, 20));
3214
- $s10 = $s10->addInt32($s18->mulInt(136657, 18));
3215
- $s11 = $s11->subInt32($s18->mulInt(683901, 20));
3216
-
3217
- $carry6 = $s6->addInt(1 << 20)->shiftRight(21);
3218
- $s7 = $s7->addInt32($carry6);
3219
- $s6 = $s6->subInt32($carry6->shiftLeft(21));
3220
-
3221
- $carry8 = $s8->addInt(1 << 20)->shiftRight(21);
3222
- $s9 = $s9->addInt32($carry8);
3223
- $s8 = $s8->subInt32($carry8->shiftLeft(21));
3224
-
3225
- $carry10 = $s10->addInt(1 << 20)->shiftRight(21);
3226
- $s11 = $s11->addInt32($carry10);
3227
- $s10 = $s10->subInt32($carry10->shiftLeft(21));
3228
-
3229
- $carry12 = $s12->addInt(1 << 20)->shiftRight(21);
3230
- $s13 = $s13->addInt32($carry12);
3231
- $s12 = $s12->subInt32($carry12->shiftLeft(21));
3232
-
3233
- $carry14 = $s14->addInt(1 << 20)->shiftRight(21);
3234
- $s15 = $s15->addInt32($carry14);
3235
- $s14 = $s14->subInt32($carry14->shiftLeft(21));
3236
-
3237
- $carry16 = $s16->addInt(1 << 20)->shiftRight(21);
3238
- $s17 = $s17->addInt32($carry16);
3239
- $s16 = $s16->subInt32($carry16->shiftLeft(21));
3240
-
3241
- $carry7 = $s7->addInt(1 << 20)->shiftRight(21);
3242
- $s8 = $s8->addInt32($carry7);
3243
- $s7 = $s7->subInt32($carry7->shiftLeft(21));
3244
-
3245
- $carry9 = $s9->addInt(1 << 20)->shiftRight(21);
3246
- $s10 = $s10->addInt32($carry9);
3247
- $s9 = $s9->subInt32($carry9->shiftLeft(21));
3248
-
3249
- $carry11 = $s11->addInt(1 << 20)->shiftRight(21);
3250
- $s12 = $s12->addInt32($carry11);
3251
- $s11 = $s11->subInt32($carry11->shiftLeft(21));
3252
-
3253
- $carry13 = $s13->addInt(1 << 20)->shiftRight(21);
3254
- $s14 = $s14->addInt32($carry13);
3255
- $s13 = $s13->subInt32($carry13->shiftLeft(21));
3256
-
3257
- $carry15 = $s15->addInt(1 << 20)->shiftRight(21);
3258
- $s16 = $s16->addInt32($carry15);
3259
- $s15 = $s15->subInt32($carry15->shiftLeft(21));
3260
-
3261
- $s5 = $s5->addInt32($s17->mulInt(666643, 20));
3262
- $s6 = $s6->addInt32($s17->mulInt(470296, 19));
3263
- $s7 = $s7->addInt32($s17->mulInt(654183, 20));
3264
- $s8 = $s8->subInt32($s17->mulInt(997805, 20));
3265
- $s9 = $s9->addInt32($s17->mulInt(136657, 18));
3266
- $s10 = $s10->subInt32($s17->mulInt(683901, 20));
3267
-
3268
- $s4 = $s4->addInt32($s16->mulInt(666643, 20));
3269
- $s5 = $s5->addInt32($s16->mulInt(470296, 19));
3270
- $s6 = $s6->addInt32($s16->mulInt(654183, 20));
3271
- $s7 = $s7->subInt32($s16->mulInt(997805, 20));
3272
- $s8 = $s8->addInt32($s16->mulInt(136657, 18));
3273
- $s9 = $s9->subInt32($s16->mulInt(683901, 20));
3274
-
3275
- $s3 = $s3->addInt32($s15->mulInt(666643, 20));
3276
- $s4 = $s4->addInt32($s15->mulInt(470296, 19));
3277
- $s5 = $s5->addInt32($s15->mulInt(654183, 20));
3278
- $s6 = $s6->subInt32($s15->mulInt(997805, 20));
3279
- $s7 = $s7->addInt32($s15->mulInt(136657, 18));
3280
- $s8 = $s8->subInt32($s15->mulInt(683901, 20));
3281
-
3282
- $s2 = $s2->addInt32($s14->mulInt(666643, 20));
3283
- $s3 = $s3->addInt32($s14->mulInt(470296, 19));
3284
- $s4 = $s4->addInt32($s14->mulInt(654183, 20));
3285
- $s5 = $s5->subInt32($s14->mulInt(997805, 20));
3286
- $s6 = $s6->addInt32($s14->mulInt(136657, 18));
3287
- $s7 = $s7->subInt32($s14->mulInt(683901, 20));
3288
-
3289
- $s1 = $s1->addInt32($s13->mulInt(666643, 20));
3290
- $s2 = $s2->addInt32($s13->mulInt(470296, 19));
3291
- $s3 = $s3->addInt32($s13->mulInt(654183, 20));
3292
- $s4 = $s4->subInt32($s13->mulInt(997805, 20));
3293
- $s5 = $s5->addInt32($s13->mulInt(136657, 18));
3294
- $s6 = $s6->subInt32($s13->mulInt(683901, 20));
3295
-
3296
- $s0 = $s0->addInt32($s12->mulInt(666643, 20));
3297
- $s1 = $s1->addInt32($s12->mulInt(470296, 19));
3298
- $s2 = $s2->addInt32($s12->mulInt(654183, 20));
3299
- $s3 = $s3->subInt32($s12->mulInt(997805, 20));
3300
- $s4 = $s4->addInt32($s12->mulInt(136657, 18));
3301
- $s5 = $s5->subInt32($s12->mulInt(683901, 20));
3302
- $s12 = new ParagonIE_Sodium_Core32_Int32();
3303
-
3304
- $carry0 = $s0->addInt(1 << 20)->shiftRight(21);
3305
- $s1 = $s1->addInt32($carry0);
3306
- $s0 = $s0->subInt32($carry0->shiftLeft(21));
3307
- $carry2 = $s2->addInt(1 << 20)->shiftRight(21);
3308
- $s3 = $s3->addInt32($carry2);
3309
- $s2 = $s2->subInt32($carry2->shiftLeft(21));
3310
- $carry4 = $s4->addInt(1 << 20)->shiftRight(21);
3311
- $s5 = $s5->addInt32($carry4);
3312
- $s4 = $s4->subInt32($carry4->shiftLeft(21));
3313
- $carry6 = $s6->addInt(1 << 20)->shiftRight(21);
3314
- $s7 = $s7->addInt32($carry6);
3315
- $s6 = $s6->subInt32($carry6->shiftLeft(21));
3316
- $carry8 = $s8->addInt(1 << 20)->shiftRight(21);
3317
- $s9 = $s9->addInt32($carry8);
3318
- $s8 = $s8->subInt32($carry8->shiftLeft(21));
3319
- $carry10 = $s10->addInt(1 << 20)->shiftRight(21);
3320
- $s11 = $s11->addInt32($carry10);
3321
- $s10 = $s10->subInt32($carry10->shiftLeft(21));
3322
- $carry1 = $s1->addInt(1 << 20)->shiftRight(21);
3323
- $s2 = $s2->addInt32($carry1);
3324
- $s1 = $s1->subInt32($carry1->shiftLeft(21));
3325
- $carry3 = $s3->addInt(1 << 20)->shiftRight(21);
3326
- $s4 = $s4->addInt32($carry3);
3327
- $s3 = $s3->subInt32($carry3->shiftLeft(21));
3328
- $carry5 = $s5->addInt(1 << 20)->shiftRight(21);
3329
- $s6 = $s6->addInt32($carry5);
3330
- $s5 = $s5->subInt32($carry5->shiftLeft(21));
3331
- $carry7 = $s7->addInt(1 << 20)->shiftRight(21);
3332
- $s8 = $s8->addInt32($carry7);
3333
- $s7 = $s7->subInt32($carry7->shiftLeft(21));
3334
- $carry9 = $s9->addInt(1 << 20)->shiftRight(21);
3335
- $s10 = $s10->addInt32($carry9);
3336
- $s9 = $s9->subInt32($carry9->shiftLeft(21));
3337
- $carry11 = $s11->addInt(1 << 20)->shiftRight(21);
3338
- $s12 = $s12->addInt32($carry11);
3339
- $s11 = $s11->subInt32($carry11->shiftLeft(21));
3340
-
3341
- $s0 = $s0->addInt32($s12->mulInt(666643, 20));
3342
- $s1 = $s1->addInt32($s12->mulInt(470296, 19));
3343
- $s2 = $s2->addInt32($s12->mulInt(654183, 20));
3344
- $s3 = $s3->subInt32($s12->mulInt(997805, 20));
3345
- $s4 = $s4->addInt32($s12->mulInt(136657, 18));
3346
- $s5 = $s5->subInt32($s12->mulInt(683901, 20));
3347
- $s12 = new ParagonIE_Sodium_Core32_Int32();
3348
-
3349
- $carry0 = $s0->shiftRight(21);
3350
- $s1 = $s1->addInt32($carry0);
3351
- $s0 = $s0->subInt32($carry0->shiftLeft(21));
3352
- $carry1 = $s1->shiftRight(21);
3353
- $s2 = $s2->addInt32($carry1);
3354
- $s1 = $s1->subInt32($carry1->shiftLeft(21));
3355
- $carry2 = $s2->shiftRight(21);
3356
- $s3 = $s3->addInt32($carry2);
3357
- $s2 = $s2->subInt32($carry2->shiftLeft(21));
3358
- $carry3 = $s3->shiftRight(21);
3359
- $s4 = $s4->addInt32($carry3);
3360
- $s3 = $s3->subInt32($carry3->shiftLeft(21));
3361
- $carry4 = $s4->shiftRight(21);
3362
- $s5 = $s5->addInt32($carry4);
3363
- $s4 = $s4->subInt32($carry4->shiftLeft(21));
3364
- $carry5 = $s5->shiftRight(21);
3365
- $s6 = $s6->addInt32($carry5);
3366
- $s5 = $s5->subInt32($carry5->shiftLeft(21));
3367
- $carry6 = $s6->shiftRight(21);
3368
- $s7 = $s7->addInt32($carry6);
3369
- $s6 = $s6->subInt32($carry6->shiftLeft(21));
3370
- $carry7 = $s7->shiftRight(21);
3371
- $s8 = $s8->addInt32($carry7);
3372
- $s7 = $s7->subInt32($carry7->shiftLeft(21));
3373
- $carry8 = $s8->shiftRight(21);
3374
- $s9 = $s9->addInt32($carry8);
3375
- $s8 = $s8->subInt32($carry8->shiftLeft(21));
3376
- $carry9 = $s9->shiftRight(21);
3377
- $s10 = $s10->addInt32($carry9);
3378
- $s9 = $s9->subInt32($carry9->shiftLeft(21));
3379
- $carry10 = $s10->shiftRight(21);
3380
- $s11 = $s11->addInt32($carry10);
3381
- $s10 = $s10->subInt32($carry10->shiftLeft(21));
3382
- $carry11 = $s11->shiftRight(21);
3383
- $s12 = $s12->addInt32($carry11);
3384
- $s11 = $s11->subInt32($carry11->shiftLeft(21));
3385
-
3386
- $s0 = $s0->addInt32($s12->mulInt(666643, 20));
3387
- $s1 = $s1->addInt32($s12->mulInt(470296, 19));
3388
- $s2 = $s2->addInt32($s12->mulInt(654183, 20));
3389
- $s3 = $s3->subInt32($s12->mulInt(997805, 20));
3390
- $s4 = $s4->addInt32($s12->mulInt(136657, 18));
3391
- $s5 = $s5->subInt32($s12->mulInt(683901, 20));
3392
-
3393
- $carry0 = $s0->shiftRight(21);
3394
- $s1 = $s1->addInt32($carry0);
3395
- $s0 = $s0->subInt32($carry0->shiftLeft(21));
3396
- $carry1 = $s1->shiftRight(21);
3397
- $s2 = $s2->addInt32($carry1);
3398
- $s1 = $s1->subInt32($carry1->shiftLeft(21));
3399
- $carry2 = $s2->shiftRight(21);
3400
- $s3 = $s3->addInt32($carry2);
3401
- $s2 = $s2->subInt32($carry2->shiftLeft(21));
3402
- $carry3 = $s3->shiftRight(21);
3403
- $s4 = $s4->addInt32($carry3);
3404
- $s3 = $s3->subInt32($carry3->shiftLeft(21));
3405
- $carry4 = $s4->shiftRight(21);
3406
- $s5 = $s5->addInt32($carry4);
3407
- $s4 = $s4->subInt32($carry4->shiftLeft(21));
3408
- $carry5 = $s5->shiftRight(21);
3409
- $s6 = $s6->addInt32($carry5);
3410
- $s5 = $s5->subInt32($carry5->shiftLeft(21));
3411
- $carry6 = $s6->shiftRight(21);
3412
- $s7 = $s7->addInt32($carry6);
3413
- $s6 = $s6->subInt32($carry6->shiftLeft(21));
3414
- $carry7 = $s7->shiftRight(21);
3415
- $s8 = $s8->addInt32($carry7);
3416
- $s7 = $s7->subInt32($carry7->shiftLeft(21));
3417
- $carry8 = $s8->shiftRight(21);
3418
- $s9 = $s9->addInt32($carry8);
3419
- $s8 = $s8->subInt32($carry8->shiftLeft(21));
3420
- $carry9 = $s9->shiftRight(21);
3421
- $s10 = $s10->addInt32($carry9);
3422
- $s9 = $s9->subInt32($carry9->shiftLeft(21));
3423
- $carry10 = $s10->shiftRight(21);
3424
- $s11 = $s11->addInt32($carry10);
3425
- $s10 = $s10->subInt32($carry10->shiftLeft(21));
3426
-
3427
- $S0 = $s0->toInt();
3428
- $S1 = $s1->toInt();
3429
- $S2 = $s2->toInt();
3430
- $S3 = $s3->toInt();
3431
- $S4 = $s4->toInt();
3432
- $S5 = $s5->toInt();
3433
- $S6 = $s6->toInt();
3434
- $S7 = $s7->toInt();
3435
- $S8 = $s8->toInt();
3436
- $S9 = $s9->toInt();
3437
- $S10 = $s10->toInt();
3438
- $S11 = $s11->toInt();
3439
-
3440
- /**
3441
- * @var array<int, int>
3442
- */
3443
- $arr = array(
3444
- (int) ($S0 >> 0),
3445
- (int) ($S0 >> 8),
3446
- (int) (($S0 >> 16) | ($S1 << 5)),
3447
- (int) ($S1 >> 3),
3448
- (int) ($S1 >> 11),
3449
- (int) (($S1 >> 19) | ($S2 << 2)),
3450
- (int) ($S2 >> 6),
3451
- (int) (($S2 >> 14) | ($S3 << 7)),
3452
- (int) ($S3 >> 1),
3453
- (int) ($S3 >> 9),
3454
- (int) (($S3 >> 17) | ($S4 << 4)),
3455
- (int) ($S4 >> 4),
3456
- (int) ($S4 >> 12),
3457
- (int) (($S4 >> 20) | ($S5 << 1)),
3458
- (int) ($S5 >> 7),
3459
- (int) (($S5 >> 15) | ($S6 << 6)),
3460
- (int) ($S6 >> 2),
3461
- (int) ($S6 >> 10),
3462
- (int) (($S6 >> 18) | ($S7 << 3)),
3463
- (int) ($S7 >> 5),
3464
- (int) ($S7 >> 13),
3465
- (int) ($S8 >> 0),
3466
- (int) ($S8 >> 8),
3467
- (int) (($S8 >> 16) | ($S9 << 5)),
3468
- (int) ($S9 >> 3),
3469
- (int) ($S9 >> 11),
3470
- (int) (($S9 >> 19) | ($S10 << 2)),
3471
- (int) ($S10 >> 6),
3472
- (int) (($S10 >> 14) | ($S11 << 7)),
3473
- (int) ($S11 >> 1),
3474
- (int) ($S11 >> 9),
3475
- (int) $S11 >> 17
3476
- );
3477
- return self::intArrayToString($arr);
3478
- }
3479
-
3480
  /**
3481
  * multiply by the order of the main subgroup l = 2^252+27742317777372353535851937790883648493
3482
  *
103
  * @param ParagonIE_Sodium_Core32_Curve25519_Fe $g
104
  * @param int $b
105
  * @return ParagonIE_Sodium_Core32_Curve25519_Fe
106
+ * @throws SodiumException
107
  * @throws TypeError
108
  * @psalm-suppress MixedAssignment
109
  * @psalm-suppress MixedMethodCall
507
  $f7_2 = $f7->shiftLeft(1);
508
  /** @var ParagonIE_Sodium_Core32_Int64 $f9_2 */
509
  $f9_2 = $f9->shiftLeft(1);
510
+ $f0g0 = $f0->mulInt64($g0, 27);
511
+ $f0g1 = $f0->mulInt64($g1, 27);
512
+ $f0g2 = $f0->mulInt64($g2, 27);
513
+ $f0g3 = $f0->mulInt64($g3, 27);
514
+ $f0g4 = $f0->mulInt64($g4, 27);
515
+ $f0g5 = $f0->mulInt64($g5, 27);
516
+ $f0g6 = $f0->mulInt64($g6, 27);
517
+ $f0g7 = $f0->mulInt64($g7, 27);
518
+ $f0g8 = $f0->mulInt64($g8, 27);
519
+ $f0g9 = $f0->mulInt64($g9, 27);
520
+ $f1g0 = $f1->mulInt64($g0, 27);
521
+ $f1g1_2 = $f1_2->mulInt64($g1, 27);
522
+ $f1g2 = $f1->mulInt64($g2, 27);
523
+ $f1g3_2 = $f1_2->mulInt64($g3, 27);
524
+ $f1g4 = $f1->mulInt64($g4, 30);
525
+ $f1g5_2 = $f1_2->mulInt64($g5, 30);
526
+ $f1g6 = $f1->mulInt64($g6, 30);
527
+ $f1g7_2 = $f1_2->mulInt64($g7, 30);
528
+ $f1g8 = $f1->mulInt64($g8, 30);
529
+ $f1g9_38 = $g9_19->mulInt64($f1_2, 30);
530
+ $f2g0 = $f2->mulInt64($g0, 30);
531
+ $f2g1 = $f2->mulInt64($g1, 29);
532
+ $f2g2 = $f2->mulInt64($g2, 30);
533
+ $f2g3 = $f2->mulInt64($g3, 29);
534
+ $f2g4 = $f2->mulInt64($g4, 30);
535
+ $f2g5 = $f2->mulInt64($g5, 29);
536
+ $f2g6 = $f2->mulInt64($g6, 30);
537
+ $f2g7 = $f2->mulInt64($g7, 29);
538
+ $f2g8_19 = $g8_19->mulInt64($f2, 30);
539
+ $f2g9_19 = $g9_19->mulInt64($f2, 30);
540
+ $f3g0 = $f3->mulInt64($g0, 30);
541
+ $f3g1_2 = $f3_2->mulInt64($g1, 30);
542
+ $f3g2 = $f3->mulInt64($g2, 30);
543
+ $f3g3_2 = $f3_2->mulInt64($g3, 30);
544
+ $f3g4 = $f3->mulInt64($g4, 30);
545
+ $f3g5_2 = $f3_2->mulInt64($g5, 30);
546
+ $f3g6 = $f3->mulInt64($g6, 30);
547
+ $f3g7_38 = $g7_19->mulInt64($f3_2, 30);
548
+ $f3g8_19 = $g8_19->mulInt64($f3, 30);
549
+ $f3g9_38 = $g9_19->mulInt64($f3_2, 30);
550
+ $f4g0 = $f4->mulInt64($g0, 30);
551
+ $f4g1 = $f4->mulInt64($g1, 30);
552
+ $f4g2 = $f4->mulInt64($g2, 30);
553
+ $f4g3 = $f4->mulInt64($g3, 30);
554
+ $f4g4 = $f4->mulInt64($g4, 30);
555
+ $f4g5 = $f4->mulInt64($g5, 30);
556
+ $f4g6_19 = $g6_19->mulInt64($f4, 30);
557
+ $f4g7_19 = $g7_19->mulInt64($f4, 30);
558
+ $f4g8_19 = $g8_19->mulInt64($f4, 30);
559
+ $f4g9_19 = $g9_19->mulInt64($f4, 30);
560
+ $f5g0 = $f5->mulInt64($g0, 30);
561
+ $f5g1_2 = $f5_2->mulInt64($g1, 30);
562
+ $f5g2 = $f5->mulInt64($g2, 30);
563
+ $f5g3_2 = $f5_2->mulInt64($g3, 30);
564
+ $f5g4 = $f5->mulInt64($g4, 30);
565
+ $f5g5_38 = $g5_19->mulInt64($f5_2, 30);
566
+ $f5g6_19 = $g6_19->mulInt64($f5, 30);
567
+ $f5g7_38 = $g7_19->mulInt64($f5_2, 30);
568
+ $f5g8_19 = $g8_19->mulInt64($f5, 30);
569
+ $f5g9_38 = $g9_19->mulInt64($f5_2, 30);
570
+ $f6g0 = $f6->mulInt64($g0, 30);
571
+ $f6g1 = $f6->mulInt64($g1, 30);
572
+ $f6g2 = $f6->mulInt64($g2, 30);
573
+ $f6g3 = $f6->mulInt64($g3, 30);
574
+ $f6g4_19 = $g4_19->mulInt64($f6, 30);
575
+ $f6g5_19 = $g5_19->mulInt64($f6, 30);
576
+ $f6g6_19 = $g6_19->mulInt64($f6, 30);
577
+ $f6g7_19 = $g7_19->mulInt64($f6, 30);
578
+ $f6g8_19 = $g8_19->mulInt64($f6, 30);
579
+ $f6g9_19 = $g9_19->mulInt64($f6, 30);
580
+ $f7g0 = $f7->mulInt64($g0, 30);
581
+ $f7g1_2 = $g1->mulInt64($f7_2, 30);
582
+ $f7g2 = $f7->mulInt64($g2, 30);
583
+ $f7g3_38 = $g3_19->mulInt64($f7_2, 30);
584
+ $f7g4_19 = $g4_19->mulInt64($f7, 30);
585
+ $f7g5_38 = $g5_19->mulInt64($f7_2, 30);
586
+ $f7g6_19 = $g6_19->mulInt64($f7, 30);
587
+ $f7g7_38 = $g7_19->mulInt64($f7_2, 30);
588
+ $f7g8_19 = $g8_19->mulInt64($f7, 30);
589
+ $f7g9_38 = $g9_19->mulInt64($f7_2, 30);
590
+ $f8g0 = $f8->mulInt64($g0, 30);
591
+ $f8g1 = $f8->mulInt64($g1, 29);
592
+ $f8g2_19 = $g2_19->mulInt64($f8, 30);
593
+ $f8g3_19 = $g3_19->mulInt64($f8, 30);
594
+ $f8g4_19 = $g4_19->mulInt64($f8, 30);
595
+ $f8g5_19 = $g5_19->mulInt64($f8, 30);
596
+ $f8g6_19 = $g6_19->mulInt64($f8, 30);
597
+ $f8g7_19 = $g7_19->mulInt64($f8, 30);
598
+ $f8g8_19 = $g8_19->mulInt64($f8, 30);
599
+ $f8g9_19 = $g9_19->mulInt64($f8, 30);
600
+ $f9g0 = $f9->mulInt64($g0, 30);
601
+ $f9g1_38 = $g1_19->mulInt64($f9_2, 30);
602
+ $f9g2_19 = $g2_19->mulInt64($f9, 30);
603
+ $f9g3_38 = $g3_19->mulInt64($f9_2, 30);
604
+ $f9g4_19 = $g4_19->mulInt64($f9, 30);
605
+ $f9g5_38 = $g5_19->mulInt64($f9_2, 30);
606
+ $f9g6_19 = $g6_19->mulInt64($f9, 30);
607
+ $f9g7_38 = $g7_19->mulInt64($f9_2, 30);
608
+ $f9g8_19 = $g8_19->mulInt64($f9, 30);
609
+ $f9g9_38 = $g9_19->mulInt64($f9_2, 30);
610
 
611
  // $h0 = $f0g0 + $f1g9_38 + $f2g8_19 + $f3g7_38 + $f4g6_19 + $f5g5_38 + $f6g4_19 + $f7g3_38 + $f8g2_19 + $f9g1_38;
612
  $h0 = $f0g0->addInt64($f1g9_38)->addInt64($f2g8_19)->addInt64($f3g7_38)
716
  $h8 = $h8->subInt64($carry8->shiftLeft(26));
717
 
718
  $carry9 = $h9->addInt(1 << 24)->shiftRight(25);
719
+ $h0 = $h0->addInt64($carry9->mulInt(19, 5));
720
  $h9 = $h9->subInt64($carry9->shiftLeft(25));
721
 
722
  $carry0 = $h0->addInt(1 << 25)->shiftRight(26);
811
  $f8_19 = $f8->mulInt(19, 5);
812
  $f9_38 = $f9->mulInt(38, 6);
813
  /** @var ParagonIE_Sodium_Core32_Int64 $f0f0*/
814
+ $f0f0 = $f0->mulInt64($f0, 28);
815
+ $f0f1_2 = $f0_2->mulInt64($f1, 28);
816
+ $f0f2_2 = $f0_2->mulInt64($f2, 28);
817
+ $f0f3_2 = $f0_2->mulInt64($f3, 28);
818
+ $f0f4_2 = $f0_2->mulInt64($f4, 28);
819
+ $f0f5_2 = $f0_2->mulInt64($f5, 28);
820
+ $f0f6_2 = $f0_2->mulInt64($f6, 28);
821
+ $f0f7_2 = $f0_2->mulInt64($f7, 28);
822
+ $f0f8_2 = $f0_2->mulInt64($f8, 28);
823
+ $f0f9_2 = $f0_2->mulInt64($f9, 28);
824
+
825
+ $f1f1_2 = $f1_2->mulInt64($f1, 28);
826
+ $f1f2_2 = $f1_2->mulInt64($f2, 28);
827
+ $f1f3_4 = $f1_2->mulInt64($f3_2, 28);
828
+ $f1f4_2 = $f1_2->mulInt64($f4, 28);
829
+ $f1f5_4 = $f1_2->mulInt64($f5_2, 30);
830
+ $f1f6_2 = $f1_2->mulInt64($f6, 28);
831
+ $f1f7_4 = $f1_2->mulInt64($f7_2, 28);
832
+ $f1f8_2 = $f1_2->mulInt64($f8, 28);
833
+ $f1f9_76 = $f9_38->mulInt64($f1_2, 30);
834
+
835
+ $f2f2 = $f2->mulInt64($f2, 28);
836
+ $f2f3_2 = $f2_2->mulInt64($f3, 28);
837
+ $f2f4_2 = $f2_2->mulInt64($f4, 28);
838
+ $f2f5_2 = $f2_2->mulInt64($f5, 28);
839
+ $f2f6_2 = $f2_2->mulInt64($f6, 28);
840
+ $f2f7_2 = $f2_2->mulInt64($f7, 28);
841
+ $f2f8_38 = $f8_19->mulInt64($f2_2, 30);
842
+ $f2f9_38 = $f9_38->mulInt64($f2, 30);
843
+
844
+ $f3f3_2 = $f3_2->mulInt64($f3, 28);
845
+ $f3f4_2 = $f3_2->mulInt64($f4, 28);
846
+ $f3f5_4 = $f3_2->mulInt64($f5_2, 30);
847
+ $f3f6_2 = $f3_2->mulInt64($f6, 28);
848
+ $f3f7_76 = $f7_38->mulInt64($f3_2, 30);
849
+ $f3f8_38 = $f8_19->mulInt64($f3_2, 30);
850
+ $f3f9_76 = $f9_38->mulInt64($f3_2, 30);
851
+
852
+ $f4f4 = $f4->mulInt64($f4, 28);
853
+ $f4f5_2 = $f4_2->mulInt64($f5, 28);
854
+ $f4f6_38 = $f6_19->mulInt64($f4_2, 30);
855
+ $f4f7_38 = $f7_38->mulInt64($f4, 30);
856
+ $f4f8_38 = $f8_19->mulInt64($f4_2, 30);
857
+ $f4f9_38 = $f9_38->mulInt64($f4, 30);
858
+
859
+ $f5f5_38 = $f5_38->mulInt64($f5, 30);
860
+ $f5f6_38 = $f6_19->mulInt64($f5_2, 30);
861
+ $f5f7_76 = $f7_38->mulInt64($f5_2, 30);
862
+ $f5f8_38 = $f8_19->mulInt64($f5_2, 30);
863
+ $f5f9_76 = $f9_38->mulInt64($f5_2, 30);
864
+
865
+ $f6f6_19 = $f6_19->mulInt64($f6, 30);
866
+ $f6f7_38 = $f7_38->mulInt64($f6, 30);
867
+ $f6f8_38 = $f8_19->mulInt64($f6_2, 30);
868
+ $f6f9_38 = $f9_38->mulInt64($f6, 30);
869
+
870
+ $f7f7_38 = $f7_38->mulInt64($f7, 28);
871
+ $f7f8_38 = $f8_19->mulInt64($f7_2, 30);
872
+ $f7f9_76 = $f9_38->mulInt64($f7_2, 30);
873
+
874
+ $f8f8_19 = $f8_19->mulInt64($f8, 30);
875
+ $f8f9_38 = $f9_38->mulInt64($f8, 30);
876
+
877
+ $f9f9_38 = $f9_38->mulInt64($f9, 28);
878
 
879
  $h0 = $f0f0->addInt64($f1f9_76)->addInt64($f2f8_38)->addInt64($f3f7_76)->addInt64($f4f6_38)->addInt64($f5f5_38);
880
  $h1 = $f0f1_2->addInt64($f2f9_38)->addInt64($f3f8_38)->addInt64($f4f7_38)->addInt64($f5f6_38);
941
  $h8 = $h8->subInt64($carry8->shiftLeft(26));
942
 
943
  $carry9 = $h9->addInt(1 << 24)->shiftRight(25);
944
+ $h0 = $h0->addInt64($carry9->mulInt(19, 5));
945
  $h9 = $h9->subInt64($carry9->shiftLeft(25));
946
 
947
  $carry0 = $h0->addInt(1 << 25)->shiftRight(26);
1013
  $f7_38 = $f7->mulInt(38, 6); /* 1.959375*2^30 */
1014
  $f8_19 = $f8->mulInt(19, 5); /* 1.959375*2^30 */
1015
  $f9_38 = $f9->mulInt(38, 6); /* 1.959375*2^30 */
1016
+ $f0f0 = $f0->mulInt64($f0, 28);
1017
+ $f0f1_2 = $f0_2->mulInt64($f1, 28);
1018
+ $f0f2_2 = $f0_2->mulInt64($f2, 28);
1019
+ $f0f3_2 = $f0_2->mulInt64($f3, 28);
1020
+ $f0f4_2 = $f0_2->mulInt64($f4, 28);
1021
+ $f0f5_2 = $f0_2->mulInt64($f5, 28);
1022
+ $f0f6_2 = $f0_2->mulInt64($f6, 28);
1023
+ $f0f7_2 = $f0_2->mulInt64($f7, 28);
1024
+ $f0f8_2 = $f0_2->mulInt64($f8, 28);
1025
+ $f0f9_2 = $f0_2->mulInt64($f9, 28);
1026
+ $f1f1_2 = $f1_2->mulInt64($f1, 28);
1027
+ $f1f2_2 = $f1_2->mulInt64($f2, 28);
1028
+ $f1f3_4 = $f1_2->mulInt64($f3_2, 29);
1029
+ $f1f4_2 = $f1_2->mulInt64($f4, 28);
1030
+ $f1f5_4 = $f1_2->mulInt64($f5_2, 29);
1031
+ $f1f6_2 = $f1_2->mulInt64($f6, 28);
1032
+ $f1f7_4 = $f1_2->mulInt64($f7_2, 29);
1033
+ $f1f8_2 = $f1_2->mulInt64($f8, 28);
1034
+ $f1f9_76 = $f9_38->mulInt64($f1_2, 29);
1035
+ $f2f2 = $f2->mulInt64($f2, 28);
1036
+ $f2f3_2 = $f2_2->mulInt64($f3, 28);
1037
+ $f2f4_2 = $f2_2->mulInt64($f4, 28);
1038
+ $f2f5_2 = $f2_2->mulInt64($f5, 28);
1039
+ $f2f6_2 = $f2_2->mulInt64($f6, 28);
1040
+ $f2f7_2 = $f2_2->mulInt64($f7, 28);
1041
+ $f2f8_38 = $f8_19->mulInt64($f2_2, 29);
1042
+ $f2f9_38 = $f9_38->mulInt64($f2, 29);
1043
+ $f3f3_2 = $f3_2->mulInt64($f3, 28);
1044
+ $f3f4_2 = $f3_2->mulInt64($f4, 28);
1045
+ $f3f5_4 = $f3_2->mulInt64($f5_2, 28);
1046
+ $f3f6_2 = $f3_2->mulInt64($f6, 28);
1047
+ $f3f7_76 = $f7_38->mulInt64($f3_2, 29);
1048
+ $f3f8_38 = $f8_19->mulInt64($f3_2, 29);
1049
+ $f3f9_76 = $f9_38->mulInt64($f3_2, 29);
1050
+ $f4f4 = $f4->mulInt64($f4, 28);
1051
+ $f4f5_2 = $f4_2->mulInt64($f5, 28);
1052
+ $f4f6_38 = $f6_19->mulInt64($f4_2, 29);
1053
+ $f4f7_38 = $f7_38->mulInt64($f4, 29);
1054
+ $f4f8_38 = $f8_19->mulInt64($f4_2, 29);
1055
+ $f4f9_38 = $f9_38->mulInt64($f4, 29);
1056
+ $f5f5_38 = $f5_38->mulInt64($f5, 29);
1057
+ $f5f6_38 = $f6_19->mulInt64($f5_2, 29);
1058
+ $f5f7_76 = $f7_38->mulInt64($f5_2, 29);
1059
+ $f5f8_38 = $f8_19->mulInt64($f5_2, 29);
1060
+ $f5f9_76 = $f9_38->mulInt64($f5_2, 29);
1061
+ $f6f6_19 = $f6_19->mulInt64($f6, 29);
1062
+ $f6f7_38 = $f7_38->mulInt64($f6, 29);
1063
+ $f6f8_38 = $f8_19->mulInt64($f6_2, 29);
1064
+ $f6f9_38 = $f9_38->mulInt64($f6, 29);
1065
+ $f7f7_38 = $f7_38->mulInt64($f7, 29);
1066
+ $f7f8_38 = $f8_19->mulInt64($f7_2, 29);
1067
+ $f7f9_76 = $f9_38->mulInt64($f7_2, 29);
1068
+ $f8f8_19 = $f8_19->mulInt64($f8, 29);
1069
+ $f8f9_38 = $f9_38->mulInt64($f8, 29);
1070
+ $f9f9_38 = $f9_38->mulInt64($f9, 29);
1071
 
1072
  $h0 = $f0f0->addInt64($f1f9_76)->addInt64($f2f8_38)->addInt64($f3f7_76)->addInt64($f4f6_38)->addInt64($f5f5_38);
1073
  $h1 = $f0f1_2->addInt64($f2f9_38)->addInt64($f3f8_38)->addInt64($f4f7_38)->addInt64($f5f6_38);
1080
  $h8 = $f0f8_2->addInt64($f1f7_4)->addInt64($f2f6_2)->addInt64($f3f5_4)->addInt64($f4f4)->addInt64($f9f9_38);
1081
  $h9 = $f0f9_2->addInt64($f1f8_2)->addInt64($f2f7_2)->addInt64($f3f6_2)->addInt64($f4f5_2);
1082
 
 
 
 
 
 
 
1083
  /**
1084
  * @var ParagonIE_Sodium_Core32_Int64 $h0
1085
  * @var ParagonIE_Sodium_Core32_Int64 $h1
1139
  $h8 = $h8->subInt64($carry8->shiftLeft(26));
1140
 
1141
  $carry9 = $h9->addInt(1 << 24)->shiftRight(25);
1142
+ $h0 = $h0->addInt64($carry9->mulInt(19, 5));
1143
  $h9 = $h9->subInt64($carry9->shiftLeft(25));
1144
 
1145
  $carry0 = $h0->addInt(1 << 25)->shiftRight(26);
2111
 
2112
  # slide(aslide,a);
2113
  # slide(bslide,b);
2114
+ /** @var array<int, int> $aslide */
2115
  $aslide = self::slide($a);
2116
+ /** @var array<int, int> $bslide */
2117
  $bslide = self::slide($b);
2118
 
2119
  # ge_p3_to_cached(&Ai[0],A);
2282
  */
2283
  public static function sc_muladd($a, $b, $c)
2284
  {
2285
+ $a0 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & self::load_3(self::substr($a, 0, 3)));
2286
+ $a1 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($a, 2, 4)) >> 5));
2287
+ $a2 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($a, 5, 3)) >> 2));
2288
+ $a3 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($a, 7, 4)) >> 7));
2289
+ $a4 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($a, 10, 4)) >> 4));
2290
+ $a5 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($a, 13, 3)) >> 1));
2291
+ $a6 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($a, 15, 4)) >> 6));
2292
+ $a7 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($a, 18, 3)) >> 3));
2293
+ $a8 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & self::load_3(self::substr($a, 21, 3)));
2294
+ $a9 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($a, 23, 4)) >> 5));
2295
+ $a10 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($a, 26, 3)) >> 2));
2296
+ $a11 = ParagonIE_Sodium_Core32_Int64::fromInt(0x1fffffff & (self::load_4(self::substr($a, 28, 4)) >> 7));
2297
+ $b0 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & self::load_3(self::substr($b, 0, 3)));
2298
+ $b1 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($b, 2, 4)) >> 5));
2299
+ $b2 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($b, 5, 3)) >> 2));
2300
+ $b3 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($b, 7, 4)) >> 7));
2301
+ $b4 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($b, 10, 4)) >> 4));
2302
+ $b5 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($b, 13, 3)) >> 1));
2303
+ $b6 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($b, 15, 4)) >> 6));
2304
+ $b7 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($b, 18, 3)) >> 3));
2305
+ $b8 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & self::load_3(self::substr($b, 21, 3)));
2306
+ $b9 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($b, 23, 4)) >> 5));
2307
+ $b10 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($b, 26, 3)) >> 2));
2308
+ $b11 = ParagonIE_Sodium_Core32_Int64::fromInt(0x1fffffff & (self::load_4(self::substr($b, 28, 4)) >> 7));
2309
+ $c0 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & self::load_3(self::substr($c, 0, 3)));
2310
+ $c1 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($c, 2, 4)) >> 5));
2311
+ $c2 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($c, 5, 3)) >> 2));
2312
+ $c3 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($c, 7, 4)) >> 7));
2313
+ $c4 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($c, 10, 4)) >> 4));
2314
+ $c5 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($c, 13, 3)) >> 1));
2315
+ $c6 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($c, 15, 4)) >> 6));
2316
+ $c7 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($c, 18, 3)) >> 3));
2317
+ $c8 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & self::load_3(self::substr($c, 21, 3)));
2318
+ $c9 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($c, 23, 4)) >> 5));
2319
+ $c10 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($c, 26, 3)) >> 2));
2320
+ $c11 = ParagonIE_Sodium_Core32_Int64::fromInt(0x1fffffff & (self::load_4(self::substr($c, 28, 4)) >> 7));
2321
 
2322
  /* Can't really avoid the pyramid here: */
2323
  /**
2350
  $s0 = $c0->addInt64($a0->mulInt64($b0, 24));
2351
  $s1 = $c1->addInt64($a0->mulInt64($b1, 24))->addInt64($a1->mulInt64($b0, 24));
2352
  $s2 = $c2->addInt64($a0->mulInt64($b2, 24))->addInt64($a1->mulInt64($b1, 24))->addInt64($a2->mulInt64($b0, 24));
2353
+ $s3 = $c3->addInt64($a0->mulInt64($b3, 24))->addInt64($a1->mulInt64($b2, 24))->addInt64($a2->mulInt64($b1, 24))
2354
+ ->addInt64($a3->mulInt64($b0, 24));
2355
+ $s4 = $c4->addInt64($a0->mulInt64($b4, 24))->addInt64($a1->mulInt64($b3, 24))->addInt64($a2->mulInt64($b2, 24))
2356
+ ->addInt64($a3->mulInt64($b1, 24))->addInt64($a4->mulInt64($b0, 24));
2357
+ $s5 = $c5->addInt64($a0->mulInt64($b5, 24))->addInt64($a1->mulInt64($b4, 24))->addInt64($a2->mulInt64($b3, 24))
2358
+ ->addInt64($a3->mulInt64($b2, 24))->addInt64($a4->mulInt64($b1, 24))->addInt64($a5->mulInt64($b0, 24));
2359
+ $s6 = $c6->addInt64($a0->mulInt64($b6, 24))->addInt64($a1->mulInt64($b5, 24))->addInt64($a2->mulInt64($b4, 24))
2360
+ ->addInt64($a3->mulInt64($b3, 24))->addInt64($a4->mulInt64($b2, 24))->addInt64($a5->mulInt64($b1, 24))
2361
  ->addInt64($a6->mulInt64($b0, 24));
2362
+ $s7 = $c7->addInt64($a0->mulInt64($b7, 24))->addInt64($a1->mulInt64($b6, 24))->addInt64($a2->mulInt64($b5, 24))
2363
+ ->addInt64($a3->mulInt64($b4, 24))->addInt64($a4->mulInt64($b3, 24))->addInt64($a5->mulInt64($b2, 24))
2364
  ->addInt64($a6->mulInt64($b1, 24))->addInt64($a7->mulInt64($b0, 24));
2365
+ $s8 = $c8->addInt64($a0->mulInt64($b8, 24))->addInt64($a1->mulInt64($b7, 24))->addInt64($a2->mulInt64($b6, 24))
2366
+ ->addInt64($a3->mulInt64($b5, 24))->addInt64($a4->mulInt64($b4, 24))->addInt64($a5->mulInt64($b3, 24))
2367
  ->addInt64($a6->mulInt64($b2, 24))->addInt64($a7->mulInt64($b1, 24))->addInt64($a8->mulInt64($b0, 24));
2368
+ $s9 = $c9->addInt64($a0->mulInt64($b9, 24))->addInt64($a1->mulInt64($b8, 24))->addInt64($a2->mulInt64($b7, 24))
2369
+ ->addInt64($a3->mulInt64($b6, 24))->addInt64($a4->mulInt64($b5, 24))->addInt64($a5->mulInt64($b4, 24))
2370
+ ->addInt64($a6->mulInt64($b3, 24))->addInt64($a7->mulInt64($b2, 24))->addInt64($a8->mulInt64($b1, 24))
2371
+ ->addInt64($a9->mulInt64($b0, 24));
2372
+ $s10 = $c10->addInt64($a0->mulInt64($b10, 24))->addInt64($a1->mulInt64($b9, 24))->addInt64($a2->mulInt64($b8, 24))
2373
+ ->addInt64($a3->mulInt64($b7, 24))->addInt64($a4->mulInt64($b6, 24))->addInt64($a5->mulInt64($b5, 24))
2374
+ ->addInt64($a6->mulInt64($b4, 24))->addInt64($a7->mulInt64($b3, 24))->addInt64($a8->mulInt64($b2, 24))
2375
+ ->addInt64($a9->mulInt64($b1, 24))->addInt64($a10->mulInt64($b0, 24));
2376
+ $s11 = $c11->addInt64($a0->mulInt64($b11, 24))->addInt64($a1->mulInt64($b10, 24))->addInt64($a2->mulInt64($b9, 24))
2377
+ ->addInt64($a3->mulInt64($b8, 24))->addInt64($a4->mulInt64($b7, 24))->addInt64($a5->mulInt64($b6, 24))
2378
+ ->addInt64($a6->mulInt64($b5, 24))->addInt64($a7->mulInt64($b4, 24))->addInt64($a8->mulInt64($b3, 24))
2379
+ ->addInt64($a9->mulInt64($b2, 24))->addInt64($a10->mulInt64($b1, 24))->addInt64($a11->mulInt64($b0, 24));
2380
+ $s12 = $a1->mulInt64($b11, 24)->addInt64($a2->mulInt64($b10, 24))->addInt64($a3->mulInt64($b9, 24))
2381
+ ->addInt64($a4->mulInt64($b8, 24))->addInt64($a5->mulInt64($b7, 24))->addInt64($a6->mulInt64($b6, 24))
2382
+ ->addInt64($a7->mulInt64($b5, 24))->addInt64($a8->mulInt64($b4, 24))->addInt64($a9->mulInt64($b3, 24))
2383
+ ->addInt64($a10->mulInt64($b2, 24))->addInt64($a11->mulInt64($b1, 24));
2384
+ $s13 = $a2->mulInt64($b11, 24)->addInt64($a3->mulInt64($b10, 24))->addInt64($a4->mulInt64($b9, 24))
2385
+ ->addInt64($a5->mulInt64($b8, 24))->addInt64($a6->mulInt64($b7, 24))->addInt64($a7->mulInt64($b6, 24))
2386
+ ->addInt64($a8->mulInt64($b5, 24))->addInt64($a9->mulInt64($b4, 24))->addInt64($a10->mulInt64($b3, 24))
2387
+ ->addInt64($a11->mulInt64($b2, 24));
2388
+ $s14 = $a3->mulInt64($b11, 24)->addInt64($a4->mulInt64($b10, 24))->addInt64($a5->mulInt64($b9, 24))
2389
+ ->addInt64($a6->mulInt64($b8, 24))->addInt64($a7->mulInt64($b7, 24))->addInt64($a8->mulInt64($b6, 24))
2390
  ->addInt64($a9->mulInt64($b5, 24))->addInt64($a10->mulInt64($b4, 24))->addInt64($a11->mulInt64($b3, 24));
2391
+ $s15 = $a4->mulInt64($b11, 24)->addInt64($a5->mulInt64($b10, 24))->addInt64($a6->mulInt64($b9, 24))
2392
+ ->addInt64($a7->mulInt64($b8, 24))->addInt64($a8->mulInt64($b7, 24))->addInt64($a9->mulInt64($b6, 24))
2393
  ->addInt64($a10->mulInt64($b5, 24))->addInt64($a11->mulInt64($b4, 24));
2394
+ $s16 = $a5->mulInt64($b11, 24)->addInt64($a6->mulInt64($b10, 24))->addInt64($a7->mulInt64($b9, 24))
2395
+ ->addInt64($a8->mulInt64($b8, 24))->addInt64($a9->mulInt64($b7, 24))->addInt64($a10->mulInt64($b6, 24))
2396
+ ->addInt64($a11->mulInt64($b5, 24));
2397
+ $s17 = $a6->mulInt64($b11, 24)->addInt64($a7->mulInt64($b10, 24))->addInt64($a8->mulInt64($b9, 24))
2398
+ ->addInt64($a9->mulInt64($b8, 24))->addInt64($a10->mulInt64($b7, 24))->addInt64($a11->mulInt64($b6, 24));
2399
+ $s18 = $a7->mulInt64($b11, 24)->addInt64($a8->mulInt64($b10, 24))->addInt64($a9->mulInt64($b9, 24))
2400
+ ->addInt64($a10->mulInt64($b8, 24))->addInt64($a11->mulInt64($b7, 24));
2401
+ $s19 = $a8->mulInt64($b11, 24)->addInt64($a9->mulInt64($b10, 24))->addInt64($a10->mulInt64($b9, 24))
2402
+ ->addInt64($a11->mulInt64($b8, 24));
2403
  $s20 = $a9->mulInt64($b11, 24)->addInt64($a10->mulInt64($b10, 24))->addInt64($a11->mulInt64($b9, 24));
2404
  $s21 = $a10->mulInt64($b11, 24)->addInt64($a11->mulInt64($b10, 24));
2405
  $s22 = $a11->mulInt64($b11, 24);
2720
  $s11 = $s11->addInt64($carry10);
2721
  $s10 = $s10->subInt64($carry10->shiftLeft(21));
2722
 
2723
+ $S0 = $s0->toInt();
2724
+ $S1 = $s1->toInt();
2725
+ $S2 = $s2->toInt();
2726
+ $S3 = $s3->toInt();
2727
+ $S4 = $s4->toInt();
2728
+ $S5 = $s5->toInt();
2729
+ $S6 = $s6->toInt();
2730
+ $S7 = $s7->toInt();
2731
+ $S8 = $s8->toInt();
2732
+ $S9 = $s9->toInt();
2733
+ $S10 = $s10->toInt();
2734
+ $S11 = $s11->toInt();
2735
 
2736
  /**
2737
  * @var array<int, int>
2809
  * @var ParagonIE_Sodium_Core32_Int64 $s22
2810
  * @var ParagonIE_Sodium_Core32_Int64 $s23
2811
  */
2812
+ $s0 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & self::load_3(self::substr($s, 0, 3)));
2813
+ $s1 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 2, 4)) >> 5));
2814
+ $s2 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($s, 5, 3)) >> 2));
2815
+ $s3 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 7, 4)) >> 7));
2816
+ $s4 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 10, 4)) >> 4));
2817
+ $s5 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($s, 13, 3)) >> 1));
2818
+ $s6 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 15, 4)) >> 6));
2819
+ $s7 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($s, 18, 4)) >> 3));
2820
+ $s8 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & self::load_3(self::substr($s, 21, 3)));
2821
+ $s9 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 23, 4)) >> 5));
2822
+ $s10 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($s, 26, 3)) >> 2));
2823
+ $s11 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 28, 4)) >> 7));
2824
+ $s12 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 31, 4)) >> 4));
2825
+ $s13 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($s, 34, 3)) >> 1));
2826
+ $s14 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 36, 4)) >> 6));
2827
+ $s15 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($s, 39, 4)) >> 3));
2828
+ $s16 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & self::load_3(self::substr($s, 42, 3)));
2829
+ $s17 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 44, 4)) >> 5));
2830
+ $s18 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($s, 47, 3)) >> 2));
2831
+ $s19 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 49, 4)) >> 7));
2832
+ $s20 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 52, 4)) >> 4));
2833
+ $s21 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_3(self::substr($s, 55, 3)) >> 1));
2834
+ $s22 = ParagonIE_Sodium_Core32_Int64::fromInt(2097151 & (self::load_4(self::substr($s, 57, 4)) >> 6));
2835
+ $s23 = ParagonIE_Sodium_Core32_Int64::fromInt(0x1fffffff & (self::load_4(self::substr($s, 60, 4)) >> 3));
2836
 
2837
  $s11 = $s11->addInt64($s23->mulInt(666643, 20));
2838
  $s12 = $s12->addInt64($s23->mulInt(470296, 19));
3130
  return self::intArrayToString($arr);
3131
  }
3132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3133
  /**
3134
  * multiply by the order of the main subgroup l = 2^252+27742317777372353535851937790883648493
3135
  *
vendor/paragonie/sodium_compat/src/Core32/Curve25519/Fe.php CHANGED
@@ -21,15 +21,6 @@ class ParagonIE_Sodium_Core32_Curve25519_Fe implements ArrayAccess
21
  */
22
  protected $size = 10;
23
 
24
- /**
25
- * ParagonIE_Sodium_Core32_Curve25519_Fe constructor.
26
- * @param int $size
27
- */
28
- public function __construct($size = 10)
29
- {
30
- $this->size = 10;
31
- }
32
-
33
  /**
34
  * @internal You should not use this directly from another application
35
  *
@@ -49,7 +40,7 @@ class ParagonIE_Sodium_Core32_Curve25519_Fe implements ArrayAccess
49
  }
50
  $array = array_values($array);
51
 
52
- $obj = new ParagonIE_Sodium_Core32_Curve25519_Fe($count);
53
  if ($save_indexes) {
54
  for ($i = 0; $i < $count; ++$i) {
55
  $array[$i]->overflow = 0;
@@ -89,7 +80,7 @@ class ParagonIE_Sodium_Core32_Curve25519_Fe implements ArrayAccess
89
  $set[$i] = ParagonIE_Sodium_Core32_Int32::fromInt($v);
90
  }
91
 
92
- $obj = new ParagonIE_Sodium_Core32_Curve25519_Fe($count);
93
  if ($save_indexes) {
94
  for ($i = 0; $i < $count; ++$i) {
95
  $set[$i]->overflow = 0;
@@ -189,33 +180,6 @@ class ParagonIE_Sodium_Core32_Curve25519_Fe implements ArrayAccess
189
  (int) ($this->container[8]->toInt()),
190
  (int) ($this->container[9]->toInt())
191
  );
192
-
193
- /*
194
- $c = array(
195
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[0]->toReverseString()),
196
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[1]->toReverseString()),
197
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[2]->toReverseString()),
198
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[3]->toReverseString()),
199
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[4]->toReverseString()),
200
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[5]->toReverseString()),
201
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[6]->toReverseString()),
202
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[7]->toReverseString()),
203
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[8]->toReverseString()),
204
- ParagonIE_Sodium_Core_Util::bin2hex($this->container[9]->toReverseString())
205
- );
206
- $c = array(
207
- json_encode($this->container[0]->limbs),
208
- json_encode($this->container[1]->limbs),
209
- json_encode($this->container[2]->limbs),
210
- json_encode($this->container[3]->limbs),
211
- json_encode($this->container[4]->limbs),
212
- json_encode($this->container[5]->limbs),
213
- json_encode($this->container[6]->limbs),
214
- json_encode($this->container[7]->limbs),
215
- json_encode($this->container[8]->limbs),
216
- json_encode($this->container[9]->limbs)
217
- );
218
- */
219
  return array(implode(', ', $c));
220
  }
221
  }
21
  */
22
  protected $size = 10;
23
 
 
 
 
 
 
 
 
 
 
24
  /**
25
  * @internal You should not use this directly from another application
26
  *
40
  }
41
  $array = array_values($array);
42
 
43
+ $obj = new ParagonIE_Sodium_Core32_Curve25519_Fe();
44
  if ($save_indexes) {
45
  for ($i = 0; $i < $count; ++$i) {
46
  $array[$i]->overflow = 0;
80
  $set[$i] = ParagonIE_Sodium_Core32_Int32::fromInt($v);
81
  }
82
 
83
+ $obj = new ParagonIE_Sodium_Core32_Curve25519_Fe();
84
  if ($save_indexes) {
85
  for ($i = 0; $i < $count; ++$i) {
86
  $set[$i]->overflow = 0;
180
  (int) ($this->container[8]->toInt()),
181
  (int) ($this->container[9]->toInt())
182
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  return array(implode(', ', $c));
184
  }
185
  }
vendor/paragonie/sodium_compat/src/Core32/Ed25519.php CHANGED
@@ -16,6 +16,7 @@ abstract class ParagonIE_Sodium_Core32_Ed25519 extends ParagonIE_Sodium_Core32_C
16
  * @internal You should not use this directly from another application
17
  *
18
  * @return string (96 bytes)
 
19
  * @throws SodiumException
20
  * @throws TypeError
21
  */
16
  * @internal You should not use this directly from another application
17
  *
18
  * @return string (96 bytes)
19
+ * @throws Exception
20
  * @throws SodiumException
21
  * @throws TypeError
22
  */
vendor/paragonie/sodium_compat/src/Core32/Int32.php CHANGED
@@ -15,7 +15,7 @@ class ParagonIE_Sodium_Core32_Int32
15
  * 0 is the higher 16 bits
16
  * 1 is the lower 16 bits
17
  */
18
- public $limbs;
19
 
20
  /**
21
  * @var int
@@ -50,21 +50,25 @@ class ParagonIE_Sodium_Core32_Int32
50
  */
51
  public function addInt32(ParagonIE_Sodium_Core32_Int32 $addend)
52
  {
53
- $return = new ParagonIE_Sodium_Core32_Int32();
54
- $return->unsignedInt = $this->unsignedInt;
 
 
55
 
56
- /** @var int $tmp */
57
- $tmp = $this->limbs[1] + $addend->limbs[1];
58
- /** @var int $carry */
59
- $carry = $tmp >> 16;
60
- $return->limbs[1] = (int) ($tmp & 0xffff);
61
 
62
- /** @var int $tmp */
63
- $tmp = $this->limbs[0] + $addend->limbs[0] + $carry;
64
- $return->limbs[0] = (int) ($tmp & 0xffff);
65
- /** @var int overflow */
66
- $return->overflow = $this->overflow + $addend->overflow + ($tmp >> 16);
67
 
 
 
 
 
 
68
  return $return;
69
  }
70
 
@@ -79,21 +83,26 @@ class ParagonIE_Sodium_Core32_Int32
79
  public function addInt($int)
80
  {
81
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
 
 
82
 
83
- $return = new ParagonIE_Sodium_Core32_Int32();
84
- $return->unsignedInt = $this->unsignedInt;
85
 
86
- /** @var int $tmp */
87
- $tmp = ($this->limbs[1] & 0xffff) + ($int & 0xffff);
88
- /** @var int $carry */
89
- $carry = $tmp >> 16;
90
- $return->limbs[1] = (int) ($tmp & 0xffff);
91
 
92
- /** @var int $tmp */
93
- $tmp = $this->limbs[0] + (($int >> 16) & 0xffff) + $carry;
94
- $return->limbs[0] = (int) ($tmp & 0xffff);
95
- /** @var int overflow */
96
- $return->overflow = $this->overflow + ($tmp >> 16);
 
 
 
 
 
 
 
97
  return $return;
98
  }
99
 
@@ -152,6 +161,11 @@ class ParagonIE_Sodium_Core32_Int32
152
  {
153
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
154
  ParagonIE_Sodium_Core32_Util::declareScalarType($size, 'int', 2);
 
 
 
 
 
155
  if (!$size) {
156
  $size = 31;
157
  }
@@ -161,12 +175,36 @@ class ParagonIE_Sodium_Core32_Int32
161
  $return = new ParagonIE_Sodium_Core32_Int32();
162
  $return->unsignedInt = $this->unsignedInt;
163
 
 
 
 
 
 
 
 
 
164
  for ($i = $size; $i >= 0; --$i) {
165
  $m = (int) (-($int & 1));
166
- $return = $return->addInt32($a->mask($m));
167
- $a = $a->shiftLeft(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  $int >>= 1;
169
  }
 
 
170
  return $return;
171
  }
172
 
@@ -190,13 +228,46 @@ class ParagonIE_Sodium_Core32_Int32
190
  $return = new ParagonIE_Sodium_Core32_Int32();
191
  $return->unsignedInt = $this->unsignedInt;
192
 
 
 
 
 
 
 
 
 
 
193
  /** @var int $i */
194
  for ($i = $size; $i >= 0; --$i) {
195
- $m = (int) (-($b->limbs[1] & 1));
196
- $return = $return->addInt32($a->mask($m));
197
- $a = $a->shiftLeft(1);
198
- $b = $b->shiftRight(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
 
 
 
200
  return $return;
201
  }
202
 
@@ -247,6 +318,8 @@ class ParagonIE_Sodium_Core32_Int32
247
  public function rotateLeft($c = 0)
248
  {
249
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
 
 
250
 
251
  $return = new ParagonIE_Sodium_Core32_Int32();
252
  $return->unsignedInt = $this->unsignedInt;
@@ -276,9 +349,9 @@ class ParagonIE_Sodium_Core32_Int32
276
  $k = ($i + $idx_shift + 1) & 1;
277
  $limbs[$i] = (int) (
278
  (
279
- ($myLimbs[$j] << $sub_shift)
280
  |
281
- ($myLimbs[$k] >> (16 - $sub_shift))
282
  ) & 0xffff
283
  );
284
  }
@@ -298,6 +371,8 @@ class ParagonIE_Sodium_Core32_Int32
298
  public function rotateRight($c = 0)
299
  {
300
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
 
 
301
 
302
  $return = new ParagonIE_Sodium_Core32_Int32();
303
  $return->unsignedInt = $this->unsignedInt;
@@ -328,9 +403,9 @@ class ParagonIE_Sodium_Core32_Int32
328
  $k = ($i - $idx_shift - 1) & 1;
329
  $limbs[$i] = (int) (
330
  (
331
- ($myLimbs[$j] >> (int) ($sub_shift))
332
  |
333
- ($myLimbs[$k] << (16 - (int) ($sub_shift)))
334
  ) & 0xffff
335
  );
336
  }
@@ -357,6 +432,9 @@ class ParagonIE_Sodium_Core32_Int32
357
  public function shiftLeft($c = 0)
358
  {
359
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
 
 
 
360
  $return = new ParagonIE_Sodium_Core32_Int32();
361
  $return->unsignedInt = $this->unsignedInt;
362
  $c &= 63;
@@ -392,6 +470,9 @@ class ParagonIE_Sodium_Core32_Int32
392
  public function shiftRight($c = 0)
393
  {
394
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
 
 
 
395
  $return = new ParagonIE_Sodium_Core32_Int32();
396
  $return->unsignedInt = $this->unsignedInt;
397
  $c &= 63;
@@ -435,6 +516,8 @@ class ParagonIE_Sodium_Core32_Int32
435
  public function subInt($int)
436
  {
437
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
 
 
438
 
439
  $return = new ParagonIE_Sodium_Core32_Int32();
440
  $return->unsignedInt = $this->unsignedInt;
@@ -500,6 +583,8 @@ class ParagonIE_Sodium_Core32_Int32
500
  public static function fromInt($signed)
501
  {
502
  ParagonIE_Sodium_Core32_Util::declareScalarType($signed, 'int', 1);;
 
 
503
 
504
  return new ParagonIE_Sodium_Core32_Int32(
505
  array(
15
  * 0 is the higher 16 bits
16
  * 1 is the lower 16 bits
17
  */
18
+ public $limbs = array(0, 0);
19
 
20
  /**
21
  * @var int
50
  */
51
  public function addInt32(ParagonIE_Sodium_Core32_Int32 $addend)
52
  {
53
+ $i0 = $this->limbs[0];
54
+ $i1 = $this->limbs[1];
55
+ $j0 = $addend->limbs[0];
56
+ $j1 = $addend->limbs[1];
57
 
58
+ $r1 = $i1 + ($j1 & 0xffff);
59
+ $carry = $r1 >> 16;
 
 
 
60
 
61
+ $r0 = $i0 + ($j0 & 0xffff) + $carry;
62
+ $carry = $r0 >> 16;
63
+
64
+ $r0 &= 0xffff;
65
+ $r1 &= 0xffff;
66
 
67
+ $return = new ParagonIE_Sodium_Core32_Int32(
68
+ array($r0, $r1)
69
+ );
70
+ $return->overflow = $carry;
71
+ $return->unsignedInt = $this->unsignedInt;
72
  return $return;
73
  }
74
 
83
  public function addInt($int)
84
  {
85
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
86
+ /** @var int $int */
87
+ $int = (int) $int;
88
 
89
+ $int = (int) $int;
 
90
 
91
+ $i0 = $this->limbs[0];
92
+ $i1 = $this->limbs[1];
 
 
 
93
 
94
+ $r1 = $i1 + ($int & 0xffff);
95
+ $carry = $r1 >> 16;
96
+
97
+ $r0 = $i0 + (($int >> 16) & 0xffff) + $carry;
98
+ $carry = $r0 >> 16;
99
+ $r0 &= 0xffff;
100
+ $r1 &= 0xffff;
101
+ $return = new ParagonIE_Sodium_Core32_Int32(
102
+ array($r0, $r1)
103
+ );
104
+ $return->overflow = $carry;
105
+ $return->unsignedInt = $this->unsignedInt;
106
  return $return;
107
  }
108
 
161
  {
162
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
163
  ParagonIE_Sodium_Core32_Util::declareScalarType($size, 'int', 2);
164
+ /** @var int $int */
165
+ $int = (int) $int;
166
+ /** @var int $size */
167
+ $size = (int) $size;
168
+
169
  if (!$size) {
170
  $size = 31;
171
  }
175
  $return = new ParagonIE_Sodium_Core32_Int32();
176
  $return->unsignedInt = $this->unsignedInt;
177
 
178
+ // Initialize:
179
+ $ret0 = 0;
180
+ $ret1 = 0;
181
+ $a0 = $a->limbs[0];
182
+ $a1 = $a->limbs[1];
183
+
184
+ /** @var int $size */
185
+ /** @var int $i */
186
  for ($i = $size; $i >= 0; --$i) {
187
  $m = (int) (-($int & 1));
188
+ $x0 = $a0 & $m;
189
+ $x1 = $a1 & $m;
190
+
191
+ $ret1 += $x1;
192
+ $c = $ret1 >> 16;
193
+
194
+ $ret0 += $x0 + $c;
195
+
196
+ $ret0 &= 0xffff;
197
+ $ret1 &= 0xffff;
198
+
199
+ $a1 = ($a1 << 1);
200
+ $x1 = $a1 >> 16;
201
+ $a0 = ($a0 << 1) | $x1;
202
+ $a0 &= 0xffff;
203
+ $a1 &= 0xffff;
204
  $int >>= 1;
205
  }
206
+ $return->limbs[0] = $ret0;
207
+ $return->limbs[1] = $ret1;
208
  return $return;
209
  }
210
 
228
  $return = new ParagonIE_Sodium_Core32_Int32();
229
  $return->unsignedInt = $this->unsignedInt;
230
 
231
+ // Initialize:
232
+ $ret0 = 0;
233
+ $ret1 = 0;
234
+ $a0 = $a->limbs[0];
235
+ $a1 = $a->limbs[1];
236
+ $b0 = $b->limbs[0];
237
+ $b1 = $b->limbs[1];
238
+
239
+ /** @var int $size */
240
  /** @var int $i */
241
  for ($i = $size; $i >= 0; --$i) {
242
+ $m = (int) (-($b1 & 1));
243
+ $x0 = $a0 & $m;
244
+ $x1 = $a1 & $m;
245
+
246
+ $ret1 += $x1;
247
+ $c = $ret1 >> 16;
248
+
249
+ $ret0 += $x0 + $c;
250
+
251
+ $ret0 &= 0xffff;
252
+ $ret1 &= 0xffff;
253
+
254
+ $a1 = ($a1 << 1);
255
+ $x1 = $a1 >> 16;
256
+ $a0 = ($a0 << 1) | $x1;
257
+ $a0 &= 0xffff;
258
+ $a1 &= 0xffff;
259
+
260
+ $x0 = ($b0 & 1) << 16;
261
+ $b0 = ($b0 >> 1);
262
+ $b1 = (($b1 | $x0) >> 1);
263
+
264
+ $b0 &= 0xffff;
265
+ $b1 &= 0xffff;
266
+
267
  }
268
+ $return->limbs[0] = $ret0;
269
+ $return->limbs[1] = $ret1;
270
+
271
  return $return;
272
  }
273
 
318
  public function rotateLeft($c = 0)
319
  {
320
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
321
+ /** @var int $c */
322
+ $c = (int) $c;
323
 
324
  $return = new ParagonIE_Sodium_Core32_Int32();
325
  $return->unsignedInt = $this->unsignedInt;
349
  $k = ($i + $idx_shift + 1) & 1;
350
  $limbs[$i] = (int) (
351
  (
352
+ ((int) ($myLimbs[$j]) << $sub_shift)
353
  |
354
+ ((int) ($myLimbs[$k]) >> (16 - $sub_shift))
355
  ) & 0xffff
356
  );
357
  }
371
  public function rotateRight($c = 0)
372
  {
373
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
374
+ /** @var int $c */
375
+ $c = (int) $c;
376
 
377
  $return = new ParagonIE_Sodium_Core32_Int32();
378
  $return->unsignedInt = $this->unsignedInt;
403
  $k = ($i - $idx_shift - 1) & 1;
404
  $limbs[$i] = (int) (
405
  (
406
+ ((int) ($myLimbs[$j]) >> (int) ($sub_shift))
407
  |
408
+ ((int) ($myLimbs[$k]) << (16 - (int) ($sub_shift)))
409
  ) & 0xffff
410
  );
411
  }
432
  public function shiftLeft($c = 0)
433
  {
434
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
435
+ /** @var int $c */
436
+ $c = (int) $c;
437
+
438
  $return = new ParagonIE_Sodium_Core32_Int32();
439
  $return->unsignedInt = $this->unsignedInt;
440
  $c &= 63;
470
  public function shiftRight($c = 0)
471
  {
472
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
473
+ /** @var int $c */
474
+ $c = (int) $c;
475
+
476
  $return = new ParagonIE_Sodium_Core32_Int32();
477
  $return->unsignedInt = $this->unsignedInt;
478
  $c &= 63;
516
  public function subInt($int)
517
  {
518
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
519
+ /** @var int $int */
520
+ $int = (int) $int;
521
 
522
  $return = new ParagonIE_Sodium_Core32_Int32();
523
  $return->unsignedInt = $this->unsignedInt;
583
  public static function fromInt($signed)
584
  {
585
  ParagonIE_Sodium_Core32_Util::declareScalarType($signed, 'int', 1);;
586
+ /** @var int $signed */
587
+ $signed = (int) $signed;
588
 
589
  return new ParagonIE_Sodium_Core32_Int32(
590
  array(
vendor/paragonie/sodium_compat/src/Core32/Int64.php CHANGED
@@ -12,7 +12,7 @@ class ParagonIE_Sodium_Core32_Int64
12
  /**
13
  * @var array<int, int> - four 16-bit integers
14
  */
15
- public $limbs;
16
 
17
  /**
18
  * @var int
@@ -49,18 +49,37 @@ class ParagonIE_Sodium_Core32_Int64
49
  */
50
  public function addInt64(ParagonIE_Sodium_Core32_Int64 $addend)
51
  {
52
- $return = new ParagonIE_Sodium_Core32_Int64();
53
- $return->unsignedInt = $this->unsignedInt;
54
- /** @var int $carry */
55
- $carry = 0;
56
- for ($i = 3; $i >= 0; --$i) {
57
- /** @var int $tmp */
58
- $tmp = $this->limbs[$i] + $addend->limbs[$i] + $carry;
59
- /** @var int $carry */
60
- $carry = $tmp >> 16;
61
- $return->limbs[$i] = (int) ($tmp & 0xffff);
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  $return->overflow = $carry;
 
64
  return $return;
65
  }
66
 
@@ -69,35 +88,41 @@ class ParagonIE_Sodium_Core32_Int64
69
  *
70
  * @param int $int
71
  * @return ParagonIE_Sodium_Core32_Int64
 
72
  * @throws TypeError
73
  */
74
  public function addInt($int)
75
  {
76
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
 
 
77
 
78
- $return = new ParagonIE_Sodium_Core32_Int64();
79
- $return->unsignedInt = $this->unsignedInt;
80
- /** @var int $carry */
81
- $carry = 0;
82
- for ($i = 3; $i >= 0; --$i) {
83
- /** @var int $step */
84
- $step = (3 - $i) << 4; // 0, 16, 32, 48
85
- if ($i < 2) {
86
- /** @var int $toAdd */
87
- $toAdd = 0;
88
- } else {
89
- /** @var int $toAdd */
90
- $toAdd = (($int >> $step) & 0xffff);
91
- }
92
- /** @var int $tmp */
93
- $tmp = $this->limbs[$i] + $toAdd + $carry;
94
 
95
- /** @var int $carry */
96
- $carry = $tmp >> 16;
97
- $return->limbs[$i] = (int) ($tmp & 0xffff);
98
- }
99
- /** @var int overflow */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  $return->overflow = $carry;
 
101
  return $return;
102
  }
103
 
@@ -182,6 +207,11 @@ class ParagonIE_Sodium_Core32_Int64
182
  {
183
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
184
  ParagonIE_Sodium_Core32_Util::declareScalarType($size, 'int', 2);
 
 
 
 
 
185
  if (!$size) {
186
  $size = 63;
187
  }
@@ -190,15 +220,58 @@ class ParagonIE_Sodium_Core32_Int64
190
  $return = new ParagonIE_Sodium_Core32_Int64();
191
  $return->unsignedInt = $this->unsignedInt;
192
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  for ($i = $size; $i >= 0; --$i) {
194
- $return = $return->addInt64(
195
- $a->mask64(
196
- (int) (-($int & 1)),
197
- (int) (-($int & 1))
198
- )
199
- );
200
- $a = $a->shiftLeft(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  $int >>= 1;
 
 
 
 
202
  }
203
  return $return;
204
  }
@@ -263,18 +336,77 @@ class ParagonIE_Sodium_Core32_Int64
263
  $return = new ParagonIE_Sodium_Core32_Int64();
264
  $return->unsignedInt = $this->unsignedInt;
265
 
266
- /** @var int $size $i */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  /** @var int $i */
268
- for ($i = $size; $i >= 0; --$i) {
269
- $return = $return->addInt64(
270
- $a->mask64(
271
- (int) (-($b->limbs[3] & 1)),
272
- (int) (-($b->limbs[3] & 1))
273
- )
274
- );
275
- $a = $a->shiftLeft(1);
276
- $b = $b->shiftRight(1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  }
 
 
 
 
 
278
  return $return;
279
  }
280
 
@@ -300,12 +432,15 @@ class ParagonIE_Sodium_Core32_Int64
300
  /**
301
  * @param int $c
302
  * @return ParagonIE_Sodium_Core32_Int64
 
303
  * @throws TypeError
304
  * @psalm-suppress MixedArrayAccess
305
  */
306
  public function rotateLeft($c = 0)
307
  {
308
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
 
 
309
 
310
  $return = new ParagonIE_Sodium_Core32_Int64();
311
  $return->unsignedInt = $this->unsignedInt;
@@ -332,9 +467,9 @@ class ParagonIE_Sodium_Core32_Int64
332
  $k = ($i + $idx_shift + 1) & 3;
333
  $limbs[$i] = (int) (
334
  (
335
- ($myLimbs[$j] << $sub_shift)
336
  |
337
- ($myLimbs[$k] >> (16 - $sub_shift))
338
  ) & 0xffff
339
  );
340
  }
@@ -347,12 +482,15 @@ class ParagonIE_Sodium_Core32_Int64
347
  *
348
  * @param int $c
349
  * @return ParagonIE_Sodium_Core32_Int64
 
350
  * @throws TypeError
351
  * @psalm-suppress MixedArrayAccess
352
  */
353
  public function rotateRight($c = 0)
354
  {
355
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
 
 
356
 
357
  /** @var ParagonIE_Sodium_Core32_Int64 $return */
358
  $return = new ParagonIE_Sodium_Core32_Int64();
@@ -381,9 +519,9 @@ class ParagonIE_Sodium_Core32_Int64
381
  $k = ($i - $idx_shift - 1) & 3;
382
  $limbs[$i] = (int) (
383
  (
384
- ($myLimbs[$j] >> (int) ($sub_shift))
385
  |
386
- ($myLimbs[$k] << (16 - (int) ($sub_shift)))
387
  ) & 0xffff
388
  );
389
  }
@@ -399,10 +537,12 @@ class ParagonIE_Sodium_Core32_Int64
399
  public function shiftLeft($c = 0)
400
  {
401
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
 
 
 
402
  $return = new ParagonIE_Sodium_Core32_Int64();
403
  $return->unsignedInt = $this->unsignedInt;
404
  $c &= 63;
405
- /** @var int $c */
406
 
407
  if ($c >= 16) {
408
  if ($c >= 48) {
@@ -510,11 +650,13 @@ class ParagonIE_Sodium_Core32_Int64
510
  *
511
  * @param int $int
512
  * @return ParagonIE_Sodium_Core32_Int64
 
513
  * @throws TypeError
514
  */
515
  public function subInt($int)
516
  {
517
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
 
518
 
519
  $return = new ParagonIE_Sodium_Core32_Int64();
520
  $return->unsignedInt = $this->unsignedInt;
@@ -576,6 +718,7 @@ class ParagonIE_Sodium_Core32_Int64
576
  * @param int $low
577
  * @param int $high
578
  * @return self
 
579
  * @throws TypeError
580
  */
581
  public static function fromInts($low, $high)
@@ -583,6 +726,8 @@ class ParagonIE_Sodium_Core32_Int64
583
  ParagonIE_Sodium_Core32_Util::declareScalarType($low, 'int', 1);
584
  ParagonIE_Sodium_Core32_Util::declareScalarType($high, 'int', 2);
585
 
 
 
586
  return new ParagonIE_Sodium_Core32_Int64(
587
  array(
588
  (int) (($high >> 16) & 0xffff),
@@ -593,9 +738,43 @@ class ParagonIE_Sodium_Core32_Int64
593
  );
594
  }
595
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
596
  /**
597
  * @param string $string
598
  * @return self
 
599
  * @throws TypeError
600
  */
601
  public static function fromString($string)
@@ -623,6 +802,7 @@ class ParagonIE_Sodium_Core32_Int64
623
  /**
624
  * @param string $string
625
  * @return self
 
626
  * @throws TypeError
627
  */
628
  public static function fromReverseString($string)
12
  /**
13
  * @var array<int, int> - four 16-bit integers
14
  */
15
+ public $limbs = array(0, 0, 0, 0);
16
 
17
  /**
18
  * @var int
49
  */
50
  public function addInt64(ParagonIE_Sodium_Core32_Int64 $addend)
51
  {
52
+ $i0 = $this->limbs[0];
53
+ $i1 = $this->limbs[1];
54
+ $i2 = $this->limbs[2];
55
+ $i3 = $this->limbs[3];
56
+ $j0 = $addend->limbs[0];
57
+ $j1 = $addend->limbs[1];
58
+ $j2 = $addend->limbs[2];
59
+ $j3 = $addend->limbs[3];
60
+
61
+ $r3 = $i3 + ($j3 & 0xffff);
62
+ $carry = $r3 >> 16;
63
+
64
+ $r2 = $i2 + ($j2 & 0xffff) + $carry;
65
+ $carry = $r2 >> 16;
66
+
67
+ $r1 = $i1 + ($j1 & 0xffff) + $carry;
68
+ $carry = $r1 >> 16;
69
+
70
+ $r0 = $i0 + ($j0 & 0xffff) + $carry;
71
+ $carry = $r0 >> 16;
72
+
73
+ $r0 &= 0xffff;
74
+ $r1 &= 0xffff;
75
+ $r2 &= 0xffff;
76
+ $r3 &= 0xffff;
77
+
78
+ $return = new ParagonIE_Sodium_Core32_Int64(
79
+ array($r0, $r1, $r2, $r3)
80
+ );
81
  $return->overflow = $carry;
82
+ $return->unsignedInt = $this->unsignedInt;
83
  return $return;
84
  }
85
 
88
  *
89
  * @param int $int
90
  * @return ParagonIE_Sodium_Core32_Int64
91
+ * @throws SodiumException
92
  * @throws TypeError
93
  */
94
  public function addInt($int)
95
  {
96
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
97
+ /** @var int $int */
98
+ $int = (int) $int;
99
 
100
+ $i0 = $this->limbs[0];
101
+ $i1 = $this->limbs[1];
102
+ $i2 = $this->limbs[2];
103
+ $i3 = $this->limbs[3];
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
+ $r3 = $i3 + ($int & 0xffff);
106
+ $carry = $r3 >> 16;
107
+
108
+ $r2 = $i2 + (($int >> 16) & 0xffff) + $carry;
109
+ $carry = $r2 >> 16;
110
+
111
+ $r1 = $i1 + $carry;
112
+ $carry = $r1 >> 16;
113
+
114
+ $r0 = $i0 + $carry;
115
+ $carry = $r0 >> 16;
116
+
117
+ $r0 &= 0xffff;
118
+ $r1 &= 0xffff;
119
+ $r2 &= 0xffff;
120
+ $r3 &= 0xffff;
121
+ $return = new ParagonIE_Sodium_Core32_Int64(
122
+ array($r0, $r1, $r2, $r3)
123
+ );
124
  $return->overflow = $carry;
125
+ $return->unsignedInt = $this->unsignedInt;
126
  return $return;
127
  }
128
 
207
  {
208
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
209
  ParagonIE_Sodium_Core32_Util::declareScalarType($size, 'int', 2);
210
+ /** @var int $int */
211
+ $int = (int) $int;
212
+ /** @var int $size */
213
+ $size = (int) $size;
214
+
215
  if (!$size) {
216
  $size = 63;
217
  }
220
  $return = new ParagonIE_Sodium_Core32_Int64();
221
  $return->unsignedInt = $this->unsignedInt;
222
 
223
+ // Initialize:
224
+ $ret0 = 0;
225
+ $ret1 = 0;
226
+ $ret2 = 0;
227
+ $ret3 = 0;
228
+ $a0 = $a->limbs[0];
229
+ $a1 = $a->limbs[1];
230
+ $a2 = $a->limbs[2];
231
+ $a3 = $a->limbs[3];
232
+
233
+ /** @var int $size */
234
+ /** @var int $i */
235
  for ($i = $size; $i >= 0; --$i) {
236
+ $mask = -($int & 1);
237
+ $x0 = $a0 & $mask;
238
+ $x1 = $a1 & $mask;
239
+ $x2 = $a2 & $mask;
240
+ $x3 = $a3 & $mask;
241
+
242
+ $ret3 += $x3;
243
+ $c = $ret3 >> 16;
244
+
245
+ $ret2 += $x2 + $c;
246
+ $c = $ret2 >> 16;
247
+
248
+ $ret1 += $x1 + $c;
249
+ $c = $ret1 >> 16;
250
+
251
+ $ret0 += $x0 + $c;
252
+
253
+ $ret0 &= 0xffff;
254
+ $ret1 &= 0xffff;
255
+ $ret2 &= 0xffff;
256
+ $ret3 &= 0xffff;
257
+
258
+ $a3 = $a3 << 1;
259
+ $x3 = $a3 >> 16;
260
+ $a2 = ($a2 << 1) | $x3;
261
+ $x2 = $a2 >> 16;
262
+ $a1 = ($a1 << 1) | $x2;
263
+ $x1 = $a1 >> 16;
264
+ $a0 = ($a0 << 1) | $x1;
265
+ $a0 &= 0xffff;
266
+ $a1 &= 0xffff;
267
+ $a2 &= 0xffff;
268
+ $a3 &= 0xffff;
269
+
270
  $int >>= 1;
271
+ $return->limbs[0] = $ret0;
272
+ $return->limbs[1] = $ret1;
273
+ $return->limbs[2] = $ret2;
274
+ $return->limbs[3] = $ret3;
275
  }
276
  return $return;
277
  }
336
  $return = new ParagonIE_Sodium_Core32_Int64();
337
  $return->unsignedInt = $this->unsignedInt;
338
 
339
+ // Initialize:
340
+ $ret0 = 0;
341
+ $ret1 = 0;
342
+ $ret2 = 0;
343
+ $ret3 = 0;
344
+ $a0 = $a->limbs[0];
345
+ $a1 = $a->limbs[1];
346
+ $a2 = $a->limbs[2];
347
+ $a3 = $a->limbs[3];
348
+ $b0 = $b->limbs[0];
349
+ $b1 = $b->limbs[1];
350
+ $b2 = $b->limbs[2];
351
+ $b3 = $b->limbs[3];
352
+
353
+ /** @var int $size */
354
  /** @var int $i */
355
+ for ($i = (int) $size; $i >= 0; --$i) {
356
+ $mask = -($b3 & 1);
357
+ $x0 = $a0 & $mask;
358
+ $x1 = $a1 & $mask;
359
+ $x2 = $a2 & $mask;
360
+ $x3 = $a3 & $mask;
361
+
362
+ $ret3 += $x3;
363
+ $c = $ret3 >> 16;
364
+
365
+ $ret2 += $x2 + $c;
366
+ $c = $ret2 >> 16;
367
+
368
+ $ret1 += $x1 + $c;
369
+ $c = $ret1 >> 16;
370
+
371
+ $ret0 += $x0 + $c;
372
+
373
+ $ret0 &= 0xffff;
374
+ $ret1 &= 0xffff;
375
+ $ret2 &= 0xffff;
376
+ $ret3 &= 0xffff;
377
+
378
+ $a3 = $a3 << 1;
379
+ $x3 = $a3 >> 16;
380
+ $a2 = ($a2 << 1) | $x3;
381
+ $x2 = $a2 >> 16;
382
+ $a1 = ($a1 << 1) | $x2;
383
+ $x1 = $a1 >> 16;
384
+ $a0 = ($a0 << 1) | $x1;
385
+ $a0 &= 0xffff;
386
+ $a1 &= 0xffff;
387
+ $a2 &= 0xffff;
388
+ $a3 &= 0xffff;
389
+
390
+ $x0 = ($b0 & 1) << 16;
391
+ $x1 = ($b1 & 1) << 16;
392
+ $x2 = ($b2 & 1) << 16;
393
+
394
+ $b0 = ($b0 >> 1);
395
+ $b1 = (($b1 | $x0) >> 1);
396
+ $b2 = (($b2 | $x1) >> 1);
397
+ $b3 = (($b3 | $x2) >> 1);
398
+
399
+ $b0 &= 0xffff;
400
+ $b1 &= 0xffff;
401
+ $b2 &= 0xffff;
402
+ $b3 &= 0xffff;
403
+
404
  }
405
+ $return->limbs[0] = $ret0;
406
+ $return->limbs[1] = $ret1;
407
+ $return->limbs[2] = $ret2;
408
+ $return->limbs[3] = $ret3;
409
+
410
  return $return;
411
  }
412
 
432
  /**
433
  * @param int $c
434
  * @return ParagonIE_Sodium_Core32_Int64
435
+ * @throws SodiumException
436
  * @throws TypeError
437
  * @psalm-suppress MixedArrayAccess
438
  */
439
  public function rotateLeft($c = 0)
440
  {
441
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
442
+ /** @var int $c */
443
+ $c = (int) $c;
444
 
445
  $return = new ParagonIE_Sodium_Core32_Int64();
446
  $return->unsignedInt = $this->unsignedInt;
467
  $k = ($i + $idx_shift + 1) & 3;
468
  $limbs[$i] = (int) (
469
  (
470
+ ((int) ($myLimbs[$j]) << $sub_shift)
471
  |
472
+ ((int) ($myLimbs[$k]) >> (16 - $sub_shift))
473
  ) & 0xffff
474
  );
475
  }
482
  *
483
  * @param int $c
484
  * @return ParagonIE_Sodium_Core32_Int64
485
+ * @throws SodiumException
486
  * @throws TypeError
487
  * @psalm-suppress MixedArrayAccess
488
  */
489
  public function rotateRight($c = 0)
490
  {
491
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
492
+ /** @var int $c */
493
+ $c = (int) $c;
494
 
495
  /** @var ParagonIE_Sodium_Core32_Int64 $return */
496
  $return = new ParagonIE_Sodium_Core32_Int64();
519
  $k = ($i - $idx_shift - 1) & 3;
520
  $limbs[$i] = (int) (
521
  (
522
+ ((int) ($myLimbs[$j]) >> (int) ($sub_shift))
523
  |
524
+ ((int) ($myLimbs[$k]) << (16 - (int) ($sub_shift)))
525
  ) & 0xffff
526
  );
527
  }
537
  public function shiftLeft($c = 0)
538
  {
539
  ParagonIE_Sodium_Core32_Util::declareScalarType($c, 'int', 1);
540
+ /** @var int $c */
541
+ $c = (int) $c;
542
+
543
  $return = new ParagonIE_Sodium_Core32_Int64();
544
  $return->unsignedInt = $this->unsignedInt;
545
  $c &= 63;
 
546
 
547
  if ($c >= 16) {
548
  if ($c >= 48) {
650
  *
651
  * @param int $int
652
  * @return ParagonIE_Sodium_Core32_Int64
653
+ * @throws SodiumException
654
  * @throws TypeError
655
  */
656
  public function subInt($int)
657
  {
658
  ParagonIE_Sodium_Core32_Util::declareScalarType($int, 'int', 1);
659
+ $int = (int) $int;
660
 
661
  $return = new ParagonIE_Sodium_Core32_Int64();
662
  $return->unsignedInt = $this->unsignedInt;
718
  * @param int $low
719
  * @param int $high
720
  * @return self
721
+ * @throws SodiumException
722
  * @throws TypeError
723
  */
724
  public static function fromInts($low, $high)
726
  ParagonIE_Sodium_Core32_Util::declareScalarType($low, 'int', 1);
727
  ParagonIE_Sodium_Core32_Util::declareScalarType($high, 'int', 2);
728
 
729
+ $high = (int) $high;
730
+ $low = (int) $low;
731
  return new ParagonIE_Sodium_Core32_Int64(
732
  array(
733
  (int) (($high >> 16) & 0xffff),
738
  );
739
  }
740
 
741
+ /**
742
+ * @param int $low
743
+ * @return self
744
+ * @throws SodiumException
745
+ * @throws TypeError
746
+ */
747
+ public static function fromInt($low)
748
+ {
749
+ ParagonIE_Sodium_Core32_Util::declareScalarType($low, 'int', 1);
750
+ $low = (int) $low;
751
+
752
+ return new ParagonIE_Sodium_Core32_Int64(
753
+ array(
754
+ 0,
755
+ 0,
756
+ (int) (($low >> 16) & 0xffff),
757
+ (int) ($low & 0xffff)
758
+ )
759
+ );
760
+ }
761
+
762
+ /**
763
+ * @return int
764
+ */
765
+ public function toInt()
766
+ {
767
+ return (int) (
768
+ (($this->limbs[2] & 0xffff) << 16)
769
+ |
770
+ ($this->limbs[3] & 0xffff)
771
+ );
772
+ }
773
+
774
  /**
775
  * @param string $string
776
  * @return self
777
+ * @throws SodiumException
778
  * @throws TypeError
779
  */
780
  public static function fromString($string)
802
  /**
803
  * @param string $string
804
  * @return self
805
+ * @throws SodiumException
806
  * @throws TypeError
807
  */
808
  public static function fromReverseString($string)
vendor/paragonie/sodium_compat/src/Core32/Poly1305/State.php CHANGED
@@ -215,10 +215,10 @@ class ParagonIE_Sodium_Core32_Poly1305_State extends ParagonIE_Sodium_Core32_Uti
215
  $r3 = $this->r[3]->toInt64();
216
  $r4 = $this->r[4]->toInt64();
217
 
218
- $s1 = $r1->toInt64()->mulInt(5);
219
- $s2 = $r2->toInt64()->mulInt(5);
220
- $s3 = $r3->toInt64()->mulInt(5);
221
- $s4 = $r4->toInt64()->mulInt(5);
222
 
223
  $h0 = $this->h[0];
224
  $h1 = $this->h[1];
@@ -226,68 +226,68 @@ class ParagonIE_Sodium_Core32_Poly1305_State extends ParagonIE_Sodium_Core32_Uti
226
  $h3 = $this->h[3];
227
  $h4 = $this->h[4];
228
 
229
- while ($bytes >= ParagonIE_Sodium_Core_Poly1305::BLOCK_SIZE) {
230
  /* h += m[i] */
231
  $h0 = $h0->addInt32(
232
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 0, 4))
233
  ->mask(0x3ffffff)
234
- );
235
  $h1 = $h1->addInt32(
236
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 3, 4))
237
  ->shiftRight(2)
238
  ->mask(0x3ffffff)
239
- );
240
  $h2 = $h2->addInt32(
241
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 6, 4))
242
  ->shiftRight(4)
243
  ->mask(0x3ffffff)
244
- );
245
  $h3 = $h3->addInt32(
246
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 9, 4))
247
  ->shiftRight(6)
248
  ->mask(0x3ffffff)
249
- );
250
  $h4 = $h4->addInt32(
251
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 12, 4))
252
  ->shiftRight(8)
253
  ->orInt32($hibit)
254
- );
255
 
256
  /* h *= r */
257
  $d0 = $zero
258
- ->addInt64($h0->toInt64()->mulInt64($r0))
259
- ->addInt64($h1->toInt64()->mulInt64($s4))
260
- ->addInt64($h2->toInt64()->mulInt64($s3))
261
- ->addInt64($h3->toInt64()->mulInt64($s2))
262
- ->addInt64($h4->toInt64()->mulInt64($s1));
263
 
264
  $d1 = $zero
265
- ->addInt64($h0->toInt64()->mulInt64($r1))
266
- ->addInt64($h1->toInt64()->mulInt64($r0))
267
- ->addInt64($h2->toInt64()->mulInt64($s4))
268
- ->addInt64($h3->toInt64()->mulInt64($s3))
269
- ->addInt64($h4->toInt64()->mulInt64($s2));
270
 
271
  $d2 = $zero
272
- ->addInt64($h0->toInt64()->mulInt64($r2))
273
- ->addInt64($h1->toInt64()->mulInt64($r1))
274
- ->addInt64($h2->toInt64()->mulInt64($r0))
275
- ->addInt64($h3->toInt64()->mulInt64($s4))
276
- ->addInt64($h4->toInt64()->mulInt64($s3));
277
 
278
  $d3 = $zero
279
- ->addInt64($h0->toInt64()->mulInt64($r3))
280
- ->addInt64($h1->toInt64()->mulInt64($r2))
281
- ->addInt64($h2->toInt64()->mulInt64($r1))
282
- ->addInt64($h3->toInt64()->mulInt64($r0))
283
- ->addInt64($h4->toInt64()->mulInt64($s4));
284
 
285
  $d4 = $zero
286
- ->addInt64($h0->toInt64()->mulInt64($r4))
287
- ->addInt64($h1->toInt64()->mulInt64($r3))
288
- ->addInt64($h2->toInt64()->mulInt64($r2))
289
- ->addInt64($h3->toInt64()->mulInt64($r1))
290
- ->addInt64($h4->toInt64()->mulInt64($r0));
291
 
292
  /* (partial) h %= p */
293
  $c = $d0->shiftRight(26);
@@ -388,7 +388,7 @@ class ParagonIE_Sodium_Core32_Poly1305_State extends ParagonIE_Sodium_Core32_Uti
388
  $c = $h4->shiftRight(26); # $c = $h4 >> 26;
389
  $h4 = $h4->mask(0x3ffffff); # $h4 &= 0x3ffffff;
390
 
391
- $h0 = $h0->addInt32($c->mulInt(5)); # $h0 += self::mul($c, 5);
392
  $c = $h0->shiftRight(26); # $c = $h0 >> 26;
393
  $h0 = $h0->mask(0x3ffffff); # $h0 &= 0x3ffffff;
394
  $h1 = $h1->addInt32($c); # $h1 += $c;
215
  $r3 = $this->r[3]->toInt64();
216
  $r4 = $this->r[4]->toInt64();
217
 
218
+ $s1 = $r1->toInt64()->mulInt(5, 3);
219
+ $s2 = $r2->toInt64()->mulInt(5, 3);
220
+ $s3 = $r3->toInt64()->mulInt(5, 3);
221
+ $s4 = $r4->toInt64()->mulInt(5, 3);
222
 
223
  $h0 = $this->h[0];
224
  $h1 = $this->h[1];
226
  $h3 = $this->h[3];
227
  $h4 = $this->h[4];
228
 
229
+ while ($bytes >= ParagonIE_Sodium_Core32_Poly1305::BLOCK_SIZE) {
230
  /* h += m[i] */
231
  $h0 = $h0->addInt32(
232
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 0, 4))
233
  ->mask(0x3ffffff)
234
+ )->toInt64();
235
  $h1 = $h1->addInt32(
236
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 3, 4))
237
  ->shiftRight(2)
238
  ->mask(0x3ffffff)
239
+ )->toInt64();
240
  $h2 = $h2->addInt32(
241
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 6, 4))
242
  ->shiftRight(4)
243
  ->mask(0x3ffffff)
244
+ )->toInt64();
245
  $h3 = $h3->addInt32(
246
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 9, 4))
247
  ->shiftRight(6)
248
  ->mask(0x3ffffff)
249
+ )->toInt64();
250
  $h4 = $h4->addInt32(
251
  ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($message, 12, 4))
252
  ->shiftRight(8)
253
  ->orInt32($hibit)
254
+ )->toInt64();
255
 
256
  /* h *= r */
257
  $d0 = $zero
258
+ ->addInt64($h0->mulInt64($r0, 25))
259
+ ->addInt64($s4->mulInt64($h1, 26))
260
+ ->addInt64($s3->mulInt64($h2, 26))
261
+ ->addInt64($s2->mulInt64($h3, 26))
262
+ ->addInt64($s1->mulInt64($h4, 26));
263
 
264
  $d1 = $zero
265
+ ->addInt64($h0->mulInt64($r1, 25))
266
+ ->addInt64($h1->mulInt64($r0, 25))
267
+ ->addInt64($s4->mulInt64($h2, 26))
268
+ ->addInt64($s3->mulInt64($h3, 26))
269
+ ->addInt64($s2->mulInt64($h4, 26));
270
 
271
  $d2 = $zero
272
+ ->addInt64($h0->mulInt64($r2, 25))
273
+ ->addInt64($h1->mulInt64($r1, 25))
274
+ ->addInt64($h2->mulInt64($r0, 25))
275
+ ->addInt64($s4->mulInt64($h3, 26))
276
+ ->addInt64($s3->mulInt64($h4, 26));
277
 
278
  $d3 = $zero
279
+ ->addInt64($h0->mulInt64($r3, 25))
280
+ ->addInt64($h1->mulInt64($r2, 25))
281
+ ->addInt64($h2->mulInt64($r1, 25))
282
+ ->addInt64($h3->mulInt64($r0, 25))
283
+ ->addInt64($s4->mulInt64($h4, 26));
284
 
285
  $d4 = $zero
286
+ ->addInt64($h0->mulInt64($r4, 25))
287
+ ->addInt64($h1->mulInt64($r3, 25))
288
+ ->addInt64($h2->mulInt64($r2, 25))
289
+ ->addInt64($h3->mulInt64($r1, 25))
290
+ ->addInt64($h4->mulInt64($r0, 25));
291
 
292
  /* (partial) h %= p */
293
  $c = $d0->shiftRight(26);
388
  $c = $h4->shiftRight(26); # $c = $h4 >> 26;
389
  $h4 = $h4->mask(0x3ffffff); # $h4 &= 0x3ffffff;
390
 
391
+ $h0 = $h0->addInt32($c->mulInt(5, 3)); # $h0 += self::mul($c, 5);
392
  $c = $h0->shiftRight(26); # $c = $h0 >> 26;
393
  $h0 = $h0->mask(0x3ffffff); # $h0 &= 0x3ffffff;
394
  $h1 = $h1->addInt32($c); # $h1 += $c;
vendor/paragonie/sodium_compat/src/Core32/SipHash.php CHANGED
@@ -202,7 +202,6 @@ class ParagonIE_Sodium_Core32_SipHash extends ParagonIE_Sodium_Core32_Util
202
  case 0:
203
  break;
204
  }
205
- // See docblock for why the 0th index gets the higher bits.
206
 
207
  # v3 ^= b;
208
  $v[3] = $v[3]->xorInt64($b);
202
  case 0:
203
  break;
204
  }
 
205
 
206
  # v3 ^= b;
207
  $v[3] = $v[3]->xorInt64($b);
vendor/paragonie/sodium_compat/src/Core32/X25519.php CHANGED
@@ -213,17 +213,23 @@ abstract class ParagonIE_Sodium_Core32_X25519 extends ParagonIE_Sodium_Core32_Cu
213
  ) >> ($pos & 7);
214
  # b &= 1;
215
  $b &= 1;
 
216
  # swap ^= b;
217
  $swap ^= $b;
 
218
  # fe_cswap(x2,x3,swap);
219
  self::fe_cswap($x2, $x3, $swap);
 
220
  # fe_cswap(z2,z3,swap);
221
  self::fe_cswap($z2, $z3, $swap);
 
222
  # swap = b;
223
  /** @var int $swap */
224
  $swap = $b;
 
225
  # fe_sub(tmp0,x3,z3);
226
  $tmp0 = self::fe_sub($x3, $z3);
 
227
  # fe_sub(tmp1,x2,z2);
228
  $tmp1 = self::fe_sub($x2, $z2);
229
 
@@ -337,7 +343,7 @@ abstract class ParagonIE_Sodium_Core32_X25519 extends ParagonIE_Sodium_Core32_Cu
337
  $A = self::ge_scalarmult_base($e);
338
  if (
339
  !($A->Y instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
340
- ||
341
  !($A->Z instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
342
  ) {
343
  throw new TypeError('Null points encountered');
213
  ) >> ($pos & 7);
214
  # b &= 1;
215
  $b &= 1;
216
+
217
  # swap ^= b;
218
  $swap ^= $b;
219
+
220
  # fe_cswap(x2,x3,swap);
221
  self::fe_cswap($x2, $x3, $swap);
222
+
223
  # fe_cswap(z2,z3,swap);
224
  self::fe_cswap($z2, $z3, $swap);
225
+
226
  # swap = b;
227
  /** @var int $swap */
228
  $swap = $b;
229
+
230
  # fe_sub(tmp0,x3,z3);
231
  $tmp0 = self::fe_sub($x3, $z3);
232
+
233
  # fe_sub(tmp1,x2,z2);
234
  $tmp1 = self::fe_sub($x2, $z2);
235
 
343
  $A = self::ge_scalarmult_base($e);
344
  if (
345
  !($A->Y instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
346
+ ||
347
  !($A->Z instanceof ParagonIE_Sodium_Core32_Curve25519_Fe)
348
  ) {
349
  throw new TypeError('Null points encountered');
vendor/paragonie/sodium_compat/src/Crypto.php CHANGED
@@ -553,6 +553,7 @@ abstract class ParagonIE_Sodium_Crypto
553
  * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
554
  *
555
  * @return string
 
556
  * @throws SodiumException
557
  * @throws TypeError
558
  */
@@ -605,7 +606,9 @@ abstract class ParagonIE_Sodium_Crypto
605
  public static function box_secretkey($keypair)
606
  {
607
  if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== 64) {
608
- throw new RangeException('Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.');
 
 
609
  }
610
  return ParagonIE_Sodium_Core_Util::substr($keypair, 0, 32);
611
  }
@@ -621,7 +624,9 @@ abstract class ParagonIE_Sodium_Crypto
621
  public static function box_publickey($keypair)
622
  {
623
  if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES) {
624
- throw new RangeException('Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.');
 
 
625
  }
626
  return ParagonIE_Sodium_Core_Util::substr($keypair, 32, 32);
627
  }
@@ -638,7 +643,9 @@ abstract class ParagonIE_Sodium_Crypto
638
  public static function box_publickey_from_secretkey($sKey)
639
  {
640
  if (ParagonIE_Sodium_Core_Util::strlen($sKey) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES) {
641
- throw new RangeException('Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES bytes long.');
 
 
642
  }
643
  return self::scalarmult_base($sKey);
644
  }
@@ -812,8 +819,8 @@ abstract class ParagonIE_Sodium_Crypto
812
  */
813
  public static function keyExchange($my_sk, $their_pk, $client_pk, $server_pk)
814
  {
815
- return self::generichash(
816
- self::scalarmult($my_sk, $their_pk) .
817
  $client_pk .
818
  $server_pk
819
  );
553
  * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
554
  *
555
  * @return string
556
+ * @throws Exception
557
  * @throws SodiumException
558
  * @throws TypeError
559
  */
606
  public static function box_secretkey($keypair)
607
  {
608
  if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== 64) {
609
+ throw new RangeException(
610
+ 'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.'
611
+ );
612
  }
613
  return ParagonIE_Sodium_Core_Util::substr($keypair, 0, 32);
614
  }
624
  public static function box_publickey($keypair)
625
  {
626
  if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES) {
627
+ throw new RangeException(
628
+ 'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.'
629
+ );
630
  }
631
  return ParagonIE_Sodium_Core_Util::substr($keypair, 32, 32);
632
  }
643
  public static function box_publickey_from_secretkey($sKey)
644
  {
645
  if (ParagonIE_Sodium_Core_Util::strlen($sKey) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES) {
646
+ throw new RangeException(
647
+ 'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES bytes long.'
648
+ );
649
  }
650
  return self::scalarmult_base($sKey);
651
  }
819
  */
820
  public static function keyExchange($my_sk, $their_pk, $client_pk, $server_pk)
821
  {
822
+ return ParagonIE_Sodium_Compat::crypto_generichash(
823
+ ParagonIE_Sodium_Compat::crypto_scalarmult($my_sk, $their_pk) .
824
  $client_pk .
825
  $server_pk
826
  );
vendor/paragonie/sodium_compat/src/Crypto32.php CHANGED
@@ -552,6 +552,7 @@ abstract class ParagonIE_Sodium_Crypto32
552
  * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
553
  *
554
  * @return string
 
555
  * @throws SodiumException
556
  * @throws TypeError
557
  */
@@ -604,7 +605,9 @@ abstract class ParagonIE_Sodium_Crypto32
604
  public static function box_secretkey($keypair)
605
  {
606
  if (ParagonIE_Sodium_Core32_Util::strlen($keypair) !== 64) {
607
- throw new RangeException('Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.');
 
 
608
  }
609
  return ParagonIE_Sodium_Core32_Util::substr($keypair, 0, 32);
610
  }
@@ -620,7 +623,9 @@ abstract class ParagonIE_Sodium_Crypto32
620
  public static function box_publickey($keypair)
621
  {
622
  if (ParagonIE_Sodium_Core32_Util::strlen($keypair) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES) {
623
- throw new RangeException('Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.');
 
 
624
  }
625
  return ParagonIE_Sodium_Core32_Util::substr($keypair, 32, 32);
626
  }
@@ -637,7 +642,9 @@ abstract class ParagonIE_Sodium_Crypto32
637
  public static function box_publickey_from_secretkey($sKey)
638
  {
639
  if (ParagonIE_Sodium_Core32_Util::strlen($sKey) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES) {
640
- throw new RangeException('Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES bytes long.');
 
 
641
  }
642
  return self::scalarmult_base($sKey);
643
  }
552
  * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
553
  *
554
  * @return string
555
+ * @throws Exception
556
  * @throws SodiumException
557
  * @throws TypeError
558
  */
605
  public static function box_secretkey($keypair)
606
  {
607
  if (ParagonIE_Sodium_Core32_Util::strlen($keypair) !== 64) {
608
+ throw new RangeException(
609
+ 'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.'
610
+ );
611
  }
612
  return ParagonIE_Sodium_Core32_Util::substr($keypair, 0, 32);
613
  }
623
  public static function box_publickey($keypair)
624
  {
625
  if (ParagonIE_Sodium_Core32_Util::strlen($keypair) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES) {
626
+ throw new RangeException(
627
+ 'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.'
628
+ );
629
  }
630
  return ParagonIE_Sodium_Core32_Util::substr($keypair, 32, 32);
631
  }
642
  public static function box_publickey_from_secretkey($sKey)
643
  {
644
  if (ParagonIE_Sodium_Core32_Util::strlen($sKey) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES) {
645
+ throw new RangeException(
646
+ 'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES bytes long.'
647
+ );
648
  }
649
  return self::scalarmult_base($sKey);
650
  }
vendor/paragonie/sodium_compat/src/File.php CHANGED
@@ -761,6 +761,18 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
761
  */
762
  protected static function box_encrypt($ifp, $ofp, $mlen, $nonce, $boxKeypair)
763
  {
 
 
 
 
 
 
 
 
 
 
 
 
764
  return self::secretbox_encrypt(
765
  $ifp,
766
  $ofp,
@@ -786,6 +798,18 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
786
  */
787
  protected static function box_decrypt($ifp, $ofp, $mlen, $nonce, $boxKeypair)
788
  {
 
 
 
 
 
 
 
 
 
 
 
 
789
  return self::secretbox_decrypt(
790
  $ifp,
791
  $ofp,
@@ -1015,8 +1039,12 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
1015
  * @throws SodiumException
1016
  * @throws TypeError
1017
  */
1018
- protected static function onetimeauth_verify(ParagonIE_Sodium_Core_Poly1305_State $state, $ifp, $tag = '', $mlen = 0)
1019
- {
 
 
 
 
1020
  /** @var int $pos */
1021
  $pos = ftell($ifp);
1022
 
@@ -1057,6 +1085,8 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
1057
  * @psalm-suppress PossiblyInvalidArgument
1058
  * PHP 7.2 changes from a resource to an object,
1059
  * which causes Psalm to complain about an error.
 
 
1060
  */
1061
  public static function updateHashWithFile($hash, $fp, $size = 0)
1062
  {
@@ -1484,8 +1514,12 @@ class ParagonIE_Sodium_File extends ParagonIE_Sodium_Core_Util
1484
  * @throws SodiumException
1485
  * @throws TypeError
1486
  */
1487
- protected static function onetimeauth_verify_core32(ParagonIE_Sodium_Core32_Poly1305_State $state, $ifp, $tag = '', $mlen = 0)
1488
- {
 
 
 
 
1489
  /** @var int $pos */
1490
  $pos = ftell($ifp);
1491
 
761
  */
762
  protected static function box_encrypt($ifp, $ofp, $mlen, $nonce, $boxKeypair)
763
  {
764
+ if (PHP_INT_SIZE === 4) {
765
+ return self::secretbox_encrypt(
766
+ $ifp,
767
+ $ofp,
768
+ $mlen,
769
+ $nonce,
770
+ ParagonIE_Sodium_Crypto32::box_beforenm(
771
+ ParagonIE_Sodium_Crypto32::box_secretkey($boxKeypair),
772
+ ParagonIE_Sodium_Crypto32::box_publickey($boxKeypair)
773
+ )
774
+ );
775
+ }
776
  return self::secretbox_encrypt(
777
  $ifp,
778
  $ofp,
798
  */
799
  protected static function box_decrypt($ifp, $ofp, $mlen, $nonce, $boxKeypair)
800
  {
801
+ if (PHP_INT_SIZE === 4) {
802
+ return self::secretbox_decrypt(
803
+ $ifp,
804
+ $ofp,
805
+ $mlen,
806
+ $nonce,
807
+ ParagonIE_Sodium_Crypto32::box_beforenm(
808
+ ParagonIE_Sodium_Crypto32::box_secretkey($boxKeypair),
809
+ ParagonIE_Sodium_Crypto32::box_publickey($boxKeypair)
810
+ )
811
+ );
812
+ }
813
  return self::secretbox_decrypt(
814
  $ifp,
815
  $ofp,
1039
  * @throws SodiumException
1040
  * @throws TypeError
1041
  */
1042
+ protected static function onetimeauth_verify(
1043
+ ParagonIE_Sodium_Core_Poly1305_State $state,
1044
+ $ifp,
1045
+ $tag = '',
1046
+ $mlen = 0
1047
+ ) {
1048
  /** @var int $pos */
1049
  $pos = ftell($ifp);
1050
 
1085
  * @psalm-suppress PossiblyInvalidArgument
1086
  * PHP 7.2 changes from a resource to an object,
1087
  * which causes Psalm to complain about an error.
1088
+ * @psalm-suppress TypeCoercion
1089
+ * Ditto.
1090
  */
1091
  public static function updateHashWithFile($hash, $fp, $size = 0)
1092
  {
1514
  * @throws SodiumException
1515
  * @throws TypeError
1516
  */
1517
+ protected static function onetimeauth_verify_core32(
1518
+ ParagonIE_Sodium_Core32_Poly1305_State $state,
1519
+ $ifp,
1520
+ $tag = '',
1521
+ $mlen = 0
1522
+ ) {
1523
  /** @var int $pos */
1524
  $pos = ftell($ifp);
1525
 
vendor/wordfence/wf-waf/src/lib/http.php CHANGED
@@ -24,13 +24,16 @@ class wfWAFHTTP {
24
  * @return wfWAFHTTPResponse|bool
25
  * @throws wfWAFHTTPTransportException
26
  */
27
- public static function get($url, $request = null) {
28
  if (!$request) {
29
  $request = new self();
30
  }
31
  $request->setUrl($url);
32
  $request->setMethod('GET');
33
- $request->setTransport(wfWAFHTTPTransport::getInstance());
 
 
 
34
  // $request->setCookies("XDEBUG_SESSION=netbeans-xdebug");
35
  return $request->send();
36
  }
@@ -42,14 +45,17 @@ class wfWAFHTTP {
42
  * @return wfWAFHTTPResponse|bool
43
  * @throws wfWAFHTTPTransportException
44
  */
45
- public static function post($url, $post = array(), $request = null) {
46
  if (!$request) {
47
  $request = new self();
48
  }
49
  $request->setUrl($url);
50
  $request->setMethod('POST');
51
  $request->setBody($post);
52
- $request->setTransport(wfWAFHTTPTransport::getInstance());
 
 
 
53
  return $request->send();
54
  }
55
 
@@ -227,11 +233,14 @@ class wfWAFHTTPResponse {
227
  }
228
 
229
  abstract class wfWAFHTTPTransport {
230
-
231
  private static $instance;
 
 
 
232
 
233
  /**
234
- * @return mixed
 
235
  */
236
  public static function getInstance() {
237
  if (!self::$instance) {
@@ -278,6 +287,20 @@ abstract class wfWAFHTTPTransport {
278
  * @return wfWAFHTTPResponse|bool
279
  */
280
  abstract public function send($request);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  }
282
 
283
  class wfWAFHTTPTransportCurl extends wfWAFHTTPTransport {
@@ -324,7 +347,8 @@ class wfWAFHTTPTransportCurl extends wfWAFHTTPTransport {
324
  }
325
  }
326
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
327
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
 
328
  curl_setopt($ch, CURLOPT_HEADER, 1);
329
  curl_setopt($ch, CURLOPT_CAINFO, WFWAF_PATH . 'cacert.pem'); //On some systems curl uses an outdated root certificate chain file
330
  $curlResponse = curl_exec($ch);
@@ -352,7 +376,7 @@ class wfWAFHTTPTransportStreams extends wfWAFHTTPTransport {
352
  * @throws wfWAFHTTPTransportException
353
  */
354
  public function send($request) {
355
- $timeout = 5;
356
 
357
  $url = $request->getUrl();
358
  if ($queryString = $request->getQueryString()) {
24
  * @return wfWAFHTTPResponse|bool
25
  * @throws wfWAFHTTPTransportException
26
  */
27
+ public static function get($url, $request = null, $timeout = 5, $connectTimeout = null) {
28
  if (!$request) {
29
  $request = new self();
30
  }
31
  $request->setUrl($url);
32
  $request->setMethod('GET');
33
+ $transport = wfWAFHTTPTransport::getInstance();
34
+ $transport->setConnectTimeout($connectTimeout);
35
+ $transport->setTimeout($timeout);
36
+ $request->setTransport($transport);
37
  // $request->setCookies("XDEBUG_SESSION=netbeans-xdebug");
38
  return $request->send();
39
  }
45
  * @return wfWAFHTTPResponse|bool
46
  * @throws wfWAFHTTPTransportException
47
  */
48
+ public static function post($url, $post = array(), $request = null, $timeout = 5, $connectTimeout = null) {
49
  if (!$request) {
50
  $request = new self();
51
  }
52
  $request->setUrl($url);
53
  $request->setMethod('POST');
54
  $request->setBody($post);
55
+ $transport = wfWAFHTTPTransport::getInstance();
56
+ $transport->setConnectTimeout($connectTimeout);
57
+ $transport->setTimeout($timeout);
58
+ $request->setTransport($transport);
59
  return $request->send();
60
  }
61
 
233
  }
234
 
235
  abstract class wfWAFHTTPTransport {
 
236
  private static $instance;
237
+
238
+ private $_connectTimeout = null;
239
+ private $_timeout = 5;
240
 
241
  /**
242
+ * @return wfWAFHTTPTransport
243
+ * @throws wfWAFHTTPTransportException
244
  */
245
  public static function getInstance() {
246
  if (!self::$instance) {
287
  * @return wfWAFHTTPResponse|bool
288
  */
289
  abstract public function send($request);
290
+
291
+ public function setConnectTimeout($connectTimeout) {
292
+ $this->_connectTimeout = $connectTimeout;
293
+ }
294
+ public function getConnectTimeout() {
295
+ return $this->_connectTimeout;
296
+ }
297
+
298
+ public function setTimeout($timeout) {
299
+ $this->_timeout = $timeout;
300
+ }
301
+ public function getTimeout() {
302
+ return $this->_timeout;
303
+ }
304
  }
305
 
306
  class wfWAFHTTPTransportCurl extends wfWAFHTTPTransport {
347
  }
348
  }
349
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
350
+ if ($this->getConnectTimeout() !== null) { curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->getConnectTimeout()); }
351
+ curl_setopt($ch, CURLOPT_TIMEOUT, $this->getTimeout());
352
  curl_setopt($ch, CURLOPT_HEADER, 1);
353
  curl_setopt($ch, CURLOPT_CAINFO, WFWAF_PATH . 'cacert.pem'); //On some systems curl uses an outdated root certificate chain file
354
  $curlResponse = curl_exec($ch);
376
  * @throws wfWAFHTTPTransportException
377
  */
378
  public function send($request) {
379
+ $timeout = $this->getTimeout();
380
 
381
  $url = $request->getUrl();
382
  if ($queryString = $request->getQueryString()) {
vendor/wordfence/wf-waf/src/lib/waf.php CHANGED
@@ -1760,7 +1760,7 @@ class wfWAFCronFetchRulesEvent extends wfWAFCronEvent {
1760
  $payload['disabled'] = implode('|', $waf->getDisabledRuleIDs());
1761
  }
1762
 
1763
- $this->response = wfWAFHTTP::get(WFWAF_API_URL_SEC . "?" . http_build_query($payload, null, '&'));
1764
  if ($this->response) {
1765
  $jsonData = wfWAFUtils::json_decode($this->response->getBody(), true);
1766
  if (is_array($jsonData)) {
@@ -1806,7 +1806,7 @@ class wfWAFCronFetchRulesEvent extends wfWAFCronEvent {
1806
  'h' => $waf->getStorageEngine()->getConfig('homeURL', null, 'synced') ? $waf->getStorageEngine()->getConfig('homeURL', null, 'synced') : $guessSiteURL,
1807
  'openssl' => $waf->hasOpenSSL() ? 1 : 0,
1808
  'betaFeed' => (int) $waf->getStorageEngine()->getConfig('betaThreatDefenseFeed', null, 'synced'),
1809
- ), null, '&'));
1810
  if ($this->response) {
1811
  $jsonData = wfWAFUtils::json_decode($this->response->getBody(), true);
1812
  if (is_array($jsonData)) {
@@ -1895,6 +1895,10 @@ class wfWAFCronFetchRulesEvent extends wfWAFCronEvent {
1895
  }
1896
  return $newEvent;
1897
  }
 
 
 
 
1898
  }
1899
 
1900
  class wfWAFCronFetchIPListEvent extends wfWAFCronEvent {
1760
  $payload['disabled'] = implode('|', $waf->getDisabledRuleIDs());
1761
  }
1762
 
1763
+ $this->response = wfWAFHTTP::get(WFWAF_API_URL_SEC . "?" . http_build_query($payload, null, '&'), null, 10, 5);
1764
  if ($this->response) {
1765
  $jsonData = wfWAFUtils::json_decode($this->response->getBody(), true);
1766
  if (is_array($jsonData)) {
1806
  'h' => $waf->getStorageEngine()->getConfig('homeURL', null, 'synced') ? $waf->getStorageEngine()->getConfig('homeURL', null, 'synced') : $guessSiteURL,
1807
  'openssl' => $waf->hasOpenSSL() ? 1 : 0,
1808
  'betaFeed' => (int) $waf->getStorageEngine()->getConfig('betaThreatDefenseFeed', null, 'synced'),
1809
+ ), null, '&'), null, 15, 5);
1810
  if ($this->response) {
1811
  $jsonData = wfWAFUtils::json_decode($this->response->getBody(), true);
1812
  if (is_array($jsonData)) {
1895
  }
1896
  return $newEvent;
1897
  }
1898
+
1899
+ public function getResponse() {
1900
+ return $this->response;
1901
+ }
1902
  }
1903
 
1904
  class wfWAFCronFetchIPListEvent extends wfWAFCronEvent {
views/common/block-navigation-option.php CHANGED
@@ -21,7 +21,7 @@ if (!defined('WORDFENCE_VERSION')) { exit; }
21
  echo $contents;
22
  ?>
23
  <?php else: ?>
24
- <img src="<?php echo esc_attr(wfUtils::getBaseURL() . '/images/' . $img); ?>" class="wf-block-navigation-option-icon" alt="<?php echo esc_attr($title); ?>">
25
  <?php endif; ?>
26
  <div class="wf-block-navigation-option-content">
27
  <h4><a href="<?php echo esc_attr($link); ?>"><?php echo esc_html($title); ?></a></h4>
21
  echo $contents;
22
  ?>
23
  <?php else: ?>
24
+ <img src="<?php echo esc_attr(wfUtils::getBaseURL() . 'images/' . $img); ?>" class="wf-block-navigation-option-icon" alt="<?php echo esc_attr($title); ?>">
25
  <?php endif; ?>
26
  <div class="wf-block-navigation-option-content">
27
  <h4><a href="<?php echo esc_attr($link); ?>"><?php echo esc_html($title); ?></a></h4>
views/dashboard/options-group-general.php CHANGED
@@ -51,7 +51,7 @@ if (!isset($collapseable)) {
51
  <?php
52
  echo wfView::create('options/option-text', array(
53
  'textOptionName' => 'alertEmails',
54
- 'textValue' => wfConfig::get('alertEmails'),
55
  'title' => __('Where to email alerts', 'wordfence'),
56
  'placeholder' => __('Separate multiple addresses with commas', 'wordfence'),
57
  'helpLink' => wfSupportController::supportURL(wfSupportController::ITEM_DASHBOARD_OPTION_ALERT_EMAILS),
51
  <?php
52
  echo wfView::create('options/option-text', array(
53
  'textOptionName' => 'alertEmails',
54
+ 'textValue' => implode(',', wfConfig::getAlertEmails()),
55
  'title' => __('Where to email alerts', 'wordfence'),
56
  'placeholder' => __('Separate multiple addresses with commas', 'wordfence'),
57
  'helpLink' => wfSupportController::supportURL(wfSupportController::ITEM_DASHBOARD_OPTION_ALERT_EMAILS),
views/onboarding/fresh-install.php CHANGED
@@ -9,7 +9,7 @@ if (!defined('WORDFENCE_VERSION')) { exit; }
9
  <div class="wf-onboarding-logo"><img src="<?php echo esc_attr(wfUtils::getBaseURL() . 'images/logo.png'); ?>" alt="<?php _e('Wordfence - Securing your WordPress Website', 'wordfence'); ?>"></div>
10
  <h3><?php printf(__('You have successfully installed Wordfence %s', 'wordfence'), WORDFENCE_VERSION); ?></h3>
11
  <h4><?php _e('Please tell us where Wordfence should send you security alerts for your website:', 'wordfence'); ?></h4>
12
- <input type="text" id="wf-onboarding-alerts" placeholder="you@example.com" value="<?php echo esc_attr(wfConfig::get('alertEmails')); ?>">
13
  <p id="wf-onboarding-alerts-disclaimer"><?php _e('We do not use this email address for any other purpose unless you opt-in to receive other mailings. You can turn off alerts in the options.', 'wordfence'); ?></p>
14
  <div id="wf-onboarding-subscribe">
15
  <label for="wf-onboarding-email-list"><?php _e('Would you also like to join our WordPress security mailing list to receive WordPress security alerts and Wordfence news?', 'wordfence'); ?></label>
9
  <div class="wf-onboarding-logo"><img src="<?php echo esc_attr(wfUtils::getBaseURL() . 'images/logo.png'); ?>" alt="<?php _e('Wordfence - Securing your WordPress Website', 'wordfence'); ?>"></div>
10
  <h3><?php printf(__('You have successfully installed Wordfence %s', 'wordfence'), WORDFENCE_VERSION); ?></h3>
11
  <h4><?php _e('Please tell us where Wordfence should send you security alerts for your website:', 'wordfence'); ?></h4>
12
+ <input type="text" id="wf-onboarding-alerts" placeholder="you@example.com" value="<?php echo esc_attr(implode(',', wfConfig::getAlertEmails())); ?>">
13
  <p id="wf-onboarding-alerts-disclaimer"><?php _e('We do not use this email address for any other purpose unless you opt-in to receive other mailings. You can turn off alerts in the options.', 'wordfence'); ?></p>
14
  <div id="wf-onboarding-subscribe">
15
  <label for="wf-onboarding-email-list"><?php _e('Would you also like to join our WordPress security mailing list to receive WordPress security alerts and Wordfence news?', 'wordfence'); ?></label>
views/onboarding/modal-final-attempt.php CHANGED
@@ -16,7 +16,7 @@ if (!defined('WORDFENCE_VERSION')) { exit; }
16
  <div class="wf-modal-content">
17
  <div id="wf-onboarding-final-attempt-1" class="wf-onboarding-modal-content"<?php if (wfConfig::get('onboardingAttempt3') == wfOnboardingController::ONBOARDING_THIRD_EMAILS) { echo ' style="display: none;"'; } ?>>
18
  <h3><?php _e('Please tell us where Wordfence should send you security alerts for your website:', 'wordfence'); ?></h3>
19
- <input type="text" id="wf-onboarding-alerts" placeholder="you@example.com" value="<?php echo esc_attr(wfConfig::get('alertEmails')); ?>">
20
  <p id="wf-onboarding-alerts-disclaimer"><?php _e('We do not use this email address for any other purpose unless you opt-in to receive other mailings. You can turn off alerts in the options.', 'wordfence'); ?></p>
21
  <div id="wf-onboarding-subscribe">
22
  <label for="wf-onboarding-email-list"><?php _e('Would you also like to join our WordPress security mailing list to receive WordPress security alerts and Wordfence news?', 'wordfence'); ?></label>
16
  <div class="wf-modal-content">
17
  <div id="wf-onboarding-final-attempt-1" class="wf-onboarding-modal-content"<?php if (wfConfig::get('onboardingAttempt3') == wfOnboardingController::ONBOARDING_THIRD_EMAILS) { echo ' style="display: none;"'; } ?>>
18
  <h3><?php _e('Please tell us where Wordfence should send you security alerts for your website:', 'wordfence'); ?></h3>
19
+ <input type="text" id="wf-onboarding-alerts" placeholder="you@example.com" value="<?php echo esc_attr(implode(',', wfConfig::getAlertEmails())); ?>">
20
  <p id="wf-onboarding-alerts-disclaimer"><?php _e('We do not use this email address for any other purpose unless you opt-in to receive other mailings. You can turn off alerts in the options.', 'wordfence'); ?></p>
21
  <div id="wf-onboarding-subscribe">
22
  <label for="wf-onboarding-email-list"><?php _e('Would you also like to join our WordPress security mailing list to receive WordPress security alerts and Wordfence news?', 'wordfence'); ?></label>
views/onboarding/plugin-header.php CHANGED
@@ -30,7 +30,7 @@ if (!defined('WORDFENCE_VERSION')) { exit; }
30
  <li id="wf-onboarding-plugin-header-stage-content">
31
  <div id="wf-onboarding-plugin-header-stage-content-1"<?php if (wfConfig::get('onboardingAttempt2') == wfOnboardingController::ONBOARDING_FIRST_EMAILS) { echo ' style="display: none;"'; } ?>>
32
  <h4><?php _e('Please tell us where Wordfence should send you security alerts for your website:', 'wordfence'); ?></h4>
33
- <input type="text" id="wf-onboarding2-alerts" placeholder="you@example.com" value="<?php echo esc_attr(wfConfig::get('alertEmails')); ?>">
34
  <p id="wf-onboarding-alerts-disclaimer"><?php _e('We do not use this email address for any other purpose unless you opt-in to receive other mailings. You can turn off alerts in the options.', 'wordfence'); ?></p>
35
  <div id="wf-onboarding2-subscribe">
36
  <label for="wf-onboarding2-email-list"><?php _e('Would you also like to join our WordPress security mailing list to receive WordPress security alerts and Wordfence news?', 'wordfence'); ?></label>
30
  <li id="wf-onboarding-plugin-header-stage-content">
31
  <div id="wf-onboarding-plugin-header-stage-content-1"<?php if (wfConfig::get('onboardingAttempt2') == wfOnboardingController::ONBOARDING_FIRST_EMAILS) { echo ' style="display: none;"'; } ?>>
32
  <h4><?php _e('Please tell us where Wordfence should send you security alerts for your website:', 'wordfence'); ?></h4>
33
+ <input type="text" id="wf-onboarding2-alerts" placeholder="you@example.com" value="<?php echo esc_attr(implode(',', wfConfig::getAlertEmails())); ?>">
34
  <p id="wf-onboarding-alerts-disclaimer"><?php _e('We do not use this email address for any other purpose unless you opt-in to receive other mailings. You can turn off alerts in the options.', 'wordfence'); ?></p>
35
  <div id="wf-onboarding2-subscribe">
36
  <label for="wf-onboarding2-email-list"><?php _e('Would you also like to join our WordPress security mailing list to receive WordPress security alerts and Wordfence news?', 'wordfence'); ?></label>
wordfence.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Wordfence Security
4
  Plugin URI: http://www.wordfence.com/
5
  Description: Wordfence Security - Anti-virus, Firewall and Malware Scan
6
  Author: Wordfence
7
- Version: 7.2.3
8
  Author URI: http://www.wordfence.com/
9
  Network: true
10
  */
@@ -15,8 +15,8 @@ if(defined('WP_INSTALLING') && WP_INSTALLING){
15
  if (!defined('ABSPATH')) {
16
  exit;
17
  }
18
- define('WORDFENCE_VERSION', '7.2.3');
19
- define('WORDFENCE_BUILD_NUMBER', '1551370846');
20
  define('WORDFENCE_BASENAME', function_exists('plugin_basename') ? plugin_basename(__FILE__) :
21
  basename(dirname(__FILE__)) . '/' . basename(__FILE__));
22
 
4
  Plugin URI: http://www.wordfence.com/
5
  Description: Wordfence Security - Anti-virus, Firewall and Malware Scan
6
  Author: Wordfence
7
+ Version: 7.2.4
8
  Author URI: http://www.wordfence.com/
9
  Network: true
10
  */
15
  if (!defined('ABSPATH')) {
16
  exit;
17
  }
18
+ define('WORDFENCE_VERSION', '7.2.4');
19
+ define('WORDFENCE_BUILD_NUMBER', '1553617391');
20
  define('WORDFENCE_BASENAME', function_exists('plugin_basename') ? plugin_basename(__FILE__) :
21
  basename(dirname(__FILE__)) . '/' . basename(__FILE__));
22