Instant Indexing for Google - Version 1.1.14

Version Description

Download this release

Release Info

Developer rankmath
Plugin Icon 128x128 Instant Indexing for Google
Version 1.1.14
Comparing to
See all releases

Code changes from version 1.1.13 to 1.1.14

Files changed (362) hide show
  1. includes/class-instant-indexing.php +1 -1
  2. instant-indexing.php +1 -1
  3. readme.txt +5 -2
  4. vendor/composer/ClassLoader.php +102 -11
  5. vendor/composer/InstalledVersions.php +6 -6
  6. vendor/composer/installed.json +274 -153
  7. vendor/composer/installed.php +42 -42
  8. vendor/firebase/php-jwt/src/CachedKeySet.php +231 -0
  9. vendor/firebase/php-jwt/src/JWK.php +41 -22
  10. vendor/firebase/php-jwt/src/JWT.php +213 -131
  11. vendor/firebase/php-jwt/src/Key.php +64 -0
  12. vendor/google/apiclient-services/renovate.json +7 -0
  13. vendor/google/apiclient-services/src/Indexing/UrlNotification.php +27 -0
  14. vendor/google/apiclient-services/src/Indexing/UrlNotificationMetadata.php +9 -0
  15. vendor/google/apiclient-services/synth.metadata +0 -18
  16. vendor/google/apiclient-services/synth.py +0 -119
  17. vendor/google/apiclient/phpstan.neon.dist +8 -0
  18. vendor/google/apiclient/src/AccessToken/Revoke.php +42 -42
  19. vendor/google/apiclient/src/AccessToken/Verify.php +232 -221
  20. vendor/google/apiclient/src/AuthHandler/AuthHandlerFactory.php +26 -26
  21. vendor/google/apiclient/src/AuthHandler/Guzzle5AuthHandler.php +89 -91
  22. vendor/google/apiclient/src/AuthHandler/Guzzle6AuthHandler.php +96 -98
  23. vendor/google/apiclient/src/AuthHandler/Guzzle7AuthHandler.php +2 -2
  24. vendor/google/apiclient/src/Client.php +1240 -1219
  25. vendor/google/apiclient/src/Collection.php +89 -66
  26. vendor/google/apiclient/src/Http/Batch.php +192 -194
  27. vendor/google/apiclient/src/Http/MediaFileUpload.php +281 -286
  28. vendor/google/apiclient/src/Http/REST.php +141 -139
  29. vendor/google/apiclient/src/Model.php +253 -245
  30. vendor/google/apiclient/src/Service.php +36 -35
  31. vendor/google/apiclient/src/Service/Exception.php +44 -44
  32. vendor/google/apiclient/src/Service/Resource.php +251 -251
  33. vendor/google/apiclient/src/Task/Composer.php +81 -83
  34. vendor/google/apiclient/src/Task/Runner.php +239 -233
  35. vendor/google/apiclient/src/Utils/UriTemplate.php +280 -281
  36. vendor/google/apiclient/src/aliases.php +61 -20
  37. vendor/google/auth/phpstan.neon.dist +10 -0
  38. vendor/google/auth/renovate.json +0 -6
  39. vendor/google/auth/src/AccessToken.php +45 -40
  40. vendor/google/auth/src/ApplicationDefaultCredentials.php +54 -18
  41. vendor/google/auth/src/Cache/Item.php +13 -33
  42. vendor/google/auth/src/Cache/MemoryCacheItemPool.php +41 -12
  43. vendor/google/auth/src/Cache/SysVCacheItemPool.php +31 -24
  44. vendor/google/auth/src/Cache/TypedItem.php +166 -0
  45. vendor/google/auth/src/CacheTrait.php +32 -5
  46. vendor/google/auth/src/Credentials/AppIdentityCredentials.php +23 -15
  47. vendor/google/auth/src/Credentials/GCECredentials.php +14 -13
  48. vendor/google/auth/src/Credentials/IAMCredentials.php +5 -5
  49. vendor/google/auth/src/Credentials/InsecureCredentials.php +3 -5
  50. vendor/google/auth/src/Credentials/ServiceAccountCredentials.php +36 -20
  51. vendor/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php +15 -10
  52. vendor/google/auth/src/Credentials/UserRefreshCredentials.php +16 -12
  53. vendor/google/auth/src/CredentialsLoader.php +81 -44
  54. vendor/google/auth/src/FetchAuthTokenCache.php +17 -16
  55. vendor/google/auth/src/FetchAuthTokenInterface.php +5 -5
  56. vendor/google/auth/src/GCECache.php +1 -11
  57. vendor/google/auth/src/HttpHandler/Guzzle5HttpHandler.php +3 -0
  58. vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php +2 -2
  59. vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php +1 -0
  60. vendor/google/auth/src/Iam.php +3 -2
  61. vendor/google/auth/src/Middleware/AuthTokenMiddleware.php +10 -3
  62. vendor/google/auth/src/Middleware/ProxyAuthTokenMiddleware.php +155 -0
  63. vendor/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php +3 -13
  64. vendor/google/auth/src/Middleware/SimpleMiddleware.php +5 -5
  65. vendor/google/auth/src/OAuth2.php +202 -78
  66. vendor/google/auth/src/ServiceAccountSignerTrait.php +1 -1
  67. vendor/google/auth/src/Subscriber/AuthTokenSubscriber.php +0 -136
  68. vendor/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php +0 -180
  69. vendor/google/auth/src/Subscriber/SimpleSubscriber.php +0 -93
  70. vendor/google/auth/src/UpdateMetadataInterface.php +2 -2
  71. vendor/guzzlehttp/guzzle/LICENSE +9 -1
  72. vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +5 -0
  73. vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +9 -2
  74. vendor/guzzlehttp/promises/LICENSE +6 -1
  75. vendor/guzzlehttp/promises/src/EachPromise.php +4 -3
  76. vendor/guzzlehttp/promises/src/Utils.php +3 -1
  77. vendor/guzzlehttp/psr7/LICENSE +8 -1
  78. vendor/guzzlehttp/psr7/src/CachingStream.php +7 -1
  79. vendor/guzzlehttp/psr7/src/MessageTrait.php +61 -5
  80. vendor/monolog/monolog/src/Monolog/Attribute/AsMonologProcessor.php +46 -0
  81. vendor/monolog/monolog/src/Monolog/ErrorHandler.php +1 -1
  82. vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php +4 -0
  83. vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php +6 -3
  84. vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php +31 -5
  85. vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php +2 -1
  86. vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php +6 -2
  87. vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php +37 -14
  88. vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php +39 -8
  89. vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php +2 -2
  90. vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php +20 -3
  91. vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php +20 -3
  92. vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php +4 -0
  93. vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php +22 -3
  94. vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php +22 -3
  95. vendor/monolog/monolog/src/Monolog/Handler/LogmaticHandler.php +23 -3
  96. vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php +16 -2
  97. vendor/monolog/monolog/src/Monolog/Handler/SendGridHandler.php +4 -0
  98. vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php +8 -6
  99. vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php +16 -2
  100. vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php +4 -0
  101. vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php +41 -10
  102. vendor/monolog/monolog/src/Monolog/Handler/SqsHandler.php +1 -1
  103. vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php +33 -6
  104. vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php +6 -1
  105. vendor/monolog/monolog/src/Monolog/Handler/SymfonyMailerHandler.php +111 -0
  106. vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php +2 -1
  107. vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php +27 -13
  108. vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php +5 -0
  109. vendor/monolog/monolog/src/Monolog/Handler/TelegramBotHandler.php +91 -7
  110. vendor/monolog/monolog/src/Monolog/LogRecord.php +34 -0
  111. vendor/monolog/monolog/src/Monolog/Logger.php +75 -51
  112. vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php +1 -0
  113. vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php +13 -9
  114. vendor/monolog/monolog/src/Monolog/Test/TestCase.php +9 -0
  115. vendor/monolog/monolog/src/Monolog/Utils.php +55 -0
  116. vendor/paragonie/constant_time_encoding/LICENSE.txt +1 -1
  117. vendor/paragonie/constant_time_encoding/psalm.xml +0 -9
  118. vendor/paragonie/constant_time_encoding/src/Base32.php +3 -4
  119. vendor/paragonie/constant_time_encoding/src/Base64.php +4 -5
  120. vendor/paragonie/constant_time_encoding/src/Binary.php +3 -1
  121. vendor/paragonie/constant_time_encoding/src/Hex.php +0 -18
  122. vendor/paragonie/constant_time_encoding/tests/Base32HexTest.php +0 -49
  123. vendor/paragonie/constant_time_encoding/tests/Base32Test.php +0 -50
  124. vendor/paragonie/constant_time_encoding/tests/Base64DotSlashOrderedTest.php +0 -34
  125. vendor/paragonie/constant_time_encoding/tests/Base64DotSlashTest.php +0 -34
  126. vendor/paragonie/constant_time_encoding/tests/Base64Test.php +0 -79
  127. vendor/paragonie/constant_time_encoding/tests/Base64UrlSafeTest.php +0 -58
  128. vendor/paragonie/constant_time_encoding/tests/EncodingTest.php +0 -307
  129. vendor/paragonie/constant_time_encoding/tests/HexTest.php +0 -39
  130. vendor/paragonie/constant_time_encoding/tests/RFC4648Test.php +0 -84
  131. vendor/phpseclib/phpseclib/appveyor.yml +0 -27
  132. vendor/phpseclib/phpseclib/phpseclib/Common/Functions/Strings.php +70 -29
  133. vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php +16 -16
  134. vendor/phpseclib/phpseclib/phpseclib/Crypt/ChaCha20.php +32 -25
  135. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/AsymmetricKey.php +21 -16
  136. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php +4 -4
  137. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS.php +1 -1
  138. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php +6 -6
  139. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php +22 -17
  140. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php +163 -35
  141. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/PrivateKey.php +6 -1
  142. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/SymmetricKey.php +294 -166
  143. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Traits/Fingerprint.php +1 -1
  144. vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Traits/PasswordProtected.php +2 -2
  145. vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php +4 -4
  146. vendor/phpseclib/phpseclib/phpseclib/Crypt/DH.php +14 -11
  147. vendor/phpseclib/phpseclib/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php +1 -1
  148. vendor/phpseclib/phpseclib/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php +4 -4
  149. vendor/phpseclib/phpseclib/phpseclib/Crypt/DH/PrivateKey.php +1 -1
  150. vendor/phpseclib/phpseclib/phpseclib/Crypt/DH/PublicKey.php +1 -1
  151. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA.php +16 -13
  152. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php +1 -2
  153. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php +2 -2
  154. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php +3 -3
  155. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php +1 -1
  156. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/XML.php +7 -1
  157. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php +1 -1
  158. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php +4 -2
  159. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PrivateKey.php +1 -1
  160. vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PublicKey.php +1 -1
  161. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC.php +18 -15
  162. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Base.php +23 -7
  163. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Binary.php +4 -5
  164. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php +5 -6
  165. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Montgomery.php +4 -6
  166. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Prime.php +34 -22
  167. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php +2 -2
  168. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Curve25519.php +25 -6
  169. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Curve448.php +30 -7
  170. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Ed25519.php +1 -2
  171. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Ed448.php +9 -6
  172. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php +1 -1
  173. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php +1 -1
  174. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php +1 -1
  175. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php +1 -1
  176. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php +1 -1
  177. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php +1 -1
  178. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php +1 -1
  179. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php +1 -1
  180. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php +1 -1
  181. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php +19 -7
  182. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php +19 -7
  183. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php +19 -7
  184. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php +19 -7
  185. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistb233.php +1 -1
  186. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistb409.php +1 -1
  187. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk163.php +1 -1
  188. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk233.php +1 -1
  189. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk283.php +1 -1
  190. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk409.php +1 -1
  191. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp192.php +1 -1
  192. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp224.php +1 -1
  193. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp256.php +1 -1
  194. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp384.php +1 -1
  195. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp521.php +1 -1
  196. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistt571.php +1 -1
  197. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v1.php +1 -1
  198. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v2.php +1 -1
  199. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v3.php +1 -1
  200. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v1.php +1 -1
  201. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v2.php +1 -1
  202. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v3.php +1 -1
  203. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime256v1.php +1 -1
  204. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp112r1.php +1 -1
  205. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp112r2.php +1 -1
  206. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp128r1.php +1 -1
  207. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp128r2.php +1 -1
  208. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160k1.php +1 -1
  209. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160r1.php +1 -1
  210. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160r2.php +1 -1
  211. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp192k1.php +1 -1
  212. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp192r1.php +2 -2
  213. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp224k1.php +1 -1
  214. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp256k1.php +1 -1
  215. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp384r1.php +1 -1
  216. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp521r1.php +1 -1
  217. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect113r1.php +1 -1
  218. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect113r2.php +1 -1
  219. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect131r1.php +1 -1
  220. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect131r2.php +1 -1
  221. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163k1.php +1 -1
  222. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163r1.php +1 -1
  223. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect409k1.php +2 -1
  224. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect409r1.php +2 -1
  225. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect571k1.php +2 -1
  226. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect571r1.php +2 -1
  227. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/Common.php +6 -7
  228. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php +8 -8
  229. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php +3 -4
  230. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php +8 -9
  231. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php +11 -13
  232. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php +13 -14
  233. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php +6 -7
  234. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/XML.php +16 -9
  235. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/libsodium.php +3 -4
  236. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/ASN1.php +1 -1
  237. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/SSH2.php +1 -1
  238. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PrivateKey.php +12 -13
  239. vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PublicKey.php +8 -8
  240. vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php +41 -38
  241. vendor/phpseclib/phpseclib/phpseclib/Crypt/PublicKeyLoader.php +12 -8
  242. vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php +1 -1
  243. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php +17 -15
  244. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php +12 -11
  245. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php +1 -2
  246. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php +3 -3
  247. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php +3 -3
  248. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PSS.php +3 -3
  249. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php +1 -1
  250. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/Raw.php +116 -33
  251. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/XML.php +7 -1
  252. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/PrivateKey.php +9 -13
  253. vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/PublicKey.php +10 -11
  254. vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php +2 -2
  255. vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php +49 -50
  256. vendor/phpseclib/phpseclib/phpseclib/Crypt/Salsa20.php +29 -27
  257. vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php +4 -3
  258. vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php +34 -34
  259. vendor/phpseclib/phpseclib/phpseclib/File/ANSI.php +22 -21
  260. vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php +58 -40
  261. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AccessDescription.php +2 -2
  262. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AdministrationDomainName.php +4 -4
  263. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php +3 -3
  264. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AnotherName.php +8 -8
  265. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attribute.php +6 -6
  266. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php +2 -2
  267. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attributes.php +3 -3
  268. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php +3 -3
  269. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php +15 -15
  270. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BasicConstraints.php +9 -9
  271. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php +3 -3
  272. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php +3 -3
  273. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php +37 -37
  274. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php +3 -3
  275. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLReason.php +11 -11
  276. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Certificate.php +4 -4
  277. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateList.php +3 -3
  278. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificatePolicies.php +3 -3
  279. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequest.php +3 -3
  280. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php +11 -11
  281. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Characteristic_two.php +1 -1
  282. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CountryName.php +4 -4
  283. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DHParameter.php +1 -1
  284. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPrivateKey.php +1 -1
  285. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DigestInfo.php +1 -1
  286. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DirectoryString.php +4 -4
  287. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DisplayText.php +4 -4
  288. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPoint.php +15 -15
  289. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPointName.php +10 -10
  290. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DssSigValue.php +1 -1
  291. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECParameters.php +1 -1
  292. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EDIPartyName.php +13 -13
  293. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EcdsaSigValue.php +1 -1
  294. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php +2 -2
  295. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php +3 -3
  296. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extension.php +6 -6
  297. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttribute.php +13 -13
  298. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttributes.php +3 -3
  299. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extensions.php +3 -3
  300. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldID.php +1 -1
  301. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralName.php +50 -50
  302. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralNames.php +3 -3
  303. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtree.php +11 -11
  304. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtrees.php +3 -3
  305. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HashAlgorithm.php +1 -1
  306. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php +39 -39
  307. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyUsage.php +1 -1
  308. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php +1 -1
  309. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Name.php +1 -1
  310. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NameConstraints.php +10 -10
  311. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NoticeReference.php +7 -7
  312. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ORAddress.php +4 -4
  313. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php +2 -2
  314. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php +3 -3
  315. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php +3 -3
  316. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBEParameter.php +1 -1
  317. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBES2params.php +2 -2
  318. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBKDF2params.php +4 -4
  319. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBMAC1params.php +3 -3
  320. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PKCS9String.php +5 -5
  321. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Pentanomial.php +4 -4
  322. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PersonalName.php +24 -24
  323. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyInformation.php +7 -7
  324. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyMappings.php +9 -9
  325. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php +2 -2
  326. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PostalAddress.php +3 -3
  327. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Prime_p.php +1 -1
  328. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateDomainName.php +2 -2
  329. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php +2 -2
  330. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php +10 -10
  331. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php +2 -2
  332. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyInfo.php +2 -2
  333. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RC2CBCParameter.php +4 -4
  334. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RDNSequence.php +3 -3
  335. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPrivateKey.php +7 -7
  336. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPublicKey.php +2 -2
  337. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php +8 -8
  338. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ReasonFlags.php +1 -1
  339. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php +3 -3
  340. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RevokedCertificate.php +7 -7
  341. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php +3 -3
  342. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php +1 -1
  343. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php +3 -3
  344. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php +3 -3
  345. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php +2 -2
  346. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertList.php +24 -24
  347. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertificate.php +29 -29
  348. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Time.php +2 -2
  349. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Trinomial.php +1 -1
  350. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UserNotice.php +8 -8
  351. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Validity.php +2 -2
  352. vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_cert_type.php +1 -1
  353. vendor/phpseclib/phpseclib/phpseclib/File/X509.php +50 -45
  354. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php +81 -50
  355. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php +35 -74
  356. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php +5 -5
  357. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php +1 -1
  358. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php +1 -1
  359. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php +1 -1
  360. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php +3 -3
  361. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php +4 -9
  362. vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/Engine.php +68 -23
includes/class-instant-indexing.php CHANGED
@@ -15,7 +15,7 @@ class RM_GIAPI {
15
  *
16
  * @var string
17
  */
18
- public $version = '1.1.13';
19
 
20
  /**
21
  * Holds the admin menu hook suffix for the "dummy" dashboard.
15
  *
16
  * @var string
17
  */
18
+ public $version = '1.1.14';
19
 
20
  /**
21
  * Holds the admin menu hook suffix for the "dummy" dashboard.
instant-indexing.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Instant Indexing
4
  * Plugin URI: https://rankmath.com/wordpress/plugin/instant-indexing/
5
  * Description: Get your website crawled immediately by Google using their NEW Indexing APIs.
6
- * Version: 1.1.13
7
  * Author: Rank Math
8
  * Author URI: https://s.rankmath.com/home
9
  * License: GPL v3
3
  * Plugin Name: Instant Indexing
4
  * Plugin URI: https://rankmath.com/wordpress/plugin/instant-indexing/
5
  * Description: Get your website crawled immediately by Google using their NEW Indexing APIs.
6
+ * Version: 1.1.14
7
  * Author: Rank Math
8
  * Author URI: https://s.rankmath.com/home
9
  * License: GPL v3
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: rankmath
3
  Plugin link: https://rankmath.com/wordpress/plugin/instant-indexing/
4
  Tags: indexing api, crawling, live streaming, fast indexing, job posting
5
- Tested up to: 5.9.2
6
  Requires at least: 5.6
7
  Requires PHP: 7.2
8
- Stable tag: 1.1.13
9
  License: GPL-2.0+
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.txt
11
 
@@ -106,6 +106,9 @@ Technically, yes. That's what the plugin is made to do. But, please note that we
106
 
107
  == Changelog ==
108
 
 
 
 
109
  = v1.1.13 [Mar 16, 2022] =
110
  * Fixed: special characters getting removed from submitted URL
111
  * Fixed: double IndexNow submissions
2
  Contributors: rankmath
3
  Plugin link: https://rankmath.com/wordpress/plugin/instant-indexing/
4
  Tags: indexing api, crawling, live streaming, fast indexing, job posting
5
+ Tested up to: 6.0
6
  Requires at least: 5.6
7
  Requires PHP: 7.2
8
+ Stable tag: 1.1.14
9
  License: GPL-2.0+
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.txt
11
 
106
 
107
  == Changelog ==
108
 
109
+ = v1.1.14 [Jun 4, 2022] =
110
+ * Updated the third-party libraries included in the plugin
111
+
112
  = v1.1.13 [Mar 16, 2022] =
113
  * Fixed: special characters getting removed from submitted URL
114
  * Fixed: double IndexNow submissions
vendor/composer/ClassLoader.php CHANGED
@@ -42,30 +42,75 @@ namespace Composer\Autoload;
42
  */
43
  class ClassLoader
44
  {
 
45
  private $vendorDir;
46
 
47
  // PSR-4
 
 
 
 
48
  private $prefixLengthsPsr4 = array();
 
 
 
 
49
  private $prefixDirsPsr4 = array();
 
 
 
 
50
  private $fallbackDirsPsr4 = array();
51
 
52
  // PSR-0
 
 
 
 
53
  private $prefixesPsr0 = array();
 
 
 
 
54
  private $fallbackDirsPsr0 = array();
55
 
 
56
  private $useIncludePath = false;
 
 
 
 
 
57
  private $classMap = array();
 
 
58
  private $classMapAuthoritative = false;
 
 
 
 
 
59
  private $missingClasses = array();
 
 
60
  private $apcuPrefix;
61
 
 
 
 
62
  private static $registeredLoaders = array();
63
 
 
 
 
64
  public function __construct($vendorDir = null)
65
  {
66
  $this->vendorDir = $vendorDir;
67
  }
68
 
 
 
 
69
  public function getPrefixes()
70
  {
71
  if (!empty($this->prefixesPsr0)) {
@@ -75,28 +120,47 @@ class ClassLoader
75
  return array();
76
  }
77
 
 
 
 
 
78
  public function getPrefixesPsr4()
79
  {
80
  return $this->prefixDirsPsr4;
81
  }
82
 
 
 
 
 
83
  public function getFallbackDirs()
84
  {
85
  return $this->fallbackDirsPsr0;
86
  }
87
 
 
 
 
 
88
  public function getFallbackDirsPsr4()
89
  {
90
  return $this->fallbackDirsPsr4;
91
  }
92
 
 
 
 
 
93
  public function getClassMap()
94
  {
95
  return $this->classMap;
96
  }
97
 
98
  /**
99
- * @param array $classMap Class to filename map
 
 
 
100
  */
101
  public function addClassMap(array $classMap)
102
  {
@@ -111,9 +175,11 @@ class ClassLoader
111
  * Registers a set of PSR-0 directories for a given prefix, either
112
  * appending or prepending to the ones previously set for this prefix.
113
  *
114
- * @param string $prefix The prefix
115
- * @param array|string $paths The PSR-0 root directories
116
- * @param bool $prepend Whether to prepend the directories
 
 
117
  */
118
  public function add($prefix, $paths, $prepend = false)
119
  {
@@ -156,11 +222,13 @@ class ClassLoader
156
  * Registers a set of PSR-4 directories for a given namespace, either
157
  * appending or prepending to the ones previously set for this namespace.
158
  *
159
- * @param string $prefix The prefix/namespace, with trailing '\\'
160
- * @param array|string $paths The PSR-4 base directories
161
- * @param bool $prepend Whether to prepend the directories
162
  *
163
  * @throws \InvalidArgumentException
 
 
164
  */
165
  public function addPsr4($prefix, $paths, $prepend = false)
166
  {
@@ -204,8 +272,10 @@ class ClassLoader
204
  * Registers a set of PSR-0 directories for a given prefix,
205
  * replacing any others previously set for this prefix.
206
  *
207
- * @param string $prefix The prefix
208
- * @param array|string $paths The PSR-0 base directories
 
 
209
  */
210
  public function set($prefix, $paths)
211
  {
@@ -220,10 +290,12 @@ class ClassLoader
220
  * Registers a set of PSR-4 directories for a given namespace,
221
  * replacing any others previously set for this namespace.
222
  *
223
- * @param string $prefix The prefix/namespace, with trailing '\\'
224
- * @param array|string $paths The PSR-4 base directories
225
  *
226
  * @throws \InvalidArgumentException
 
 
227
  */
228
  public function setPsr4($prefix, $paths)
229
  {
@@ -243,6 +315,8 @@ class ClassLoader
243
  * Turns on searching the include path for class files.
244
  *
245
  * @param bool $useIncludePath
 
 
246
  */
247
  public function setUseIncludePath($useIncludePath)
248
  {
@@ -265,6 +339,8 @@ class ClassLoader
265
  * that have not been registered with the class map.
266
  *
267
  * @param bool $classMapAuthoritative
 
 
268
  */
269
  public function setClassMapAuthoritative($classMapAuthoritative)
270
  {
@@ -285,6 +361,8 @@ class ClassLoader
285
  * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
286
  *
287
  * @param string|null $apcuPrefix
 
 
288
  */
289
  public function setApcuPrefix($apcuPrefix)
290
  {
@@ -305,6 +383,8 @@ class ClassLoader
305
  * Registers this instance as an autoloader.
306
  *
307
  * @param bool $prepend Whether to prepend the autoloader or not
 
 
308
  */
309
  public function register($prepend = false)
310
  {
@@ -324,6 +404,8 @@ class ClassLoader
324
 
325
  /**
326
  * Unregisters this instance as an autoloader.
 
 
327
  */
328
  public function unregister()
329
  {
@@ -403,6 +485,11 @@ class ClassLoader
403
  return self::$registeredLoaders;
404
  }
405
 
 
 
 
 
 
406
  private function findFileWithExtension($class, $ext)
407
  {
408
  // PSR-4 lookup
@@ -474,6 +561,10 @@ class ClassLoader
474
  * Scope isolated include.
475
  *
476
  * Prevents access to $this/self from included files.
 
 
 
 
477
  */
478
  function includeFile($file)
479
  {
42
  */
43
  class ClassLoader
44
  {
45
+ /** @var ?string */
46
  private $vendorDir;
47
 
48
  // PSR-4
49
+ /**
50
+ * @var array[]
51
+ * @psalm-var array<string, array<string, int>>
52
+ */
53
  private $prefixLengthsPsr4 = array();
54
+ /**
55
+ * @var array[]
56
+ * @psalm-var array<string, array<int, string>>
57
+ */
58
  private $prefixDirsPsr4 = array();
59
+ /**
60
+ * @var array[]
61
+ * @psalm-var array<string, string>
62
+ */
63
  private $fallbackDirsPsr4 = array();
64
 
65
  // PSR-0
66
+ /**
67
+ * @var array[]
68
+ * @psalm-var array<string, array<string, string[]>>
69
+ */
70
  private $prefixesPsr0 = array();
71
+ /**
72
+ * @var array[]
73
+ * @psalm-var array<string, string>
74
+ */
75
  private $fallbackDirsPsr0 = array();
76
 
77
+ /** @var bool */
78
  private $useIncludePath = false;
79
+
80
+ /**
81
+ * @var string[]
82
+ * @psalm-var array<string, string>
83
+ */
84
  private $classMap = array();
85
+
86
+ /** @var bool */
87
  private $classMapAuthoritative = false;
88
+
89
+ /**
90
+ * @var bool[]
91
+ * @psalm-var array<string, bool>
92
+ */
93
  private $missingClasses = array();
94
+
95
+ /** @var ?string */
96
  private $apcuPrefix;
97
 
98
+ /**
99
+ * @var self[]
100
+ */
101
  private static $registeredLoaders = array();
102
 
103
+ /**
104
+ * @param ?string $vendorDir
105
+ */
106
  public function __construct($vendorDir = null)
107
  {
108
  $this->vendorDir = $vendorDir;
109
  }
110
 
111
+ /**
112
+ * @return string[]
113
+ */
114
  public function getPrefixes()
115
  {
116
  if (!empty($this->prefixesPsr0)) {
120
  return array();
121
  }
122
 
123
+ /**
124
+ * @return array[]
125
+ * @psalm-return array<string, array<int, string>>
126
+ */
127
  public function getPrefixesPsr4()
128
  {
129
  return $this->prefixDirsPsr4;
130
  }
131
 
132
+ /**
133
+ * @return array[]
134
+ * @psalm-return array<string, string>
135
+ */
136
  public function getFallbackDirs()
137
  {
138
  return $this->fallbackDirsPsr0;
139
  }
140
 
141
+ /**
142
+ * @return array[]
143
+ * @psalm-return array<string, string>
144
+ */
145
  public function getFallbackDirsPsr4()
146
  {
147
  return $this->fallbackDirsPsr4;
148
  }
149
 
150
+ /**
151
+ * @return string[] Array of classname => path
152
+ * @psalm-var array<string, string>
153
+ */
154
  public function getClassMap()
155
  {
156
  return $this->classMap;
157
  }
158
 
159
  /**
160
+ * @param string[] $classMap Class to filename map
161
+ * @psalm-param array<string, string> $classMap
162
+ *
163
+ * @return void
164
  */
165
  public function addClassMap(array $classMap)
166
  {
175
  * Registers a set of PSR-0 directories for a given prefix, either
176
  * appending or prepending to the ones previously set for this prefix.
177
  *
178
+ * @param string $prefix The prefix
179
+ * @param string[]|string $paths The PSR-0 root directories
180
+ * @param bool $prepend Whether to prepend the directories
181
+ *
182
+ * @return void
183
  */
184
  public function add($prefix, $paths, $prepend = false)
185
  {
222
  * Registers a set of PSR-4 directories for a given namespace, either
223
  * appending or prepending to the ones previously set for this namespace.
224
  *
225
+ * @param string $prefix The prefix/namespace, with trailing '\\'
226
+ * @param string[]|string $paths The PSR-4 base directories
227
+ * @param bool $prepend Whether to prepend the directories
228
  *
229
  * @throws \InvalidArgumentException
230
+ *
231
+ * @return void
232
  */
233
  public function addPsr4($prefix, $paths, $prepend = false)
234
  {
272
  * Registers a set of PSR-0 directories for a given prefix,
273
  * replacing any others previously set for this prefix.
274
  *
275
+ * @param string $prefix The prefix
276
+ * @param string[]|string $paths The PSR-0 base directories
277
+ *
278
+ * @return void
279
  */
280
  public function set($prefix, $paths)
281
  {
290
  * Registers a set of PSR-4 directories for a given namespace,
291
  * replacing any others previously set for this namespace.
292
  *
293
+ * @param string $prefix The prefix/namespace, with trailing '\\'
294
+ * @param string[]|string $paths The PSR-4 base directories
295
  *
296
  * @throws \InvalidArgumentException
297
+ *
298
+ * @return void
299
  */
300
  public function setPsr4($prefix, $paths)
301
  {
315
  * Turns on searching the include path for class files.
316
  *
317
  * @param bool $useIncludePath
318
+ *
319
+ * @return void
320
  */
321
  public function setUseIncludePath($useIncludePath)
322
  {
339
  * that have not been registered with the class map.
340
  *
341
  * @param bool $classMapAuthoritative
342
+ *
343
+ * @return void
344
  */
345
  public function setClassMapAuthoritative($classMapAuthoritative)
346
  {
361
  * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
362
  *
363
  * @param string|null $apcuPrefix
364
+ *
365
+ * @return void
366
  */
367
  public function setApcuPrefix($apcuPrefix)
368
  {
383
  * Registers this instance as an autoloader.
384
  *
385
  * @param bool $prepend Whether to prepend the autoloader or not
386
+ *
387
+ * @return void
388
  */
389
  public function register($prepend = false)
390
  {
404
 
405
  /**
406
  * Unregisters this instance as an autoloader.
407
+ *
408
+ * @return void
409
  */
410
  public function unregister()
411
  {
485
  return self::$registeredLoaders;
486
  }
487
 
488
+ /**
489
+ * @param string $class
490
+ * @param string $ext
491
+ * @return string|false
492
+ */
493
  private function findFileWithExtension($class, $ext)
494
  {
495
  // PSR-4 lookup
561
  * Scope isolated include.
562
  *
563
  * Prevents access to $this/self from included files.
564
+ *
565
+ * @param string $file
566
+ * @return void
567
+ * @private
568
  */
569
  function includeFile($file)
570
  {
vendor/composer/InstalledVersions.php CHANGED
@@ -20,7 +20,7 @@ use Composer\Semver\VersionParser;
20
  *
21
  * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
22
  *
23
- * To require it's presence, you can require `composer-runtime-api ^2.0`
24
  */
25
  class InstalledVersions
26
  {
@@ -228,7 +228,7 @@ class InstalledVersions
228
 
229
  /**
230
  * @return array
231
- * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}
232
  */
233
  public static function getRootPackage()
234
  {
@@ -242,7 +242,7 @@ class InstalledVersions
242
  *
243
  * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
244
  * @return array[]
245
- * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}
246
  */
247
  public static function getRawData()
248
  {
@@ -265,7 +265,7 @@ class InstalledVersions
265
  * Returns the raw data of all installed.php which are currently loaded for custom implementations
266
  *
267
  * @return array[]
268
- * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
269
  */
270
  public static function getAllRawData()
271
  {
@@ -288,7 +288,7 @@ class InstalledVersions
288
  * @param array[] $data A vendor/composer/installed.php data set
289
  * @return void
290
  *
291
- * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>} $data
292
  */
293
  public static function reload($data)
294
  {
@@ -298,7 +298,7 @@ class InstalledVersions
298
 
299
  /**
300
  * @return array[]
301
- * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
302
  */
303
  private static function getInstalled()
304
  {
20
  *
21
  * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
22
  *
23
+ * To require its presence, you can require `composer-runtime-api ^2.0`
24
  */
25
  class InstalledVersions
26
  {
228
 
229
  /**
230
  * @return array
231
+ * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
232
  */
233
  public static function getRootPackage()
234
  {
242
  *
243
  * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
244
  * @return array[]
245
+ * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
246
  */
247
  public static function getRawData()
248
  {
265
  * Returns the raw data of all installed.php which are currently loaded for custom implementations
266
  *
267
  * @return array[]
268
+ * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
269
  */
270
  public static function getAllRawData()
271
  {
288
  * @param array[] $data A vendor/composer/installed.php data set
289
  * @return void
290
  *
291
+ * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
292
  */
293
  public static function reload($data)
294
  {
298
 
299
  /**
300
  * @return array[]
301
+ * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
302
  */
303
  private static function getInstalled()
304
  {
vendor/composer/installed.json CHANGED
@@ -2,29 +2,34 @@
2
  "packages": [
3
  {
4
  "name": "firebase/php-jwt",
5
- "version": "v5.4.0",
6
- "version_normalized": "5.4.0.0",
7
  "source": {
8
  "type": "git",
9
  "url": "https://github.com/firebase/php-jwt.git",
10
- "reference": "d2113d9b2e0e349796e72d2a63cf9319100382d2"
11
  },
12
  "dist": {
13
  "type": "zip",
14
- "url": "https://api.github.com/repos/firebase/php-jwt/zipball/d2113d9b2e0e349796e72d2a63cf9319100382d2",
15
- "reference": "d2113d9b2e0e349796e72d2a63cf9319100382d2",
16
  "shasum": ""
17
  },
18
  "require": {
19
- "php": ">=5.3.0"
20
  },
21
  "require-dev": {
22
- "phpunit/phpunit": ">=4.8 <=9"
 
 
 
 
 
23
  },
24
  "suggest": {
25
  "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present"
26
  },
27
- "time": "2021-06-23T19:00:23+00:00",
28
  "type": "library",
29
  "installation-source": "dist",
30
  "autoload": {
@@ -56,63 +61,64 @@
56
  ],
57
  "support": {
58
  "issues": "https://github.com/firebase/php-jwt/issues",
59
- "source": "https://github.com/firebase/php-jwt/tree/v5.4.0"
60
  },
61
  "install-path": "../firebase/php-jwt"
62
  },
63
  {
64
  "name": "google/apiclient",
65
- "version": "v2.10.1",
66
- "version_normalized": "2.10.1.0",
67
  "source": {
68
  "type": "git",
69
  "url": "https://github.com/googleapis/google-api-php-client.git",
70
- "reference": "11871e94006ce7a419bb6124d51b6f9ace3f679b"
71
  },
72
  "dist": {
73
  "type": "zip",
74
- "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/11871e94006ce7a419bb6124d51b6f9ace3f679b",
75
- "reference": "11871e94006ce7a419bb6124d51b6f9ace3f679b",
76
  "shasum": ""
77
  },
78
  "require": {
79
- "firebase/php-jwt": "~2.0||~3.0||~4.0||~5.0",
80
  "google/apiclient-services": "~0.200",
81
  "google/auth": "^1.10",
82
  "guzzlehttp/guzzle": "~5.3.3||~6.0||~7.0",
83
- "guzzlehttp/psr7": "^1.2",
84
- "monolog/monolog": "^1.17|^2.0",
85
  "php": "^5.6|^7.0|^8.0",
86
  "phpseclib/phpseclib": "~2.0||^3.0.2"
87
  },
88
  "require-dev": {
89
  "cache/filesystem-adapter": "^0.3.2|^1.1",
90
  "composer/composer": "^1.10.22",
91
- "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
92
  "phpcompatibility/php-compatibility": "^9.2",
93
- "phpunit/phpunit": "^5.7||^8.5.13",
94
- "squizlabs/php_codesniffer": "~2.3",
 
95
  "symfony/css-selector": "~2.1",
96
- "symfony/dom-crawler": "~2.1"
 
97
  },
98
  "suggest": {
99
  "cache/filesystem-adapter": "For caching certs and tokens (using Google\\Client::setCache)"
100
  },
101
- "time": "2021-06-25T14:25:44+00:00",
102
  "type": "library",
103
  "extra": {
104
  "branch-alias": {
105
- "dev-master": "2.x-dev"
106
  }
107
  },
108
  "installation-source": "dist",
109
  "autoload": {
110
- "psr-4": {
111
- "Google\\": "src/"
112
- },
113
  "files": [
114
  "src/aliases.php"
115
  ],
 
 
 
116
  "classmap": [
117
  "src/aliases.php"
118
  ]
@@ -128,23 +134,23 @@
128
  ],
129
  "support": {
130
  "issues": "https://github.com/googleapis/google-api-php-client/issues",
131
- "source": "https://github.com/googleapis/google-api-php-client/tree/v2.10.1"
132
  },
133
  "install-path": "../google/apiclient"
134
  },
135
  {
136
  "name": "google/apiclient-services",
137
- "version": "v0.206.0",
138
- "version_normalized": "0.206.0.0",
139
  "source": {
140
  "type": "git",
141
  "url": "https://github.com/googleapis/google-api-php-client-services.git",
142
- "reference": "8ac3f4a7c201bbf794801b215e63f75f15cd0208"
143
  },
144
  "dist": {
145
  "type": "zip",
146
- "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/8ac3f4a7c201bbf794801b215e63f75f15cd0208",
147
- "reference": "8ac3f4a7c201bbf794801b215e63f75f15cd0208",
148
  "shasum": ""
149
  },
150
  "require": {
@@ -153,16 +159,16 @@
153
  "require-dev": {
154
  "phpunit/phpunit": "^5.7||^8.5.13"
155
  },
156
- "time": "2021-07-31T11:20:25+00:00",
157
  "type": "library",
158
  "installation-source": "dist",
159
  "autoload": {
160
- "psr-4": {
161
- "Google\\Service\\": "src"
162
- },
163
  "files": [
164
  "autoload.php"
165
- ]
 
 
 
166
  },
167
  "notification-url": "https://packagist.org/downloads/",
168
  "license": [
@@ -175,45 +181,46 @@
175
  ],
176
  "support": {
177
  "issues": "https://github.com/googleapis/google-api-php-client-services/issues",
178
- "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.206.0"
179
  },
180
  "install-path": "../google/apiclient-services"
181
  },
182
  {
183
  "name": "google/auth",
184
- "version": "v1.16.0",
185
- "version_normalized": "1.16.0.0",
186
  "source": {
187
  "type": "git",
188
  "url": "https://github.com/googleapis/google-auth-library-php.git",
189
- "reference": "c747738d2dd450f541f09f26510198fbedd1c8a0"
190
  },
191
  "dist": {
192
  "type": "zip",
193
- "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/c747738d2dd450f541f09f26510198fbedd1c8a0",
194
- "reference": "c747738d2dd450f541f09f26510198fbedd1c8a0",
195
  "shasum": ""
196
  },
197
  "require": {
198
- "firebase/php-jwt": "~2.0|~3.0|~4.0|~5.0",
199
- "guzzlehttp/guzzle": "^5.3.1|^6.2.1|^7.0",
200
- "guzzlehttp/psr7": "^1.2",
201
- "php": ">=5.4",
202
- "psr/cache": "^1.0|^2.0",
203
  "psr/http-message": "^1.0"
204
  },
205
  "require-dev": {
206
  "guzzlehttp/promises": "0.1.1|^1.3",
207
  "kelvinmo/simplejwt": "^0.2.5|^0.5.1",
208
  "phpseclib/phpseclib": "^2.0.31",
209
- "phpunit/phpunit": "^4.8.36|^5.7",
 
210
  "sebastian/comparator": ">=1.2.3",
211
  "squizlabs/php_codesniffer": "^3.5"
212
  },
213
  "suggest": {
214
  "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2."
215
  },
216
- "time": "2021-06-22T18:06:03+00:00",
217
  "type": "library",
218
  "installation-source": "dist",
219
  "autoload": {
@@ -233,25 +240,25 @@
233
  "oauth2"
234
  ],
235
  "support": {
236
- "docs": "https://googleapis.github.io/google-auth-library-php/master/",
237
  "issues": "https://github.com/googleapis/google-auth-library-php/issues",
238
- "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.16.0"
239
  },
240
  "install-path": "../google/auth"
241
  },
242
  {
243
  "name": "guzzlehttp/guzzle",
244
- "version": "6.5.5",
245
- "version_normalized": "6.5.5.0",
246
  "source": {
247
  "type": "git",
248
  "url": "https://github.com/guzzle/guzzle.git",
249
- "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e"
250
  },
251
  "dist": {
252
  "type": "zip",
253
- "url": "https://api.github.com/repos/guzzle/guzzle/zipball/9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
254
- "reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
255
  "shasum": ""
256
  },
257
  "require": {
@@ -269,7 +276,7 @@
269
  "suggest": {
270
  "psr/log": "Required for using the Log middleware"
271
  },
272
- "time": "2020-06-16T21:01:06+00:00",
273
  "type": "library",
274
  "extra": {
275
  "branch-alias": {
@@ -278,22 +285,52 @@
278
  },
279
  "installation-source": "dist",
280
  "autoload": {
281
- "psr-4": {
282
- "GuzzleHttp\\": "src/"
283
- },
284
  "files": [
285
  "src/functions_include.php"
286
- ]
 
 
 
287
  },
288
  "notification-url": "https://packagist.org/downloads/",
289
  "license": [
290
  "MIT"
291
  ],
292
  "authors": [
 
 
 
 
 
293
  {
294
  "name": "Michael Dowling",
295
  "email": "mtdowling@gmail.com",
296
  "homepage": "https://github.com/mtdowling"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  }
298
  ],
299
  "description": "Guzzle is a PHP HTTP client library",
@@ -309,23 +346,37 @@
309
  ],
310
  "support": {
311
  "issues": "https://github.com/guzzle/guzzle/issues",
312
- "source": "https://github.com/guzzle/guzzle/tree/6.5"
313
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  "install-path": "../guzzlehttp/guzzle"
315
  },
316
  {
317
  "name": "guzzlehttp/promises",
318
- "version": "1.4.1",
319
- "version_normalized": "1.4.1.0",
320
  "source": {
321
  "type": "git",
322
  "url": "https://github.com/guzzle/promises.git",
323
- "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d"
324
  },
325
  "dist": {
326
  "type": "zip",
327
- "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d",
328
- "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d",
329
  "shasum": ""
330
  },
331
  "require": {
@@ -334,31 +385,46 @@
334
  "require-dev": {
335
  "symfony/phpunit-bridge": "^4.4 || ^5.1"
336
  },
337
- "time": "2021-03-07T09:25:29+00:00",
338
  "type": "library",
339
  "extra": {
340
  "branch-alias": {
341
- "dev-master": "1.4-dev"
342
  }
343
  },
344
  "installation-source": "dist",
345
  "autoload": {
346
- "psr-4": {
347
- "GuzzleHttp\\Promise\\": "src/"
348
- },
349
  "files": [
350
  "src/functions_include.php"
351
- ]
 
 
 
352
  },
353
  "notification-url": "https://packagist.org/downloads/",
354
  "license": [
355
  "MIT"
356
  ],
357
  "authors": [
 
 
 
 
 
358
  {
359
  "name": "Michael Dowling",
360
  "email": "mtdowling@gmail.com",
361
  "homepage": "https://github.com/mtdowling"
 
 
 
 
 
 
 
 
 
 
362
  }
363
  ],
364
  "description": "Guzzle promises library",
@@ -367,23 +433,37 @@
367
  ],
368
  "support": {
369
  "issues": "https://github.com/guzzle/promises/issues",
370
- "source": "https://github.com/guzzle/promises/tree/1.4.1"
371
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  "install-path": "../guzzlehttp/promises"
373
  },
374
  {
375
  "name": "guzzlehttp/psr7",
376
- "version": "1.8.2",
377
- "version_normalized": "1.8.2.0",
378
  "source": {
379
  "type": "git",
380
  "url": "https://github.com/guzzle/psr7.git",
381
- "reference": "dc960a912984efb74d0a90222870c72c87f10c91"
382
  },
383
  "dist": {
384
  "type": "zip",
385
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/dc960a912984efb74d0a90222870c72c87f10c91",
386
- "reference": "dc960a912984efb74d0a90222870c72c87f10c91",
387
  "shasum": ""
388
  },
389
  "require": {
@@ -401,7 +481,7 @@
401
  "suggest": {
402
  "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
403
  },
404
- "time": "2021-04-26T09:17:50+00:00",
405
  "type": "library",
406
  "extra": {
407
  "branch-alias": {
@@ -410,25 +490,46 @@
410
  },
411
  "installation-source": "dist",
412
  "autoload": {
413
- "psr-4": {
414
- "GuzzleHttp\\Psr7\\": "src/"
415
- },
416
  "files": [
417
  "src/functions_include.php"
418
- ]
 
 
 
419
  },
420
  "notification-url": "https://packagist.org/downloads/",
421
  "license": [
422
  "MIT"
423
  ],
424
  "authors": [
 
 
 
 
 
425
  {
426
  "name": "Michael Dowling",
427
  "email": "mtdowling@gmail.com",
428
  "homepage": "https://github.com/mtdowling"
429
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  {
431
  "name": "Tobias Schultze",
 
432
  "homepage": "https://github.com/Tobion"
433
  }
434
  ],
@@ -445,55 +546,77 @@
445
  ],
446
  "support": {
447
  "issues": "https://github.com/guzzle/psr7/issues",
448
- "source": "https://github.com/guzzle/psr7/tree/1.8.2"
449
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
  "install-path": "../guzzlehttp/psr7"
451
  },
452
  {
453
  "name": "monolog/monolog",
454
- "version": "2.3.2",
455
- "version_normalized": "2.3.2.0",
456
  "source": {
457
  "type": "git",
458
  "url": "https://github.com/Seldaek/monolog.git",
459
- "reference": "71312564759a7db5b789296369c1a264efc43aad"
460
  },
461
  "dist": {
462
  "type": "zip",
463
- "url": "https://api.github.com/repos/Seldaek/monolog/zipball/71312564759a7db5b789296369c1a264efc43aad",
464
- "reference": "71312564759a7db5b789296369c1a264efc43aad",
465
  "shasum": ""
466
  },
467
  "require": {
468
  "php": ">=7.2",
469
- "psr/log": "^1.0.1"
470
  },
471
  "provide": {
472
- "psr/log-implementation": "1.0.0"
473
  },
474
  "require-dev": {
475
  "aws/aws-sdk-php": "^2.4.9 || ^3.0",
476
  "doctrine/couchdb": "~1.0@dev",
477
- "elasticsearch/elasticsearch": "^7",
 
478
  "graylog2/gelf-php": "^1.4.2",
 
 
479
  "mongodb/mongodb": "^1.8",
480
- "php-amqplib/php-amqplib": "~2.4",
481
  "php-console/php-console": "^3.1.3",
482
- "phpspec/prophecy": "^1.6.1",
483
  "phpstan/phpstan": "^0.12.91",
484
- "phpunit/phpunit": "^8.5",
485
  "predis/predis": "^1.1",
486
- "rollbar/rollbar": "^1.3",
487
- "ruflin/elastica": ">=0.90 <7.0.1",
488
- "swiftmailer/swiftmailer": "^5.3|^6.0"
 
 
489
  },
490
  "suggest": {
491
  "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
492
  "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
493
  "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
494
  "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
 
495
  "ext-mbstring": "Allow to work properly with unicode symbols",
496
  "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
 
 
497
  "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
498
  "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
499
  "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
@@ -501,7 +624,7 @@
501
  "rollbar/rollbar": "Allow sending log messages to Rollbar",
502
  "ruflin/elastica": "Allow sending log messages to an Elastic Search server"
503
  },
504
- "time": "2021-07-23T07:42:52+00:00",
505
  "type": "library",
506
  "extra": {
507
  "branch-alias": {
@@ -534,7 +657,7 @@
534
  ],
535
  "support": {
536
  "issues": "https://github.com/Seldaek/monolog/issues",
537
- "source": "https://github.com/Seldaek/monolog/tree/2.3.2"
538
  },
539
  "funding": [
540
  {
@@ -550,17 +673,17 @@
550
  },
551
  {
552
  "name": "paragonie/constant_time_encoding",
553
- "version": "v2.4.0",
554
- "version_normalized": "2.4.0.0",
555
  "source": {
556
  "type": "git",
557
  "url": "https://github.com/paragonie/constant_time_encoding.git",
558
- "reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c"
559
  },
560
  "dist": {
561
  "type": "zip",
562
- "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c",
563
- "reference": "f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c",
564
  "shasum": ""
565
  },
566
  "require": {
@@ -570,7 +693,7 @@
570
  "phpunit/phpunit": "^6|^7|^8|^9",
571
  "vimeo/psalm": "^1|^2|^3|^4"
572
  },
573
- "time": "2020-12-06T15:14:20+00:00",
574
  "type": "library",
575
  "installation-source": "dist",
576
  "autoload": {
@@ -673,17 +796,17 @@
673
  },
674
  {
675
  "name": "phpseclib/phpseclib",
676
- "version": "3.0.9",
677
- "version_normalized": "3.0.9.0",
678
  "source": {
679
  "type": "git",
680
  "url": "https://github.com/phpseclib/phpseclib.git",
681
- "reference": "a127a5133804ff2f47ae629dd529b129da616ad7"
682
  },
683
  "dist": {
684
  "type": "zip",
685
- "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/a127a5133804ff2f47ae629dd529b129da616ad7",
686
- "reference": "a127a5133804ff2f47ae629dd529b129da616ad7",
687
  "shasum": ""
688
  },
689
  "require": {
@@ -692,9 +815,7 @@
692
  "php": ">=5.6.1"
693
  },
694
  "require-dev": {
695
- "phing/phing": "~2.7",
696
- "phpunit/phpunit": "^5.7|^6.0|^9.4",
697
- "squizlabs/php_codesniffer": "~2.0"
698
  },
699
  "suggest": {
700
  "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
@@ -702,7 +823,7 @@
702
  "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
703
  "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
704
  },
705
- "time": "2021-06-14T06:54:45+00:00",
706
  "type": "library",
707
  "installation-source": "dist",
708
  "autoload": {
@@ -767,7 +888,7 @@
767
  ],
768
  "support": {
769
  "issues": "https://github.com/phpseclib/phpseclib/issues",
770
- "source": "https://github.com/phpseclib/phpseclib/tree/3.0.9"
771
  },
772
  "funding": [
773
  {
@@ -995,17 +1116,17 @@
995
  },
996
  {
997
  "name": "symfony/polyfill-intl-idn",
998
- "version": "v1.23.0",
999
- "version_normalized": "1.23.0.0",
1000
  "source": {
1001
  "type": "git",
1002
  "url": "https://github.com/symfony/polyfill-intl-idn.git",
1003
- "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65"
1004
  },
1005
  "dist": {
1006
  "type": "zip",
1007
- "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/65bd267525e82759e7d8c4e8ceea44f398838e65",
1008
- "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65",
1009
  "shasum": ""
1010
  },
1011
  "require": {
@@ -1016,11 +1137,11 @@
1016
  "suggest": {
1017
  "ext-intl": "For best performance"
1018
  },
1019
- "time": "2021-05-27T09:27:20+00:00",
1020
  "type": "library",
1021
  "extra": {
1022
  "branch-alias": {
1023
- "dev-main": "1.23-dev"
1024
  },
1025
  "thanks": {
1026
  "name": "symfony/polyfill",
@@ -1029,12 +1150,12 @@
1029
  },
1030
  "installation-source": "dist",
1031
  "autoload": {
1032
- "psr-4": {
1033
- "Symfony\\Polyfill\\Intl\\Idn\\": ""
1034
- },
1035
  "files": [
1036
  "bootstrap.php"
1037
- ]
 
 
 
1038
  },
1039
  "notification-url": "https://packagist.org/downloads/",
1040
  "license": [
@@ -1065,7 +1186,7 @@
1065
  "shim"
1066
  ],
1067
  "support": {
1068
- "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.23.0"
1069
  },
1070
  "funding": [
1071
  {
@@ -1085,17 +1206,17 @@
1085
  },
1086
  {
1087
  "name": "symfony/polyfill-intl-normalizer",
1088
- "version": "v1.23.0",
1089
- "version_normalized": "1.23.0.0",
1090
  "source": {
1091
  "type": "git",
1092
  "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
1093
- "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8"
1094
  },
1095
  "dist": {
1096
  "type": "zip",
1097
- "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8",
1098
- "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8",
1099
  "shasum": ""
1100
  },
1101
  "require": {
@@ -1104,11 +1225,11 @@
1104
  "suggest": {
1105
  "ext-intl": "For best performance"
1106
  },
1107
- "time": "2021-02-19T12:13:01+00:00",
1108
  "type": "library",
1109
  "extra": {
1110
  "branch-alias": {
1111
- "dev-main": "1.23-dev"
1112
  },
1113
  "thanks": {
1114
  "name": "symfony/polyfill",
@@ -1117,12 +1238,12 @@
1117
  },
1118
  "installation-source": "dist",
1119
  "autoload": {
1120
- "psr-4": {
1121
- "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
1122
- },
1123
  "files": [
1124
  "bootstrap.php"
1125
  ],
 
 
 
1126
  "classmap": [
1127
  "Resources/stubs"
1128
  ]
@@ -1152,7 +1273,7 @@
1152
  "shim"
1153
  ],
1154
  "support": {
1155
- "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0"
1156
  },
1157
  "funding": [
1158
  {
@@ -1172,27 +1293,27 @@
1172
  },
1173
  {
1174
  "name": "symfony/polyfill-php72",
1175
- "version": "v1.23.0",
1176
- "version_normalized": "1.23.0.0",
1177
  "source": {
1178
  "type": "git",
1179
  "url": "https://github.com/symfony/polyfill-php72.git",
1180
- "reference": "9a142215a36a3888e30d0a9eeea9766764e96976"
1181
  },
1182
  "dist": {
1183
  "type": "zip",
1184
- "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976",
1185
- "reference": "9a142215a36a3888e30d0a9eeea9766764e96976",
1186
  "shasum": ""
1187
  },
1188
  "require": {
1189
  "php": ">=7.1"
1190
  },
1191
- "time": "2021-05-27T09:17:38+00:00",
1192
  "type": "library",
1193
  "extra": {
1194
  "branch-alias": {
1195
- "dev-main": "1.23-dev"
1196
  },
1197
  "thanks": {
1198
  "name": "symfony/polyfill",
@@ -1201,12 +1322,12 @@
1201
  },
1202
  "installation-source": "dist",
1203
  "autoload": {
1204
- "psr-4": {
1205
- "Symfony\\Polyfill\\Php72\\": ""
1206
- },
1207
  "files": [
1208
  "bootstrap.php"
1209
- ]
 
 
 
1210
  },
1211
  "notification-url": "https://packagist.org/downloads/",
1212
  "license": [
@@ -1231,7 +1352,7 @@
1231
  "shim"
1232
  ],
1233
  "support": {
1234
- "source": "https://github.com/symfony/polyfill-php72/tree/v1.23.0"
1235
  },
1236
  "funding": [
1237
  {
2
  "packages": [
3
  {
4
  "name": "firebase/php-jwt",
5
+ "version": "v6.2.0",
6
+ "version_normalized": "6.2.0.0",
7
  "source": {
8
  "type": "git",
9
  "url": "https://github.com/firebase/php-jwt.git",
10
+ "reference": "d28e6df83830252650da4623c78aaaf98fb385f3"
11
  },
12
  "dist": {
13
  "type": "zip",
14
+ "url": "https://api.github.com/repos/firebase/php-jwt/zipball/d28e6df83830252650da4623c78aaaf98fb385f3",
15
+ "reference": "d28e6df83830252650da4623c78aaaf98fb385f3",
16
  "shasum": ""
17
  },
18
  "require": {
19
+ "php": "^7.1||^8.0"
20
  },
21
  "require-dev": {
22
+ "guzzlehttp/guzzle": "^6.5||^7.4",
23
+ "phpspec/prophecy-phpunit": "^1.1",
24
+ "phpunit/phpunit": "^7.5||^9.5",
25
+ "psr/cache": "^1.0||^2.0",
26
+ "psr/http-client": "^1.0",
27
+ "psr/http-factory": "^1.0"
28
  },
29
  "suggest": {
30
  "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present"
31
  },
32
+ "time": "2022-05-13T20:54:50+00:00",
33
  "type": "library",
34
  "installation-source": "dist",
35
  "autoload": {
61
  ],
62
  "support": {
63
  "issues": "https://github.com/firebase/php-jwt/issues",
64
+ "source": "https://github.com/firebase/php-jwt/tree/v6.2.0"
65
  },
66
  "install-path": "../firebase/php-jwt"
67
  },
68
  {
69
  "name": "google/apiclient",
70
+ "version": "v2.12.5",
71
+ "version_normalized": "2.12.5.0",
72
  "source": {
73
  "type": "git",
74
  "url": "https://github.com/googleapis/google-api-php-client.git",
75
+ "reference": "eb10f733eb0ebec058776cda206009d01af9f9e3"
76
  },
77
  "dist": {
78
  "type": "zip",
79
+ "url": "https://api.github.com/repos/googleapis/google-api-php-client/zipball/eb10f733eb0ebec058776cda206009d01af9f9e3",
80
+ "reference": "eb10f733eb0ebec058776cda206009d01af9f9e3",
81
  "shasum": ""
82
  },
83
  "require": {
84
+ "firebase/php-jwt": "~2.0||~3.0||~4.0||~5.0||~6.0",
85
  "google/apiclient-services": "~0.200",
86
  "google/auth": "^1.10",
87
  "guzzlehttp/guzzle": "~5.3.3||~6.0||~7.0",
88
+ "guzzlehttp/psr7": "^1.8.4||^2.2.1",
89
+ "monolog/monolog": "^1.17||^2.0||^3.0",
90
  "php": "^5.6|^7.0|^8.0",
91
  "phpseclib/phpseclib": "~2.0||^3.0.2"
92
  },
93
  "require-dev": {
94
  "cache/filesystem-adapter": "^0.3.2|^1.1",
95
  "composer/composer": "^1.10.22",
 
96
  "phpcompatibility/php-compatibility": "^9.2",
97
+ "phpspec/prophecy-phpunit": "^1.1||^2.0",
98
+ "phpunit/phpunit": "^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
99
+ "squizlabs/php_codesniffer": "^3.0",
100
  "symfony/css-selector": "~2.1",
101
+ "symfony/dom-crawler": "~2.1",
102
+ "yoast/phpunit-polyfills": "^1.0"
103
  },
104
  "suggest": {
105
  "cache/filesystem-adapter": "For caching certs and tokens (using Google\\Client::setCache)"
106
  },
107
+ "time": "2022-05-31T14:44:17+00:00",
108
  "type": "library",
109
  "extra": {
110
  "branch-alias": {
111
+ "dev-main": "2.x-dev"
112
  }
113
  },
114
  "installation-source": "dist",
115
  "autoload": {
 
 
 
116
  "files": [
117
  "src/aliases.php"
118
  ],
119
+ "psr-4": {
120
+ "Google\\": "src/"
121
+ },
122
  "classmap": [
123
  "src/aliases.php"
124
  ]
134
  ],
135
  "support": {
136
  "issues": "https://github.com/googleapis/google-api-php-client/issues",
137
+ "source": "https://github.com/googleapis/google-api-php-client/tree/v2.12.5"
138
  },
139
  "install-path": "../google/apiclient"
140
  },
141
  {
142
  "name": "google/apiclient-services",
143
+ "version": "v0.251.0",
144
+ "version_normalized": "0.251.0.0",
145
  "source": {
146
  "type": "git",
147
  "url": "https://github.com/googleapis/google-api-php-client-services.git",
148
+ "reference": "73b7a41113bd6b5ae2d42795dbe0d76e0c482782"
149
  },
150
  "dist": {
151
  "type": "zip",
152
+ "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/73b7a41113bd6b5ae2d42795dbe0d76e0c482782",
153
+ "reference": "73b7a41113bd6b5ae2d42795dbe0d76e0c482782",
154
  "shasum": ""
155
  },
156
  "require": {
159
  "require-dev": {
160
  "phpunit/phpunit": "^5.7||^8.5.13"
161
  },
162
+ "time": "2022-05-30T00:56:11+00:00",
163
  "type": "library",
164
  "installation-source": "dist",
165
  "autoload": {
 
 
 
166
  "files": [
167
  "autoload.php"
168
+ ],
169
+ "psr-4": {
170
+ "Google\\Service\\": "src"
171
+ }
172
  },
173
  "notification-url": "https://packagist.org/downloads/",
174
  "license": [
181
  ],
182
  "support": {
183
  "issues": "https://github.com/googleapis/google-api-php-client-services/issues",
184
+ "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.251.0"
185
  },
186
  "install-path": "../google/apiclient-services"
187
  },
188
  {
189
  "name": "google/auth",
190
+ "version": "v1.21.0",
191
+ "version_normalized": "1.21.0.0",
192
  "source": {
193
  "type": "git",
194
  "url": "https://github.com/googleapis/google-auth-library-php.git",
195
+ "reference": "73392bad2eb6852eea9084b6bbdec752515cb849"
196
  },
197
  "dist": {
198
  "type": "zip",
199
+ "url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/73392bad2eb6852eea9084b6bbdec752515cb849",
200
+ "reference": "73392bad2eb6852eea9084b6bbdec752515cb849",
201
  "shasum": ""
202
  },
203
  "require": {
204
+ "firebase/php-jwt": "^5.5||^6.0",
205
+ "guzzlehttp/guzzle": "^6.2.1|^7.0",
206
+ "guzzlehttp/psr7": "^1.7|^2.0",
207
+ "php": "^7.1||^8.0",
208
+ "psr/cache": "^1.0|^2.0|^3.0",
209
  "psr/http-message": "^1.0"
210
  },
211
  "require-dev": {
212
  "guzzlehttp/promises": "0.1.1|^1.3",
213
  "kelvinmo/simplejwt": "^0.2.5|^0.5.1",
214
  "phpseclib/phpseclib": "^2.0.31",
215
+ "phpspec/prophecy-phpunit": "^1.1",
216
+ "phpunit/phpunit": "^7.5||^8.5",
217
  "sebastian/comparator": ">=1.2.3",
218
  "squizlabs/php_codesniffer": "^3.5"
219
  },
220
  "suggest": {
221
  "phpseclib/phpseclib": "May be used in place of OpenSSL for signing strings or for token management. Please require version ^2."
222
  },
223
+ "time": "2022-04-13T20:35:52+00:00",
224
  "type": "library",
225
  "installation-source": "dist",
226
  "autoload": {
240
  "oauth2"
241
  ],
242
  "support": {
243
+ "docs": "https://googleapis.github.io/google-auth-library-php/main/",
244
  "issues": "https://github.com/googleapis/google-auth-library-php/issues",
245
+ "source": "https://github.com/googleapis/google-auth-library-php/tree/v1.21.0"
246
  },
247
  "install-path": "../google/auth"
248
  },
249
  {
250
  "name": "guzzlehttp/guzzle",
251
+ "version": "6.5.6",
252
+ "version_normalized": "6.5.6.0",
253
  "source": {
254
  "type": "git",
255
  "url": "https://github.com/guzzle/guzzle.git",
256
+ "reference": "f092dd734083473658de3ee4bef093ed77d2689c"
257
  },
258
  "dist": {
259
  "type": "zip",
260
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f092dd734083473658de3ee4bef093ed77d2689c",
261
+ "reference": "f092dd734083473658de3ee4bef093ed77d2689c",
262
  "shasum": ""
263
  },
264
  "require": {
276
  "suggest": {
277
  "psr/log": "Required for using the Log middleware"
278
  },
279
+ "time": "2022-05-25T13:19:12+00:00",
280
  "type": "library",
281
  "extra": {
282
  "branch-alias": {
285
  },
286
  "installation-source": "dist",
287
  "autoload": {
 
 
 
288
  "files": [
289
  "src/functions_include.php"
290
+ ],
291
+ "psr-4": {
292
+ "GuzzleHttp\\": "src/"
293
+ }
294
  },
295
  "notification-url": "https://packagist.org/downloads/",
296
  "license": [
297
  "MIT"
298
  ],
299
  "authors": [
300
+ {
301
+ "name": "Graham Campbell",
302
+ "email": "hello@gjcampbell.co.uk",
303
+ "homepage": "https://github.com/GrahamCampbell"
304
+ },
305
  {
306
  "name": "Michael Dowling",
307
  "email": "mtdowling@gmail.com",
308
  "homepage": "https://github.com/mtdowling"
309
+ },
310
+ {
311
+ "name": "Jeremy Lindblom",
312
+ "email": "jeremeamia@gmail.com",
313
+ "homepage": "https://github.com/jeremeamia"
314
+ },
315
+ {
316
+ "name": "George Mponos",
317
+ "email": "gmponos@gmail.com",
318
+ "homepage": "https://github.com/gmponos"
319
+ },
320
+ {
321
+ "name": "Tobias Nyholm",
322
+ "email": "tobias.nyholm@gmail.com",
323
+ "homepage": "https://github.com/Nyholm"
324
+ },
325
+ {
326
+ "name": "Márk Sági-Kazár",
327
+ "email": "mark.sagikazar@gmail.com",
328
+ "homepage": "https://github.com/sagikazarmark"
329
+ },
330
+ {
331
+ "name": "Tobias Schultze",
332
+ "email": "webmaster@tubo-world.de",
333
+ "homepage": "https://github.com/Tobion"
334
  }
335
  ],
336
  "description": "Guzzle is a PHP HTTP client library",
346
  ],
347
  "support": {
348
  "issues": "https://github.com/guzzle/guzzle/issues",
349
+ "source": "https://github.com/guzzle/guzzle/tree/6.5.6"
350
  },
351
+ "funding": [
352
+ {
353
+ "url": "https://github.com/GrahamCampbell",
354
+ "type": "github"
355
+ },
356
+ {
357
+ "url": "https://github.com/Nyholm",
358
+ "type": "github"
359
+ },
360
+ {
361
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
362
+ "type": "tidelift"
363
+ }
364
+ ],
365
  "install-path": "../guzzlehttp/guzzle"
366
  },
367
  {
368
  "name": "guzzlehttp/promises",
369
+ "version": "1.5.1",
370
+ "version_normalized": "1.5.1.0",
371
  "source": {
372
  "type": "git",
373
  "url": "https://github.com/guzzle/promises.git",
374
+ "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da"
375
  },
376
  "dist": {
377
  "type": "zip",
378
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
379
+ "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da",
380
  "shasum": ""
381
  },
382
  "require": {
385
  "require-dev": {
386
  "symfony/phpunit-bridge": "^4.4 || ^5.1"
387
  },
388
+ "time": "2021-10-22T20:56:57+00:00",
389
  "type": "library",
390
  "extra": {
391
  "branch-alias": {
392
+ "dev-master": "1.5-dev"
393
  }
394
  },
395
  "installation-source": "dist",
396
  "autoload": {
 
 
 
397
  "files": [
398
  "src/functions_include.php"
399
+ ],
400
+ "psr-4": {
401
+ "GuzzleHttp\\Promise\\": "src/"
402
+ }
403
  },
404
  "notification-url": "https://packagist.org/downloads/",
405
  "license": [
406
  "MIT"
407
  ],
408
  "authors": [
409
+ {
410
+ "name": "Graham Campbell",
411
+ "email": "hello@gjcampbell.co.uk",
412
+ "homepage": "https://github.com/GrahamCampbell"
413
+ },
414
  {
415
  "name": "Michael Dowling",
416
  "email": "mtdowling@gmail.com",
417
  "homepage": "https://github.com/mtdowling"
418
+ },
419
+ {
420
+ "name": "Tobias Nyholm",
421
+ "email": "tobias.nyholm@gmail.com",
422
+ "homepage": "https://github.com/Nyholm"
423
+ },
424
+ {
425
+ "name": "Tobias Schultze",
426
+ "email": "webmaster@tubo-world.de",
427
+ "homepage": "https://github.com/Tobion"
428
  }
429
  ],
430
  "description": "Guzzle promises library",
433
  ],
434
  "support": {
435
  "issues": "https://github.com/guzzle/promises/issues",
436
+ "source": "https://github.com/guzzle/promises/tree/1.5.1"
437
  },
438
+ "funding": [
439
+ {
440
+ "url": "https://github.com/GrahamCampbell",
441
+ "type": "github"
442
+ },
443
+ {
444
+ "url": "https://github.com/Nyholm",
445
+ "type": "github"
446
+ },
447
+ {
448
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
449
+ "type": "tidelift"
450
+ }
451
+ ],
452
  "install-path": "../guzzlehttp/promises"
453
  },
454
  {
455
  "name": "guzzlehttp/psr7",
456
+ "version": "1.8.5",
457
+ "version_normalized": "1.8.5.0",
458
  "source": {
459
  "type": "git",
460
  "url": "https://github.com/guzzle/psr7.git",
461
+ "reference": "337e3ad8e5716c15f9657bd214d16cc5e69df268"
462
  },
463
  "dist": {
464
  "type": "zip",
465
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/337e3ad8e5716c15f9657bd214d16cc5e69df268",
466
+ "reference": "337e3ad8e5716c15f9657bd214d16cc5e69df268",
467
  "shasum": ""
468
  },
469
  "require": {
481
  "suggest": {
482
  "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
483
  },
484
+ "time": "2022-03-20T21:51:18+00:00",
485
  "type": "library",
486
  "extra": {
487
  "branch-alias": {
490
  },
491
  "installation-source": "dist",
492
  "autoload": {
 
 
 
493
  "files": [
494
  "src/functions_include.php"
495
+ ],
496
+ "psr-4": {
497
+ "GuzzleHttp\\Psr7\\": "src/"
498
+ }
499
  },
500
  "notification-url": "https://packagist.org/downloads/",
501
  "license": [
502
  "MIT"
503
  ],
504
  "authors": [
505
+ {
506
+ "name": "Graham Campbell",
507
+ "email": "hello@gjcampbell.co.uk",
508
+ "homepage": "https://github.com/GrahamCampbell"
509
+ },
510
  {
511
  "name": "Michael Dowling",
512
  "email": "mtdowling@gmail.com",
513
  "homepage": "https://github.com/mtdowling"
514
  },
515
+ {
516
+ "name": "George Mponos",
517
+ "email": "gmponos@gmail.com",
518
+ "homepage": "https://github.com/gmponos"
519
+ },
520
+ {
521
+ "name": "Tobias Nyholm",
522
+ "email": "tobias.nyholm@gmail.com",
523
+ "homepage": "https://github.com/Nyholm"
524
+ },
525
+ {
526
+ "name": "Márk Sági-Kazár",
527
+ "email": "mark.sagikazar@gmail.com",
528
+ "homepage": "https://github.com/sagikazarmark"
529
+ },
530
  {
531
  "name": "Tobias Schultze",
532
+ "email": "webmaster@tubo-world.de",
533
  "homepage": "https://github.com/Tobion"
534
  }
535
  ],
546
  ],
547
  "support": {
548
  "issues": "https://github.com/guzzle/psr7/issues",
549
+ "source": "https://github.com/guzzle/psr7/tree/1.8.5"
550
  },
551
+ "funding": [
552
+ {
553
+ "url": "https://github.com/GrahamCampbell",
554
+ "type": "github"
555
+ },
556
+ {
557
+ "url": "https://github.com/Nyholm",
558
+ "type": "github"
559
+ },
560
+ {
561
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
562
+ "type": "tidelift"
563
+ }
564
+ ],
565
  "install-path": "../guzzlehttp/psr7"
566
  },
567
  {
568
  "name": "monolog/monolog",
569
+ "version": "2.6.0",
570
+ "version_normalized": "2.6.0.0",
571
  "source": {
572
  "type": "git",
573
  "url": "https://github.com/Seldaek/monolog.git",
574
+ "reference": "247918972acd74356b0a91dfaa5adcaec069b6c0"
575
  },
576
  "dist": {
577
  "type": "zip",
578
+ "url": "https://api.github.com/repos/Seldaek/monolog/zipball/247918972acd74356b0a91dfaa5adcaec069b6c0",
579
+ "reference": "247918972acd74356b0a91dfaa5adcaec069b6c0",
580
  "shasum": ""
581
  },
582
  "require": {
583
  "php": ">=7.2",
584
+ "psr/log": "^1.0.1 || ^2.0 || ^3.0"
585
  },
586
  "provide": {
587
+ "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0"
588
  },
589
  "require-dev": {
590
  "aws/aws-sdk-php": "^2.4.9 || ^3.0",
591
  "doctrine/couchdb": "~1.0@dev",
592
+ "elasticsearch/elasticsearch": "^7 || ^8",
593
+ "ext-json": "*",
594
  "graylog2/gelf-php": "^1.4.2",
595
+ "guzzlehttp/guzzle": "^7.4",
596
+ "guzzlehttp/psr7": "^2.2",
597
  "mongodb/mongodb": "^1.8",
598
+ "php-amqplib/php-amqplib": "~2.4 || ^3",
599
  "php-console/php-console": "^3.1.3",
600
+ "phpspec/prophecy": "^1.15",
601
  "phpstan/phpstan": "^0.12.91",
602
+ "phpunit/phpunit": "^8.5.14",
603
  "predis/predis": "^1.1",
604
+ "rollbar/rollbar": "^1.3 || ^2 || ^3",
605
+ "ruflin/elastica": "^7",
606
+ "swiftmailer/swiftmailer": "^5.3|^6.0",
607
+ "symfony/mailer": "^5.4 || ^6",
608
+ "symfony/mime": "^5.4 || ^6"
609
  },
610
  "suggest": {
611
  "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
612
  "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
613
  "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
614
  "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
615
+ "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler",
616
  "ext-mbstring": "Allow to work properly with unicode symbols",
617
  "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
618
+ "ext-openssl": "Required to send log messages using SSL",
619
+ "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)",
620
  "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
621
  "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
622
  "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
624
  "rollbar/rollbar": "Allow sending log messages to Rollbar",
625
  "ruflin/elastica": "Allow sending log messages to an Elastic Search server"
626
  },
627
+ "time": "2022-05-10T09:36:00+00:00",
628
  "type": "library",
629
  "extra": {
630
  "branch-alias": {
657
  ],
658
  "support": {
659
  "issues": "https://github.com/Seldaek/monolog/issues",
660
+ "source": "https://github.com/Seldaek/monolog/tree/2.6.0"
661
  },
662
  "funding": [
663
  {
673
  },
674
  {
675
  "name": "paragonie/constant_time_encoding",
676
+ "version": "v2.5.0",
677
+ "version_normalized": "2.5.0.0",
678
  "source": {
679
  "type": "git",
680
  "url": "https://github.com/paragonie/constant_time_encoding.git",
681
+ "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8"
682
  },
683
  "dist": {
684
  "type": "zip",
685
+ "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/9229e15f2e6ba772f0c55dd6986c563b937170a8",
686
+ "reference": "9229e15f2e6ba772f0c55dd6986c563b937170a8",
687
  "shasum": ""
688
  },
689
  "require": {
693
  "phpunit/phpunit": "^6|^7|^8|^9",
694
  "vimeo/psalm": "^1|^2|^3|^4"
695
  },
696
+ "time": "2022-01-17T05:32:27+00:00",
697
  "type": "library",
698
  "installation-source": "dist",
699
  "autoload": {
796
  },
797
  {
798
  "name": "phpseclib/phpseclib",
799
+ "version": "3.0.14",
800
+ "version_normalized": "3.0.14.0",
801
  "source": {
802
  "type": "git",
803
  "url": "https://github.com/phpseclib/phpseclib.git",
804
+ "reference": "2f0b7af658cbea265cbb4a791d6c29a6613f98ef"
805
  },
806
  "dist": {
807
  "type": "zip",
808
+ "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/2f0b7af658cbea265cbb4a791d6c29a6613f98ef",
809
+ "reference": "2f0b7af658cbea265cbb4a791d6c29a6613f98ef",
810
  "shasum": ""
811
  },
812
  "require": {
815
  "php": ">=5.6.1"
816
  },
817
  "require-dev": {
818
+ "phpunit/phpunit": "*"
 
 
819
  },
820
  "suggest": {
821
  "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
823
  "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
824
  "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
825
  },
826
+ "time": "2022-04-04T05:15:45+00:00",
827
  "type": "library",
828
  "installation-source": "dist",
829
  "autoload": {
888
  ],
889
  "support": {
890
  "issues": "https://github.com/phpseclib/phpseclib/issues",
891
+ "source": "https://github.com/phpseclib/phpseclib/tree/3.0.14"
892
  },
893
  "funding": [
894
  {
1116
  },
1117
  {
1118
  "name": "symfony/polyfill-intl-idn",
1119
+ "version": "v1.26.0",
1120
+ "version_normalized": "1.26.0.0",
1121
  "source": {
1122
  "type": "git",
1123
  "url": "https://github.com/symfony/polyfill-intl-idn.git",
1124
+ "reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8"
1125
  },
1126
  "dist": {
1127
  "type": "zip",
1128
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/59a8d271f00dd0e4c2e518104cc7963f655a1aa8",
1129
+ "reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8",
1130
  "shasum": ""
1131
  },
1132
  "require": {
1137
  "suggest": {
1138
  "ext-intl": "For best performance"
1139
  },
1140
+ "time": "2022-05-24T11:49:31+00:00",
1141
  "type": "library",
1142
  "extra": {
1143
  "branch-alias": {
1144
+ "dev-main": "1.26-dev"
1145
  },
1146
  "thanks": {
1147
  "name": "symfony/polyfill",
1150
  },
1151
  "installation-source": "dist",
1152
  "autoload": {
 
 
 
1153
  "files": [
1154
  "bootstrap.php"
1155
+ ],
1156
+ "psr-4": {
1157
+ "Symfony\\Polyfill\\Intl\\Idn\\": ""
1158
+ }
1159
  },
1160
  "notification-url": "https://packagist.org/downloads/",
1161
  "license": [
1186
  "shim"
1187
  ],
1188
  "support": {
1189
+ "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.26.0"
1190
  },
1191
  "funding": [
1192
  {
1206
  },
1207
  {
1208
  "name": "symfony/polyfill-intl-normalizer",
1209
+ "version": "v1.26.0",
1210
+ "version_normalized": "1.26.0.0",
1211
  "source": {
1212
  "type": "git",
1213
  "url": "https://github.com/symfony/polyfill-intl-normalizer.git",
1214
+ "reference": "219aa369ceff116e673852dce47c3a41794c14bd"
1215
  },
1216
  "dist": {
1217
  "type": "zip",
1218
+ "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd",
1219
+ "reference": "219aa369ceff116e673852dce47c3a41794c14bd",
1220
  "shasum": ""
1221
  },
1222
  "require": {
1225
  "suggest": {
1226
  "ext-intl": "For best performance"
1227
  },
1228
+ "time": "2022-05-24T11:49:31+00:00",
1229
  "type": "library",
1230
  "extra": {
1231
  "branch-alias": {
1232
+ "dev-main": "1.26-dev"
1233
  },
1234
  "thanks": {
1235
  "name": "symfony/polyfill",
1238
  },
1239
  "installation-source": "dist",
1240
  "autoload": {
 
 
 
1241
  "files": [
1242
  "bootstrap.php"
1243
  ],
1244
+ "psr-4": {
1245
+ "Symfony\\Polyfill\\Intl\\Normalizer\\": ""
1246
+ },
1247
  "classmap": [
1248
  "Resources/stubs"
1249
  ]
1273
  "shim"
1274
  ],
1275
  "support": {
1276
+ "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0"
1277
  },
1278
  "funding": [
1279
  {
1293
  },
1294
  {
1295
  "name": "symfony/polyfill-php72",
1296
+ "version": "v1.26.0",
1297
+ "version_normalized": "1.26.0.0",
1298
  "source": {
1299
  "type": "git",
1300
  "url": "https://github.com/symfony/polyfill-php72.git",
1301
+ "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2"
1302
  },
1303
  "dist": {
1304
  "type": "zip",
1305
+ "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/bf44a9fd41feaac72b074de600314a93e2ae78e2",
1306
+ "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2",
1307
  "shasum": ""
1308
  },
1309
  "require": {
1310
  "php": ">=7.1"
1311
  },
1312
+ "time": "2022-05-24T11:49:31+00:00",
1313
  "type": "library",
1314
  "extra": {
1315
  "branch-alias": {
1316
+ "dev-main": "1.26-dev"
1317
  },
1318
  "thanks": {
1319
  "name": "symfony/polyfill",
1322
  },
1323
  "installation-source": "dist",
1324
  "autoload": {
 
 
 
1325
  "files": [
1326
  "bootstrap.php"
1327
+ ],
1328
+ "psr-4": {
1329
+ "Symfony\\Polyfill\\Php72\\": ""
1330
+ }
1331
  },
1332
  "notification-url": "https://packagist.org/downloads/",
1333
  "license": [
1352
  "shim"
1353
  ],
1354
  "support": {
1355
+ "source": "https://github.com/symfony/polyfill-php72/tree/v1.26.0"
1356
  },
1357
  "funding": [
1358
  {
vendor/composer/installed.php CHANGED
@@ -5,7 +5,7 @@
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => '8a59076f3959d1cd0460111e53f32577b4718150',
9
  'name' => '__root__',
10
  'dev' => true,
11
  ),
@@ -16,88 +16,88 @@
16
  'type' => 'library',
17
  'install_path' => __DIR__ . '/../../',
18
  'aliases' => array(),
19
- 'reference' => '8a59076f3959d1cd0460111e53f32577b4718150',
20
  'dev_requirement' => false,
21
  ),
22
  'firebase/php-jwt' => array(
23
- 'pretty_version' => 'v5.4.0',
24
- 'version' => '5.4.0.0',
25
  'type' => 'library',
26
  'install_path' => __DIR__ . '/../firebase/php-jwt',
27
  'aliases' => array(),
28
- 'reference' => 'd2113d9b2e0e349796e72d2a63cf9319100382d2',
29
  'dev_requirement' => false,
30
  ),
31
  'google/apiclient' => array(
32
- 'pretty_version' => 'v2.10.1',
33
- 'version' => '2.10.1.0',
34
  'type' => 'library',
35
  'install_path' => __DIR__ . '/../google/apiclient',
36
  'aliases' => array(),
37
- 'reference' => '11871e94006ce7a419bb6124d51b6f9ace3f679b',
38
  'dev_requirement' => false,
39
  ),
40
  'google/apiclient-services' => array(
41
- 'pretty_version' => 'v0.206.0',
42
- 'version' => '0.206.0.0',
43
  'type' => 'library',
44
  'install_path' => __DIR__ . '/../google/apiclient-services',
45
  'aliases' => array(),
46
- 'reference' => '8ac3f4a7c201bbf794801b215e63f75f15cd0208',
47
  'dev_requirement' => false,
48
  ),
49
  'google/auth' => array(
50
- 'pretty_version' => 'v1.16.0',
51
- 'version' => '1.16.0.0',
52
  'type' => 'library',
53
  'install_path' => __DIR__ . '/../google/auth',
54
  'aliases' => array(),
55
- 'reference' => 'c747738d2dd450f541f09f26510198fbedd1c8a0',
56
  'dev_requirement' => false,
57
  ),
58
  'guzzlehttp/guzzle' => array(
59
- 'pretty_version' => '6.5.5',
60
- 'version' => '6.5.5.0',
61
  'type' => 'library',
62
  'install_path' => __DIR__ . '/../guzzlehttp/guzzle',
63
  'aliases' => array(),
64
- 'reference' => '9d4290de1cfd701f38099ef7e183b64b4b7b0c5e',
65
  'dev_requirement' => false,
66
  ),
67
  'guzzlehttp/promises' => array(
68
- 'pretty_version' => '1.4.1',
69
- 'version' => '1.4.1.0',
70
  'type' => 'library',
71
  'install_path' => __DIR__ . '/../guzzlehttp/promises',
72
  'aliases' => array(),
73
- 'reference' => '8e7d04f1f6450fef59366c399cfad4b9383aa30d',
74
  'dev_requirement' => false,
75
  ),
76
  'guzzlehttp/psr7' => array(
77
- 'pretty_version' => '1.8.2',
78
- 'version' => '1.8.2.0',
79
  'type' => 'library',
80
  'install_path' => __DIR__ . '/../guzzlehttp/psr7',
81
  'aliases' => array(),
82
- 'reference' => 'dc960a912984efb74d0a90222870c72c87f10c91',
83
  'dev_requirement' => false,
84
  ),
85
  'monolog/monolog' => array(
86
- 'pretty_version' => '2.3.2',
87
- 'version' => '2.3.2.0',
88
  'type' => 'library',
89
  'install_path' => __DIR__ . '/../monolog/monolog',
90
  'aliases' => array(),
91
- 'reference' => '71312564759a7db5b789296369c1a264efc43aad',
92
  'dev_requirement' => false,
93
  ),
94
  'paragonie/constant_time_encoding' => array(
95
- 'pretty_version' => 'v2.4.0',
96
- 'version' => '2.4.0.0',
97
  'type' => 'library',
98
  'install_path' => __DIR__ . '/../paragonie/constant_time_encoding',
99
  'aliases' => array(),
100
- 'reference' => 'f34c2b11eb9d2c9318e13540a1dbc2a3afbd939c',
101
  'dev_requirement' => false,
102
  ),
103
  'paragonie/random_compat' => array(
@@ -110,12 +110,12 @@
110
  'dev_requirement' => false,
111
  ),
112
  'phpseclib/phpseclib' => array(
113
- 'pretty_version' => '3.0.9',
114
- 'version' => '3.0.9.0',
115
  'type' => 'library',
116
  'install_path' => __DIR__ . '/../phpseclib/phpseclib',
117
  'aliases' => array(),
118
- 'reference' => 'a127a5133804ff2f47ae629dd529b129da616ad7',
119
  'dev_requirement' => false,
120
  ),
121
  'psr/cache' => array(
@@ -154,7 +154,7 @@
154
  'psr/log-implementation' => array(
155
  'dev_requirement' => false,
156
  'provided' => array(
157
- 0 => '1.0.0',
158
  ),
159
  ),
160
  'ralouphie/getallheaders' => array(
@@ -167,30 +167,30 @@
167
  'dev_requirement' => false,
168
  ),
169
  'symfony/polyfill-intl-idn' => array(
170
- 'pretty_version' => 'v1.23.0',
171
- 'version' => '1.23.0.0',
172
  'type' => 'library',
173
  'install_path' => __DIR__ . '/../symfony/polyfill-intl-idn',
174
  'aliases' => array(),
175
- 'reference' => '65bd267525e82759e7d8c4e8ceea44f398838e65',
176
  'dev_requirement' => false,
177
  ),
178
  'symfony/polyfill-intl-normalizer' => array(
179
- 'pretty_version' => 'v1.23.0',
180
- 'version' => '1.23.0.0',
181
  'type' => 'library',
182
  'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer',
183
  'aliases' => array(),
184
- 'reference' => '8590a5f561694770bdcd3f9b5c69dde6945028e8',
185
  'dev_requirement' => false,
186
  ),
187
  'symfony/polyfill-php72' => array(
188
- 'pretty_version' => 'v1.23.0',
189
- 'version' => '1.23.0.0',
190
  'type' => 'library',
191
  'install_path' => __DIR__ . '/../symfony/polyfill-php72',
192
  'aliases' => array(),
193
- 'reference' => '9a142215a36a3888e30d0a9eeea9766764e96976',
194
  'dev_requirement' => false,
195
  ),
196
  ),
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
+ 'reference' => '82113c705aa243720cd831a7dfb75fd767ea9248',
9
  'name' => '__root__',
10
  'dev' => true,
11
  ),
16
  'type' => 'library',
17
  'install_path' => __DIR__ . '/../../',
18
  'aliases' => array(),
19
+ 'reference' => '82113c705aa243720cd831a7dfb75fd767ea9248',
20
  'dev_requirement' => false,
21
  ),
22
  'firebase/php-jwt' => array(
23
+ 'pretty_version' => 'v6.2.0',
24
+ 'version' => '6.2.0.0',
25
  'type' => 'library',
26
  'install_path' => __DIR__ . '/../firebase/php-jwt',
27
  'aliases' => array(),
28
+ 'reference' => 'd28e6df83830252650da4623c78aaaf98fb385f3',
29
  'dev_requirement' => false,
30
  ),
31
  'google/apiclient' => array(
32
+ 'pretty_version' => 'v2.12.5',
33
+ 'version' => '2.12.5.0',
34
  'type' => 'library',
35
  'install_path' => __DIR__ . '/../google/apiclient',
36
  'aliases' => array(),
37
+ 'reference' => 'eb10f733eb0ebec058776cda206009d01af9f9e3',
38
  'dev_requirement' => false,
39
  ),
40
  'google/apiclient-services' => array(
41
+ 'pretty_version' => 'v0.251.0',
42
+ 'version' => '0.251.0.0',
43
  'type' => 'library',
44
  'install_path' => __DIR__ . '/../google/apiclient-services',
45
  'aliases' => array(),
46
+ 'reference' => '73b7a41113bd6b5ae2d42795dbe0d76e0c482782',
47
  'dev_requirement' => false,
48
  ),
49
  'google/auth' => array(
50
+ 'pretty_version' => 'v1.21.0',
51
+ 'version' => '1.21.0.0',
52
  'type' => 'library',
53
  'install_path' => __DIR__ . '/../google/auth',
54
  'aliases' => array(),
55
+ 'reference' => '73392bad2eb6852eea9084b6bbdec752515cb849',
56
  'dev_requirement' => false,
57
  ),
58
  'guzzlehttp/guzzle' => array(
59
+ 'pretty_version' => '6.5.6',
60
+ 'version' => '6.5.6.0',
61
  'type' => 'library',
62
  'install_path' => __DIR__ . '/../guzzlehttp/guzzle',
63
  'aliases' => array(),
64
+ 'reference' => 'f092dd734083473658de3ee4bef093ed77d2689c',
65
  'dev_requirement' => false,
66
  ),
67
  'guzzlehttp/promises' => array(
68
+ 'pretty_version' => '1.5.1',
69
+ 'version' => '1.5.1.0',
70
  'type' => 'library',
71
  'install_path' => __DIR__ . '/../guzzlehttp/promises',
72
  'aliases' => array(),
73
+ 'reference' => 'fe752aedc9fd8fcca3fe7ad05d419d32998a06da',
74
  'dev_requirement' => false,
75
  ),
76
  'guzzlehttp/psr7' => array(
77
+ 'pretty_version' => '1.8.5',
78
+ 'version' => '1.8.5.0',
79
  'type' => 'library',
80
  'install_path' => __DIR__ . '/../guzzlehttp/psr7',
81
  'aliases' => array(),
82
+ 'reference' => '337e3ad8e5716c15f9657bd214d16cc5e69df268',
83
  'dev_requirement' => false,
84
  ),
85
  'monolog/monolog' => array(
86
+ 'pretty_version' => '2.6.0',
87
+ 'version' => '2.6.0.0',
88
  'type' => 'library',
89
  'install_path' => __DIR__ . '/../monolog/monolog',
90
  'aliases' => array(),
91
+ 'reference' => '247918972acd74356b0a91dfaa5adcaec069b6c0',
92
  'dev_requirement' => false,
93
  ),
94
  'paragonie/constant_time_encoding' => array(
95
+ 'pretty_version' => 'v2.5.0',
96
+ 'version' => '2.5.0.0',
97
  'type' => 'library',
98
  'install_path' => __DIR__ . '/../paragonie/constant_time_encoding',
99
  'aliases' => array(),
100
+ 'reference' => '9229e15f2e6ba772f0c55dd6986c563b937170a8',
101
  'dev_requirement' => false,
102
  ),
103
  'paragonie/random_compat' => array(
110
  'dev_requirement' => false,
111
  ),
112
  'phpseclib/phpseclib' => array(
113
+ 'pretty_version' => '3.0.14',
114
+ 'version' => '3.0.14.0',
115
  'type' => 'library',
116
  'install_path' => __DIR__ . '/../phpseclib/phpseclib',
117
  'aliases' => array(),
118
+ 'reference' => '2f0b7af658cbea265cbb4a791d6c29a6613f98ef',
119
  'dev_requirement' => false,
120
  ),
121
  'psr/cache' => array(
154
  'psr/log-implementation' => array(
155
  'dev_requirement' => false,
156
  'provided' => array(
157
+ 0 => '1.0.0 || 2.0.0 || 3.0.0',
158
  ),
159
  ),
160
  'ralouphie/getallheaders' => array(
167
  'dev_requirement' => false,
168
  ),
169
  'symfony/polyfill-intl-idn' => array(
170
+ 'pretty_version' => 'v1.26.0',
171
+ 'version' => '1.26.0.0',
172
  'type' => 'library',
173
  'install_path' => __DIR__ . '/../symfony/polyfill-intl-idn',
174
  'aliases' => array(),
175
+ 'reference' => '59a8d271f00dd0e4c2e518104cc7963f655a1aa8',
176
  'dev_requirement' => false,
177
  ),
178
  'symfony/polyfill-intl-normalizer' => array(
179
+ 'pretty_version' => 'v1.26.0',
180
+ 'version' => '1.26.0.0',
181
  'type' => 'library',
182
  'install_path' => __DIR__ . '/../symfony/polyfill-intl-normalizer',
183
  'aliases' => array(),
184
+ 'reference' => '219aa369ceff116e673852dce47c3a41794c14bd',
185
  'dev_requirement' => false,
186
  ),
187
  'symfony/polyfill-php72' => array(
188
+ 'pretty_version' => 'v1.26.0',
189
+ 'version' => '1.26.0.0',
190
  'type' => 'library',
191
  'install_path' => __DIR__ . '/../symfony/polyfill-php72',
192
  'aliases' => array(),
193
+ 'reference' => 'bf44a9fd41feaac72b074de600314a93e2ae78e2',
194
  'dev_requirement' => false,
195
  ),
196
  ),
vendor/firebase/php-jwt/src/CachedKeySet.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Firebase\JWT;
4
+
5
+ use ArrayAccess;
6
+ use LogicException;
7
+ use OutOfBoundsException;
8
+ use Psr\Cache\CacheItemInterface;
9
+ use Psr\Cache\CacheItemPoolInterface;
10
+ use Psr\Http\Client\ClientInterface;
11
+ use Psr\Http\Message\RequestFactoryInterface;
12
+ use RuntimeException;
13
+
14
+ /**
15
+ * @implements ArrayAccess<string, Key>
16
+ */
17
+ class CachedKeySet implements ArrayAccess
18
+ {
19
+ /**
20
+ * @var string
21
+ */
22
+ private $jwksUri;
23
+ /**
24
+ * @var ClientInterface
25
+ */
26
+ private $httpClient;
27
+ /**
28
+ * @var RequestFactoryInterface
29
+ */
30
+ private $httpFactory;
31
+ /**
32
+ * @var CacheItemPoolInterface
33
+ */
34
+ private $cache;
35
+ /**
36
+ * @var ?int
37
+ */
38
+ private $expiresAfter;
39
+ /**
40
+ * @var ?CacheItemInterface
41
+ */
42
+ private $cacheItem;
43
+ /**
44
+ * @var array<string, Key>
45
+ */
46
+ private $keySet;
47
+ /**
48
+ * @var string
49
+ */
50
+ private $cacheKey;
51
+ /**
52
+ * @var string
53
+ */
54
+ private $cacheKeyPrefix = 'jwks';
55
+ /**
56
+ * @var int
57
+ */
58
+ private $maxKeyLength = 64;
59
+ /**
60
+ * @var bool
61
+ */
62
+ private $rateLimit;
63
+ /**
64
+ * @var string
65
+ */
66
+ private $rateLimitCacheKey;
67
+ /**
68
+ * @var int
69
+ */
70
+ private $maxCallsPerMinute = 10;
71
+ /**
72
+ * @var string|null
73
+ */
74
+ private $defaultAlg;
75
+
76
+ public function __construct(
77
+ string $jwksUri,
78
+ ClientInterface $httpClient,
79
+ RequestFactoryInterface $httpFactory,
80
+ CacheItemPoolInterface $cache,
81
+ int $expiresAfter = null,
82
+ bool $rateLimit = false,
83
+ string $defaultAlg = null
84
+ ) {
85
+ $this->jwksUri = $jwksUri;
86
+ $this->httpClient = $httpClient;
87
+ $this->httpFactory = $httpFactory;
88
+ $this->cache = $cache;
89
+ $this->expiresAfter = $expiresAfter;
90
+ $this->rateLimit = $rateLimit;
91
+ $this->defaultAlg = $defaultAlg;
92
+ $this->setCacheKeys();
93
+ }
94
+
95
+ /**
96
+ * @param string $keyId
97
+ * @return Key
98
+ */
99
+ public function offsetGet($keyId): Key
100
+ {
101
+ if (!$this->keyIdExists($keyId)) {
102
+ throw new OutOfBoundsException('Key ID not found');
103
+ }
104
+ return $this->keySet[$keyId];
105
+ }
106
+
107
+ /**
108
+ * @param string $keyId
109
+ * @return bool
110
+ */
111
+ public function offsetExists($keyId): bool
112
+ {
113
+ return $this->keyIdExists($keyId);
114
+ }
115
+
116
+ /**
117
+ * @param string $offset
118
+ * @param Key $value
119
+ */
120
+ public function offsetSet($offset, $value): void
121
+ {
122
+ throw new LogicException('Method not implemented');
123
+ }
124
+
125
+ /**
126
+ * @param string $offset
127
+ */
128
+ public function offsetUnset($offset): void
129
+ {
130
+ throw new LogicException('Method not implemented');
131
+ }
132
+
133
+ private function keyIdExists(string $keyId): bool
134
+ {
135
+ $keySetToCache = null;
136
+ if (null === $this->keySet) {
137
+ $item = $this->getCacheItem();
138
+ // Try to load keys from cache
139
+ if ($item->isHit()) {
140
+ // item found! Return it
141
+ $this->keySet = $item->get();
142
+ }
143
+ }
144
+
145
+ if (!isset($this->keySet[$keyId])) {
146
+ if ($this->rateLimitExceeded()) {
147
+ return false;
148
+ }
149
+ $request = $this->httpFactory->createRequest('get', $this->jwksUri);
150
+ $jwksResponse = $this->httpClient->sendRequest($request);
151
+ $jwks = json_decode((string) $jwksResponse->getBody(), true);
152
+ $this->keySet = $keySetToCache = JWK::parseKeySet($jwks, $this->defaultAlg);
153
+
154
+ if (!isset($this->keySet[$keyId])) {
155
+ return false;
156
+ }
157
+ }
158
+
159
+ if ($keySetToCache) {
160
+ $item = $this->getCacheItem();
161
+ $item->set($keySetToCache);
162
+ if ($this->expiresAfter) {
163
+ $item->expiresAfter($this->expiresAfter);
164
+ }
165
+ $this->cache->save($item);
166
+ }
167
+
168
+ return true;
169
+ }
170
+
171
+ private function rateLimitExceeded(): bool
172
+ {
173
+ if (!$this->rateLimit) {
174
+ return false;
175
+ }
176
+
177
+ $cacheItem = $this->cache->getItem($this->rateLimitCacheKey);
178
+ if (!$cacheItem->isHit()) {
179
+ $cacheItem->expiresAfter(1); // # of calls are cached each minute
180
+ }
181
+
182
+ $callsPerMinute = (int) $cacheItem->get();
183
+ if (++$callsPerMinute > $this->maxCallsPerMinute) {
184
+ return true;
185
+ }
186
+ $cacheItem->set($callsPerMinute);
187
+ $this->cache->save($cacheItem);
188
+ return false;
189
+ }
190
+
191
+ private function getCacheItem(): CacheItemInterface
192
+ {
193
+ if (\is_null($this->cacheItem)) {
194
+ $this->cacheItem = $this->cache->getItem($this->cacheKey);
195
+ }
196
+
197
+ return $this->cacheItem;
198
+ }
199
+
200
+ private function setCacheKeys(): void
201
+ {
202
+ if (empty($this->jwksUri)) {
203
+ throw new RuntimeException('JWKS URI is empty');
204
+ }
205
+
206
+ // ensure we do not have illegal characters
207
+ $key = preg_replace('|[^a-zA-Z0-9_\.!]|', '', $this->jwksUri);
208
+
209
+ // add prefix
210
+ $key = $this->cacheKeyPrefix . $key;
211
+
212
+ // Hash keys if they exceed $maxKeyLength of 64
213
+ if (\strlen($key) > $this->maxKeyLength) {
214
+ $key = substr(hash('sha256', $key), 0, $this->maxKeyLength);
215
+ }
216
+
217
+ $this->cacheKey = $key;
218
+
219
+ if ($this->rateLimit) {
220
+ // add prefix
221
+ $rateLimitKey = $this->cacheKeyPrefix . 'ratelimit' . $key;
222
+
223
+ // Hash keys if they exceed $maxKeyLength of 64
224
+ if (\strlen($rateLimitKey) > $this->maxKeyLength) {
225
+ $rateLimitKey = substr(hash('sha256', $rateLimitKey), 0, $this->maxKeyLength);
226
+ }
227
+
228
+ $this->rateLimitCacheKey = $rateLimitKey;
229
+ }
230
+ }
231
+ }
vendor/firebase/php-jwt/src/JWK.php CHANGED
@@ -23,9 +23,11 @@ class JWK
23
  /**
24
  * Parse a set of JWK keys
25
  *
26
- * @param array $jwks The JSON Web Key Set as an associative array
 
 
27
  *
28
- * @return array An associative array that represents the set of keys
29
  *
30
  * @throws InvalidArgumentException Provided JWK Set is empty
31
  * @throws UnexpectedValueException Provided JWK Set was invalid
@@ -33,21 +35,22 @@ class JWK
33
  *
34
  * @uses parseKey
35
  */
36
- public static function parseKeySet(array $jwks)
37
  {
38
- $keys = array();
39
 
40
  if (!isset($jwks['keys'])) {
41
  throw new UnexpectedValueException('"keys" member must exist in the JWK Set');
42
  }
 
43
  if (empty($jwks['keys'])) {
44
  throw new InvalidArgumentException('JWK Set did not contain any keys');
45
  }
46
 
47
  foreach ($jwks['keys'] as $k => $v) {
48
  $kid = isset($v['kid']) ? $v['kid'] : $k;
49
- if ($key = self::parseKey($v)) {
50
- $keys[$kid] = $key;
51
  }
52
  }
53
 
@@ -61,9 +64,11 @@ class JWK
61
  /**
62
  * Parse a JWK key
63
  *
64
- * @param array $jwk An individual JWK
 
 
65
  *
66
- * @return resource|array An associative array that represents the key
67
  *
68
  * @throws InvalidArgumentException Provided JWK is empty
69
  * @throws UnexpectedValueException Provided JWK was invalid
@@ -71,15 +76,27 @@ class JWK
71
  *
72
  * @uses createPemFromModulusAndExponent
73
  */
74
- public static function parseKey(array $jwk)
75
  {
76
  if (empty($jwk)) {
77
  throw new InvalidArgumentException('JWK must not be empty');
78
  }
 
79
  if (!isset($jwk['kty'])) {
80
  throw new UnexpectedValueException('JWK must contain a "kty" parameter');
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
83
  switch ($jwk['kty']) {
84
  case 'RSA':
85
  if (!empty($jwk['d'])) {
@@ -96,11 +113,13 @@ class JWK
96
  'OpenSSL error: ' . \openssl_error_string()
97
  );
98
  }
99
- return $publicKey;
100
  default:
101
  // Currently only RSA is supported
102
  break;
103
  }
 
 
104
  }
105
 
106
  /**
@@ -113,22 +132,22 @@ class JWK
113
  *
114
  * @uses encodeLength
115
  */
116
- private static function createPemFromModulusAndExponent($n, $e)
117
- {
118
- $modulus = JWT::urlsafeB64Decode($n);
119
- $publicExponent = JWT::urlsafeB64Decode($e);
 
 
120
 
121
- $components = array(
122
- 'modulus' => \pack('Ca*a*', 2, self::encodeLength(\strlen($modulus)), $modulus),
123
- 'publicExponent' => \pack('Ca*a*', 2, self::encodeLength(\strlen($publicExponent)), $publicExponent)
124
- );
125
 
126
  $rsaPublicKey = \pack(
127
  'Ca*a*a*',
128
  48,
129
- self::encodeLength(\strlen($components['modulus']) + \strlen($components['publicExponent'])),
130
- $components['modulus'],
131
- $components['publicExponent']
132
  );
133
 
134
  // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption.
@@ -159,7 +178,7 @@ class JWK
159
  * @param int $length
160
  * @return string
161
  */
162
- private static function encodeLength($length)
163
  {
164
  if ($length <= 0x7F) {
165
  return \chr($length);
23
  /**
24
  * Parse a set of JWK keys
25
  *
26
+ * @param array<mixed> $jwks The JSON Web Key Set as an associative array
27
+ * @param string $defaultAlg The algorithm for the Key object if "alg" is not set in the
28
+ * JSON Web Key Set
29
  *
30
+ * @return array<string, Key> An associative array of key IDs (kid) to Key objects
31
  *
32
  * @throws InvalidArgumentException Provided JWK Set is empty
33
  * @throws UnexpectedValueException Provided JWK Set was invalid
35
  *
36
  * @uses parseKey
37
  */
38
+ public static function parseKeySet(array $jwks, string $defaultAlg = null): array
39
  {
40
+ $keys = [];
41
 
42
  if (!isset($jwks['keys'])) {
43
  throw new UnexpectedValueException('"keys" member must exist in the JWK Set');
44
  }
45
+
46
  if (empty($jwks['keys'])) {
47
  throw new InvalidArgumentException('JWK Set did not contain any keys');
48
  }
49
 
50
  foreach ($jwks['keys'] as $k => $v) {
51
  $kid = isset($v['kid']) ? $v['kid'] : $k;
52
+ if ($key = self::parseKey($v, $defaultAlg)) {
53
+ $keys[(string) $kid] = $key;
54
  }
55
  }
56
 
64
  /**
65
  * Parse a JWK key
66
  *
67
+ * @param array<mixed> $jwk An individual JWK
68
+ * @param string $defaultAlg The algorithm for the Key object if "alg" is not set in the
69
+ * JSON Web Key Set
70
  *
71
+ * @return Key The key object for the JWK
72
  *
73
  * @throws InvalidArgumentException Provided JWK is empty
74
  * @throws UnexpectedValueException Provided JWK was invalid
76
  *
77
  * @uses createPemFromModulusAndExponent
78
  */
79
+ public static function parseKey(array $jwk, string $defaultAlg = null): ?Key
80
  {
81
  if (empty($jwk)) {
82
  throw new InvalidArgumentException('JWK must not be empty');
83
  }
84
+
85
  if (!isset($jwk['kty'])) {
86
  throw new UnexpectedValueException('JWK must contain a "kty" parameter');
87
  }
88
 
89
+ if (!isset($jwk['alg'])) {
90
+ if (\is_null($defaultAlg)) {
91
+ // The "alg" parameter is optional in a KTY, but an algorithm is required
92
+ // for parsing in this library. Use the $defaultAlg parameter when parsing the
93
+ // key set in order to prevent this error.
94
+ // @see https://datatracker.ietf.org/doc/html/rfc7517#section-4.4
95
+ throw new UnexpectedValueException('JWK must contain an "alg" parameter');
96
+ }
97
+ $jwk['alg'] = $defaultAlg;
98
+ }
99
+
100
  switch ($jwk['kty']) {
101
  case 'RSA':
102
  if (!empty($jwk['d'])) {
113
  'OpenSSL error: ' . \openssl_error_string()
114
  );
115
  }
116
+ return new Key($publicKey, $jwk['alg']);
117
  default:
118
  // Currently only RSA is supported
119
  break;
120
  }
121
+
122
+ return null;
123
  }
124
 
125
  /**
132
  *
133
  * @uses encodeLength
134
  */
135
+ private static function createPemFromModulusAndExponent(
136
+ string $n,
137
+ string $e
138
+ ): string {
139
+ $mod = JWT::urlsafeB64Decode($n);
140
+ $exp = JWT::urlsafeB64Decode($e);
141
 
142
+ $modulus = \pack('Ca*a*', 2, self::encodeLength(\strlen($mod)), $mod);
143
+ $publicExponent = \pack('Ca*a*', 2, self::encodeLength(\strlen($exp)), $exp);
 
 
144
 
145
  $rsaPublicKey = \pack(
146
  'Ca*a*a*',
147
  48,
148
+ self::encodeLength(\strlen($modulus) + \strlen($publicExponent)),
149
+ $modulus,
150
+ $publicExponent
151
  );
152
 
153
  // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption.
178
  * @param int $length
179
  * @return string
180
  */
181
+ private static function encodeLength(int $length): string
182
  {
183
  if ($length <= 0x7F) {
184
  return \chr($length);
vendor/firebase/php-jwt/src/JWT.php CHANGED
@@ -2,11 +2,15 @@
2
 
3
  namespace Firebase\JWT;
4
 
 
 
5
  use DomainException;
6
  use Exception;
7
  use InvalidArgumentException;
 
 
 
8
  use UnexpectedValueException;
9
- use DateTime;
10
 
11
  /**
12
  * JSON Web Token implementation, based on this spec:
@@ -23,50 +27,57 @@ use DateTime;
23
  */
24
  class JWT
25
  {
26
- const ASN1_INTEGER = 0x02;
27
- const ASN1_SEQUENCE = 0x10;
28
- const ASN1_BIT_STRING = 0x03;
29
 
30
  /**
31
  * When checking nbf, iat or expiration times,
32
  * we want to provide some extra leeway time to
33
  * account for clock skew.
 
 
34
  */
35
  public static $leeway = 0;
36
 
37
  /**
38
  * Allow the current timestamp to be specified.
39
  * Useful for fixing a value within unit testing.
40
- *
41
  * Will default to PHP time() value if null.
 
 
42
  */
43
  public static $timestamp = null;
44
 
45
- public static $supported_algs = array(
46
- 'ES384' => array('openssl', 'SHA384'),
47
- 'ES256' => array('openssl', 'SHA256'),
48
- 'HS256' => array('hash_hmac', 'SHA256'),
49
- 'HS384' => array('hash_hmac', 'SHA384'),
50
- 'HS512' => array('hash_hmac', 'SHA512'),
51
- 'RS256' => array('openssl', 'SHA256'),
52
- 'RS384' => array('openssl', 'SHA384'),
53
- 'RS512' => array('openssl', 'SHA512'),
54
- 'EdDSA' => array('sodium_crypto', 'EdDSA'),
55
- );
 
 
 
56
 
57
  /**
58
  * Decodes a JWT string into a PHP object.
59
  *
60
- * @param string $jwt The JWT
61
- * @param string|array|resource $key The key, or map of keys.
62
- * If the algorithm used is asymmetric, this is the public key
63
- * @param array $allowed_algs List of supported verification algorithms
64
- * Supported algorithms are 'ES384','ES256', 'HS256', 'HS384',
65
- * 'HS512', 'RS256', 'RS384', and 'RS512'
66
  *
67
- * @return object The JWT's payload as a PHP object
68
  *
69
- * @throws InvalidArgumentException Provided JWT was empty
 
70
  * @throws UnexpectedValueException Provided JWT was invalid
71
  * @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
72
  * @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
@@ -76,11 +87,14 @@ class JWT
76
  * @uses jsonDecode
77
  * @uses urlsafeB64Decode
78
  */
79
- public static function decode($jwt, $key, array $allowed_algs = array())
80
- {
 
 
 
81
  $timestamp = \is_null(static::$timestamp) ? \time() : static::$timestamp;
82
 
83
- if (empty($key)) {
84
  throw new InvalidArgumentException('Key may not be empty');
85
  }
86
  $tks = \explode('.', $jwt);
@@ -88,42 +102,41 @@ class JWT
88
  throw new UnexpectedValueException('Wrong number of segments');
89
  }
90
  list($headb64, $bodyb64, $cryptob64) = $tks;
91
- if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
 
92
  throw new UnexpectedValueException('Invalid header encoding');
93
  }
94
- if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
 
95
  throw new UnexpectedValueException('Invalid claims encoding');
96
  }
97
- if (false === ($sig = static::urlsafeB64Decode($cryptob64))) {
98
- throw new UnexpectedValueException('Invalid signature encoding');
 
99
  }
 
 
 
 
100
  if (empty($header->alg)) {
101
  throw new UnexpectedValueException('Empty algorithm');
102
  }
103
  if (empty(static::$supported_algs[$header->alg])) {
104
  throw new UnexpectedValueException('Algorithm not supported');
105
  }
106
- if (!\in_array($header->alg, $allowed_algs)) {
107
- throw new UnexpectedValueException('Algorithm not allowed');
 
 
 
 
 
108
  }
109
  if ($header->alg === 'ES256' || $header->alg === 'ES384') {
110
  // OpenSSL expects an ASN.1 DER sequence for ES256/ES384 signatures
111
  $sig = self::signatureToDER($sig);
112
  }
113
-
114
- if (\is_array($key) || $key instanceof \ArrayAccess) {
115
- if (isset($header->kid)) {
116
- if (!isset($key[$header->kid])) {
117
- throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key');
118
- }
119
- $key = $key[$header->kid];
120
- } else {
121
- throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
122
- }
123
- }
124
-
125
- // Check the signature
126
- if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
127
  throw new SignatureInvalidException('Signature verification failed');
128
  }
129
 
@@ -155,32 +168,35 @@ class JWT
155
  /**
156
  * Converts and signs a PHP object or array into a JWT string.
157
  *
158
- * @param object|array $payload PHP object or array
159
- * @param string|resource $key The secret key.
160
- * If the algorithm used is asymmetric, this is the private key
161
- * @param string $alg The signing algorithm.
162
- * Supported algorithms are 'ES384','ES256', 'HS256', 'HS384',
163
- * 'HS512', 'RS256', 'RS384', and 'RS512'
164
- * @param mixed $keyId
165
- * @param array $head An array with header elements to attach
166
  *
167
  * @return string A signed JWT
168
  *
169
  * @uses jsonEncode
170
  * @uses urlsafeB64Encode
171
  */
172
- public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null)
173
- {
174
- $header = array('typ' => 'JWT', 'alg' => $alg);
 
 
 
 
 
175
  if ($keyId !== null) {
176
  $header['kid'] = $keyId;
177
  }
178
  if (isset($head) && \is_array($head)) {
179
  $header = \array_merge($head, $header);
180
  }
181
- $segments = array();
182
- $segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
183
- $segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
184
  $signing_input = \implode('.', $segments);
185
 
186
  $signature = static::sign($signing_input, $key, $alg);
@@ -192,30 +208,35 @@ class JWT
192
  /**
193
  * Sign a string with a given key and algorithm.
194
  *
195
- * @param string $msg The message to sign
196
- * @param string|resource $key The secret key
197
- * @param string $alg The signing algorithm.
198
- * Supported algorithms are 'ES384','ES256', 'HS256', 'HS384',
199
- * 'HS512', 'RS256', 'RS384', and 'RS512'
200
  *
201
  * @return string An encrypted message
202
  *
203
  * @throws DomainException Unsupported algorithm or bad key was specified
204
  */
205
- public static function sign($msg, $key, $alg = 'HS256')
206
- {
 
 
 
207
  if (empty(static::$supported_algs[$alg])) {
208
  throw new DomainException('Algorithm not supported');
209
  }
210
  list($function, $algorithm) = static::$supported_algs[$alg];
211
  switch ($function) {
212
  case 'hash_hmac':
 
 
 
213
  return \hash_hmac($algorithm, $msg, $key, true);
214
  case 'openssl':
215
  $signature = '';
216
- $success = \openssl_sign($msg, $signature, $key, $algorithm);
217
  if (!$success) {
218
- throw new DomainException("OpenSSL unable to sign data");
219
  }
220
  if ($alg === 'ES256') {
221
  $signature = self::signatureFromDER($signature, 256);
@@ -224,35 +245,44 @@ class JWT
224
  }
225
  return $signature;
226
  case 'sodium_crypto':
227
- if (!function_exists('sodium_crypto_sign_detached')) {
228
  throw new DomainException('libsodium is not available');
229
  }
 
 
 
230
  try {
231
  // The last non-empty line is used as the key.
232
  $lines = array_filter(explode("\n", $key));
233
- $key = base64_decode(end($lines));
234
  return sodium_crypto_sign_detached($msg, $key);
235
  } catch (Exception $e) {
236
  throw new DomainException($e->getMessage(), 0, $e);
237
  }
238
  }
 
 
239
  }
240
 
241
  /**
242
  * Verify a signature with the message, key and method. Not all methods
243
  * are symmetric, so we must have a separate verify and sign method.
244
  *
245
- * @param string $msg The original message (header and body)
246
- * @param string $signature The original signature
247
- * @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
248
- * @param string $alg The algorithm
249
  *
250
  * @return bool
251
  *
252
  * @throws DomainException Invalid Algorithm, bad key, or OpenSSL failure
253
  */
254
- private static function verify($msg, $signature, $key, $alg)
255
- {
 
 
 
 
256
  if (empty(static::$supported_algs[$alg])) {
257
  throw new DomainException('Algorithm not supported');
258
  }
@@ -260,7 +290,7 @@ class JWT
260
  list($function, $algorithm) = static::$supported_algs[$alg];
261
  switch ($function) {
262
  case 'openssl':
263
- $success = \openssl_verify($msg, $signature, $key, $algorithm);
264
  if ($success === 1) {
265
  return true;
266
  } elseif ($success === 0) {
@@ -271,32 +301,27 @@ class JWT
271
  'OpenSSL error: ' . \openssl_error_string()
272
  );
273
  case 'sodium_crypto':
274
- if (!function_exists('sodium_crypto_sign_verify_detached')) {
275
  throw new DomainException('libsodium is not available');
276
  }
 
 
 
277
  try {
278
  // The last non-empty line is used as the key.
279
- $lines = array_filter(explode("\n", $key));
280
- $key = base64_decode(end($lines));
281
  return sodium_crypto_sign_verify_detached($signature, $msg, $key);
282
  } catch (Exception $e) {
283
  throw new DomainException($e->getMessage(), 0, $e);
284
  }
285
  case 'hash_hmac':
286
  default:
287
- $hash = \hash_hmac($algorithm, $msg, $key, true);
288
- if (\function_exists('hash_equals')) {
289
- return \hash_equals($signature, $hash);
290
  }
291
- $len = \min(static::safeStrlen($signature), static::safeStrlen($hash));
292
-
293
- $status = 0;
294
- for ($i = 0; $i < $len; $i++) {
295
- $status |= (\ord($signature[$i]) ^ \ord($hash[$i]));
296
- }
297
- $status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash));
298
-
299
- return ($status === 0);
300
  }
301
  }
302
 
@@ -305,30 +330,16 @@ class JWT
305
  *
306
  * @param string $input JSON string
307
  *
308
- * @return object Object representation of JSON string
309
  *
310
  * @throws DomainException Provided string was invalid JSON
311
  */
312
- public static function jsonDecode($input)
313
  {
314
- if (\version_compare(PHP_VERSION, '5.4.0', '>=') && !(\defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
315
- /** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
316
- * to specify that large ints (like Steam Transaction IDs) should be treated as
317
- * strings, rather than the PHP default behaviour of converting them to floats.
318
- */
319
- $obj = \json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
320
- } else {
321
- /** Not all servers will support that, however, so for older versions we must
322
- * manually detect large ints in the JSON string and quote them (thus converting
323
- *them to strings) before decoding, hence the preg_replace() call.
324
- */
325
- $max_int_length = \strlen((string) PHP_INT_MAX) - 1;
326
- $json_without_bigints = \preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input);
327
- $obj = \json_decode($json_without_bigints);
328
- }
329
 
330
  if ($errno = \json_last_error()) {
331
- static::handleJsonError($errno);
332
  } elseif ($obj === null && $input !== 'null') {
333
  throw new DomainException('Null result with non-null input');
334
  }
@@ -336,22 +347,30 @@ class JWT
336
  }
337
 
338
  /**
339
- * Encode a PHP object into a JSON string.
340
  *
341
- * @param object|array $input A PHP object or array
342
  *
343
- * @return string JSON representation of the PHP object or array
344
  *
345
  * @throws DomainException Provided object could not be encoded to valid JSON
346
  */
347
- public static function jsonEncode($input)
348
  {
349
- $json = \json_encode($input);
 
 
 
 
 
350
  if ($errno = \json_last_error()) {
351
- static::handleJsonError($errno);
352
  } elseif ($json === 'null' && $input !== null) {
353
  throw new DomainException('Null result with non-null input');
354
  }
 
 
 
355
  return $json;
356
  }
357
 
@@ -361,8 +380,10 @@ class JWT
361
  * @param string $input A Base64 encoded string
362
  *
363
  * @return string A decoded string
 
 
364
  */
365
- public static function urlsafeB64Decode($input)
366
  {
367
  $remainder = \strlen($input) % 4;
368
  if ($remainder) {
@@ -379,27 +400,84 @@ class JWT
379
  *
380
  * @return string The base64 encode of what you passed in
381
  */
382
- public static function urlsafeB64Encode($input)
383
  {
384
  return \str_replace('=', '', \strtr(\base64_encode($input), '+/', '-_'));
385
  }
386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  /**
388
  * Helper method to create a JSON error.
389
  *
390
  * @param int $errno An error number from json_last_error()
391
  *
 
 
392
  * @return void
393
  */
394
- private static function handleJsonError($errno)
395
  {
396
- $messages = array(
397
  JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
398
  JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
399
  JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
400
  JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
401
  JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3
402
- );
403
  throw new DomainException(
404
  isset($messages[$errno])
405
  ? $messages[$errno]
@@ -414,7 +492,7 @@ class JWT
414
  *
415
  * @return int
416
  */
417
- private static function safeStrlen($str)
418
  {
419
  if (\function_exists('mb_strlen')) {
420
  return \mb_strlen($str, '8bit');
@@ -428,10 +506,11 @@ class JWT
428
  * @param string $sig The ECDSA signature to convert
429
  * @return string The encoded DER object
430
  */
431
- private static function signatureToDER($sig)
432
  {
433
  // Separate the signature into r-value and s-value
434
- list($r, $s) = \str_split($sig, (int) (\strlen($sig) / 2));
 
435
 
436
  // Trim leading zeros
437
  $r = \ltrim($r, "\x00");
@@ -458,9 +537,10 @@ class JWT
458
  *
459
  * @param int $type DER tag
460
  * @param string $value the value to encode
 
461
  * @return string the encoded object
462
  */
463
- private static function encodeDER($type, $value)
464
  {
465
  $tag_header = 0;
466
  if ($type === self::ASN1_SEQUENCE) {
@@ -481,9 +561,10 @@ class JWT
481
  *
482
  * @param string $der binary signature in DER format
483
  * @param int $keySize the number of bits in the key
 
484
  * @return string the signature
485
  */
486
- private static function signatureFromDER($der, $keySize)
487
  {
488
  // OpenSSL returns the ECDSA signatures as a binary ASN.1 DER SEQUENCE
489
  list($offset, $_) = self::readDER($der);
@@ -508,9 +589,10 @@ class JWT
508
  * @param string $der the binary data in DER format
509
  * @param int $offset the offset of the data stream containing the object
510
  * to decode
511
- * @return array [$offset, $data] the new offset and the decoded object
 
512
  */
513
- private static function readDER($der, $offset = 0)
514
  {
515
  $pos = $offset;
516
  $size = \strlen($der);
@@ -539,6 +621,6 @@ class JWT
539
  $data = null;
540
  }
541
 
542
- return array($pos, $data);
543
  }
544
  }
2
 
3
  namespace Firebase\JWT;
4
 
5
+ use ArrayAccess;
6
+ use DateTime;
7
  use DomainException;
8
  use Exception;
9
  use InvalidArgumentException;
10
+ use OpenSSLAsymmetricKey;
11
+ use OpenSSLCertificate;
12
+ use stdClass;
13
  use UnexpectedValueException;
 
14
 
15
  /**
16
  * JSON Web Token implementation, based on this spec:
27
  */
28
  class JWT
29
  {
30
+ private const ASN1_INTEGER = 0x02;
31
+ private const ASN1_SEQUENCE = 0x10;
32
+ private const ASN1_BIT_STRING = 0x03;
33
 
34
  /**
35
  * When checking nbf, iat or expiration times,
36
  * we want to provide some extra leeway time to
37
  * account for clock skew.
38
+ *
39
+ * @var int
40
  */
41
  public static $leeway = 0;
42
 
43
  /**
44
  * Allow the current timestamp to be specified.
45
  * Useful for fixing a value within unit testing.
 
46
  * Will default to PHP time() value if null.
47
+ *
48
+ * @var ?int
49
  */
50
  public static $timestamp = null;
51
 
52
+ /**
53
+ * @var array<string, string[]>
54
+ */
55
+ public static $supported_algs = [
56
+ 'ES384' => ['openssl', 'SHA384'],
57
+ 'ES256' => ['openssl', 'SHA256'],
58
+ 'HS256' => ['hash_hmac', 'SHA256'],
59
+ 'HS384' => ['hash_hmac', 'SHA384'],
60
+ 'HS512' => ['hash_hmac', 'SHA512'],
61
+ 'RS256' => ['openssl', 'SHA256'],
62
+ 'RS384' => ['openssl', 'SHA384'],
63
+ 'RS512' => ['openssl', 'SHA512'],
64
+ 'EdDSA' => ['sodium_crypto', 'EdDSA'],
65
+ ];
66
 
67
  /**
68
  * Decodes a JWT string into a PHP object.
69
  *
70
+ * @param string $jwt The JWT
71
+ * @param Key|array<string,Key> $keyOrKeyArray The Key or associative array of key IDs (kid) to Key objects.
72
+ * If the algorithm used is asymmetric, this is the public key
73
+ * Each Key object contains an algorithm and matching key.
74
+ * Supported algorithms are 'ES384','ES256', 'HS256', 'HS384',
75
+ * 'HS512', 'RS256', 'RS384', and 'RS512'
76
  *
77
+ * @return stdClass The JWT's payload as a PHP object
78
  *
79
+ * @throws InvalidArgumentException Provided key/key-array was empty
80
+ * @throws DomainException Provided JWT is malformed
81
  * @throws UnexpectedValueException Provided JWT was invalid
82
  * @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
83
  * @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
87
  * @uses jsonDecode
88
  * @uses urlsafeB64Decode
89
  */
90
+ public static function decode(
91
+ string $jwt,
92
+ $keyOrKeyArray
93
+ ): stdClass {
94
+ // Validate JWT
95
  $timestamp = \is_null(static::$timestamp) ? \time() : static::$timestamp;
96
 
97
+ if (empty($keyOrKeyArray)) {
98
  throw new InvalidArgumentException('Key may not be empty');
99
  }
100
  $tks = \explode('.', $jwt);
102
  throw new UnexpectedValueException('Wrong number of segments');
103
  }
104
  list($headb64, $bodyb64, $cryptob64) = $tks;
105
+ $headerRaw = static::urlsafeB64Decode($headb64);
106
+ if (null === ($header = static::jsonDecode($headerRaw))) {
107
  throw new UnexpectedValueException('Invalid header encoding');
108
  }
109
+ $payloadRaw = static::urlsafeB64Decode($bodyb64);
110
+ if (null === ($payload = static::jsonDecode($payloadRaw))) {
111
  throw new UnexpectedValueException('Invalid claims encoding');
112
  }
113
+ if (\is_array($payload)) {
114
+ // prevent PHP Fatal Error in edge-cases when payload is empty array
115
+ $payload = (object) $payload;
116
  }
117
+ if (!$payload instanceof stdClass) {
118
+ throw new UnexpectedValueException('Payload must be a JSON object');
119
+ }
120
+ $sig = static::urlsafeB64Decode($cryptob64);
121
  if (empty($header->alg)) {
122
  throw new UnexpectedValueException('Empty algorithm');
123
  }
124
  if (empty(static::$supported_algs[$header->alg])) {
125
  throw new UnexpectedValueException('Algorithm not supported');
126
  }
127
+
128
+ $key = self::getKey($keyOrKeyArray, property_exists($header, 'kid') ? $header->kid : null);
129
+
130
+ // Check the algorithm
131
+ if (!self::constantTimeEquals($key->getAlgorithm(), $header->alg)) {
132
+ // See issue #351
133
+ throw new UnexpectedValueException('Incorrect key for this algorithm');
134
  }
135
  if ($header->alg === 'ES256' || $header->alg === 'ES384') {
136
  // OpenSSL expects an ASN.1 DER sequence for ES256/ES384 signatures
137
  $sig = self::signatureToDER($sig);
138
  }
139
+ if (!self::verify("$headb64.$bodyb64", $sig, $key->getKeyMaterial(), $header->alg)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  throw new SignatureInvalidException('Signature verification failed');
141
  }
142
 
168
  /**
169
  * Converts and signs a PHP object or array into a JWT string.
170
  *
171
+ * @param array<mixed> $payload PHP array
172
+ * @param string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate $key The secret key.
173
+ * @param string $alg Supported algorithms are 'ES384','ES256', 'HS256', 'HS384',
174
+ * 'HS512', 'RS256', 'RS384', and 'RS512'
175
+ * @param string $keyId
176
+ * @param array<string, string> $head An array with header elements to attach
 
 
177
  *
178
  * @return string A signed JWT
179
  *
180
  * @uses jsonEncode
181
  * @uses urlsafeB64Encode
182
  */
183
+ public static function encode(
184
+ array $payload,
185
+ $key,
186
+ string $alg,
187
+ string $keyId = null,
188
+ array $head = null
189
+ ): string {
190
+ $header = ['typ' => 'JWT', 'alg' => $alg];
191
  if ($keyId !== null) {
192
  $header['kid'] = $keyId;
193
  }
194
  if (isset($head) && \is_array($head)) {
195
  $header = \array_merge($head, $header);
196
  }
197
+ $segments = [];
198
+ $segments[] = static::urlsafeB64Encode((string) static::jsonEncode($header));
199
+ $segments[] = static::urlsafeB64Encode((string) static::jsonEncode($payload));
200
  $signing_input = \implode('.', $segments);
201
 
202
  $signature = static::sign($signing_input, $key, $alg);
208
  /**
209
  * Sign a string with a given key and algorithm.
210
  *
211
+ * @param string $msg The message to sign
212
+ * @param string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate $key The secret key.
213
+ * @param string $alg Supported algorithms are 'ES384','ES256', 'HS256', 'HS384',
214
+ * 'HS512', 'RS256', 'RS384', and 'RS512'
 
215
  *
216
  * @return string An encrypted message
217
  *
218
  * @throws DomainException Unsupported algorithm or bad key was specified
219
  */
220
+ public static function sign(
221
+ string $msg,
222
+ $key,
223
+ string $alg
224
+ ): string {
225
  if (empty(static::$supported_algs[$alg])) {
226
  throw new DomainException('Algorithm not supported');
227
  }
228
  list($function, $algorithm) = static::$supported_algs[$alg];
229
  switch ($function) {
230
  case 'hash_hmac':
231
+ if (!\is_string($key)) {
232
+ throw new InvalidArgumentException('key must be a string when using hmac');
233
+ }
234
  return \hash_hmac($algorithm, $msg, $key, true);
235
  case 'openssl':
236
  $signature = '';
237
+ $success = \openssl_sign($msg, $signature, $key, $algorithm); // @phpstan-ignore-line
238
  if (!$success) {
239
+ throw new DomainException('OpenSSL unable to sign data');
240
  }
241
  if ($alg === 'ES256') {
242
  $signature = self::signatureFromDER($signature, 256);
245
  }
246
  return $signature;
247
  case 'sodium_crypto':
248
+ if (!\function_exists('sodium_crypto_sign_detached')) {
249
  throw new DomainException('libsodium is not available');
250
  }
251
+ if (!\is_string($key)) {
252
+ throw new InvalidArgumentException('key must be a string when using EdDSA');
253
+ }
254
  try {
255
  // The last non-empty line is used as the key.
256
  $lines = array_filter(explode("\n", $key));
257
+ $key = base64_decode((string) end($lines));
258
  return sodium_crypto_sign_detached($msg, $key);
259
  } catch (Exception $e) {
260
  throw new DomainException($e->getMessage(), 0, $e);
261
  }
262
  }
263
+
264
+ throw new DomainException('Algorithm not supported');
265
  }
266
 
267
  /**
268
  * Verify a signature with the message, key and method. Not all methods
269
  * are symmetric, so we must have a separate verify and sign method.
270
  *
271
+ * @param string $msg The original message (header and body)
272
+ * @param string $signature The original signature
273
+ * @param string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate $keyMaterial For HS*, a string key works. for RS*, must be an instance of OpenSSLAsymmetricKey
274
+ * @param string $alg The algorithm
275
  *
276
  * @return bool
277
  *
278
  * @throws DomainException Invalid Algorithm, bad key, or OpenSSL failure
279
  */
280
+ private static function verify(
281
+ string $msg,
282
+ string $signature,
283
+ $keyMaterial,
284
+ string $alg
285
+ ): bool {
286
  if (empty(static::$supported_algs[$alg])) {
287
  throw new DomainException('Algorithm not supported');
288
  }
290
  list($function, $algorithm) = static::$supported_algs[$alg];
291
  switch ($function) {
292
  case 'openssl':
293
+ $success = \openssl_verify($msg, $signature, $keyMaterial, $algorithm); // @phpstan-ignore-line
294
  if ($success === 1) {
295
  return true;
296
  } elseif ($success === 0) {
301
  'OpenSSL error: ' . \openssl_error_string()
302
  );
303
  case 'sodium_crypto':
304
+ if (!\function_exists('sodium_crypto_sign_verify_detached')) {
305
  throw new DomainException('libsodium is not available');
306
  }
307
+ if (!\is_string($keyMaterial)) {
308
+ throw new InvalidArgumentException('key must be a string when using EdDSA');
309
+ }
310
  try {
311
  // The last non-empty line is used as the key.
312
+ $lines = array_filter(explode("\n", $keyMaterial));
313
+ $key = base64_decode((string) end($lines));
314
  return sodium_crypto_sign_verify_detached($signature, $msg, $key);
315
  } catch (Exception $e) {
316
  throw new DomainException($e->getMessage(), 0, $e);
317
  }
318
  case 'hash_hmac':
319
  default:
320
+ if (!\is_string($keyMaterial)) {
321
+ throw new InvalidArgumentException('key must be a string when using hmac');
 
322
  }
323
+ $hash = \hash_hmac($algorithm, $msg, $keyMaterial, true);
324
+ return self::constantTimeEquals($hash, $signature);
 
 
 
 
 
 
 
325
  }
326
  }
327
 
330
  *
331
  * @param string $input JSON string
332
  *
333
+ * @return mixed The decoded JSON string
334
  *
335
  * @throws DomainException Provided string was invalid JSON
336
  */
337
+ public static function jsonDecode(string $input)
338
  {
339
+ $obj = \json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
 
341
  if ($errno = \json_last_error()) {
342
+ self::handleJsonError($errno);
343
  } elseif ($obj === null && $input !== 'null') {
344
  throw new DomainException('Null result with non-null input');
345
  }
347
  }
348
 
349
  /**
350
+ * Encode a PHP array into a JSON string.
351
  *
352
+ * @param array<mixed> $input A PHP array
353
  *
354
+ * @return string JSON representation of the PHP array
355
  *
356
  * @throws DomainException Provided object could not be encoded to valid JSON
357
  */
358
+ public static function jsonEncode(array $input): string
359
  {
360
+ if (PHP_VERSION_ID >= 50400) {
361
+ $json = \json_encode($input, \JSON_UNESCAPED_SLASHES);
362
+ } else {
363
+ // PHP 5.3 only
364
+ $json = \json_encode($input);
365
+ }
366
  if ($errno = \json_last_error()) {
367
+ self::handleJsonError($errno);
368
  } elseif ($json === 'null' && $input !== null) {
369
  throw new DomainException('Null result with non-null input');
370
  }
371
+ if ($json === false) {
372
+ throw new DomainException('Provided object could not be encoded to valid JSON');
373
+ }
374
  return $json;
375
  }
376
 
380
  * @param string $input A Base64 encoded string
381
  *
382
  * @return string A decoded string
383
+ *
384
+ * @throws InvalidArgumentException invalid base64 characters
385
  */
386
+ public static function urlsafeB64Decode(string $input): string
387
  {
388
  $remainder = \strlen($input) % 4;
389
  if ($remainder) {
400
  *
401
  * @return string The base64 encode of what you passed in
402
  */
403
+ public static function urlsafeB64Encode(string $input): string
404
  {
405
  return \str_replace('=', '', \strtr(\base64_encode($input), '+/', '-_'));
406
  }
407
 
408
+
409
+ /**
410
+ * Determine if an algorithm has been provided for each Key
411
+ *
412
+ * @param Key|ArrayAccess<string,Key>|array<string,Key> $keyOrKeyArray
413
+ * @param string|null $kid
414
+ *
415
+ * @throws UnexpectedValueException
416
+ *
417
+ * @return Key
418
+ */
419
+ private static function getKey(
420
+ $keyOrKeyArray,
421
+ ?string $kid
422
+ ): Key {
423
+ if ($keyOrKeyArray instanceof Key) {
424
+ return $keyOrKeyArray;
425
+ }
426
+
427
+ if ($keyOrKeyArray instanceof CachedKeySet) {
428
+ // Skip "isset" check, as this will automatically refresh if not set
429
+ return $keyOrKeyArray[$kid];
430
+ }
431
+
432
+ if (empty($kid)) {
433
+ throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
434
+ }
435
+ if (!isset($keyOrKeyArray[$kid])) {
436
+ throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key');
437
+ }
438
+
439
+ return $keyOrKeyArray[$kid];
440
+ }
441
+
442
+ /**
443
+ * @param string $left The string of known length to compare against
444
+ * @param string $right The user-supplied string
445
+ * @return bool
446
+ */
447
+ public static function constantTimeEquals(string $left, string $right): bool
448
+ {
449
+ if (\function_exists('hash_equals')) {
450
+ return \hash_equals($left, $right);
451
+ }
452
+ $len = \min(self::safeStrlen($left), self::safeStrlen($right));
453
+
454
+ $status = 0;
455
+ for ($i = 0; $i < $len; $i++) {
456
+ $status |= (\ord($left[$i]) ^ \ord($right[$i]));
457
+ }
458
+ $status |= (self::safeStrlen($left) ^ self::safeStrlen($right));
459
+
460
+ return ($status === 0);
461
+ }
462
+
463
  /**
464
  * Helper method to create a JSON error.
465
  *
466
  * @param int $errno An error number from json_last_error()
467
  *
468
+ * @throws DomainException
469
+ *
470
  * @return void
471
  */
472
+ private static function handleJsonError(int $errno): void
473
  {
474
+ $messages = [
475
  JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
476
  JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
477
  JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
478
  JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
479
  JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3
480
+ ];
481
  throw new DomainException(
482
  isset($messages[$errno])
483
  ? $messages[$errno]
492
  *
493
  * @return int
494
  */
495
+ private static function safeStrlen(string $str): int
496
  {
497
  if (\function_exists('mb_strlen')) {
498
  return \mb_strlen($str, '8bit');
506
  * @param string $sig The ECDSA signature to convert
507
  * @return string The encoded DER object
508
  */
509
+ private static function signatureToDER(string $sig): string
510
  {
511
  // Separate the signature into r-value and s-value
512
+ $length = max(1, (int) (\strlen($sig) / 2));
513
+ list($r, $s) = \str_split($sig, $length > 0 ? $length : 1);
514
 
515
  // Trim leading zeros
516
  $r = \ltrim($r, "\x00");
537
  *
538
  * @param int $type DER tag
539
  * @param string $value the value to encode
540
+ *
541
  * @return string the encoded object
542
  */
543
+ private static function encodeDER(int $type, string $value): string
544
  {
545
  $tag_header = 0;
546
  if ($type === self::ASN1_SEQUENCE) {
561
  *
562
  * @param string $der binary signature in DER format
563
  * @param int $keySize the number of bits in the key
564
+ *
565
  * @return string the signature
566
  */
567
+ private static function signatureFromDER(string $der, int $keySize): string
568
  {
569
  // OpenSSL returns the ECDSA signatures as a binary ASN.1 DER SEQUENCE
570
  list($offset, $_) = self::readDER($der);
589
  * @param string $der the binary data in DER format
590
  * @param int $offset the offset of the data stream containing the object
591
  * to decode
592
+ *
593
+ * @return array{int, string|null} the new offset and the decoded object
594
  */
595
+ private static function readDER(string $der, int $offset = 0): array
596
  {
597
  $pos = $offset;
598
  $size = \strlen($der);
621
  $data = null;
622
  }
623
 
624
+ return [$pos, $data];
625
  }
626
  }
vendor/firebase/php-jwt/src/Key.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Firebase\JWT;
4
+
5
+ use InvalidArgumentException;
6
+ use OpenSSLAsymmetricKey;
7
+ use OpenSSLCertificate;
8
+ use TypeError;
9
+
10
+ class Key
11
+ {
12
+ /** @var string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate */
13
+ private $keyMaterial;
14
+ /** @var string */
15
+ private $algorithm;
16
+
17
+ /**
18
+ * @param string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate $keyMaterial
19
+ * @param string $algorithm
20
+ */
21
+ public function __construct(
22
+ $keyMaterial,
23
+ string $algorithm
24
+ ) {
25
+ if (
26
+ !\is_string($keyMaterial)
27
+ && !$keyMaterial instanceof OpenSSLAsymmetricKey
28
+ && !$keyMaterial instanceof OpenSSLCertificate
29
+ && !\is_resource($keyMaterial)
30
+ ) {
31
+ throw new TypeError('Key material must be a string, resource, or OpenSSLAsymmetricKey');
32
+ }
33
+
34
+ if (empty($keyMaterial)) {
35
+ throw new InvalidArgumentException('Key material must not be empty');
36
+ }
37
+
38
+ if (empty($algorithm)) {
39
+ throw new InvalidArgumentException('Algorithm must not be empty');
40
+ }
41
+
42
+ // TODO: Remove in PHP 8.0 in favor of class constructor property promotion
43
+ $this->keyMaterial = $keyMaterial;
44
+ $this->algorithm = $algorithm;
45
+ }
46
+
47
+ /**
48
+ * Return the algorithm valid for this key
49
+ *
50
+ * @return string
51
+ */
52
+ public function getAlgorithm(): string
53
+ {
54
+ return $this->algorithm;
55
+ }
56
+
57
+ /**
58
+ * @return string|resource|OpenSSLAsymmetricKey|OpenSSLCertificate
59
+ */
60
+ public function getKeyMaterial()
61
+ {
62
+ return $this->keyMaterial;
63
+ }
64
+ }
vendor/google/apiclient-services/renovate.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ],
5
+ "pinVersions": false,
6
+ "rebaseStalePrs": true
7
+ }
vendor/google/apiclient-services/src/Indexing/UrlNotification.php CHANGED
@@ -19,30 +19,57 @@ namespace Google\Service\Indexing;
19
 
20
  class UrlNotification extends \Google\Model
21
  {
 
 
 
22
  public $notifyTime;
 
 
 
23
  public $type;
 
 
 
24
  public $url;
25
 
 
 
 
26
  public function setNotifyTime($notifyTime)
27
  {
28
  $this->notifyTime = $notifyTime;
29
  }
 
 
 
30
  public function getNotifyTime()
31
  {
32
  return $this->notifyTime;
33
  }
 
 
 
34
  public function setType($type)
35
  {
36
  $this->type = $type;
37
  }
 
 
 
38
  public function getType()
39
  {
40
  return $this->type;
41
  }
 
 
 
42
  public function setUrl($url)
43
  {
44
  $this->url = $url;
45
  }
 
 
 
46
  public function getUrl()
47
  {
48
  return $this->url;
19
 
20
  class UrlNotification extends \Google\Model
21
  {
22
+ /**
23
+ * @var string
24
+ */
25
  public $notifyTime;
26
+ /**
27
+ * @var string
28
+ */
29
  public $type;
30
+ /**
31
+ * @var string
32
+ */
33
  public $url;
34
 
35
+ /**
36
+ * @param string
37
+ */
38
  public function setNotifyTime($notifyTime)
39
  {
40
  $this->notifyTime = $notifyTime;
41
  }
42
+ /**
43
+ * @return string
44
+ */
45
  public function getNotifyTime()
46
  {
47
  return $this->notifyTime;
48
  }
49
+ /**
50
+ * @param string
51
+ */
52
  public function setType($type)
53
  {
54
  $this->type = $type;
55
  }
56
+ /**
57
+ * @return string
58
+ */
59
  public function getType()
60
  {
61
  return $this->type;
62
  }
63
+ /**
64
+ * @param string
65
+ */
66
  public function setUrl($url)
67
  {
68
  $this->url = $url;
69
  }
70
+ /**
71
+ * @return string
72
+ */
73
  public function getUrl()
74
  {
75
  return $this->url;
vendor/google/apiclient-services/src/Indexing/UrlNotificationMetadata.php CHANGED
@@ -23,6 +23,9 @@ class UrlNotificationMetadata extends \Google\Model
23
  protected $latestRemoveDataType = '';
24
  protected $latestUpdateType = UrlNotification::class;
25
  protected $latestUpdateDataType = '';
 
 
 
26
  public $url;
27
 
28
  /**
@@ -53,10 +56,16 @@ class UrlNotificationMetadata extends \Google\Model
53
  {
54
  return $this->latestUpdate;
55
  }
 
 
 
56
  public function setUrl($url)
57
  {
58
  $this->url = $url;
59
  }
 
 
 
60
  public function getUrl()
61
  {
62
  return $this->url;
23
  protected $latestRemoveDataType = '';
24
  protected $latestUpdateType = UrlNotification::class;
25
  protected $latestUpdateDataType = '';
26
+ /**
27
+ * @var string
28
+ */
29
  public $url;
30
 
31
  /**
56
  {
57
  return $this->latestUpdate;
58
  }
59
+ /**
60
+ * @param string
61
+ */
62
  public function setUrl($url)
63
  {
64
  $this->url = $url;
65
  }
66
+ /**
67
+ * @return string
68
+ */
69
  public function getUrl()
70
  {
71
  return $this->url;
vendor/google/apiclient-services/synth.metadata DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "sources": [
3
- {
4
- "git": {
5
- "name": ".",
6
- "remote": "https://github.com/googleapis/google-api-php-client-services.git",
7
- "sha": "9c653d59ab16b2d6b970de862b406535ff0eb7ee"
8
- }
9
- },
10
- {
11
- "git": {
12
- "name": "discovery-artifact-manager",
13
- "remote": "https://github.com/googleapis/discovery-artifact-manager.git",
14
- "sha": "c542af134eaf20b46c56e52b861065c2b120be16"
15
- }
16
- }
17
- ]
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/google/apiclient-services/synth.py DELETED
@@ -1,119 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """This script is used to synthesize generated parts of this library."""
16
-
17
- import synthtool as s
18
- from synthtool.__main__ import extra_args
19
- from synthtool import log, shell
20
- from synthtool.sources import git
21
- import logging
22
- from os import path, remove
23
- from pathlib import Path
24
- import glob
25
- import json
26
- import re
27
- import sys
28
- from packaging import version
29
-
30
- logging.basicConfig(level=logging.DEBUG)
31
-
32
- VERSION_REGEX = r"([^\.]*)\.(.+)\.json$"
33
-
34
- TEMPLATE_VERSIONS = [
35
- "default",
36
- ]
37
- discovery_url = "https://github.com/googleapis/discovery-artifact-manager.git"
38
-
39
- repository = Path('.')
40
-
41
- log.debug(f"Cloning {discovery_url}.")
42
- discovery = git.clone(discovery_url)
43
-
44
- log.debug("Cleaning output directory.")
45
- shell.run("rm -rf .cache".split(), cwd=repository)
46
-
47
- log.debug("Installing dependencies.")
48
- shell.run(
49
- "python2 -m pip install -e generator/ --user".split(),
50
- cwd=repository
51
- )
52
-
53
- def generate_service(disco: str):
54
- m = re.search(VERSION_REGEX, disco)
55
- name = m.group(1)
56
- version = m.group(2)
57
- template = TEMPLATE_VERSIONS[-1] # Generate for latest version
58
-
59
- log.info(f"Generating {name} {version} ({template}).")
60
-
61
- output_dir = repository / ".cache" / name / version
62
- input_file = discovery / "discoveries" / disco
63
-
64
- command = (
65
- f"python2 -m googleapis.codegen --output_dir={output_dir}" +
66
- f" --input={input_file} --language=php --language_variant={template}" +
67
- f" --package_path=api/services"
68
- )
69
-
70
- shell.run(f"mkdir -p {output_dir}".split(), cwd=repository / "generator")
71
- shell.run(command.split(), cwd=repository, hide_output=False)
72
-
73
- s.copy(output_dir, f"src")
74
-
75
- def all_discoveries(skip=None, prefer=None):
76
- """Returns a map of API IDs to Discovery document filenames.
77
-
78
- Args:
79
- skip (list, optional): a list of API IDs to skip.
80
- prefer (list, optional): a list of API IDs to include.
81
-
82
- Returns:
83
- list(string): A list of Discovery document filenames.
84
- """
85
- discos = {}
86
- for file in sorted(glob.glob(str(discovery / 'discoveries/*.*.json'))):
87
- api_id = None
88
- with open(file) as api_file:
89
- api_id = json.load(api_file)['id']
90
- # If an API has already been visited, skip it.
91
- if api_id in discos:
92
- continue
93
- # Skip APIs explicitly listed in "skip" arg
94
- if skip and api_id in skip:
95
- continue
96
- discos[api_id] = path.basename(file)
97
-
98
- # Skip APIs not preferred in index.json and not listed in "prefer" arg
99
- index = {}
100
- with open(str(discovery / 'discoveries/index.json')) as file:
101
- index = json.load(file)
102
- for api in index['items']:
103
- api_id = api['id']
104
- if prefer and api_id in prefer:
105
- continue
106
- if api['preferred']:
107
- continue
108
- discos.pop(api_id, None)
109
-
110
- return discos.values()
111
-
112
- def generate_services(services):
113
- for service in services:
114
- generate_service(service)
115
-
116
- skip = ['discovery:v1', 'websecurityscanner:v1']
117
- prefer = ['admin:directory_v1', 'admin:datatransfer_v1']
118
- discoveries = all_discoveries(skip, prefer)
119
- generate_services(discoveries)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/google/apiclient/phpstan.neon.dist ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ parameters:
2
+ treatPhpDocTypesAsCertain: false
3
+ level: 5
4
+ paths:
5
+ - src
6
+ excludePaths:
7
+ - src/AuthHandler/Guzzle5AuthHandler.php
8
+
vendor/google/apiclient/src/AccessToken/Revoke.php CHANGED
@@ -30,52 +30,52 @@ use GuzzleHttp\Psr7\Request;
30
  */
31
  class Revoke
32
  {
33
- /**
34
- * @var ClientInterface The http client
35
- */
36
- private $http;
37
 
38
- /**
39
- * Instantiates the class, but does not initiate the login flow, leaving it
40
- * to the discretion of the caller.
41
- */
42
- public function __construct(ClientInterface $http = null)
43
- {
44
- $this->http = $http;
45
- }
46
-
47
- /**
48
- * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
49
- * token, if a token isn't provided.
50
- *
51
- * @param string|array $token The token (access token or a refresh token) that should be revoked.
52
- * @return boolean Returns True if the revocation was successful, otherwise False.
53
- */
54
- public function revokeToken($token)
55
- {
56
- if (is_array($token)) {
57
- if (isset($token['refresh_token'])) {
58
- $token = $token['refresh_token'];
59
- } else {
60
- $token = $token['access_token'];
61
- }
62
  }
63
 
64
- $body = Psr7\stream_for(http_build_query(array('token' => $token)));
65
- $request = new Request(
66
- 'POST',
67
- Client::OAUTH2_REVOKE_URI,
68
- [
69
- 'Cache-Control' => 'no-store',
70
- 'Content-Type' => 'application/x-www-form-urlencoded',
71
- ],
72
- $body
73
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
- $httpHandler = HttpHandlerFactory::build($this->http);
76
 
77
- $response = $httpHandler($request);
78
 
79
- return $response->getStatusCode() == 200;
80
- }
81
  }
30
  */
31
  class Revoke
32
  {
33
+ /**
34
+ * @var ClientInterface The http client
35
+ */
36
+ private $http;
37
 
38
+ /**
39
+ * Instantiates the class, but does not initiate the login flow, leaving it
40
+ * to the discretion of the caller.
41
+ */
42
+ public function __construct(ClientInterface $http = null)
43
+ {
44
+ $this->http = $http;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
+ /**
48
+ * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
49
+ * token, if a token isn't provided.
50
+ *
51
+ * @param string|array $token The token (access token or a refresh token) that should be revoked.
52
+ * @return boolean Returns True if the revocation was successful, otherwise False.
53
+ */
54
+ public function revokeToken($token)
55
+ {
56
+ if (is_array($token)) {
57
+ if (isset($token['refresh_token'])) {
58
+ $token = $token['refresh_token'];
59
+ } else {
60
+ $token = $token['access_token'];
61
+ }
62
+ }
63
+
64
+ $body = Psr7\Utils::streamFor(http_build_query(['token' => $token]));
65
+ $request = new Request(
66
+ 'POST',
67
+ Client::OAUTH2_REVOKE_URI,
68
+ [
69
+ 'Cache-Control' => 'no-store',
70
+ 'Content-Type' => 'application/x-www-form-urlencoded',
71
+ ],
72
+ $body
73
+ );
74
 
75
+ $httpHandler = HttpHandlerFactory::build($this->http);
76
 
77
+ $response = $httpHandler($request);
78
 
79
+ return $response->getStatusCode() == 200;
80
+ }
81
  }
vendor/google/apiclient/src/AccessToken/Verify.php CHANGED
@@ -18,22 +18,22 @@
18
 
19
  namespace Google\AccessToken;
20
 
 
 
 
 
21
  use Firebase\JWT\ExpiredException as ExpiredExceptionV3;
 
22
  use Firebase\JWT\SignatureInvalidException;
 
 
23
  use GuzzleHttp\Client;
24
  use GuzzleHttp\ClientInterface;
 
 
25
  use phpseclib3\Crypt\PublicKeyLoader;
26
- use phpseclib3\Crypt\RSA\PublicKey;
27
  use Psr\Cache\CacheItemPoolInterface;
28
- use Google\Auth\Cache\MemoryCacheItemPool;
29
- use Google\Exception as GoogleException;
30
- use Stash\Driver\FileSystem;
31
- use Stash\Pool;
32
- use DateTime;
33
- use DomainException;
34
- use Exception;
35
- use ExpiredException; // Firebase v2
36
- use LogicException;
37
 
38
  /**
39
  * Wrapper around Google Access Tokens which provides convenience functions
@@ -41,253 +41,264 @@ use LogicException;
41
  */
42
  class Verify
43
  {
44
- const FEDERATED_SIGNON_CERT_URL = 'https://www.googleapis.com/oauth2/v3/certs';
45
- const OAUTH2_ISSUER = 'accounts.google.com';
46
- const OAUTH2_ISSUER_HTTPS = 'https://accounts.google.com';
47
-
48
- /**
49
- * @var ClientInterface The http client
50
- */
51
- private $http;
52
-
53
- /**
54
- * @var CacheItemPoolInterface cache class
55
- */
56
- private $cache;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
- /**
59
- * Instantiates the class, but does not initiate the login flow, leaving it
60
- * to the discretion of the caller.
61
- */
62
- public function __construct(
63
- ClientInterface $http = null,
64
- CacheItemPoolInterface $cache = null,
65
- $jwt = null
66
- ) {
67
- if (null === $http) {
68
- $http = new Client();
69
- }
70
 
71
- if (null === $cache) {
72
- $cache = new MemoryCacheItemPool;
 
73
  }
74
 
75
- $this->http = $http;
76
- $this->cache = $cache;
77
- $this->jwt = $jwt ?: $this->getJwtService();
78
- }
79
-
80
- /**
81
- * Verifies an id token and returns the authenticated apiLoginTicket.
82
- * Throws an exception if the id token is not valid.
83
- * The audience parameter can be used to control which id tokens are
84
- * accepted. By default, the id token must have been issued to this OAuth2 client.
85
- *
86
- * @param string $idToken the ID token in JWT format
87
- * @param string $audience Optional. The audience to verify against JWt "aud"
88
- * @return array the token payload, if successful
89
- */
90
- public function verifyIdToken($idToken, $audience = null)
91
- {
92
- if (empty($idToken)) {
93
- throw new LogicException('id_token cannot be null');
94
- }
95
-
96
- // set phpseclib constants if applicable
97
- $this->setPhpsecConstants();
98
-
99
- // Check signature
100
- $certs = $this->getFederatedSignOnCerts();
101
- foreach ($certs as $cert) {
102
- try {
103
- $payload = $this->jwt->decode(
104
- $idToken,
105
- $this->getPublicKey($cert),
106
- array('RS256')
107
- );
108
-
109
- if (property_exists($payload, 'aud')) {
110
- if ($audience && $payload->aud != $audience) {
111
- return false;
112
- }
113
  }
114
 
115
- // support HTTP and HTTPS issuers
116
- // @see https://developers.google.com/identity/sign-in/web/backend-auth
117
- $issuers = array(self::OAUTH2_ISSUER, self::OAUTH2_ISSUER_HTTPS);
118
- if (!isset($payload->iss) || !in_array($payload->iss, $issuers)) {
119
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  }
121
 
122
- return (array) $payload;
123
- } catch (ExpiredException $e) {
124
  return false;
125
- } catch (ExpiredExceptionV3 $e) {
126
- return false;
127
- } catch (SignatureInvalidException $e) {
128
- // continue
129
- } catch (DomainException $e) {
130
- // continue
131
- }
132
  }
133
 
134
- return false;
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
- private function getCache()
138
- {
139
- return $this->cache;
140
- }
141
 
142
- /**
143
- * Retrieve and cache a certificates file.
144
- *
145
- * @param $url string location
146
- * @throws \Google\Exception
147
- * @return array certificates
148
- */
149
- private function retrieveCertsFromLocation($url)
150
- {
151
- // If we're retrieving a local file, just grab it.
152
- if (0 !== strpos($url, 'http')) {
153
- if (!$file = file_get_contents($url)) {
154
  throw new GoogleException(
155
- "Failed to retrieve verification certificates: '" .
156
- $url . "'."
 
 
 
157
  );
158
- }
159
-
160
- return json_decode($file, true);
161
  }
162
 
163
- $response = $this->http->get($url);
 
 
 
 
 
 
 
 
 
164
 
165
- if ($response->getStatusCode() == 200) {
166
- return json_decode((string) $response->getBody(), true);
167
- }
168
- throw new GoogleException(
169
- sprintf(
170
- 'Failed to retrieve verification certificates: "%s".',
171
- $response->getBody()->getContents()
172
- ),
173
- $response->getStatusCode()
174
- );
175
- }
176
-
177
- // Gets federated sign-on certificates to use for verifying identity tokens.
178
- // Returns certs as array structure, where keys are key ids, and values
179
- // are PEM encoded certificates.
180
- private function getFederatedSignOnCerts()
181
- {
182
- $certs = null;
183
- if ($cache = $this->getCache()) {
184
- $cacheItem = $cache->getItem('federated_signon_certs_v3');
185
- $certs = $cacheItem->get();
186
- }
187
 
 
 
 
 
188
 
189
- if (!$certs) {
190
- $certs = $this->retrieveCertsFromLocation(
191
- self::FEDERATED_SIGNON_CERT_URL
192
- );
 
 
193
 
194
- if ($cache) {
195
- $cacheItem->expiresAt(new DateTime('+1 hour'));
196
- $cacheItem->set($certs);
197
- $cache->save($cacheItem);
198
- }
199
- }
200
 
201
- if (!isset($certs['keys'])) {
202
- throw new InvalidArgumentException(
203
- 'federated sign-on certs expects "keys" to be set'
204
- );
205
  }
206
 
207
- return $certs['keys'];
208
- }
 
 
 
 
209
 
210
- private function getJwtService()
211
- {
212
- $jwtClass = 'JWT';
213
- if (class_exists('\Firebase\JWT\JWT')) {
214
- $jwtClass = 'Firebase\JWT\JWT';
215
- }
216
 
217
- if (property_exists($jwtClass, 'leeway') && $jwtClass::$leeway < 1) {
218
- // Ensures JWT leeway is at least 1
219
- // @see https://github.com/google/google-api-php-client/issues/827
220
- $jwtClass::$leeway = 1;
221
  }
222
 
223
- return new $jwtClass;
224
- }
 
 
 
 
 
 
 
 
225
 
226
- private function getPublicKey($cert)
227
- {
228
- $bigIntClass = $this->getBigIntClass();
229
- $modulus = new $bigIntClass($this->jwt->urlsafeB64Decode($cert['n']), 256);
230
- $exponent = new $bigIntClass($this->jwt->urlsafeB64Decode($cert['e']), 256);
231
- $component = array('n' => $modulus, 'e' => $exponent);
232
 
233
- if (class_exists('phpseclib3\Crypt\RSA\PublicKey')) {
234
- /** @var PublicKey $loader */
235
- $loader = PublicKeyLoader::load($component);
236
 
237
- return $loader->toString('PKCS8');
238
  }
239
 
240
- $rsaClass = $this->getRsaClass();
241
- $rsa = new $rsaClass();
242
- $rsa->loadKey($component);
243
-
244
- return $rsa->getPublicKey();
245
- }
246
 
247
- private function getRsaClass()
248
- {
249
- if (class_exists('phpseclib3\Crypt\RSA')) {
250
- return 'phpseclib3\Crypt\RSA';
251
- }
252
 
253
- if (class_exists('phpseclib\Crypt\RSA')) {
254
- return 'phpseclib\Crypt\RSA';
255
  }
256
 
257
- return 'Crypt_RSA';
258
- }
 
 
 
259
 
260
- private function getBigIntClass()
261
- {
262
- if (class_exists('phpseclib3\Math\BigInteger')) {
263
- return 'phpseclib3\Math\BigInteger';
264
- }
265
 
266
- if (class_exists('phpseclib\Math\BigInteger')) {
267
- return 'phpseclib\Math\BigInteger';
268
  }
269
 
270
- return 'Math_BigInteger';
271
- }
 
 
 
272
 
273
- private function getOpenSslConstant()
274
- {
275
- if (class_exists('phpseclib3\Crypt\AES')) {
276
- return 'phpseclib3\Crypt\AES::ENGINE_OPENSSL';
277
- }
278
 
279
- if (class_exists('phpseclib\Crypt\RSA')) {
280
- return 'phpseclib\Crypt\RSA::MODE_OPENSSL';
281
- }
282
 
283
- if (class_exists('Crypt_RSA')) {
284
- return 'CRYPT_RSA_MODE_OPENSSL';
285
  }
286
 
287
- throw new Exception('Cannot find RSA class');
288
- }
289
-
290
- /**
291
  * phpseclib calls "phpinfo" by default, which requires special
292
  * whitelisting in the AppEngine VM environment. This function
293
  * sets constants to bypass the need for phpseclib to check phpinfo
@@ -295,15 +306,15 @@ class Verify
295
  * @see phpseclib/Math/BigInteger
296
  * @see https://github.com/GoogleCloudPlatform/getting-started-php/issues/85
297
  */
298
- private function setPhpsecConstants()
299
- {
300
- if (filter_var(getenv('GAE_VM'), FILTER_VALIDATE_BOOLEAN)) {
301
- if (!defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {
302
- define('MATH_BIGINTEGER_OPENSSL_ENABLED', true);
303
- }
304
- if (!defined('CRYPT_RSA_MODE')) {
305
- define('CRYPT_RSA_MODE', constant($this->getOpenSslConstant()));
306
- }
 
307
  }
308
- }
309
  }
18
 
19
  namespace Google\AccessToken;
20
 
21
+ use DateTime;
22
+ use DomainException;
23
+ use Exception;
24
+ use ExpiredException;
25
  use Firebase\JWT\ExpiredException as ExpiredExceptionV3;
26
+ use Firebase\JWT\Key;
27
  use Firebase\JWT\SignatureInvalidException;
28
+ use Google\Auth\Cache\MemoryCacheItemPool;
29
+ use Google\Exception as GoogleException;
30
  use GuzzleHttp\Client;
31
  use GuzzleHttp\ClientInterface;
32
+ use InvalidArgumentException;
33
+ use LogicException;
34
  use phpseclib3\Crypt\PublicKeyLoader;
35
+ use phpseclib3\Crypt\RSA\PublicKey; // Firebase v2
36
  use Psr\Cache\CacheItemPoolInterface;
 
 
 
 
 
 
 
 
 
37
 
38
  /**
39
  * Wrapper around Google Access Tokens which provides convenience functions
41
  */
42
  class Verify
43
  {
44
+ const FEDERATED_SIGNON_CERT_URL = 'https://www.googleapis.com/oauth2/v3/certs';
45
+ const OAUTH2_ISSUER = 'accounts.google.com';
46
+ const OAUTH2_ISSUER_HTTPS = 'https://accounts.google.com';
47
+
48
+ /**
49
+ * @var ClientInterface The http client
50
+ */
51
+ private $http;
52
+
53
+ /**
54
+ * @var CacheItemPoolInterface cache class
55
+ */
56
+ private $cache;
57
+
58
+ /**
59
+ * @var \Firebase\JWT\JWT
60
+ */
61
+ public $jwt;
62
+
63
+ /**
64
+ * Instantiates the class, but does not initiate the login flow, leaving it
65
+ * to the discretion of the caller.
66
+ */
67
+ public function __construct(
68
+ ClientInterface $http = null,
69
+ CacheItemPoolInterface $cache = null,
70
+ $jwt = null
71
+ ) {
72
+ if (null === $http) {
73
+ $http = new Client();
74
+ }
75
 
76
+ if (null === $cache) {
77
+ $cache = new MemoryCacheItemPool();
78
+ }
 
 
 
 
 
 
 
 
 
79
 
80
+ $this->http = $http;
81
+ $this->cache = $cache;
82
+ $this->jwt = $jwt ?: $this->getJwtService();
83
  }
84
 
85
+ /**
86
+ * Verifies an id token and returns the authenticated apiLoginTicket.
87
+ * Throws an exception if the id token is not valid.
88
+ * The audience parameter can be used to control which id tokens are
89
+ * accepted. By default, the id token must have been issued to this OAuth2 client.
90
+ *
91
+ * @param string $idToken the ID token in JWT format
92
+ * @param string $audience Optional. The audience to verify against JWt "aud"
93
+ * @return array|false the token payload, if successful
94
+ */
95
+ public function verifyIdToken($idToken, $audience = null)
96
+ {
97
+ if (empty($idToken)) {
98
+ throw new LogicException('id_token cannot be null');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
 
101
+ // set phpseclib constants if applicable
102
+ $this->setPhpsecConstants();
103
+
104
+ // Check signature
105
+ $certs = $this->getFederatedSignOnCerts();
106
+ foreach ($certs as $cert) {
107
+ try {
108
+ $args = [$idToken];
109
+ $publicKey = $this->getPublicKey($cert);
110
+ if (class_exists(Key::class)) {
111
+ $args[] = new Key($publicKey, 'RS256');
112
+ } else {
113
+ $args[] = $publicKey;
114
+ $args[] = ['RS256'];
115
+ }
116
+ $payload = \call_user_func_array([$this->jwt, 'decode'], $args);
117
+
118
+ if (property_exists($payload, 'aud')) {
119
+ if ($audience && $payload->aud != $audience) {
120
+ return false;
121
+ }
122
+ }
123
+
124
+ // support HTTP and HTTPS issuers
125
+ // @see https://developers.google.com/identity/sign-in/web/backend-auth
126
+ $issuers = [self::OAUTH2_ISSUER, self::OAUTH2_ISSUER_HTTPS];
127
+ if (!isset($payload->iss) || !in_array($payload->iss, $issuers)) {
128
+ return false;
129
+ }
130
+
131
+ return (array) $payload;
132
+ } catch (ExpiredException $e) { // @phpstan-ignore-line
133
+ return false;
134
+ } catch (ExpiredExceptionV3 $e) {
135
+ return false;
136
+ } catch (SignatureInvalidException $e) {
137
+ // continue
138
+ } catch (DomainException $e) {
139
+ // continue
140
+ }
141
  }
142
 
 
 
143
  return false;
 
 
 
 
 
 
 
144
  }
145
 
146
+ private function getCache()
147
+ {
148
+ return $this->cache;
149
+ }
150
+
151
+ /**
152
+ * Retrieve and cache a certificates file.
153
+ *
154
+ * @param string $url location
155
+ * @throws \Google\Exception
156
+ * @return array certificates
157
+ */
158
+ private function retrieveCertsFromLocation($url)
159
+ {
160
+ // If we're retrieving a local file, just grab it.
161
+ if (0 !== strpos($url, 'http')) {
162
+ if (!$file = file_get_contents($url)) {
163
+ throw new GoogleException(
164
+ "Failed to retrieve verification certificates: '" .
165
+ $url . "'."
166
+ );
167
+ }
168
+
169
+ return json_decode($file, true);
170
+ }
171
 
172
+ // @phpstan-ignore-next-line
173
+ $response = $this->http->get($url);
 
 
174
 
175
+ if ($response->getStatusCode() == 200) {
176
+ return json_decode((string) $response->getBody(), true);
177
+ }
 
 
 
 
 
 
 
 
 
178
  throw new GoogleException(
179
+ sprintf(
180
+ 'Failed to retrieve verification certificates: "%s".',
181
+ $response->getBody()->getContents()
182
+ ),
183
+ $response->getStatusCode()
184
  );
 
 
 
185
  }
186
 
187
+ // Gets federated sign-on certificates to use for verifying identity tokens.
188
+ // Returns certs as array structure, where keys are key ids, and values
189
+ // are PEM encoded certificates.
190
+ private function getFederatedSignOnCerts()
191
+ {
192
+ $certs = null;
193
+ if ($cache = $this->getCache()) {
194
+ $cacheItem = $cache->getItem('federated_signon_certs_v3');
195
+ $certs = $cacheItem->get();
196
+ }
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
+ if (!$certs) {
200
+ $certs = $this->retrieveCertsFromLocation(
201
+ self::FEDERATED_SIGNON_CERT_URL
202
+ );
203
 
204
+ if ($cache) {
205
+ $cacheItem->expiresAt(new DateTime('+1 hour'));
206
+ $cacheItem->set($certs);
207
+ $cache->save($cacheItem);
208
+ }
209
+ }
210
 
211
+ if (!isset($certs['keys'])) {
212
+ throw new InvalidArgumentException(
213
+ 'federated sign-on certs expects "keys" to be set'
214
+ );
215
+ }
 
216
 
217
+ return $certs['keys'];
 
 
 
218
  }
219
 
220
+ private function getJwtService()
221
+ {
222
+ $jwtClass = 'JWT';
223
+ if (class_exists('\Firebase\JWT\JWT')) {
224
+ $jwtClass = 'Firebase\JWT\JWT';
225
+ }
226
 
227
+ if (property_exists($jwtClass, 'leeway') && $jwtClass::$leeway < 1) {
228
+ // Ensures JWT leeway is at least 1
229
+ // @see https://github.com/google/google-api-php-client/issues/827
230
+ $jwtClass::$leeway = 1;
231
+ }
 
232
 
233
+ // @phpstan-ignore-next-line
234
+ return new $jwtClass();
 
 
235
  }
236
 
237
+ private function getPublicKey($cert)
238
+ {
239
+ $bigIntClass = $this->getBigIntClass();
240
+ $modulus = new $bigIntClass($this->jwt->urlsafeB64Decode($cert['n']), 256);
241
+ $exponent = new $bigIntClass($this->jwt->urlsafeB64Decode($cert['e']), 256);
242
+ $component = ['n' => $modulus, 'e' => $exponent];
243
+
244
+ if (class_exists('phpseclib3\Crypt\RSA\PublicKey')) {
245
+ /** @var PublicKey $loader */
246
+ $loader = PublicKeyLoader::load($component);
247
 
248
+ return $loader->toString('PKCS8');
249
+ }
 
 
 
 
250
 
251
+ $rsaClass = $this->getRsaClass();
252
+ $rsa = new $rsaClass();
253
+ $rsa->loadKey($component);
254
 
255
+ return $rsa->getPublicKey();
256
  }
257
 
258
+ private function getRsaClass()
259
+ {
260
+ if (class_exists('phpseclib3\Crypt\RSA')) {
261
+ return 'phpseclib3\Crypt\RSA';
262
+ }
 
263
 
264
+ if (class_exists('phpseclib\Crypt\RSA')) {
265
+ return 'phpseclib\Crypt\RSA';
266
+ }
 
 
267
 
268
+ return 'Crypt_RSA';
 
269
  }
270
 
271
+ private function getBigIntClass()
272
+ {
273
+ if (class_exists('phpseclib3\Math\BigInteger')) {
274
+ return 'phpseclib3\Math\BigInteger';
275
+ }
276
 
277
+ if (class_exists('phpseclib\Math\BigInteger')) {
278
+ return 'phpseclib\Math\BigInteger';
279
+ }
 
 
280
 
281
+ return 'Math_BigInteger';
 
282
  }
283
 
284
+ private function getOpenSslConstant()
285
+ {
286
+ if (class_exists('phpseclib3\Crypt\AES')) {
287
+ return 'phpseclib3\Crypt\AES::ENGINE_OPENSSL';
288
+ }
289
 
290
+ if (class_exists('phpseclib\Crypt\RSA')) {
291
+ return 'phpseclib\Crypt\RSA::MODE_OPENSSL';
292
+ }
 
 
293
 
294
+ if (class_exists('Crypt_RSA')) {
295
+ return 'CRYPT_RSA_MODE_OPENSSL';
296
+ }
297
 
298
+ throw new Exception('Cannot find RSA class');
 
299
  }
300
 
301
+ /**
 
 
 
302
  * phpseclib calls "phpinfo" by default, which requires special
303
  * whitelisting in the AppEngine VM environment. This function
304
  * sets constants to bypass the need for phpseclib to check phpinfo
306
  * @see phpseclib/Math/BigInteger
307
  * @see https://github.com/GoogleCloudPlatform/getting-started-php/issues/85
308
  */
309
+ private function setPhpsecConstants()
310
+ {
311
+ if (filter_var(getenv('GAE_VM'), FILTER_VALIDATE_BOOLEAN)) {
312
+ if (!defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {
313
+ define('MATH_BIGINTEGER_OPENSSL_ENABLED', true);
314
+ }
315
+ if (!defined('CRYPT_RSA_MODE')) {
316
+ define('CRYPT_RSA_MODE', constant($this->getOpenSslConstant()));
317
+ }
318
+ }
319
  }
 
320
  }
vendor/google/apiclient/src/AuthHandler/AuthHandlerFactory.php CHANGED
@@ -17,36 +17,36 @@
17
 
18
  namespace Google\AuthHandler;
19
 
20
- use GuzzleHttp\Client;
21
- use GuzzleHttp\ClientInterface;
22
  use Exception;
 
23
 
24
  class AuthHandlerFactory
25
  {
26
- /**
27
- * Builds out a default http handler for the installed version of guzzle.
28
- *
29
- * @return Guzzle5AuthHandler|Guzzle6AuthHandler|Guzzle7AuthHandler
30
- * @throws Exception
31
- */
32
- public static function build($cache = null, array $cacheConfig = [])
33
- {
34
- $guzzleVersion = null;
35
- if (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
36
- $guzzleVersion = ClientInterface::MAJOR_VERSION;
37
- } elseif (defined('\GuzzleHttp\ClientInterface::VERSION')) {
38
- $guzzleVersion = (int) substr(ClientInterface::VERSION, 0, 1);
39
- }
 
40
 
41
- switch ($guzzleVersion) {
42
- case 5:
43
- return new Guzzle5AuthHandler($cache, $cacheConfig);
44
- case 6:
45
- return new Guzzle6AuthHandler($cache, $cacheConfig);
46
- case 7:
47
- return new Guzzle7AuthHandler($cache, $cacheConfig);
48
- default:
49
- throw new Exception('Version not supported');
 
50
  }
51
- }
52
  }
17
 
18
  namespace Google\AuthHandler;
19
 
 
 
20
  use Exception;
21
+ use GuzzleHttp\ClientInterface;
22
 
23
  class AuthHandlerFactory
24
  {
25
+ /**
26
+ * Builds out a default http handler for the installed version of guzzle.
27
+ *
28
+ * @return Guzzle5AuthHandler|Guzzle6AuthHandler|Guzzle7AuthHandler
29
+ * @throws Exception
30
+ */
31
+ public static function build($cache = null, array $cacheConfig = [])
32
+ {
33
+ $guzzleVersion = null;
34
+ if (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
35
+ $guzzleVersion = ClientInterface::MAJOR_VERSION;
36
+ } elseif (defined('\GuzzleHttp\ClientInterface::VERSION')) {
37
+ // @phpstan-ignore-next-line
38
+ $guzzleVersion = (int) substr(ClientInterface::VERSION, 0, 1);
39
+ }
40
 
41
+ switch ($guzzleVersion) {
42
+ case 5:
43
+ return new Guzzle5AuthHandler($cache, $cacheConfig);
44
+ case 6:
45
+ return new Guzzle6AuthHandler($cache, $cacheConfig);
46
+ case 7:
47
+ return new Guzzle7AuthHandler($cache, $cacheConfig);
48
+ default:
49
+ throw new Exception('Version not supported');
50
+ }
51
  }
 
52
  }
vendor/google/apiclient/src/AuthHandler/Guzzle5AuthHandler.php CHANGED
@@ -3,8 +3,8 @@
3
  namespace Google\AuthHandler;
4
 
5
  use Google\Auth\CredentialsLoader;
6
- use Google\Auth\HttpHandler\HttpHandlerFactory;
7
  use Google\Auth\FetchAuthTokenCache;
 
8
  use Google\Auth\Subscriber\AuthTokenSubscriber;
9
  use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
10
  use Google\Auth\Subscriber\SimpleSubscriber;
@@ -13,98 +13,96 @@ use GuzzleHttp\ClientInterface;
13
  use Psr\Cache\CacheItemPoolInterface;
14
 
15
  /**
16
- *
17
- */
18
  class Guzzle5AuthHandler
19
  {
20
- protected $cache;
21
- protected $cacheConfig;
22
-
23
- public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
24
- {
25
- $this->cache = $cache;
26
- $this->cacheConfig = $cacheConfig;
27
- }
28
-
29
- public function attachCredentials(
30
- ClientInterface $http,
31
- CredentialsLoader $credentials,
32
- callable $tokenCallback = null
33
- ) {
34
- // use the provided cache
35
- if ($this->cache) {
36
- $credentials = new FetchAuthTokenCache(
37
- $credentials,
38
- $this->cacheConfig,
39
- $this->cache
40
- );
 
 
 
41
  }
42
 
43
- return $this->attachCredentialsCache($http, $credentials, $tokenCallback);
44
- }
45
-
46
- public function attachCredentialsCache(
47
- ClientInterface $http,
48
- FetchAuthTokenCache $credentials,
49
- callable $tokenCallback = null
50
- ) {
51
- // if we end up needing to make an HTTP request to retrieve credentials, we
52
- // can use our existing one, but we need to throw exceptions so the error
53
- // bubbles up.
54
- $authHttp = $this->createAuthHttp($http);
55
- $authHttpHandler = HttpHandlerFactory::build($authHttp);
56
- $subscriber = new AuthTokenSubscriber(
57
- $credentials,
58
- $authHttpHandler,
59
- $tokenCallback
60
- );
61
-
62
- $http->setDefaultOption('auth', 'google_auth');
63
- $http->getEmitter()->attach($subscriber);
64
-
65
- return $http;
66
- }
67
-
68
- public function attachToken(ClientInterface $http, array $token, array $scopes)
69
- {
70
- $tokenFunc = function ($scopes) use ($token) {
71
- return $token['access_token'];
72
- };
73
-
74
- $subscriber = new ScopedAccessTokenSubscriber(
75
- $tokenFunc,
76
- $scopes,
77
- $this->cacheConfig,
78
- $this->cache
79
- );
80
-
81
- $http->setDefaultOption('auth', 'scoped');
82
- $http->getEmitter()->attach($subscriber);
83
-
84
- return $http;
85
- }
86
-
87
- public function attachKey(ClientInterface $http, $key)
88
- {
89
- $subscriber = new SimpleSubscriber(['key' => $key]);
90
-
91
- $http->setDefaultOption('auth', 'simple');
92
- $http->getEmitter()->attach($subscriber);
93
-
94
- return $http;
95
- }
96
-
97
- private function createAuthHttp(ClientInterface $http)
98
- {
99
- return new Client(
100
- [
101
- 'base_url' => $http->getBaseUrl(),
102
- 'defaults' => [
103
- 'exceptions' => true,
104
- 'verify' => $http->getDefaultOption('verify'),
105
- 'proxy' => $http->getDefaultOption('proxy'),
106
- ]
107
- ]
108
- );
109
- }
110
  }
3
  namespace Google\AuthHandler;
4
 
5
  use Google\Auth\CredentialsLoader;
 
6
  use Google\Auth\FetchAuthTokenCache;
7
+ use Google\Auth\HttpHandler\HttpHandlerFactory;
8
  use Google\Auth\Subscriber\AuthTokenSubscriber;
9
  use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
10
  use Google\Auth\Subscriber\SimpleSubscriber;
13
  use Psr\Cache\CacheItemPoolInterface;
14
 
15
  /**
16
+ * This supports Guzzle 5
17
+ */
18
  class Guzzle5AuthHandler
19
  {
20
+ protected $cache;
21
+ protected $cacheConfig;
22
+
23
+ public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
24
+ {
25
+ $this->cache = $cache;
26
+ $this->cacheConfig = $cacheConfig;
27
+ }
28
+
29
+ public function attachCredentials(
30
+ ClientInterface $http,
31
+ CredentialsLoader $credentials,
32
+ callable $tokenCallback = null
33
+ ) {
34
+ // use the provided cache
35
+ if ($this->cache) {
36
+ $credentials = new FetchAuthTokenCache(
37
+ $credentials,
38
+ $this->cacheConfig,
39
+ $this->cache
40
+ );
41
+ }
42
+
43
+ return $this->attachCredentialsCache($http, $credentials, $tokenCallback);
44
  }
45
 
46
+ public function attachCredentialsCache(
47
+ ClientInterface $http,
48
+ FetchAuthTokenCache $credentials,
49
+ callable $tokenCallback = null
50
+ ) {
51
+ // if we end up needing to make an HTTP request to retrieve credentials, we
52
+ // can use our existing one, but we need to throw exceptions so the error
53
+ // bubbles up.
54
+ $authHttp = $this->createAuthHttp($http);
55
+ $authHttpHandler = HttpHandlerFactory::build($authHttp);
56
+ $subscriber = new AuthTokenSubscriber(
57
+ $credentials,
58
+ $authHttpHandler,
59
+ $tokenCallback
60
+ );
61
+
62
+ $http->setDefaultOption('auth', 'google_auth');
63
+ $http->getEmitter()->attach($subscriber);
64
+
65
+ return $http;
66
+ }
67
+
68
+ public function attachToken(ClientInterface $http, array $token, array $scopes)
69
+ {
70
+ $tokenFunc = function ($scopes) use ($token) {
71
+ return $token['access_token'];
72
+ };
73
+
74
+ $subscriber = new ScopedAccessTokenSubscriber(
75
+ $tokenFunc,
76
+ $scopes,
77
+ $this->cacheConfig,
78
+ $this->cache
79
+ );
80
+
81
+ $http->setDefaultOption('auth', 'scoped');
82
+ $http->getEmitter()->attach($subscriber);
83
+
84
+ return $http;
85
+ }
86
+
87
+ public function attachKey(ClientInterface $http, $key)
88
+ {
89
+ $subscriber = new SimpleSubscriber(['key' => $key]);
90
+
91
+ $http->setDefaultOption('auth', 'simple');
92
+ $http->getEmitter()->attach($subscriber);
93
+
94
+ return $http;
95
+ }
96
+
97
+ private function createAuthHttp(ClientInterface $http)
98
+ {
99
+ return new Client([
100
+ 'base_url' => $http->getBaseUrl(),
101
+ 'defaults' => [
102
+ 'exceptions' => true,
103
+ 'verify' => $http->getDefaultOption('verify'),
104
+ 'proxy' => $http->getDefaultOption('proxy'),
105
+ ]
106
+ ]);
107
+ }
 
 
 
 
 
108
  }
vendor/google/apiclient/src/AuthHandler/Guzzle6AuthHandler.php CHANGED
@@ -3,8 +3,8 @@
3
  namespace Google\AuthHandler;
4
 
5
  use Google\Auth\CredentialsLoader;
6
- use Google\Auth\HttpHandler\HttpHandlerFactory;
7
  use Google\Auth\FetchAuthTokenCache;
 
8
  use Google\Auth\Middleware\AuthTokenMiddleware;
9
  use Google\Auth\Middleware\ScopedAccessTokenMiddleware;
10
  use Google\Auth\Middleware\SimpleMiddleware;
@@ -13,105 +13,103 @@ use GuzzleHttp\ClientInterface;
13
  use Psr\Cache\CacheItemPoolInterface;
14
 
15
  /**
16
- * This supports Guzzle 6
17
- */
18
  class Guzzle6AuthHandler
19
  {
20
- protected $cache;
21
- protected $cacheConfig;
22
-
23
- public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
24
- {
25
- $this->cache = $cache;
26
- $this->cacheConfig = $cacheConfig;
27
- }
28
-
29
- public function attachCredentials(
30
- ClientInterface $http,
31
- CredentialsLoader $credentials,
32
- callable $tokenCallback = null
33
- ) {
34
- // use the provided cache
35
- if ($this->cache) {
36
- $credentials = new FetchAuthTokenCache(
37
- $credentials,
38
- $this->cacheConfig,
39
- $this->cache
40
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
 
43
- return $this->attachCredentialsCache($http, $credentials, $tokenCallback);
44
- }
45
-
46
- public function attachCredentialsCache(
47
- ClientInterface $http,
48
- FetchAuthTokenCache $credentials,
49
- callable $tokenCallback = null
50
- ) {
51
- // if we end up needing to make an HTTP request to retrieve credentials, we
52
- // can use our existing one, but we need to throw exceptions so the error
53
- // bubbles up.
54
- $authHttp = $this->createAuthHttp($http);
55
- $authHttpHandler = HttpHandlerFactory::build($authHttp);
56
- $middleware = new AuthTokenMiddleware(
57
- $credentials,
58
- $authHttpHandler,
59
- $tokenCallback
60
- );
61
-
62
- $config = $http->getConfig();
63
- $config['handler']->remove('google_auth');
64
- $config['handler']->push($middleware, 'google_auth');
65
- $config['auth'] = 'google_auth';
66
- $http = new Client($config);
67
-
68
- return $http;
69
- }
70
-
71
- public function attachToken(ClientInterface $http, array $token, array $scopes)
72
- {
73
- $tokenFunc = function ($scopes) use ($token) {
74
- return $token['access_token'];
75
- };
76
-
77
- $middleware = new ScopedAccessTokenMiddleware(
78
- $tokenFunc,
79
- $scopes,
80
- $this->cacheConfig,
81
- $this->cache
82
- );
83
-
84
- $config = $http->getConfig();
85
- $config['handler']->remove('google_auth');
86
- $config['handler']->push($middleware, 'google_auth');
87
- $config['auth'] = 'scoped';
88
- $http = new Client($config);
89
-
90
- return $http;
91
- }
92
-
93
- public function attachKey(ClientInterface $http, $key)
94
- {
95
- $middleware = new SimpleMiddleware(['key' => $key]);
96
-
97
- $config = $http->getConfig();
98
- $config['handler']->remove('google_auth');
99
- $config['handler']->push($middleware, 'google_auth');
100
- $config['auth'] = 'simple';
101
- $http = new Client($config);
102
-
103
- return $http;
104
- }
105
-
106
- private function createAuthHttp(ClientInterface $http)
107
- {
108
- return new Client(
109
- [
110
- 'base_uri' => $http->getConfig('base_uri'),
111
- 'http_errors' => true,
112
- 'verify' => $http->getConfig('verify'),
113
- 'proxy' => $http->getConfig('proxy'),
114
- ]
115
- );
116
- }
117
  }
3
  namespace Google\AuthHandler;
4
 
5
  use Google\Auth\CredentialsLoader;
 
6
  use Google\Auth\FetchAuthTokenCache;
7
+ use Google\Auth\HttpHandler\HttpHandlerFactory;
8
  use Google\Auth\Middleware\AuthTokenMiddleware;
9
  use Google\Auth\Middleware\ScopedAccessTokenMiddleware;
10
  use Google\Auth\Middleware\SimpleMiddleware;
13
  use Psr\Cache\CacheItemPoolInterface;
14
 
15
  /**
16
+ * This supports Guzzle 6
17
+ */
18
  class Guzzle6AuthHandler
19
  {
20
+ protected $cache;
21
+ protected $cacheConfig;
22
+
23
+ public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
24
+ {
25
+ $this->cache = $cache;
26
+ $this->cacheConfig = $cacheConfig;
27
+ }
28
+
29
+ public function attachCredentials(
30
+ ClientInterface $http,
31
+ CredentialsLoader $credentials,
32
+ callable $tokenCallback = null
33
+ ) {
34
+ // use the provided cache
35
+ if ($this->cache) {
36
+ $credentials = new FetchAuthTokenCache(
37
+ $credentials,
38
+ $this->cacheConfig,
39
+ $this->cache
40
+ );
41
+ }
42
+
43
+ return $this->attachCredentialsCache($http, $credentials, $tokenCallback);
44
+ }
45
+
46
+ public function attachCredentialsCache(
47
+ ClientInterface $http,
48
+ FetchAuthTokenCache $credentials,
49
+ callable $tokenCallback = null
50
+ ) {
51
+ // if we end up needing to make an HTTP request to retrieve credentials, we
52
+ // can use our existing one, but we need to throw exceptions so the error
53
+ // bubbles up.
54
+ $authHttp = $this->createAuthHttp($http);
55
+ $authHttpHandler = HttpHandlerFactory::build($authHttp);
56
+ $middleware = new AuthTokenMiddleware(
57
+ $credentials,
58
+ $authHttpHandler,
59
+ $tokenCallback
60
+ );
61
+
62
+ $config = $http->getConfig();
63
+ $config['handler']->remove('google_auth');
64
+ $config['handler']->push($middleware, 'google_auth');
65
+ $config['auth'] = 'google_auth';
66
+ $http = new Client($config);
67
+
68
+ return $http;
69
  }
70
 
71
+ public function attachToken(ClientInterface $http, array $token, array $scopes)
72
+ {
73
+ $tokenFunc = function ($scopes) use ($token) {
74
+ return $token['access_token'];
75
+ };
76
+
77
+ $middleware = new ScopedAccessTokenMiddleware(
78
+ $tokenFunc,
79
+ $scopes,
80
+ $this->cacheConfig,
81
+ $this->cache
82
+ );
83
+
84
+ $config = $http->getConfig();
85
+ $config['handler']->remove('google_auth');
86
+ $config['handler']->push($middleware, 'google_auth');
87
+ $config['auth'] = 'scoped';
88
+ $http = new Client($config);
89
+
90
+ return $http;
91
+ }
92
+
93
+ public function attachKey(ClientInterface $http, $key)
94
+ {
95
+ $middleware = new SimpleMiddleware(['key' => $key]);
96
+
97
+ $config = $http->getConfig();
98
+ $config['handler']->remove('google_auth');
99
+ $config['handler']->push($middleware, 'google_auth');
100
+ $config['auth'] = 'simple';
101
+ $http = new Client($config);
102
+
103
+ return $http;
104
+ }
105
+
106
+ private function createAuthHttp(ClientInterface $http)
107
+ {
108
+ return new Client([
109
+ 'base_uri' => $http->getConfig('base_uri'),
110
+ 'http_errors' => true,
111
+ 'verify' => $http->getConfig('verify'),
112
+ 'proxy' => $http->getConfig('proxy'),
113
+ ]);
114
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
vendor/google/apiclient/src/AuthHandler/Guzzle7AuthHandler.php CHANGED
@@ -18,8 +18,8 @@
18
  namespace Google\AuthHandler;
19
 
20
  /**
21
- * This supports Guzzle 7
22
- */
23
  class Guzzle7AuthHandler extends Guzzle6AuthHandler
24
  {
25
  }
18
  namespace Google\AuthHandler;
19
 
20
  /**
21
+ * This supports Guzzle 7
22
+ */
23
  class Guzzle7AuthHandler extends Guzzle6AuthHandler
24
  {
25
  }
vendor/google/apiclient/src/Client.php CHANGED
@@ -17,31 +17,33 @@
17
 
18
  namespace Google;
19
 
 
 
20
  use Google\AccessToken\Revoke;
21
  use Google\AccessToken\Verify;
22
  use Google\Auth\ApplicationDefaultCredentials;
23
  use Google\Auth\Cache\MemoryCacheItemPool;
 
 
24
  use Google\Auth\CredentialsLoader;
25
  use Google\Auth\FetchAuthTokenCache;
26
  use Google\Auth\HttpHandler\HttpHandlerFactory;
27
  use Google\Auth\OAuth2;
28
- use Google\Auth\Credentials\ServiceAccountCredentials;
29
- use Google\Auth\Credentials\UserRefreshCredentials;
30
  use Google\AuthHandler\AuthHandlerFactory;
31
  use Google\Http\REST;
32
  use GuzzleHttp\Client as GuzzleClient;
33
  use GuzzleHttp\ClientInterface;
34
  use GuzzleHttp\Ring\Client\StreamHandler;
 
 
 
 
 
35
  use Psr\Cache\CacheItemPoolInterface;
36
  use Psr\Http\Message\RequestInterface;
 
37
  use Psr\Log\LoggerInterface;
38
- use Monolog\Logger;
39
- use Monolog\Handler\StreamHandler as MonologStreamHandler;
40
- use Monolog\Handler\SyslogHandler as MonologSyslogHandler;
41
- use BadMethodCallException;
42
- use DomainException;
43
- use InvalidArgumentException;
44
- use LogicException;
45
 
46
  /**
47
  * The Google API Client
@@ -49,1226 +51,1245 @@ use LogicException;
49
  */
50
  class Client
51
  {
52
- const LIBVER = "2.10.1";
53
- const USER_AGENT_SUFFIX = "google-api-php-client/";
54
- const OAUTH2_REVOKE_URI = 'https://oauth2.googleapis.com/revoke';
55
- const OAUTH2_TOKEN_URI = 'https://oauth2.googleapis.com/token';
56
- const OAUTH2_AUTH_URL = 'https://accounts.google.com/o/oauth2/auth';
57
- const API_BASE_PATH = 'https://www.googleapis.com';
58
-
59
- /**
60
- * @var OAuth2 $auth
61
- */
62
- private $auth;
63
-
64
- /**
65
- * @var ClientInterface $http
66
- */
67
- private $http;
68
-
69
- /**
70
- * @var CacheItemPoolInterface $cache
71
- */
72
- private $cache;
73
-
74
- /**
75
- * @var array access token
76
- */
77
- private $token;
78
-
79
- /**
80
- * @var array $config
81
- */
82
- private $config;
83
-
84
- /**
85
- * @var LoggerInterface $logger
86
- */
87
- private $logger;
88
-
89
- /**
90
- * @var boolean $deferExecution
91
- */
92
- private $deferExecution = false;
93
-
94
- /** @var array $scopes */
95
- // Scopes requested by the client
96
- protected $requestedScopes = [];
97
-
98
- /**
99
- * Construct the Google Client.
100
- *
101
- * @param array $config
102
- */
103
- public function __construct(array $config = array())
104
- {
105
- $this->config = array_merge(
106
- [
107
- 'application_name' => '',
108
-
109
- // Don't change these unless you're working against a special development
110
- // or testing environment.
111
- 'base_path' => self::API_BASE_PATH,
112
-
113
- // https://developers.google.com/console
114
- 'client_id' => '',
115
- 'client_secret' => '',
116
-
117
- // Path to JSON credentials or an array representing those credentials
118
- // @see Google\Client::setAuthConfig
119
- 'credentials' => null,
120
- // @see Google\Client::setScopes
121
- 'scopes' => null,
122
- // Sets X-Goog-User-Project, which specifies a user project to bill
123
- // for access charges associated with the request
124
- 'quota_project' => null,
125
-
126
- 'redirect_uri' => null,
127
- 'state' => null,
128
-
129
- // Simple API access key, also from the API console. Ensure you get
130
- // a Server key, and not a Browser key.
131
- 'developer_key' => '',
132
-
133
- // For use with Google Cloud Platform
134
- // fetch the ApplicationDefaultCredentials, if applicable
135
- // @see https://developers.google.com/identity/protocols/application-default-credentials
136
- 'use_application_default_credentials' => false,
137
- 'signing_key' => null,
138
- 'signing_algorithm' => null,
139
- 'subject' => null,
140
-
141
- // Other OAuth2 parameters.
142
- 'hd' => '',
143
- 'prompt' => '',
144
- 'openid.realm' => '',
145
- 'include_granted_scopes' => null,
146
- 'login_hint' => '',
147
- 'request_visible_actions' => '',
148
- 'access_type' => 'online',
149
- 'approval_prompt' => 'auto',
150
-
151
- // Task Runner retry configuration
152
- // @see Google\Task\Runner
153
- 'retry' => array(),
154
- 'retry_map' => null,
155
-
156
- // Cache class implementing Psr\Cache\CacheItemPoolInterface.
157
- // Defaults to Google\Auth\Cache\MemoryCacheItemPool.
158
- 'cache' => null,
159
- // cache config for downstream auth caching
160
- 'cache_config' => [],
161
-
162
- // function to be called when an access token is fetched
163
- // follows the signature function ($cacheKey, $accessToken)
164
- 'token_callback' => null,
165
-
166
- // Service class used in Google\Client::verifyIdToken.
167
- // Explicitly pass this in to avoid setting JWT::$leeway
168
- 'jwt' => null,
169
-
170
- // Setting api_format_v2 will return more detailed error messages
171
- // from certain APIs.
172
- 'api_format_v2' => false
173
- ],
174
- $config
175
- );
176
-
177
- if (!is_null($this->config['credentials'])) {
178
- $this->setAuthConfig($this->config['credentials']);
179
- unset($this->config['credentials']);
180
- }
181
-
182
- if (!is_null($this->config['scopes'])) {
183
- $this->setScopes($this->config['scopes']);
184
- unset($this->config['scopes']);
185
- }
186
-
187
- // Set a default token callback to update the in-memory access token
188
- if (is_null($this->config['token_callback'])) {
189
- $this->config['token_callback'] = function ($cacheKey, $newAccessToken) {
190
- $this->setAccessToken(
191
- [
192
- 'access_token' => $newAccessToken,
193
- 'expires_in' => 3600, // Google default
194
- 'created' => time(),
195
- ]
196
- );
197
- };
198
- }
199
-
200
- if (!is_null($this->config['cache'])) {
201
- $this->setCache($this->config['cache']);
202
- unset($this->config['cache']);
203
- }
204
- }
205
-
206
- /**
207
- * Get a string containing the version of the library.
208
- *
209
- * @return string
210
- */
211
- public function getLibraryVersion()
212
- {
213
- return self::LIBVER;
214
- }
215
-
216
- /**
217
- * For backwards compatibility
218
- * alias for fetchAccessTokenWithAuthCode
219
- *
220
- * @param $code string code from accounts.google.com
221
- * @return array access token
222
- * @deprecated
223
- */
224
- public function authenticate($code)
225
- {
226
- return $this->fetchAccessTokenWithAuthCode($code);
227
- }
228
-
229
- /**
230
- * Attempt to exchange a code for an valid authentication token.
231
- * Helper wrapped around the OAuth 2.0 implementation.
232
- *
233
- * @param $code string code from accounts.google.com
234
- * @return array access token
235
- */
236
- public function fetchAccessTokenWithAuthCode($code)
237
- {
238
- if (strlen($code) == 0) {
239
- throw new InvalidArgumentException("Invalid code");
240
- }
241
-
242
- $auth = $this->getOAuth2Service();
243
- $auth->setCode($code);
244
- $auth->setRedirectUri($this->getRedirectUri());
245
-
246
- $httpHandler = HttpHandlerFactory::build($this->getHttpClient());
247
- $creds = $auth->fetchAuthToken($httpHandler);
248
- if ($creds && isset($creds['access_token'])) {
249
- $creds['created'] = time();
250
- $this->setAccessToken($creds);
251
- }
252
-
253
- return $creds;
254
- }
255
-
256
- /**
257
- * For backwards compatibility
258
- * alias for fetchAccessTokenWithAssertion
259
- *
260
- * @return array access token
261
- * @deprecated
262
- */
263
- public function refreshTokenWithAssertion()
264
- {
265
- return $this->fetchAccessTokenWithAssertion();
266
- }
267
-
268
- /**
269
- * Fetches a fresh access token with a given assertion token.
270
- * @param ClientInterface $authHttp optional.
271
- * @return array access token
272
- */
273
- public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null)
274
- {
275
- if (!$this->isUsingApplicationDefaultCredentials()) {
276
- throw new DomainException(
277
- 'set the JSON service account credentials using'
278
- . ' Google\Client::setAuthConfig or set the path to your JSON file'
279
- . ' with the "GOOGLE_APPLICATION_CREDENTIALS" environment variable'
280
- . ' and call Google\Client::useApplicationDefaultCredentials to'
281
- . ' refresh a token with assertion.'
282
- );
283
- }
284
-
285
- $this->getLogger()->log(
286
- 'info',
287
- 'OAuth2 access token refresh with Signed JWT assertion grants.'
288
- );
289
-
290
- $credentials = $this->createApplicationDefaultCredentials();
291
-
292
- $httpHandler = HttpHandlerFactory::build($authHttp);
293
- $creds = $credentials->fetchAuthToken($httpHandler);
294
- if ($creds && isset($creds['access_token'])) {
295
- $creds['created'] = time();
296
- $this->setAccessToken($creds);
297
- }
298
-
299
- return $creds;
300
- }
301
-
302
- /**
303
- * For backwards compatibility
304
- * alias for fetchAccessTokenWithRefreshToken
305
- *
306
- * @param string $refreshToken
307
- * @return array access token
308
- */
309
- public function refreshToken($refreshToken)
310
- {
311
- return $this->fetchAccessTokenWithRefreshToken($refreshToken);
312
- }
313
-
314
- /**
315
- * Fetches a fresh OAuth 2.0 access token with the given refresh token.
316
- * @param string $refreshToken
317
- * @return array access token
318
- */
319
- public function fetchAccessTokenWithRefreshToken($refreshToken = null)
320
- {
321
- if (null === $refreshToken) {
322
- if (!isset($this->token['refresh_token'])) {
323
- throw new LogicException(
324
- 'refresh token must be passed in or set as part of setAccessToken'
325
  );
326
- }
327
- $refreshToken = $this->token['refresh_token'];
328
- }
329
- $this->getLogger()->info('OAuth2 access token refresh');
330
- $auth = $this->getOAuth2Service();
331
- $auth->setRefreshToken($refreshToken);
332
-
333
- $httpHandler = HttpHandlerFactory::build($this->getHttpClient());
334
- $creds = $auth->fetchAuthToken($httpHandler);
335
- if ($creds && isset($creds['access_token'])) {
336
- $creds['created'] = time();
337
- if (!isset($creds['refresh_token'])) {
338
- $creds['refresh_token'] = $refreshToken;
339
- }
340
- $this->setAccessToken($creds);
341
- }
342
-
343
- return $creds;
344
- }
345
-
346
- /**
347
- * Create a URL to obtain user authorization.
348
- * The authorization endpoint allows the user to first
349
- * authenticate, and then grant/deny the access request.
350
- * @param string|array $scope The scope is expressed as an array or list of space-delimited strings.
351
- * @return string
352
- */
353
- public function createAuthUrl($scope = null)
354
- {
355
- if (empty($scope)) {
356
- $scope = $this->prepareScopes();
357
- }
358
- if (is_array($scope)) {
359
- $scope = implode(' ', $scope);
360
- }
361
-
362
- // only accept one of prompt or approval_prompt
363
- $approvalPrompt = $this->config['prompt']
364
- ? null
365
- : $this->config['approval_prompt'];
366
-
367
- // include_granted_scopes should be string "true", string "false", or null
368
- $includeGrantedScopes = $this->config['include_granted_scopes'] === null
369
- ? null
370
- : var_export($this->config['include_granted_scopes'], true);
371
-
372
- $params = array_filter(
373
- [
374
- 'access_type' => $this->config['access_type'],
375
- 'approval_prompt' => $approvalPrompt,
376
- 'hd' => $this->config['hd'],
377
- 'include_granted_scopes' => $includeGrantedScopes,
378
- 'login_hint' => $this->config['login_hint'],
379
- 'openid.realm' => $this->config['openid.realm'],
380
- 'prompt' => $this->config['prompt'],
381
- 'response_type' => 'code',
382
- 'scope' => $scope,
383
- 'state' => $this->config['state'],
384
- ]
385
- );
386
-
387
- // If the list of scopes contains plus.login, add request_visible_actions
388
- // to auth URL.
389
- $rva = $this->config['request_visible_actions'];
390
- if (strlen($rva) > 0 && false !== strpos($scope, 'plus.login')) {
391
- $params['request_visible_actions'] = $rva;
392
- }
393
-
394
- $auth = $this->getOAuth2Service();
395
-
396
- return (string) $auth->buildFullAuthorizationUri($params);
397
- }
398
-
399
- /**
400
- * Adds auth listeners to the HTTP client based on the credentials
401
- * set in the Google API Client object
402
- *
403
- * @param ClientInterface $http the http client object.
404
- * @return ClientInterface the http client object
405
- */
406
- public function authorize(ClientInterface $http = null)
407
- {
408
- $credentials = null;
409
- $token = null;
410
- $scopes = null;
411
- $http = $http ?: $this->getHttpClient();
412
- $authHandler = $this->getAuthHandler();
413
-
414
- // These conditionals represent the decision tree for authentication
415
- // 1. Check for Application Default Credentials
416
- // 2. Check for API Key
417
- // 3a. Check for an Access Token
418
- // 3b. If access token exists but is expired, try to refresh it
419
- if ($this->isUsingApplicationDefaultCredentials()) {
420
- $credentials = $this->createApplicationDefaultCredentials();
421
- $http = $authHandler->attachCredentialsCache(
422
- $http,
423
- $credentials,
424
- $this->config['token_callback']
425
- );
426
- } elseif ($token = $this->getAccessToken()) {
427
- $scopes = $this->prepareScopes();
428
- // add refresh subscriber to request a new token
429
- if (isset($token['refresh_token']) && $this->isAccessTokenExpired()) {
430
- $credentials = $this->createUserRefreshCredentials(
431
- $scopes,
432
- $token['refresh_token']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  );
434
- $http = $authHandler->attachCredentials(
435
- $http,
436
- $credentials,
437
- $this->config['token_callback']
 
 
 
 
 
438
  );
439
- } else {
440
- $http = $authHandler->attachToken($http, $token, (array) $scopes);
441
- }
442
- } elseif ($key = $this->config['developer_key']) {
443
- $http = $authHandler->attachKey($http, $key);
444
- }
445
-
446
- return $http;
447
- }
448
-
449
- /**
450
- * Set the configuration to use application default credentials for
451
- * authentication
452
- *
453
- * @see https://developers.google.com/identity/protocols/application-default-credentials
454
- * @param boolean $useAppCreds
455
- */
456
- public function useApplicationDefaultCredentials($useAppCreds = true)
457
- {
458
- $this->config['use_application_default_credentials'] = $useAppCreds;
459
- }
460
-
461
- /**
462
- * To prevent useApplicationDefaultCredentials from inappropriately being
463
- * called in a conditional
464
- *
465
- * @see https://developers.google.com/identity/protocols/application-default-credentials
466
- */
467
- public function isUsingApplicationDefaultCredentials()
468
- {
469
- return $this->config['use_application_default_credentials'];
470
- }
471
-
472
- /**
473
- * Set the access token used for requests.
474
- *
475
- * Note that at the time requests are sent, tokens are cached. A token will be
476
- * cached for each combination of service and authentication scopes. If a
477
- * cache pool is not provided, creating a new instance of the client will
478
- * allow modification of access tokens. If a persistent cache pool is
479
- * provided, in order to change the access token, you must clear the cached
480
- * token by calling `$client->getCache()->clear()`. (Use caution in this case,
481
- * as calling `clear()` will remove all cache items, including any items not
482
- * related to Google API PHP Client.)
483
- *
484
- * @param string|array $token
485
- * @throws InvalidArgumentException
486
- */
487
- public function setAccessToken($token)
488
- {
489
- if (is_string($token)) {
490
- if ($json = json_decode($token, true)) {
491
- $token = $json;
492
- } else {
493
- // assume $token is just the token string
494
- $token = array(
495
- 'access_token' => $token,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  );
497
- }
498
- }
499
- if ($token == null) {
500
- throw new InvalidArgumentException('invalid json token');
501
- }
502
- if (!isset($token['access_token'])) {
503
- throw new InvalidArgumentException("Invalid token format");
504
- }
505
- $this->token = $token;
506
- }
507
-
508
- public function getAccessToken()
509
- {
510
- return $this->token;
511
- }
512
-
513
- /**
514
- * @return string|null
515
- */
516
- public function getRefreshToken()
517
- {
518
- if (isset($this->token['refresh_token'])) {
519
- return $this->token['refresh_token'];
520
- }
521
-
522
- return null;
523
- }
524
-
525
- /**
526
- * Returns if the access_token is expired.
527
- * @return bool Returns True if the access_token is expired.
528
- */
529
- public function isAccessTokenExpired()
530
- {
531
- if (!$this->token) {
532
- return true;
533
- }
534
-
535
- $created = 0;
536
- if (isset($this->token['created'])) {
537
- $created = $this->token['created'];
538
- } elseif (isset($this->token['id_token'])) {
539
- // check the ID token for "iat"
540
- // signature verification is not required here, as we are just
541
- // using this for convenience to save a round trip request
542
- // to the Google API server
543
- $idToken = $this->token['id_token'];
544
- if (substr_count($idToken, '.') == 2) {
545
- $parts = explode('.', $idToken);
546
- $payload = json_decode(base64_decode($parts[1]), true);
547
- if ($payload && isset($payload['iat'])) {
548
- $created = $payload['iat'];
549
  }
550
- }
551
- }
552
-
553
- // If the token is set to expire in the next 30 seconds.
554
- return ($created + ($this->token['expires_in'] - 30)) < time();
555
- }
556
-
557
- /**
558
- * @deprecated See UPGRADING.md for more information
559
- */
560
- public function getAuth()
561
- {
562
- throw new BadMethodCallException(
563
- 'This function no longer exists. See UPGRADING.md for more information'
564
- );
565
- }
566
-
567
- /**
568
- * @deprecated See UPGRADING.md for more information
569
- */
570
- public function setAuth($auth)
571
- {
572
- throw new BadMethodCallException(
573
- 'This function no longer exists. See UPGRADING.md for more information'
574
- );
575
- }
576
-
577
- /**
578
- * Set the OAuth 2.0 Client ID.
579
- * @param string $clientId
580
- */
581
- public function setClientId($clientId)
582
- {
583
- $this->config['client_id'] = $clientId;
584
- }
585
-
586
- public function getClientId()
587
- {
588
- return $this->config['client_id'];
589
- }
590
-
591
- /**
592
- * Set the OAuth 2.0 Client Secret.
593
- * @param string $clientSecret
594
- */
595
- public function setClientSecret($clientSecret)
596
- {
597
- $this->config['client_secret'] = $clientSecret;
598
- }
599
-
600
- public function getClientSecret()
601
- {
602
- return $this->config['client_secret'];
603
- }
604
-
605
- /**
606
- * Set the OAuth 2.0 Redirect URI.
607
- * @param string $redirectUri
608
- */
609
- public function setRedirectUri($redirectUri)
610
- {
611
- $this->config['redirect_uri'] = $redirectUri;
612
- }
613
-
614
- public function getRedirectUri()
615
- {
616
- return $this->config['redirect_uri'];
617
- }
618
-
619
- /**
620
- * Set OAuth 2.0 "state" parameter to achieve per-request customization.
621
- * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.1.2.2
622
- * @param string $state
623
- */
624
- public function setState($state)
625
- {
626
- $this->config['state'] = $state;
627
- }
628
-
629
- /**
630
- * @param string $accessType Possible values for access_type include:
631
- * {@code "offline"} to request offline access from the user.
632
- * {@code "online"} to request online access from the user.
633
- */
634
- public function setAccessType($accessType)
635
- {
636
- $this->config['access_type'] = $accessType;
637
- }
638
-
639
- /**
640
- * @param string $approvalPrompt Possible values for approval_prompt include:
641
- * {@code "force"} to force the approval UI to appear.
642
- * {@code "auto"} to request auto-approval when possible. (This is the default value)
643
- */
644
- public function setApprovalPrompt($approvalPrompt)
645
- {
646
- $this->config['approval_prompt'] = $approvalPrompt;
647
- }
648
-
649
- /**
650
- * Set the login hint, email address or sub id.
651
- * @param string $loginHint
652
- */
653
- public function setLoginHint($loginHint)
654
- {
655
- $this->config['login_hint'] = $loginHint;
656
- }
657
-
658
- /**
659
- * Set the application name, this is included in the User-Agent HTTP header.
660
- * @param string $applicationName
661
- */
662
- public function setApplicationName($applicationName)
663
- {
664
- $this->config['application_name'] = $applicationName;
665
- }
666
-
667
- /**
668
- * If 'plus.login' is included in the list of requested scopes, you can use
669
- * this method to define types of app activities that your app will write.
670
- * You can find a list of available types here:
671
- * @link https://developers.google.com/+/api/moment-types
672
- *
673
- * @param array $requestVisibleActions Array of app activity types
674
- */
675
- public function setRequestVisibleActions($requestVisibleActions)
676
- {
677
- if (is_array($requestVisibleActions)) {
678
- $requestVisibleActions = implode(" ", $requestVisibleActions);
679
- }
680
- $this->config['request_visible_actions'] = $requestVisibleActions;
681
- }
682
-
683
- /**
684
- * Set the developer key to use, these are obtained through the API Console.
685
- * @see http://code.google.com/apis/console-help/#generatingdevkeys
686
- * @param string $developerKey
687
- */
688
- public function setDeveloperKey($developerKey)
689
- {
690
- $this->config['developer_key'] = $developerKey;
691
- }
692
-
693
- /**
694
- * Set the hd (hosted domain) parameter streamlines the login process for
695
- * Google Apps hosted accounts. By including the domain of the user, you
696
- * restrict sign-in to accounts at that domain.
697
- * @param $hd string - the domain to use.
698
- */
699
- public function setHostedDomain($hd)
700
- {
701
- $this->config['hd'] = $hd;
702
- }
703
-
704
- /**
705
- * Set the prompt hint. Valid values are none, consent and select_account.
706
- * If no value is specified and the user has not previously authorized
707
- * access, then the user is shown a consent screen.
708
- * @param $prompt string
709
- * {@code "none"} Do not display any authentication or consent screens. Must not be specified with other values.
710
- * {@code "consent"} Prompt the user for consent.
711
- * {@code "select_account"} Prompt the user to select an account.
712
- */
713
- public function setPrompt($prompt)
714
- {
715
- $this->config['prompt'] = $prompt;
716
- }
717
-
718
- /**
719
- * openid.realm is a parameter from the OpenID 2.0 protocol, not from OAuth
720
- * 2.0. It is used in OpenID 2.0 requests to signify the URL-space for which
721
- * an authentication request is valid.
722
- * @param $realm string - the URL-space to use.
723
- */
724
- public function setOpenidRealm($realm)
725
- {
726
- $this->config['openid.realm'] = $realm;
727
- }
728
-
729
- /**
730
- * If this is provided with the value true, and the authorization request is
731
- * granted, the authorization will include any previous authorizations
732
- * granted to this user/application combination for other scopes.
733
- * @param $include boolean - the URL-space to use.
734
- */
735
- public function setIncludeGrantedScopes($include)
736
- {
737
- $this->config['include_granted_scopes'] = $include;
738
- }
739
-
740
- /**
741
- * sets function to be called when an access token is fetched
742
- * @param callable $tokenCallback - function ($cacheKey, $accessToken)
743
- */
744
- public function setTokenCallback(callable $tokenCallback)
745
- {
746
- $this->config['token_callback'] = $tokenCallback;
747
- }
748
-
749
- /**
750
- * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
751
- * token, if a token isn't provided.
752
- *
753
- * @param string|array|null $token The token (access token or a refresh token) that should be revoked.
754
- * @return boolean Returns True if the revocation was successful, otherwise False.
755
- */
756
- public function revokeToken($token = null)
757
- {
758
- $tokenRevoker = new Revoke($this->getHttpClient());
759
-
760
- return $tokenRevoker->revokeToken($token ?: $this->getAccessToken());
761
- }
762
-
763
- /**
764
- * Verify an id_token. This method will verify the current id_token, if one
765
- * isn't provided.
766
- *
767
- * @throws LogicException If no token was provided and no token was set using `setAccessToken`.
768
- * @throws UnexpectedValueException If the token is not a valid JWT.
769
- * @param string|null $idToken The token (id_token) that should be verified.
770
- * @return array|false Returns the token payload as an array if the verification was
771
- * successful, false otherwise.
772
- */
773
- public function verifyIdToken($idToken = null)
774
- {
775
- $tokenVerifier = new Verify(
776
- $this->getHttpClient(),
777
- $this->getCache(),
778
- $this->config['jwt']
779
- );
780
-
781
- if (null === $idToken) {
782
- $token = $this->getAccessToken();
783
- if (!isset($token['id_token'])) {
784
- throw new LogicException(
785
- 'id_token must be passed in or set as part of setAccessToken'
786
  );
787
- }
788
- $idToken = $token['id_token'];
789
- }
790
-
791
- return $tokenVerifier->verifyIdToken(
792
- $idToken,
793
- $this->getClientId()
794
- );
795
- }
796
-
797
- /**
798
- * Set the scopes to be requested. Must be called before createAuthUrl().
799
- * Will remove any previously configured scopes.
800
- * @param string|array $scope_or_scopes, ie:
801
- * array(
802
- * 'https://www.googleapis.com/auth/plus.login',
803
- * 'https://www.googleapis.com/auth/moderator'
804
- * );
805
- */
806
- public function setScopes($scope_or_scopes)
807
- {
808
- $this->requestedScopes = array();
809
- $this->addScope($scope_or_scopes);
810
- }
811
-
812
- /**
813
- * This functions adds a scope to be requested as part of the OAuth2.0 flow.
814
- * Will append any scopes not previously requested to the scope parameter.
815
- * A single string will be treated as a scope to request. An array of strings
816
- * will each be appended.
817
- * @param $scope_or_scopes string|array e.g. "profile"
818
- */
819
- public function addScope($scope_or_scopes)
820
- {
821
- if (is_string($scope_or_scopes) && !in_array($scope_or_scopes, $this->requestedScopes)) {
822
- $this->requestedScopes[] = $scope_or_scopes;
823
- } else if (is_array($scope_or_scopes)) {
824
- foreach ($scope_or_scopes as $scope) {
825
- $this->addScope($scope);
826
- }
827
- }
828
- }
829
-
830
- /**
831
- * Returns the list of scopes requested by the client
832
- * @return array the list of scopes
833
- *
834
- */
835
- public function getScopes()
836
- {
837
- return $this->requestedScopes;
838
- }
839
-
840
- /**
841
- * @return string|null
842
- * @visible For Testing
843
- */
844
- public function prepareScopes()
845
- {
846
- if (empty($this->requestedScopes)) {
847
- return null;
848
- }
849
-
850
- return implode(' ', $this->requestedScopes);
851
- }
852
-
853
- /**
854
- * Helper method to execute deferred HTTP requests.
855
- *
856
- * @param $request RequestInterface|\Google\Http\Batch
857
- * @param string $expectedClass
858
- * @throws \Google\Exception
859
- * @return object of the type of the expected class or Psr\Http\Message\ResponseInterface.
860
- */
861
- public function execute(RequestInterface $request, $expectedClass = null)
862
- {
863
- $request = $request
864
- ->withHeader(
865
- 'User-Agent',
866
- sprintf(
867
- '%s %s%s',
868
- $this->config['application_name'],
869
- self::USER_AGENT_SUFFIX,
870
- $this->getLibraryVersion()
871
- )
872
- )
873
- ->withHeader(
874
- 'x-goog-api-client',
875
- sprintf(
876
- 'gl-php/%s gdcl/%s',
877
- phpversion(),
878
- $this->getLibraryVersion()
879
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
880
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
881
 
882
- if ($this->config['api_format_v2']) {
883
- $request = $request->withHeader(
884
- 'X-GOOG-API-FORMAT-VERSION',
885
- 2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
886
  );
887
  }
888
 
889
- // call the authorize method
890
- // this is where most of the grunt work is done
891
- $http = $this->authorize();
892
-
893
- return REST::execute(
894
- $http,
895
- $request,
896
- $expectedClass,
897
- $this->config['retry'],
898
- $this->config['retry_map']
899
- );
900
- }
901
-
902
- /**
903
- * Declare whether batch calls should be used. This may increase throughput
904
- * by making multiple requests in one connection.
905
- *
906
- * @param boolean $useBatch True if the batch support should
907
- * be enabled. Defaults to False.
908
- */
909
- public function setUseBatch($useBatch)
910
- {
911
- // This is actually an alias for setDefer.
912
- $this->setDefer($useBatch);
913
- }
914
-
915
- /**
916
- * Are we running in Google AppEngine?
917
- * return bool
918
- */
919
- public function isAppEngine()
920
- {
921
- return (isset($_SERVER['SERVER_SOFTWARE']) &&
922
- strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false);
923
- }
924
-
925
- public function setConfig($name, $value)
926
- {
927
- $this->config[$name] = $value;
928
- }
929
-
930
- public function getConfig($name, $default = null)
931
- {
932
- return isset($this->config[$name]) ? $this->config[$name] : $default;
933
- }
934
-
935
- /**
936
- * For backwards compatibility
937
- * alias for setAuthConfig
938
- *
939
- * @param string $file the configuration file
940
- * @throws \Google\Exception
941
- * @deprecated
942
- */
943
- public function setAuthConfigFile($file)
944
- {
945
- $this->setAuthConfig($file);
946
- }
947
-
948
- /**
949
- * Set the auth config from new or deprecated JSON config.
950
- * This structure should match the file downloaded from
951
- * the "Download JSON" button on in the Google Developer
952
- * Console.
953
- * @param string|array $config the configuration json
954
- * @throws \Google\Exception
955
- */
956
- public function setAuthConfig($config)
957
- {
958
- if (is_string($config)) {
959
- if (!file_exists($config)) {
960
- throw new InvalidArgumentException(sprintf('file "%s" does not exist', $config));
961
- }
962
-
963
- $json = file_get_contents($config);
964
-
965
- if (!$config = json_decode($json, true)) {
966
- throw new LogicException('invalid json for auth config');
967
- }
968
- }
969
-
970
- $key = isset($config['installed']) ? 'installed' : 'web';
971
- if (isset($config['type']) && $config['type'] == 'service_account') {
972
- // application default credentials
973
- $this->useApplicationDefaultCredentials();
974
-
975
- // set the information from the config
976
- $this->setClientId($config['client_id']);
977
- $this->config['client_email'] = $config['client_email'];
978
- $this->config['signing_key'] = $config['private_key'];
979
- $this->config['signing_algorithm'] = 'HS256';
980
- } elseif (isset($config[$key])) {
981
- // old-style
982
- $this->setClientId($config[$key]['client_id']);
983
- $this->setClientSecret($config[$key]['client_secret']);
984
- if (isset($config[$key]['redirect_uris'])) {
985
- $this->setRedirectUri($config[$key]['redirect_uris'][0]);
986
- }
987
- } else {
988
- // new-style
989
- $this->setClientId($config['client_id']);
990
- $this->setClientSecret($config['client_secret']);
991
- if (isset($config['redirect_uris'])) {
992
- $this->setRedirectUri($config['redirect_uris'][0]);
993
- }
994
- }
995
- }
996
-
997
- /**
998
- * Use when the service account has been delegated domain wide access.
999
- *
1000
- * @param string $subject an email address account to impersonate
1001
- */
1002
- public function setSubject($subject)
1003
- {
1004
- $this->config['subject'] = $subject;
1005
- }
1006
-
1007
- /**
1008
- * Declare whether making API calls should make the call immediately, or
1009
- * return a request which can be called with ->execute();
1010
- *
1011
- * @param boolean $defer True if calls should not be executed right away.
1012
- */
1013
- public function setDefer($defer)
1014
- {
1015
- $this->deferExecution = $defer;
1016
- }
1017
-
1018
- /**
1019
- * Whether or not to return raw requests
1020
- * @return boolean
1021
- */
1022
- public function shouldDefer()
1023
- {
1024
- return $this->deferExecution;
1025
- }
1026
-
1027
- /**
1028
- * @return OAuth2 implementation
1029
- */
1030
- public function getOAuth2Service()
1031
- {
1032
- if (!isset($this->auth)) {
1033
- $this->auth = $this->createOAuth2Service();
1034
- }
1035
-
1036
- return $this->auth;
1037
- }
1038
-
1039
- /**
1040
- * create a default google auth object
1041
- */
1042
- protected function createOAuth2Service()
1043
- {
1044
- $auth = new OAuth2(
1045
- [
1046
- 'clientId' => $this->getClientId(),
1047
- 'clientSecret' => $this->getClientSecret(),
1048
- 'authorizationUri' => self::OAUTH2_AUTH_URL,
1049
- 'tokenCredentialUri' => self::OAUTH2_TOKEN_URI,
1050
- 'redirectUri' => $this->getRedirectUri(),
1051
- 'issuer' => $this->config['client_id'],
1052
- 'signingKey' => $this->config['signing_key'],
1053
- 'signingAlgorithm' => $this->config['signing_algorithm'],
1054
- ]
1055
- );
1056
-
1057
- return $auth;
1058
- }
1059
-
1060
- /**
1061
- * Set the Cache object
1062
- * @param CacheItemPoolInterface $cache
1063
- */
1064
- public function setCache(CacheItemPoolInterface $cache)
1065
- {
1066
- $this->cache = $cache;
1067
- }
1068
-
1069
- /**
1070
- * @return CacheItemPoolInterface
1071
- */
1072
- public function getCache()
1073
- {
1074
- if (!$this->cache) {
1075
- $this->cache = $this->createDefaultCache();
1076
- }
1077
-
1078
- return $this->cache;
1079
- }
1080
-
1081
- /**
1082
- * @param array $cacheConfig
1083
- */
1084
- public function setCacheConfig(array $cacheConfig)
1085
- {
1086
- $this->config['cache_config'] = $cacheConfig;
1087
- }
1088
-
1089
- /**
1090
- * Set the Logger object
1091
- * @param LoggerInterface $logger
1092
- */
1093
- public function setLogger(LoggerInterface $logger)
1094
- {
1095
- $this->logger = $logger;
1096
- }
1097
-
1098
- /**
1099
- * @return LoggerInterface
1100
- */
1101
- public function getLogger()
1102
- {
1103
- if (!isset($this->logger)) {
1104
- $this->logger = $this->createDefaultLogger();
1105
- }
1106
-
1107
- return $this->logger;
1108
- }
1109
-
1110
- protected function createDefaultLogger()
1111
- {
1112
- $logger = new Logger('google-api-php-client');
1113
- if ($this->isAppEngine()) {
1114
- $handler = new MonologSyslogHandler('app', LOG_USER, Logger::NOTICE);
1115
- } else {
1116
- $handler = new MonologStreamHandler('php://stderr', Logger::NOTICE);
1117
- }
1118
- $logger->pushHandler($handler);
1119
-
1120
- return $logger;
1121
- }
1122
-
1123
- protected function createDefaultCache()
1124
- {
1125
- return new MemoryCacheItemPool;
1126
- }
1127
-
1128
- /**
1129
- * Set the Http Client object
1130
- * @param ClientInterface $http
1131
- */
1132
- public function setHttpClient(ClientInterface $http)
1133
- {
1134
- $this->http = $http;
1135
- }
1136
-
1137
- /**
1138
- * @return ClientInterface
1139
- */
1140
- public function getHttpClient()
1141
- {
1142
- if (null === $this->http) {
1143
- $this->http = $this->createDefaultHttpClient();
1144
- }
1145
-
1146
- return $this->http;
1147
- }
1148
-
1149
- /**
1150
- * Set the API format version.
1151
- *
1152
- * `true` will use V2, which may return more useful error messages.
1153
- *
1154
- * @param bool $value
1155
- */
1156
- public function setApiFormatV2($value)
1157
- {
1158
- $this->config['api_format_v2'] = (bool) $value;
1159
- }
1160
-
1161
- protected function createDefaultHttpClient()
1162
- {
1163
- $guzzleVersion = null;
1164
- if (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
1165
- $guzzleVersion = ClientInterface::MAJOR_VERSION;
1166
- } elseif (defined('\GuzzleHttp\ClientInterface::VERSION')) {
1167
- $guzzleVersion = (int)substr(ClientInterface::VERSION, 0, 1);
1168
- }
1169
-
1170
- if (5 === $guzzleVersion) {
1171
- $options = [
1172
- 'base_url' => $this->config['base_path'],
1173
- 'defaults' => ['exceptions' => false],
1174
- ];
1175
- if ($this->isAppEngine()) {
1176
- // set StreamHandler on AppEngine by default
1177
- $options['handler'] = new StreamHandler();
1178
- $options['defaults']['verify'] = '/etc/ca-certificates.crt';
1179
- }
1180
- } elseif (6 === $guzzleVersion || 7 === $guzzleVersion) {
1181
- // guzzle 6 or 7
1182
- $options = [
1183
- 'base_uri' => $this->config['base_path'],
1184
- 'http_errors' => false,
1185
- ];
1186
- } else {
1187
- throw new LogicException('Could not find supported version of Guzzle.');
1188
- }
1189
-
1190
- return new GuzzleClient($options);
1191
- }
1192
-
1193
- /**
1194
- * @return FetchAuthTokenCache
1195
- */
1196
- private function createApplicationDefaultCredentials()
1197
- {
1198
- $scopes = $this->prepareScopes();
1199
- $sub = $this->config['subject'];
1200
- $signingKey = $this->config['signing_key'];
1201
-
1202
- // create credentials using values supplied in setAuthConfig
1203
- if ($signingKey) {
1204
- $serviceAccountCredentials = array(
1205
- 'client_id' => $this->config['client_id'],
1206
- 'client_email' => $this->config['client_email'],
1207
- 'private_key' => $signingKey,
1208
- 'type' => 'service_account',
1209
- 'quota_project_id' => $this->config['quota_project'],
1210
- );
1211
- $credentials = CredentialsLoader::makeCredentials(
1212
- $scopes,
1213
- $serviceAccountCredentials
1214
- );
1215
- } else {
1216
- // When $sub is provided, we cannot pass cache classes to ::getCredentials
1217
- // because FetchAuthTokenCache::setSub does not exist.
1218
- // The result is when $sub is provided, calls to ::onGce are not cached.
1219
- $credentials = ApplicationDefaultCredentials::getCredentials(
1220
- $scopes,
1221
- null,
1222
- $sub ? null : $this->config['cache_config'],
1223
- $sub ? null : $this->getCache(),
1224
- $this->config['quota_project']
1225
- );
1226
- }
1227
-
1228
- // for service account domain-wide authority (impersonating a user)
1229
- // @see https://developers.google.com/identity/protocols/OAuth2ServiceAccount
1230
- if ($sub) {
1231
- if (!$credentials instanceof ServiceAccountCredentials) {
1232
- throw new DomainException('domain-wide authority requires service account credentials');
1233
- }
1234
-
1235
- $credentials->setSub($sub);
1236
- }
1237
-
1238
- // If we are not using FetchAuthTokenCache yet, create it now
1239
- if (!$credentials instanceof FetchAuthTokenCache) {
1240
- $credentials = new FetchAuthTokenCache(
1241
- $credentials,
1242
- $this->config['cache_config'],
1243
- $this->getCache()
1244
- );
1245
- }
1246
- return $credentials;
1247
- }
1248
-
1249
- protected function getAuthHandler()
1250
- {
1251
- // Be very careful using the cache, as the underlying auth library's cache
1252
- // implementation is naive, and the cache keys do not account for user
1253
- // sessions.
1254
- //
1255
- // @see https://github.com/google/google-api-php-client/issues/821
1256
- return AuthHandlerFactory::build(
1257
- $this->getCache(),
1258
- $this->config['cache_config']
1259
- );
1260
- }
1261
-
1262
- private function createUserRefreshCredentials($scope, $refreshToken)
1263
- {
1264
- $creds = array_filter(
1265
- array(
1266
- 'client_id' => $this->getClientId(),
1267
- 'client_secret' => $this->getClientSecret(),
1268
- 'refresh_token' => $refreshToken,
1269
- )
1270
- );
1271
-
1272
- return new UserRefreshCredentials($scope, $creds);
1273
- }
1274
  }
17
 
18
  namespace Google;
19
 
20
+ use BadMethodCallException;
21
+ use DomainException;
22
  use Google\AccessToken\Revoke;
23
  use Google\AccessToken\Verify;
24
  use Google\Auth\ApplicationDefaultCredentials;
25
  use Google\Auth\Cache\MemoryCacheItemPool;
26
+ use Google\Auth\Credentials\ServiceAccountCredentials;
27
+ use Google\Auth\Credentials\UserRefreshCredentials;
28
  use Google\Auth\CredentialsLoader;
29
  use Google\Auth\FetchAuthTokenCache;
30
  use Google\Auth\HttpHandler\HttpHandlerFactory;
31
  use Google\Auth\OAuth2;
 
 
32
  use Google\AuthHandler\AuthHandlerFactory;
33
  use Google\Http\REST;
34
  use GuzzleHttp\Client as GuzzleClient;
35
  use GuzzleHttp\ClientInterface;
36
  use GuzzleHttp\Ring\Client\StreamHandler;
37
+ use InvalidArgumentException;
38
+ use LogicException;
39
+ use Monolog\Handler\StreamHandler as MonologStreamHandler;
40
+ use Monolog\Handler\SyslogHandler as MonologSyslogHandler;
41
+ use Monolog\Logger;
42
  use Psr\Cache\CacheItemPoolInterface;
43
  use Psr\Http\Message\RequestInterface;
44
+ use Psr\Http\Message\ResponseInterface;
45
  use Psr\Log\LoggerInterface;
46
+ use UnexpectedValueException;
 
 
 
 
 
 
47
 
48
  /**
49
  * The Google API Client
51
  */
52
  class Client
53
  {
54
+ const LIBVER = "2.12.1";
55
+ const USER_AGENT_SUFFIX = "google-api-php-client/";
56
+ const OAUTH2_REVOKE_URI = 'https://oauth2.googleapis.com/revoke';
57
+ const OAUTH2_TOKEN_URI = 'https://oauth2.googleapis.com/token';
58
+ const OAUTH2_AUTH_URL = 'https://accounts.google.com/o/oauth2/auth';
59
+ const API_BASE_PATH = 'https://www.googleapis.com';
60
+
61
+ /**
62
+ * @var ?OAuth2 $auth
63
+ */
64
+ private $auth;
65
+
66
+ /**
67
+ * @var ClientInterface $http
68
+ */
69
+ private $http;
70
+
71
+ /**
72
+ * @var ?CacheItemPoolInterface $cache
73
+ */
74
+ private $cache;
75
+
76
+ /**
77
+ * @var array access token
78
+ */
79
+ private $token;
80
+
81
+ /**
82
+ * @var array $config
83
+ */
84
+ private $config;
85
+
86
+ /**
87
+ * @var ?LoggerInterface $logger
88
+ */
89
+ private $logger;
90
+
91
+ /**
92
+ * @var ?CredentialsLoader $credentials
93
+ */
94
+ private $credentials;
95
+
96
+ /**
97
+ * @var boolean $deferExecution
98
+ */
99
+ private $deferExecution = false;
100
+
101
+ /** @var array $scopes */
102
+ // Scopes requested by the client
103
+ protected $requestedScopes = [];
104
+
105
+ /**
106
+ * Construct the Google Client.
107
+ *
108
+ * @param array $config
109
+ */
110
+ public function __construct(array $config = [])
111
+ {
112
+ $this->config = array_merge([
113
+ 'application_name' => '',
114
+
115
+ // Don't change these unless you're working against a special development
116
+ // or testing environment.
117
+ 'base_path' => self::API_BASE_PATH,
118
+
119
+ // https://developers.google.com/console
120
+ 'client_id' => '',
121
+ 'client_secret' => '',
122
+
123
+ // Can be a path to JSON credentials or an array representing those
124
+ // credentials (@see Google\Client::setAuthConfig), or an instance of
125
+ // Google\Auth\CredentialsLoader.
126
+ 'credentials' => null,
127
+ // @see Google\Client::setScopes
128
+ 'scopes' => null,
129
+ // Sets X-Goog-User-Project, which specifies a user project to bill
130
+ // for access charges associated with the request
131
+ 'quota_project' => null,
132
+
133
+ 'redirect_uri' => null,
134
+ 'state' => null,
135
+
136
+ // Simple API access key, also from the API console. Ensure you get
137
+ // a Server key, and not a Browser key.
138
+ 'developer_key' => '',
139
+
140
+ // For use with Google Cloud Platform
141
+ // fetch the ApplicationDefaultCredentials, if applicable
142
+ // @see https://developers.google.com/identity/protocols/application-default-credentials
143
+ 'use_application_default_credentials' => false,
144
+ 'signing_key' => null,
145
+ 'signing_algorithm' => null,
146
+ 'subject' => null,
147
+
148
+ // Other OAuth2 parameters.
149
+ 'hd' => '',
150
+ 'prompt' => '',
151
+ 'openid.realm' => '',
152
+ 'include_granted_scopes' => null,
153
+ 'login_hint' => '',
154
+ 'request_visible_actions' => '',
155
+ 'access_type' => 'online',
156
+ 'approval_prompt' => 'auto',
157
+
158
+ // Task Runner retry configuration
159
+ // @see Google\Task\Runner
160
+ 'retry' => [],
161
+ 'retry_map' => null,
162
+
163
+ // Cache class implementing Psr\Cache\CacheItemPoolInterface.
164
+ // Defaults to Google\Auth\Cache\MemoryCacheItemPool.
165
+ 'cache' => null,
166
+ // cache config for downstream auth caching
167
+ 'cache_config' => [],
168
+
169
+ // function to be called when an access token is fetched
170
+ // follows the signature function ($cacheKey, $accessToken)
171
+ 'token_callback' => null,
172
+
173
+ // Service class used in Google\Client::verifyIdToken.
174
+ // Explicitly pass this in to avoid setting JWT::$leeway
175
+ 'jwt' => null,
176
+
177
+ // Setting api_format_v2 will return more detailed error messages
178
+ // from certain APIs.
179
+ 'api_format_v2' => false
180
+ ], $config);
181
+
182
+ if (!is_null($this->config['credentials'])) {
183
+ if ($this->config['credentials'] instanceof CredentialsLoader) {
184
+ $this->credentials = $this->config['credentials'];
185
+ } else {
186
+ $this->setAuthConfig($this->config['credentials']);
187
+ }
188
+ unset($this->config['credentials']);
189
+ }
190
+
191
+ if (!is_null($this->config['scopes'])) {
192
+ $this->setScopes($this->config['scopes']);
193
+ unset($this->config['scopes']);
194
+ }
195
+
196
+ // Set a default token callback to update the in-memory access token
197
+ if (is_null($this->config['token_callback'])) {
198
+ $this->config['token_callback'] = function ($cacheKey, $newAccessToken) {
199
+ $this->setAccessToken(
200
+ [
201
+ 'access_token' => $newAccessToken,
202
+ 'expires_in' => 3600, // Google default
203
+ 'created' => time(),
204
+ ]
205
+ );
206
+ };
207
+ }
208
+
209
+ if (!is_null($this->config['cache'])) {
210
+ $this->setCache($this->config['cache']);
211
+ unset($this->config['cache']);
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Get a string containing the version of the library.
217
+ *
218
+ * @return string
219
+ */
220
+ public function getLibraryVersion()
221
+ {
222
+ return self::LIBVER;
223
+ }
224
+
225
+ /**
226
+ * For backwards compatibility
227
+ * alias for fetchAccessTokenWithAuthCode
228
+ *
229
+ * @param string $code string code from accounts.google.com
230
+ * @return array access token
231
+ * @deprecated
232
+ */
233
+ public function authenticate($code)
234
+ {
235
+ return $this->fetchAccessTokenWithAuthCode($code);
236
+ }
237
+
238
+ /**
239
+ * Attempt to exchange a code for an valid authentication token.
240
+ * Helper wrapped around the OAuth 2.0 implementation.
241
+ *
242
+ * @param string $code code from accounts.google.com
243
+ * @return array access token
244
+ */
245
+ public function fetchAccessTokenWithAuthCode($code)
246
+ {
247
+ if (strlen($code) == 0) {
248
+ throw new InvalidArgumentException("Invalid code");
249
+ }
250
+
251
+ $auth = $this->getOAuth2Service();
252
+ $auth->setCode($code);
253
+ $auth->setRedirectUri($this->getRedirectUri());
254
+
255
+ $httpHandler = HttpHandlerFactory::build($this->getHttpClient());
256
+ $creds = $auth->fetchAuthToken($httpHandler);
257
+ if ($creds && isset($creds['access_token'])) {
258
+ $creds['created'] = time();
259
+ $this->setAccessToken($creds);
260
+ }
261
+
262
+ return $creds;
263
+ }
264
+
265
+ /**
266
+ * For backwards compatibility
267
+ * alias for fetchAccessTokenWithAssertion
268
+ *
269
+ * @return array access token
270
+ * @deprecated
271
+ */
272
+ public function refreshTokenWithAssertion()
273
+ {
274
+ return $this->fetchAccessTokenWithAssertion();
275
+ }
276
+
277
+ /**
278
+ * Fetches a fresh access token with a given assertion token.
279
+ * @param ClientInterface $authHttp optional.
280
+ * @return array access token
281
+ */
282
+ public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null)
283
+ {
284
+ if (!$this->isUsingApplicationDefaultCredentials()) {
285
+ throw new DomainException(
286
+ 'set the JSON service account credentials using'
287
+ . ' Google\Client::setAuthConfig or set the path to your JSON file'
288
+ . ' with the "GOOGLE_APPLICATION_CREDENTIALS" environment variable'
289
+ . ' and call Google\Client::useApplicationDefaultCredentials to'
290
+ . ' refresh a token with assertion.'
291
+ );
292
+ }
293
+
294
+ $this->getLogger()->log(
295
+ 'info',
296
+ 'OAuth2 access token refresh with Signed JWT assertion grants.'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  );
298
+
299
+ $credentials = $this->createApplicationDefaultCredentials();
300
+
301
+ $httpHandler = HttpHandlerFactory::build($authHttp);
302
+ $creds = $credentials->fetchAuthToken($httpHandler);
303
+ if ($creds && isset($creds['access_token'])) {
304
+ $creds['created'] = time();
305
+ $this->setAccessToken($creds);
306
+ }
307
+
308
+ return $creds;
309
+ }
310
+
311
+ /**
312
+ * For backwards compatibility
313
+ * alias for fetchAccessTokenWithRefreshToken
314
+ *
315
+ * @param string $refreshToken
316
+ * @return array access token
317
+ */
318
+ public function refreshToken($refreshToken)
319
+ {
320
+ return $this->fetchAccessTokenWithRefreshToken($refreshToken);
321
+ }
322
+
323
+ /**
324
+ * Fetches a fresh OAuth 2.0 access token with the given refresh token.
325
+ * @param string $refreshToken
326
+ * @return array access token
327
+ */
328
+ public function fetchAccessTokenWithRefreshToken($refreshToken = null)
329
+ {
330
+ if (null === $refreshToken) {
331
+ if (!isset($this->token['refresh_token'])) {
332
+ throw new LogicException(
333
+ 'refresh token must be passed in or set as part of setAccessToken'
334
+ );
335
+ }
336
+ $refreshToken = $this->token['refresh_token'];
337
+ }
338
+ $this->getLogger()->info('OAuth2 access token refresh');
339
+ $auth = $this->getOAuth2Service();
340
+ $auth->setRefreshToken($refreshToken);
341
+
342
+ $httpHandler = HttpHandlerFactory::build($this->getHttpClient());
343
+ $creds = $auth->fetchAuthToken($httpHandler);
344
+ if ($creds && isset($creds['access_token'])) {
345
+ $creds['created'] = time();
346
+ if (!isset($creds['refresh_token'])) {
347
+ $creds['refresh_token'] = $refreshToken;
348
+ }
349
+ $this->setAccessToken($creds);
350
+ }
351
+
352
+ return $creds;
353
+ }
354
+
355
+ /**
356
+ * Create a URL to obtain user authorization.
357
+ * The authorization endpoint allows the user to first
358
+ * authenticate, and then grant/deny the access request.
359
+ * @param string|array $scope The scope is expressed as an array or list of space-delimited strings.
360
+ * @return string
361
+ */
362
+ public function createAuthUrl($scope = null)
363
+ {
364
+ if (empty($scope)) {
365
+ $scope = $this->prepareScopes();
366
+ }
367
+ if (is_array($scope)) {
368
+ $scope = implode(' ', $scope);
369
+ }
370
+
371
+ // only accept one of prompt or approval_prompt
372
+ $approvalPrompt = $this->config['prompt']
373
+ ? null
374
+ : $this->config['approval_prompt'];
375
+
376
+ // include_granted_scopes should be string "true", string "false", or null
377
+ $includeGrantedScopes = $this->config['include_granted_scopes'] === null
378
+ ? null
379
+ : var_export($this->config['include_granted_scopes'], true);
380
+
381
+ $params = array_filter([
382
+ 'access_type' => $this->config['access_type'],
383
+ 'approval_prompt' => $approvalPrompt,
384
+ 'hd' => $this->config['hd'],
385
+ 'include_granted_scopes' => $includeGrantedScopes,
386
+ 'login_hint' => $this->config['login_hint'],
387
+ 'openid.realm' => $this->config['openid.realm'],
388
+ 'prompt' => $this->config['prompt'],
389
+ 'response_type' => 'code',
390
+ 'scope' => $scope,
391
+ 'state' => $this->config['state'],
392
+ ]);
393
+
394
+ // If the list of scopes contains plus.login, add request_visible_actions
395
+ // to auth URL.
396
+ $rva = $this->config['request_visible_actions'];
397
+ if (strlen($rva) > 0 && false !== strpos($scope, 'plus.login')) {
398
+ $params['request_visible_actions'] = $rva;
399
+ }
400
+
401
+ $auth = $this->getOAuth2Service();
402
+
403
+ return (string) $auth->buildFullAuthorizationUri($params);
404
+ }
405
+
406
+ /**
407
+ * Adds auth listeners to the HTTP client based on the credentials
408
+ * set in the Google API Client object
409
+ *
410
+ * @param ClientInterface $http the http client object.
411
+ * @return ClientInterface the http client object
412
+ */
413
+ public function authorize(ClientInterface $http = null)
414
+ {
415
+ $http = $http ?: $this->getHttpClient();
416
+ $authHandler = $this->getAuthHandler();
417
+
418
+ // These conditionals represent the decision tree for authentication
419
+ // 1. Check if a Google\Auth\CredentialsLoader instance has been supplied via the "credentials" option
420
+ // 2. Check for Application Default Credentials
421
+ // 3a. Check for an Access Token
422
+ // 3b. If access token exists but is expired, try to refresh it
423
+ // 4. Check for API Key
424
+ if ($this->credentials) {
425
+ return $authHandler->attachCredentials(
426
+ $http,
427
+ $this->credentials,
428
+ $this->config['token_callback']
429
+ );
430
+ }
431
+
432
+ if ($this->isUsingApplicationDefaultCredentials()) {
433
+ $credentials = $this->createApplicationDefaultCredentials();
434
+ return $authHandler->attachCredentialsCache(
435
+ $http,
436
+ $credentials,
437
+ $this->config['token_callback']
438
+ );
439
+ }
440
+
441
+ if ($token = $this->getAccessToken()) {
442
+ $scopes = $this->prepareScopes();
443
+ // add refresh subscriber to request a new token
444
+ if (isset($token['refresh_token']) && $this->isAccessTokenExpired()) {
445
+ $credentials = $this->createUserRefreshCredentials(
446
+ $scopes,
447
+ $token['refresh_token']
448
+ );
449
+ return $authHandler->attachCredentials(
450
+ $http,
451
+ $credentials,
452
+ $this->config['token_callback']
453
+ );
454
+ }
455
+
456
+ return $authHandler->attachToken($http, $token, (array) $scopes);
457
+ }
458
+
459
+ if ($key = $this->config['developer_key']) {
460
+ return $authHandler->attachKey($http, $key);
461
+ }
462
+
463
+ return $http;
464
+ }
465
+
466
+ /**
467
+ * Set the configuration to use application default credentials for
468
+ * authentication
469
+ *
470
+ * @see https://developers.google.com/identity/protocols/application-default-credentials
471
+ * @param boolean $useAppCreds
472
+ */
473
+ public function useApplicationDefaultCredentials($useAppCreds = true)
474
+ {
475
+ $this->config['use_application_default_credentials'] = $useAppCreds;
476
+ }
477
+
478
+ /**
479
+ * To prevent useApplicationDefaultCredentials from inappropriately being
480
+ * called in a conditional
481
+ *
482
+ * @see https://developers.google.com/identity/protocols/application-default-credentials
483
+ */
484
+ public function isUsingApplicationDefaultCredentials()
485
+ {
486
+ return $this->config['use_application_default_credentials'];
487
+ }
488
+
489
+ /**
490
+ * Set the access token used for requests.
491
+ *
492
+ * Note that at the time requests are sent, tokens are cached. A token will be
493
+ * cached for each combination of service and authentication scopes. If a
494
+ * cache pool is not provided, creating a new instance of the client will
495
+ * allow modification of access tokens. If a persistent cache pool is
496
+ * provided, in order to change the access token, you must clear the cached
497
+ * token by calling `$client->getCache()->clear()`. (Use caution in this case,
498
+ * as calling `clear()` will remove all cache items, including any items not
499
+ * related to Google API PHP Client.)
500
+ *
501
+ * @param string|array $token
502
+ * @throws InvalidArgumentException
503
+ */
504
+ public function setAccessToken($token)
505
+ {
506
+ if (is_string($token)) {
507
+ if ($json = json_decode($token, true)) {
508
+ $token = $json;
509
+ } else {
510
+ // assume $token is just the token string
511
+ $token = [
512
+ 'access_token' => $token,
513
+ ];
514
+ }
515
+ }
516
+ if ($token == null) {
517
+ throw new InvalidArgumentException('invalid json token');
518
+ }
519
+ if (!isset($token['access_token'])) {
520
+ throw new InvalidArgumentException("Invalid token format");
521
+ }
522
+ $this->token = $token;
523
+ }
524
+
525
+ public function getAccessToken()
526
+ {
527
+ return $this->token;
528
+ }
529
+
530
+ /**
531
+ * @return string|null
532
+ */
533
+ public function getRefreshToken()
534
+ {
535
+ if (isset($this->token['refresh_token'])) {
536
+ return $this->token['refresh_token'];
537
+ }
538
+
539
+ return null;
540
+ }
541
+
542
+ /**
543
+ * Returns if the access_token is expired.
544
+ * @return bool Returns True if the access_token is expired.
545
+ */
546
+ public function isAccessTokenExpired()
547
+ {
548
+ if (!$this->token) {
549
+ return true;
550
+ }
551
+
552
+ $created = 0;
553
+ if (isset($this->token['created'])) {
554
+ $created = $this->token['created'];
555
+ } elseif (isset($this->token['id_token'])) {
556
+ // check the ID token for "iat"
557
+ // signature verification is not required here, as we are just
558
+ // using this for convenience to save a round trip request
559
+ // to the Google API server
560
+ $idToken = $this->token['id_token'];
561
+ if (substr_count($idToken, '.') == 2) {
562
+ $parts = explode('.', $idToken);
563
+ $payload = json_decode(base64_decode($parts[1]), true);
564
+ if ($payload && isset($payload['iat'])) {
565
+ $created = $payload['iat'];
566
+ }
567
+ }
568
+ }
569
+ if (!isset($this->token['expires_in'])) {
570
+ // if the token does not have an "expires_in", then it's considered expired
571
+ return true;
572
+ }
573
+
574
+ // If the token is set to expire in the next 30 seconds.
575
+ return ($created + ($this->token['expires_in'] - 30)) < time();
576
+ }
577
+
578
+ /**
579
+ * @deprecated See UPGRADING.md for more information
580
+ */
581
+ public function getAuth()
582
+ {
583
+ throw new BadMethodCallException(
584
+ 'This function no longer exists. See UPGRADING.md for more information'
585
  );
586
+ }
587
+
588
+ /**
589
+ * @deprecated See UPGRADING.md for more information
590
+ */
591
+ public function setAuth($auth)
592
+ {
593
+ throw new BadMethodCallException(
594
+ 'This function no longer exists. See UPGRADING.md for more information'
595
  );
596
+ }
597
+
598
+ /**
599
+ * Set the OAuth 2.0 Client ID.
600
+ * @param string $clientId
601
+ */
602
+ public function setClientId($clientId)
603
+ {
604
+ $this->config['client_id'] = $clientId;
605
+ }
606
+
607
+ public function getClientId()
608
+ {
609
+ return $this->config['client_id'];
610
+ }
611
+
612
+ /**
613
+ * Set the OAuth 2.0 Client Secret.
614
+ * @param string $clientSecret
615
+ */
616
+ public function setClientSecret($clientSecret)
617
+ {
618
+ $this->config['client_secret'] = $clientSecret;
619
+ }
620
+
621
+ public function getClientSecret()
622
+ {
623
+ return $this->config['client_secret'];
624
+ }
625
+
626
+ /**
627
+ * Set the OAuth 2.0 Redirect URI.
628
+ * @param string $redirectUri
629
+ */
630
+ public function setRedirectUri($redirectUri)
631
+ {
632
+ $this->config['redirect_uri'] = $redirectUri;
633
+ }
634
+
635
+ public function getRedirectUri()
636
+ {
637
+ return $this->config['redirect_uri'];
638
+ }
639
+
640
+ /**
641
+ * Set OAuth 2.0 "state" parameter to achieve per-request customization.
642
+ * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.1.2.2
643
+ * @param string $state
644
+ */
645
+ public function setState($state)
646
+ {
647
+ $this->config['state'] = $state;
648
+ }
649
+
650
+ /**
651
+ * @param string $accessType Possible values for access_type include:
652
+ * {@code "offline"} to request offline access from the user.
653
+ * {@code "online"} to request online access from the user.
654
+ */
655
+ public function setAccessType($accessType)
656
+ {
657
+ $this->config['access_type'] = $accessType;
658
+ }
659
+
660
+ /**
661
+ * @param string $approvalPrompt Possible values for approval_prompt include:
662
+ * {@code "force"} to force the approval UI to appear.
663
+ * {@code "auto"} to request auto-approval when possible. (This is the default value)
664
+ */
665
+ public function setApprovalPrompt($approvalPrompt)
666
+ {
667
+ $this->config['approval_prompt'] = $approvalPrompt;
668
+ }
669
+
670
+ /**
671
+ * Set the login hint, email address or sub id.
672
+ * @param string $loginHint
673
+ */
674
+ public function setLoginHint($loginHint)
675
+ {
676
+ $this->config['login_hint'] = $loginHint;
677
+ }
678
+
679
+ /**
680
+ * Set the application name, this is included in the User-Agent HTTP header.
681
+ * @param string $applicationName
682
+ */
683
+ public function setApplicationName($applicationName)
684
+ {
685
+ $this->config['application_name'] = $applicationName;
686
+ }
687
+
688
+ /**
689
+ * If 'plus.login' is included in the list of requested scopes, you can use
690
+ * this method to define types of app activities that your app will write.
691
+ * You can find a list of available types here:
692
+ * @link https://developers.google.com/+/api/moment-types
693
+ *
694
+ * @param array $requestVisibleActions Array of app activity types
695
+ */
696
+ public function setRequestVisibleActions($requestVisibleActions)
697
+ {
698
+ if (is_array($requestVisibleActions)) {
699
+ $requestVisibleActions = implode(" ", $requestVisibleActions);
700
+ }
701
+ $this->config['request_visible_actions'] = $requestVisibleActions;
702
+ }
703
+
704
+ /**
705
+ * Set the developer key to use, these are obtained through the API Console.
706
+ * @see http://code.google.com/apis/console-help/#generatingdevkeys
707
+ * @param string $developerKey
708
+ */
709
+ public function setDeveloperKey($developerKey)
710
+ {
711
+ $this->config['developer_key'] = $developerKey;
712
+ }
713
+
714
+ /**
715
+ * Set the hd (hosted domain) parameter streamlines the login process for
716
+ * Google Apps hosted accounts. By including the domain of the user, you
717
+ * restrict sign-in to accounts at that domain.
718
+ * @param string $hd the domain to use.
719
+ */
720
+ public function setHostedDomain($hd)
721
+ {
722
+ $this->config['hd'] = $hd;
723
+ }
724
+
725
+ /**
726
+ * Set the prompt hint. Valid values are none, consent and select_account.
727
+ * If no value is specified and the user has not previously authorized
728
+ * access, then the user is shown a consent screen.
729
+ * @param string $prompt
730
+ * {@code "none"} Do not display any authentication or consent screens. Must not be specified with other values.
731
+ * {@code "consent"} Prompt the user for consent.
732
+ * {@code "select_account"} Prompt the user to select an account.
733
+ */
734
+ public function setPrompt($prompt)
735
+ {
736
+ $this->config['prompt'] = $prompt;
737
+ }
738
+
739
+ /**
740
+ * openid.realm is a parameter from the OpenID 2.0 protocol, not from OAuth
741
+ * 2.0. It is used in OpenID 2.0 requests to signify the URL-space for which
742
+ * an authentication request is valid.
743
+ * @param string $realm the URL-space to use.
744
+ */
745
+ public function setOpenidRealm($realm)
746
+ {
747
+ $this->config['openid.realm'] = $realm;
748
+ }
749
+
750
+ /**
751
+ * If this is provided with the value true, and the authorization request is
752
+ * granted, the authorization will include any previous authorizations
753
+ * granted to this user/application combination for other scopes.
754
+ * @param bool $include the URL-space to use.
755
+ */
756
+ public function setIncludeGrantedScopes($include)
757
+ {
758
+ $this->config['include_granted_scopes'] = $include;
759
+ }
760
+
761
+ /**
762
+ * sets function to be called when an access token is fetched
763
+ * @param callable $tokenCallback - function ($cacheKey, $accessToken)
764
+ */
765
+ public function setTokenCallback(callable $tokenCallback)
766
+ {
767
+ $this->config['token_callback'] = $tokenCallback;
768
+ }
769
+
770
+ /**
771
+ * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
772
+ * token, if a token isn't provided.
773
+ *
774
+ * @param string|array|null $token The token (access token or a refresh token) that should be revoked.
775
+ * @return boolean Returns True if the revocation was successful, otherwise False.
776
+ */
777
+ public function revokeToken($token = null)
778
+ {
779
+ $tokenRevoker = new Revoke($this->getHttpClient());
780
+
781
+ return $tokenRevoker->revokeToken($token ?: $this->getAccessToken());
782
+ }
783
+
784
+ /**
785
+ * Verify an id_token. This method will verify the current id_token, if one
786
+ * isn't provided.
787
+ *
788
+ * @throws LogicException If no token was provided and no token was set using `setAccessToken`.
789
+ * @throws UnexpectedValueException If the token is not a valid JWT.
790
+ * @param string|null $idToken The token (id_token) that should be verified.
791
+ * @return array|false Returns the token payload as an array if the verification was
792
+ * successful, false otherwise.
793
+ */
794
+ public function verifyIdToken($idToken = null)
795
+ {
796
+ $tokenVerifier = new Verify(
797
+ $this->getHttpClient(),
798
+ $this->getCache(),
799
+ $this->config['jwt']
800
  );
801
+
802
+ if (null === $idToken) {
803
+ $token = $this->getAccessToken();
804
+ if (!isset($token['id_token'])) {
805
+ throw new LogicException(
806
+ 'id_token must be passed in or set as part of setAccessToken'
807
+ );
808
+ }
809
+ $idToken = $token['id_token'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
810
  }
811
+
812
+ return $tokenVerifier->verifyIdToken(
813
+ $idToken,
814
+ $this->getClientId()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815
  );
816
+ }
817
+
818
+ /**
819
+ * Set the scopes to be requested. Must be called before createAuthUrl().
820
+ * Will remove any previously configured scopes.
821
+ * @param string|array $scope_or_scopes, ie:
822
+ * array(
823
+ * 'https://www.googleapis.com/auth/plus.login',
824
+ * 'https://www.googleapis.com/auth/moderator'
825
+ * );
826
+ */
827
+ public function setScopes($scope_or_scopes)
828
+ {
829
+ $this->requestedScopes = [];
830
+ $this->addScope($scope_or_scopes);
831
+ }
832
+
833
+ /**
834
+ * This functions adds a scope to be requested as part of the OAuth2.0 flow.
835
+ * Will append any scopes not previously requested to the scope parameter.
836
+ * A single string will be treated as a scope to request. An array of strings
837
+ * will each be appended.
838
+ * @param string|string[] $scope_or_scopes e.g. "profile"
839
+ */
840
+ public function addScope($scope_or_scopes)
841
+ {
842
+ if (is_string($scope_or_scopes) && !in_array($scope_or_scopes, $this->requestedScopes)) {
843
+ $this->requestedScopes[] = $scope_or_scopes;
844
+ } elseif (is_array($scope_or_scopes)) {
845
+ foreach ($scope_or_scopes as $scope) {
846
+ $this->addScope($scope);
847
+ }
848
+ }
849
+ }
850
+
851
+ /**
852
+ * Returns the list of scopes requested by the client
853
+ * @return array the list of scopes
854
+ *
855
+ */
856
+ public function getScopes()
857
+ {
858
+ return $this->requestedScopes;
859
+ }
860
+
861
+ /**
862
+ * @return string|null
863
+ * @visible For Testing
864
+ */
865
+ public function prepareScopes()
866
+ {
867
+ if (empty($this->requestedScopes)) {
868
+ return null;
869
+ }
870
+
871
+ return implode(' ', $this->requestedScopes);
872
+ }
873
+
874
+ /**
875
+ * Helper method to execute deferred HTTP requests.
876
+ *
877
+ * @template T
878
+ * @param RequestInterface $request
879
+ * @param class-string<T> $expectedClass
880
+ * @throws \Google\Exception
881
+ * @return mixed|T|ResponseInterface
882
+ */
883
+ public function execute(RequestInterface $request, $expectedClass = null)
884
+ {
885
+ $request = $request
886
+ ->withHeader(
887
+ 'User-Agent',
888
+ sprintf(
889
+ '%s %s%s',
890
+ $this->config['application_name'],
891
+ self::USER_AGENT_SUFFIX,
892
+ $this->getLibraryVersion()
893
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
894
  )
895
+ ->withHeader(
896
+ 'x-goog-api-client',
897
+ sprintf(
898
+ 'gl-php/%s gdcl/%s',
899
+ phpversion(),
900
+ $this->getLibraryVersion()
901
+ )
902
+ );
903
+
904
+ if ($this->config['api_format_v2']) {
905
+ $request = $request->withHeader(
906
+ 'X-GOOG-API-FORMAT-VERSION',
907
+ '2'
908
+ );
909
+ }
910
+
911
+ // call the authorize method
912
+ // this is where most of the grunt work is done
913
+ $http = $this->authorize();
914
+
915
+ return REST::execute(
916
+ $http,
917
+ $request,
918
+ $expectedClass,
919
+ $this->config['retry'],
920
+ $this->config['retry_map']
921
  );
922
+ }
923
+
924
+ /**
925
+ * Declare whether batch calls should be used. This may increase throughput
926
+ * by making multiple requests in one connection.
927
+ *
928
+ * @param boolean $useBatch True if the batch support should
929
+ * be enabled. Defaults to False.
930
+ */
931
+ public function setUseBatch($useBatch)
932
+ {
933
+ // This is actually an alias for setDefer.
934
+ $this->setDefer($useBatch);
935
+ }
936
+
937
+ /**
938
+ * Are we running in Google AppEngine?
939
+ * return bool
940
+ */
941
+ public function isAppEngine()
942
+ {
943
+ return (isset($_SERVER['SERVER_SOFTWARE']) &&
944
+ strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false);
945
+ }
946
+
947
+ public function setConfig($name, $value)
948
+ {
949
+ $this->config[$name] = $value;
950
+ }
951
+
952
+ public function getConfig($name, $default = null)
953
+ {
954
+ return isset($this->config[$name]) ? $this->config[$name] : $default;
955
+ }
956
+
957
+ /**
958
+ * For backwards compatibility
959
+ * alias for setAuthConfig
960
+ *
961
+ * @param string $file the configuration file
962
+ * @throws \Google\Exception
963
+ * @deprecated
964
+ */
965
+ public function setAuthConfigFile($file)
966
+ {
967
+ $this->setAuthConfig($file);
968
+ }
969
+
970
+ /**
971
+ * Set the auth config from new or deprecated JSON config.
972
+ * This structure should match the file downloaded from
973
+ * the "Download JSON" button on in the Google Developer
974
+ * Console.
975
+ * @param string|array $config the configuration json
976
+ * @throws \Google\Exception
977
+ */
978
+ public function setAuthConfig($config)
979
+ {
980
+ if (is_string($config)) {
981
+ if (!file_exists($config)) {
982
+ throw new InvalidArgumentException(sprintf('file "%s" does not exist', $config));
983
+ }
984
+
985
+ $json = file_get_contents($config);
986
+
987
+ if (!$config = json_decode($json, true)) {
988
+ throw new LogicException('invalid json for auth config');
989
+ }
990
+ }
991
+
992
+ $key = isset($config['installed']) ? 'installed' : 'web';
993
+ if (isset($config['type']) && $config['type'] == 'service_account') {
994
+ // application default credentials
995
+ $this->useApplicationDefaultCredentials();
996
+
997
+ // set the information from the config
998
+ $this->setClientId($config['client_id']);
999
+ $this->config['client_email'] = $config['client_email'];
1000
+ $this->config['signing_key'] = $config['private_key'];
1001
+ $this->config['signing_algorithm'] = 'HS256';
1002
+ } elseif (isset($config[$key])) {
1003
+ // old-style
1004
+ $this->setClientId($config[$key]['client_id']);
1005
+ $this->setClientSecret($config[$key]['client_secret']);
1006
+ if (isset($config[$key]['redirect_uris'])) {
1007
+ $this->setRedirectUri($config[$key]['redirect_uris'][0]);
1008
+ }
1009
+ } else {
1010
+ // new-style
1011
+ $this->setClientId($config['client_id']);
1012
+ $this->setClientSecret($config['client_secret']);
1013
+ if (isset($config['redirect_uris'])) {
1014
+ $this->setRedirectUri($config['redirect_uris'][0]);
1015
+ }
1016
+ }
1017
+ }
1018
+
1019
+ /**
1020
+ * Use when the service account has been delegated domain wide access.
1021
+ *
1022
+ * @param string $subject an email address account to impersonate
1023
+ */
1024
+ public function setSubject($subject)
1025
+ {
1026
+ $this->config['subject'] = $subject;
1027
+ }
1028
+
1029
+ /**
1030
+ * Declare whether making API calls should make the call immediately, or
1031
+ * return a request which can be called with ->execute();
1032
+ *
1033
+ * @param boolean $defer True if calls should not be executed right away.
1034
+ */
1035
+ public function setDefer($defer)
1036
+ {
1037
+ $this->deferExecution = $defer;
1038
+ }
1039
+
1040
+ /**
1041
+ * Whether or not to return raw requests
1042
+ * @return boolean
1043
+ */
1044
+ public function shouldDefer()
1045
+ {
1046
+ return $this->deferExecution;
1047
+ }
1048
+
1049
+ /**
1050
+ * @return OAuth2 implementation
1051
+ */
1052
+ public function getOAuth2Service()
1053
+ {
1054
+ if (!isset($this->auth)) {
1055
+ $this->auth = $this->createOAuth2Service();
1056
+ }
1057
+
1058
+ return $this->auth;
1059
+ }
1060
+
1061
+ /**
1062
+ * create a default google auth object
1063
+ */
1064
+ protected function createOAuth2Service()
1065
+ {
1066
+ $auth = new OAuth2([
1067
+ 'clientId' => $this->getClientId(),
1068
+ 'clientSecret' => $this->getClientSecret(),
1069
+ 'authorizationUri' => self::OAUTH2_AUTH_URL,
1070
+ 'tokenCredentialUri' => self::OAUTH2_TOKEN_URI,
1071
+ 'redirectUri' => $this->getRedirectUri(),
1072
+ 'issuer' => $this->config['client_id'],
1073
+ 'signingKey' => $this->config['signing_key'],
1074
+ 'signingAlgorithm' => $this->config['signing_algorithm'],
1075
+ ]);
1076
+
1077
+ return $auth;
1078
+ }
1079
+
1080
+ /**
1081
+ * Set the Cache object
1082
+ * @param CacheItemPoolInterface $cache
1083
+ */
1084
+ public function setCache(CacheItemPoolInterface $cache)
1085
+ {
1086
+ $this->cache = $cache;
1087
+ }
1088
+
1089
+ /**
1090
+ * @return CacheItemPoolInterface
1091
+ */
1092
+ public function getCache()
1093
+ {
1094
+ if (!$this->cache) {
1095
+ $this->cache = $this->createDefaultCache();
1096
+ }
1097
+
1098
+ return $this->cache;
1099
+ }
1100
+
1101
+ /**
1102
+ * @param array $cacheConfig
1103
+ */
1104
+ public function setCacheConfig(array $cacheConfig)
1105
+ {
1106
+ $this->config['cache_config'] = $cacheConfig;
1107
+ }
1108
+
1109
+ /**
1110
+ * Set the Logger object
1111
+ * @param LoggerInterface $logger
1112
+ */
1113
+ public function setLogger(LoggerInterface $logger)
1114
+ {
1115
+ $this->logger = $logger;
1116
+ }
1117
+
1118
+ /**
1119
+ * @return LoggerInterface
1120
+ */
1121
+ public function getLogger()
1122
+ {
1123
+ if (!isset($this->logger)) {
1124
+ $this->logger = $this->createDefaultLogger();
1125
+ }
1126
+
1127
+ return $this->logger;
1128
+ }
1129
+
1130
+ protected function createDefaultLogger()
1131
+ {
1132
+ $logger = new Logger('google-api-php-client');
1133
+ if ($this->isAppEngine()) {
1134
+ $handler = new MonologSyslogHandler('app', LOG_USER, Logger::NOTICE);
1135
+ } else {
1136
+ $handler = new MonologStreamHandler('php://stderr', Logger::NOTICE);
1137
+ }
1138
+ $logger->pushHandler($handler);
1139
+
1140
+ return $logger;
1141
+ }
1142
+
1143
+ protected function createDefaultCache()
1144
+ {
1145
+ return new MemoryCacheItemPool();
1146
+ }
1147
+
1148
+ /**
1149
+ * Set the Http Client object
1150
+ * @param ClientInterface $http
1151
+ */
1152
+ public function setHttpClient(ClientInterface $http)
1153
+ {
1154
+ $this->http = $http;
1155
+ }
1156
+
1157
+ /**
1158
+ * @return ClientInterface
1159
+ */
1160
+ public function getHttpClient()
1161
+ {
1162
+ if (null === $this->http) {
1163
+ $this->http = $this->createDefaultHttpClient();
1164
+ }
1165
+
1166
+ return $this->http;
1167
+ }
1168
+
1169
+ /**
1170
+ * Set the API format version.
1171
+ *
1172
+ * `true` will use V2, which may return more useful error messages.
1173
+ *
1174
+ * @param bool $value
1175
+ */
1176
+ public function setApiFormatV2($value)
1177
+ {
1178
+ $this->config['api_format_v2'] = (bool) $value;
1179
+ }
1180
+
1181
+ protected function createDefaultHttpClient()
1182
+ {
1183
+ $guzzleVersion = null;
1184
+ if (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
1185
+ $guzzleVersion = ClientInterface::MAJOR_VERSION;
1186
+ } elseif (defined('\GuzzleHttp\ClientInterface::VERSION')) {
1187
+ // @phpstan-ignore-next-line
1188
+ $guzzleVersion = (int)substr(ClientInterface::VERSION, 0, 1);
1189
+ }
1190
 
1191
+ if (5 === $guzzleVersion) {
1192
+ $options = [
1193
+ 'base_url' => $this->config['base_path'],
1194
+ 'defaults' => ['exceptions' => false],
1195
+ ];
1196
+ if ($this->isAppEngine()) {
1197
+ if (class_exists(StreamHandler::class)) {
1198
+ // set StreamHandler on AppEngine by default
1199
+ $options['handler'] = new StreamHandler();
1200
+ $options['defaults']['verify'] = '/etc/ca-certificates.crt';
1201
+ }
1202
+ }
1203
+ } elseif (6 === $guzzleVersion || 7 === $guzzleVersion) {
1204
+ // guzzle 6 or 7
1205
+ $options = [
1206
+ 'base_uri' => $this->config['base_path'],
1207
+ 'http_errors' => false,
1208
+ ];
1209
+ } else {
1210
+ throw new LogicException('Could not find supported version of Guzzle.');
1211
+ }
1212
+
1213
+ return new GuzzleClient($options);
1214
+ }
1215
+
1216
+ /**
1217
+ * @return FetchAuthTokenCache
1218
+ */
1219
+ private function createApplicationDefaultCredentials()
1220
+ {
1221
+ $scopes = $this->prepareScopes();
1222
+ $sub = $this->config['subject'];
1223
+ $signingKey = $this->config['signing_key'];
1224
+
1225
+ // create credentials using values supplied in setAuthConfig
1226
+ if ($signingKey) {
1227
+ $serviceAccountCredentials = [
1228
+ 'client_id' => $this->config['client_id'],
1229
+ 'client_email' => $this->config['client_email'],
1230
+ 'private_key' => $signingKey,
1231
+ 'type' => 'service_account',
1232
+ 'quota_project_id' => $this->config['quota_project'],
1233
+ ];
1234
+ $credentials = CredentialsLoader::makeCredentials(
1235
+ $scopes,
1236
+ $serviceAccountCredentials
1237
+ );
1238
+ } else {
1239
+ // When $sub is provided, we cannot pass cache classes to ::getCredentials
1240
+ // because FetchAuthTokenCache::setSub does not exist.
1241
+ // The result is when $sub is provided, calls to ::onGce are not cached.
1242
+ $credentials = ApplicationDefaultCredentials::getCredentials(
1243
+ $scopes,
1244
+ null,
1245
+ $sub ? null : $this->config['cache_config'],
1246
+ $sub ? null : $this->getCache(),
1247
+ $this->config['quota_project']
1248
+ );
1249
+ }
1250
+
1251
+ // for service account domain-wide authority (impersonating a user)
1252
+ // @see https://developers.google.com/identity/protocols/OAuth2ServiceAccount
1253
+ if ($sub) {
1254
+ if (!$credentials instanceof ServiceAccountCredentials) {
1255
+ throw new DomainException('domain-wide authority requires service account credentials');
1256
+ }
1257
+
1258
+ $credentials->setSub($sub);
1259
+ }
1260
+
1261
+ // If we are not using FetchAuthTokenCache yet, create it now
1262
+ if (!$credentials instanceof FetchAuthTokenCache) {
1263
+ $credentials = new FetchAuthTokenCache(
1264
+ $credentials,
1265
+ $this->config['cache_config'],
1266
+ $this->getCache()
1267
+ );
1268
+ }
1269
+ return $credentials;
1270
+ }
1271
+
1272
+ protected function getAuthHandler()
1273
+ {
1274
+ // Be very careful using the cache, as the underlying auth library's cache
1275
+ // implementation is naive, and the cache keys do not account for user
1276
+ // sessions.
1277
+ //
1278
+ // @see https://github.com/google/google-api-php-client/issues/821
1279
+ return AuthHandlerFactory::build(
1280
+ $this->getCache(),
1281
+ $this->config['cache_config']
1282
  );
1283
  }
1284
 
1285
+ private function createUserRefreshCredentials($scope, $refreshToken)
1286
+ {
1287
+ $creds = array_filter([
1288
+ 'client_id' => $this->getClientId(),
1289
+ 'client_secret' => $this->getClientSecret(),
1290
+ 'refresh_token' => $refreshToken,
1291
+ ]);
1292
+
1293
+ return new UserRefreshCredentials($scope, $creds);
1294
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1295
  }
vendor/google/apiclient/src/Collection.php CHANGED
@@ -9,90 +9,113 @@ namespace Google;
9
  */
10
  class Collection extends Model implements \Iterator, \Countable
11
  {
12
- protected $collection_key = 'items';
13
 
14
- public function rewind()
15
- {
16
- if (isset($this->{$this->collection_key})
17
- && is_array($this->{$this->collection_key})) {
18
- reset($this->{$this->collection_key});
 
 
 
 
 
19
  }
20
- }
21
 
22
- public function current()
23
- {
24
- $this->coerceType($this->key());
25
- if (is_array($this->{$this->collection_key})) {
26
- return current($this->{$this->collection_key});
 
 
 
27
  }
28
- }
29
 
30
- public function key()
31
- {
32
- if (isset($this->{$this->collection_key})
33
- && is_array($this->{$this->collection_key})) {
34
- return key($this->{$this->collection_key});
 
 
 
 
 
35
  }
36
- }
37
 
38
- public function next()
39
- {
40
- return next($this->{$this->collection_key});
41
- }
 
 
42
 
43
- public function valid()
44
- {
45
- $key = $this->key();
46
- return $key !== null && $key !== false;
47
- }
 
 
48
 
49
- public function count()
50
- {
51
- if (!isset($this->{$this->collection_key})) {
52
- return 0;
 
 
 
 
53
  }
54
- return count($this->{$this->collection_key});
55
- }
56
 
57
- public function offsetExists($offset)
58
- {
59
- if (!is_numeric($offset)) {
60
- return parent::offsetExists($offset);
 
 
 
 
61
  }
62
- return isset($this->{$this->collection_key}[$offset]);
63
- }
64
 
65
- public function offsetGet($offset)
66
- {
67
- if (!is_numeric($offset)) {
68
- return parent::offsetGet($offset);
 
 
 
 
69
  }
70
- $this->coerceType($offset);
71
- return $this->{$this->collection_key}[$offset];
72
- }
73
 
74
- public function offsetSet($offset, $value)
75
- {
76
- if (!is_numeric($offset)) {
77
- return parent::offsetSet($offset, $value);
 
 
 
 
78
  }
79
- $this->{$this->collection_key}[$offset] = $value;
80
- }
81
 
82
- public function offsetUnset($offset)
83
- {
84
- if (!is_numeric($offset)) {
85
- return parent::offsetUnset($offset);
 
 
 
 
86
  }
87
- unset($this->{$this->collection_key}[$offset]);
88
- }
89
 
90
- private function coerceType($offset)
91
- {
92
- $keyType = $this->keyType($this->collection_key);
93
- if ($keyType && !is_object($this->{$this->collection_key}[$offset])) {
94
- $this->{$this->collection_key}[$offset] =
95
- new $keyType($this->{$this->collection_key}[$offset]);
 
96
  }
97
- }
98
  }
9
  */
10
  class Collection extends Model implements \Iterator, \Countable
11
  {
12
+ protected $collection_key = 'items';
13
 
14
+ /** @return void */
15
+ #[\ReturnTypeWillChange]
16
+ public function rewind()
17
+ {
18
+ if (
19
+ isset($this->{$this->collection_key})
20
+ && is_array($this->{$this->collection_key})
21
+ ) {
22
+ reset($this->{$this->collection_key});
23
+ }
24
  }
 
25
 
26
+ /** @return mixed */
27
+ #[\ReturnTypeWillChange]
28
+ public function current()
29
+ {
30
+ $this->coerceType($this->key());
31
+ if (is_array($this->{$this->collection_key})) {
32
+ return current($this->{$this->collection_key});
33
+ }
34
  }
 
35
 
36
+ /** @return mixed */
37
+ #[\ReturnTypeWillChange]
38
+ public function key()
39
+ {
40
+ if (
41
+ isset($this->{$this->collection_key})
42
+ && is_array($this->{$this->collection_key})
43
+ ) {
44
+ return key($this->{$this->collection_key});
45
+ }
46
  }
 
47
 
48
+ /** @return mixed */
49
+ #[\ReturnTypeWillChange]
50
+ public function next()
51
+ {
52
+ return next($this->{$this->collection_key});
53
+ }
54
 
55
+ /** @return bool */
56
+ #[\ReturnTypeWillChange]
57
+ public function valid()
58
+ {
59
+ $key = $this->key();
60
+ return $key !== null && $key !== false;
61
+ }
62
 
63
+ /** @return int */
64
+ #[\ReturnTypeWillChange]
65
+ public function count()
66
+ {
67
+ if (!isset($this->{$this->collection_key})) {
68
+ return 0;
69
+ }
70
+ return count($this->{$this->collection_key});
71
  }
 
 
72
 
73
+ /** @return bool */
74
+ #[\ReturnTypeWillChange]
75
+ public function offsetExists($offset)
76
+ {
77
+ if (!is_numeric($offset)) {
78
+ return parent::offsetExists($offset);
79
+ }
80
+ return isset($this->{$this->collection_key}[$offset]);
81
  }
 
 
82
 
83
+ /** @return mixed */
84
+ public function offsetGet($offset)
85
+ {
86
+ if (!is_numeric($offset)) {
87
+ return parent::offsetGet($offset);
88
+ }
89
+ $this->coerceType($offset);
90
+ return $this->{$this->collection_key}[$offset];
91
  }
 
 
 
92
 
93
+ /** @return void */
94
+ #[\ReturnTypeWillChange]
95
+ public function offsetSet($offset, $value)
96
+ {
97
+ if (!is_numeric($offset)) {
98
+ parent::offsetSet($offset, $value);
99
+ }
100
+ $this->{$this->collection_key}[$offset] = $value;
101
  }
 
 
102
 
103
+ /** @return void */
104
+ #[\ReturnTypeWillChange]
105
+ public function offsetUnset($offset)
106
+ {
107
+ if (!is_numeric($offset)) {
108
+ parent::offsetUnset($offset);
109
+ }
110
+ unset($this->{$this->collection_key}[$offset]);
111
  }
 
 
112
 
113
+ private function coerceType($offset)
114
+ {
115
+ $keyType = $this->keyType($this->collection_key);
116
+ if ($keyType && !is_object($this->{$this->collection_key}[$offset])) {
117
+ $this->{$this->collection_key}[$offset] =
118
+ new $keyType($this->{$this->collection_key}[$offset]);
119
+ }
120
  }
 
121
  }
vendor/google/apiclient/src/Http/Batch.php CHANGED
@@ -18,7 +18,6 @@
18
  namespace Google\Http;
19
 
20
  use Google\Client;
21
- use Google\Http\REST;
22
  use Google\Service\Exception as GoogleServiceException;
23
  use GuzzleHttp\Psr7;
24
  use GuzzleHttp\Psr7\Request;
@@ -35,52 +34,52 @@ use Psr\Http\Message\ResponseInterface;
35
  */
36
  class Batch
37
  {
38
- const BATCH_PATH = 'batch';
39
-
40
- private static $CONNECTION_ESTABLISHED_HEADERS = array(
41
- "HTTP/1.0 200 Connection established\r\n\r\n",
42
- "HTTP/1.1 200 Connection established\r\n\r\n",
43
- );
44
-
45
- /** @var string Multipart Boundary. */
46
- private $boundary;
47
-
48
- /** @var array service requests to be executed. */
49
- private $requests = array();
50
-
51
- /** @var Client */
52
- private $client;
53
-
54
- private $rootUrl;
55
-
56
- private $batchPath;
57
-
58
- public function __construct(
59
- Client $client,
60
- $boundary = false,
61
- $rootUrl = null,
62
- $batchPath = null
63
- ) {
64
- $this->client = $client;
65
- $this->boundary = $boundary ?: mt_rand();
66
- $this->rootUrl = rtrim($rootUrl ?: $this->client->getConfig('base_path'), '/');
67
- $this->batchPath = $batchPath ?: self::BATCH_PATH;
68
- }
69
-
70
- public function add(RequestInterface $request, $key = false)
71
- {
72
- if (false == $key) {
73
- $key = mt_rand();
74
  }
75
 
76
- $this->requests[$key] = $request;
77
- }
 
 
 
 
 
 
78
 
79
- public function execute()
80
- {
81
- $body = '';
82
- $classes = array();
83
- $batchHttpTemplate = <<<EOF
84
  --%s
85
  Content-Type: application/http
86
  Content-Transfer-Encoding: binary
@@ -93,166 +92,165 @@ Content-ID: %s
93
 
94
  EOF;
95
 
96
- /** @var RequestInterface $req */
97
- foreach ($this->requests as $key => $request) {
98
- $firstLine = sprintf(
99
- '%s %s HTTP/%s',
100
- $request->getMethod(),
101
- $request->getRequestTarget(),
102
- $request->getProtocolVersion()
103
- );
104
-
105
- $content = (string) $request->getBody();
106
-
107
- $headers = '';
108
- foreach ($request->getHeaders() as $name => $values) {
109
- $headers .= sprintf("%s:%s\r\n", $name, implode(', ', $values));
110
- }
111
-
112
- $body .= sprintf(
113
- $batchHttpTemplate,
114
- $this->boundary,
115
- $key,
116
- $firstLine,
117
- $headers,
118
- $content ? "\n".$content : ''
119
- );
120
-
121
- $classes['response-' . $key] = $request->getHeaderLine('X-Php-Expected-Class');
122
- }
 
 
 
 
 
 
 
 
123
 
124
- $body .= "--{$this->boundary}--";
125
- $body = trim($body);
126
- $url = $this->rootUrl . '/' . $this->batchPath;
127
- $headers = array(
128
- 'Content-Type' => sprintf('multipart/mixed; boundary=%s', $this->boundary),
129
- 'Content-Length' => strlen($body),
130
- );
131
-
132
- $request = new Request(
133
- 'POST',
134
- $url,
135
- $headers,
136
- $body
137
- );
138
-
139
- $response = $this->client->execute($request);
140
-
141
- return $this->parseResponse($response, $classes);
142
- }
143
-
144
- public function parseResponse(ResponseInterface $response, $classes = array())
145
- {
146
- $contentType = $response->getHeaderLine('content-type');
147
- $contentType = explode(';', $contentType);
148
- $boundary = false;
149
- foreach ($contentType as $part) {
150
- $part = explode('=', $part, 2);
151
- if (isset($part[0]) && 'boundary' == trim($part[0])) {
152
- $boundary = $part[1];
153
- }
154
  }
155
 
156
- $body = (string) $response->getBody();
157
- if (!empty($body)) {
158
- $body = str_replace("--$boundary--", "--$boundary", $body);
159
- $parts = explode("--$boundary", $body);
160
- $responses = array();
161
- $requests = array_values($this->requests);
162
-
163
- foreach ($parts as $i => $part) {
164
- $part = trim($part);
165
- if (!empty($part)) {
166
- list($rawHeaders, $part) = explode("\r\n\r\n", $part, 2);
167
- $headers = $this->parseRawHeaders($rawHeaders);
168
-
169
- $status = substr($part, 0, strpos($part, "\n"));
170
- $status = explode(" ", $status);
171
- $status = $status[1];
172
-
173
- list($partHeaders, $partBody) = $this->parseHttpResponse($part, false);
174
- $response = new Response(
175
- $status,
176
- $partHeaders,
177
- Psr7\stream_for($partBody)
178
- );
179
-
180
- // Need content id.
181
- $key = $headers['content-id'];
182
-
183
- try {
184
- $response = REST::decodeHttpResponse($response, $requests[$i-1]);
185
- } catch (GoogleServiceException $e) {
186
- // Store the exception as the response, so successful responses
187
- // can be processed.
188
- $response = $e;
189
- }
190
-
191
- $responses[$key] = $response;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  }
193
- }
194
 
195
- return $responses;
196
  }
197
 
198
- return null;
199
- }
200
-
201
- private function parseRawHeaders($rawHeaders)
202
- {
203
- $headers = array();
204
- $responseHeaderLines = explode("\r\n", $rawHeaders);
205
- foreach ($responseHeaderLines as $headerLine) {
206
- if ($headerLine && strpos($headerLine, ':') !== false) {
207
- list($header, $value) = explode(': ', $headerLine, 2);
208
- $header = strtolower($header);
209
- if (isset($headers[$header])) {
210
- $headers[$header] .= "\n" . $value;
211
- } else {
212
- $headers[$header] = $value;
213
  }
214
- }
215
- }
216
- return $headers;
217
- }
218
-
219
- /**
220
- * Used by the IO lib and also the batch processing.
221
- *
222
- * @param $respData
223
- * @param $headerSize
224
- * @return array
225
- */
226
- private function parseHttpResponse($respData, $headerSize)
227
- {
228
- // check proxy header
229
- foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) {
230
- if (stripos($respData, $established_header) !== false) {
231
- // existed, remove it
232
- $respData = str_ireplace($established_header, '', $respData);
233
- // Subtract the proxy header size unless the cURL bug prior to 7.30.0
234
- // is present which prevented the proxy header size from being taken into
235
- // account.
236
- // @TODO look into this
237
- // if (!$this->needsQuirk()) {
238
- // $headerSize -= strlen($established_header);
239
- // }
240
- break;
241
- }
242
  }
243
 
244
- if ($headerSize) {
245
- $responseBody = substr($respData, $headerSize);
246
- $responseHeaders = substr($respData, 0, $headerSize);
247
- } else {
248
- $responseSegments = explode("\r\n\r\n", $respData, 2);
249
- $responseHeaders = $responseSegments[0];
250
- $responseBody = isset($responseSegments[1]) ? $responseSegments[1] :
251
- null;
252
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
 
254
- $responseHeaders = $this->parseRawHeaders($responseHeaders);
255
 
256
- return array($responseHeaders, $responseBody);
257
- }
258
  }
18
  namespace Google\Http;
19
 
20
  use Google\Client;
 
21
  use Google\Service\Exception as GoogleServiceException;
22
  use GuzzleHttp\Psr7;
23
  use GuzzleHttp\Psr7\Request;
34
  */
35
  class Batch
36
  {
37
+ const BATCH_PATH = 'batch';
38
+
39
+ private static $CONNECTION_ESTABLISHED_HEADERS = [
40
+ "HTTP/1.0 200 Connection established\r\n\r\n",
41
+ "HTTP/1.1 200 Connection established\r\n\r\n",
42
+ ];
43
+
44
+ /** @var string Multipart Boundary. */
45
+ private $boundary;
46
+
47
+ /** @var array service requests to be executed. */
48
+ private $requests = [];
49
+
50
+ /** @var Client */
51
+ private $client;
52
+
53
+ private $rootUrl;
54
+
55
+ private $batchPath;
56
+
57
+ public function __construct(
58
+ Client $client,
59
+ $boundary = false,
60
+ $rootUrl = null,
61
+ $batchPath = null
62
+ ) {
63
+ $this->client = $client;
64
+ $this->boundary = $boundary ?: mt_rand();
65
+ $this->rootUrl = rtrim($rootUrl ?: $this->client->getConfig('base_path'), '/');
66
+ $this->batchPath = $batchPath ?: self::BATCH_PATH;
 
 
 
 
 
 
67
  }
68
 
69
+ public function add(RequestInterface $request, $key = false)
70
+ {
71
+ if (false == $key) {
72
+ $key = mt_rand();
73
+ }
74
+
75
+ $this->requests[$key] = $request;
76
+ }
77
 
78
+ public function execute()
79
+ {
80
+ $body = '';
81
+ $classes = [];
82
+ $batchHttpTemplate = <<<EOF
83
  --%s
84
  Content-Type: application/http
85
  Content-Transfer-Encoding: binary
92
 
93
  EOF;
94
 
95
+ /** @var RequestInterface $request */
96
+ foreach ($this->requests as $key => $request) {
97
+ $firstLine = sprintf(
98
+ '%s %s HTTP/%s',
99
+ $request->getMethod(),
100
+ $request->getRequestTarget(),
101
+ $request->getProtocolVersion()
102
+ );
103
+
104
+ $content = (string) $request->getBody();
105
+
106
+ $headers = '';
107
+ foreach ($request->getHeaders() as $name => $values) {
108
+ $headers .= sprintf("%s:%s\r\n", $name, implode(', ', $values));
109
+ }
110
+
111
+ $body .= sprintf(
112
+ $batchHttpTemplate,
113
+ $this->boundary,
114
+ $key,
115
+ $firstLine,
116
+ $headers,
117
+ $content ? "\n" . $content : ''
118
+ );
119
+
120
+ $classes['response-' . $key] = $request->getHeaderLine('X-Php-Expected-Class');
121
+ }
122
+
123
+ $body .= "--{$this->boundary}--";
124
+ $body = trim($body);
125
+ $url = $this->rootUrl . '/' . $this->batchPath;
126
+ $headers = [
127
+ 'Content-Type' => sprintf('multipart/mixed; boundary=%s', $this->boundary),
128
+ 'Content-Length' => (string) strlen($body),
129
+ ];
130
 
131
+ $request = new Request(
132
+ 'POST',
133
+ $url,
134
+ $headers,
135
+ $body
136
+ );
137
+
138
+ $response = $this->client->execute($request);
139
+
140
+ return $this->parseResponse($response, $classes);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
 
143
+ public function parseResponse(ResponseInterface $response, $classes = [])
144
+ {
145
+ $contentType = $response->getHeaderLine('content-type');
146
+ $contentType = explode(';', $contentType);
147
+ $boundary = false;
148
+ foreach ($contentType as $part) {
149
+ $part = explode('=', $part, 2);
150
+ if (isset($part[0]) && 'boundary' == trim($part[0])) {
151
+ $boundary = $part[1];
152
+ }
153
+ }
154
+
155
+ $body = (string) $response->getBody();
156
+ if (!empty($body)) {
157
+ $body = str_replace("--$boundary--", "--$boundary", $body);
158
+ $parts = explode("--$boundary", $body);
159
+ $responses = [];
160
+ $requests = array_values($this->requests);
161
+
162
+ foreach ($parts as $i => $part) {
163
+ $part = trim($part);
164
+ if (!empty($part)) {
165
+ list($rawHeaders, $part) = explode("\r\n\r\n", $part, 2);
166
+ $headers = $this->parseRawHeaders($rawHeaders);
167
+
168
+ $status = substr($part, 0, strpos($part, "\n"));
169
+ $status = explode(" ", $status);
170
+ $status = $status[1];
171
+
172
+ list($partHeaders, $partBody) = $this->parseHttpResponse($part, 0);
173
+ $response = new Response(
174
+ (int) $status,
175
+ $partHeaders,
176
+ Psr7\Utils::streamFor($partBody)
177
+ );
178
+
179
+ // Need content id.
180
+ $key = $headers['content-id'];
181
+
182
+ try {
183
+ $response = REST::decodeHttpResponse($response, $requests[$i-1]);
184
+ } catch (GoogleServiceException $e) {
185
+ // Store the exception as the response, so successful responses
186
+ // can be processed.
187
+ $response = $e;
188
+ }
189
+
190
+ $responses[$key] = $response;
191
+ }
192
+ }
193
+
194
+ return $responses;
195
  }
 
196
 
197
+ return null;
198
  }
199
 
200
+ private function parseRawHeaders($rawHeaders)
201
+ {
202
+ $headers = [];
203
+ $responseHeaderLines = explode("\r\n", $rawHeaders);
204
+ foreach ($responseHeaderLines as $headerLine) {
205
+ if ($headerLine && strpos($headerLine, ':') !== false) {
206
+ list($header, $value) = explode(': ', $headerLine, 2);
207
+ $header = strtolower($header);
208
+ if (isset($headers[$header])) {
209
+ $headers[$header] = array_merge((array)$headers[$header], (array)$value);
210
+ } else {
211
+ $headers[$header] = $value;
212
+ }
213
+ }
 
214
  }
215
+ return $headers;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  }
217
 
218
+ /**
219
+ * Used by the IO lib and also the batch processing.
220
+ *
221
+ * @param string $respData
222
+ * @param int $headerSize
223
+ * @return array
224
+ */
225
+ private function parseHttpResponse($respData, $headerSize)
226
+ {
227
+ // check proxy header
228
+ foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) {
229
+ if (stripos($respData, $established_header) !== false) {
230
+ // existed, remove it
231
+ $respData = str_ireplace($established_header, '', $respData);
232
+ // Subtract the proxy header size unless the cURL bug prior to 7.30.0
233
+ // is present which prevented the proxy header size from being taken into
234
+ // account.
235
+ // @TODO look into this
236
+ // if (!$this->needsQuirk()) {
237
+ // $headerSize -= strlen($established_header);
238
+ // }
239
+ break;
240
+ }
241
+ }
242
+
243
+ if ($headerSize) {
244
+ $responseBody = substr($respData, $headerSize);
245
+ $responseHeaders = substr($respData, 0, $headerSize);
246
+ } else {
247
+ $responseSegments = explode("\r\n\r\n", $respData, 2);
248
+ $responseHeaders = $responseSegments[0];
249
+ $responseBody = isset($responseSegments[1]) ? $responseSegments[1] : null;
250
+ }
251
 
252
+ $responseHeaders = $this->parseRawHeaders($responseHeaders);
253
 
254
+ return [$responseHeaders, $responseBody];
255
+ }
256
  }
vendor/google/apiclient/src/Http/MediaFileUpload.php CHANGED
@@ -18,7 +18,6 @@
18
  namespace Google\Http;
19
 
20
  use Google\Client;
21
- use Google\Http\REST;
22
  use Google\Exception as GoogleException;
23
  use GuzzleHttp\Psr7;
24
  use GuzzleHttp\Psr7\Request;
@@ -31,328 +30,324 @@ use Psr\Http\Message\RequestInterface;
31
  */
32
  class MediaFileUpload
33
  {
34
- const UPLOAD_MEDIA_TYPE = 'media';
35
- const UPLOAD_MULTIPART_TYPE = 'multipart';
36
- const UPLOAD_RESUMABLE_TYPE = 'resumable';
37
 
38
- /** @var string $mimeType */
39
- private $mimeType;
40
 
41
- /** @var string $data */
42
- private $data;
43
 
44
- /** @var bool $resumable */
45
- private $resumable;
46
 
47
- /** @var int $chunkSize */
48
- private $chunkSize;
49
 
50
- /** @var int $size */
51
- private $size;
52
 
53
- /** @var string $resumeUri */
54
- private $resumeUri;
55
 
56
- /** @var int $progress */
57
- private $progress;
58
 
59
- /** @var Client */
60
- private $client;
61
 
62
- /** @var RequestInterface */
63
- private $request;
64
 
65
- /** @var string */
66
- private $boundary;
67
 
68
- /**
69
  * Result code from last HTTP call
70
  * @var int
71
  */
72
- private $httpResultCode;
73
-
74
- /**
75
- * @param Client $client
76
- * @param RequestInterface $request
77
- * @param string $mimeType
78
- * @param string $data The bytes you want to upload.
79
- * @param bool $resumable
80
- * @param bool $chunkSize File will be uploaded in chunks of this many bytes.
81
- * only used if resumable=True
82
- */
83
- public function __construct(
84
- Client $client,
85
- RequestInterface $request,
86
- $mimeType,
87
- $data,
88
- $resumable = false,
89
- $chunkSize = false
90
- ) {
91
- $this->client = $client;
92
- $this->request = $request;
93
- $this->mimeType = $mimeType;
94
- $this->data = $data;
95
- $this->resumable = $resumable;
96
- $this->chunkSize = $chunkSize;
97
- $this->progress = 0;
98
-
99
- $this->process();
100
- }
101
-
102
- /**
103
- * Set the size of the file that is being uploaded.
104
- * @param $size - int file size in bytes
105
- */
106
- public function setFileSize($size)
107
- {
108
- $this->size = $size;
109
- }
110
-
111
- /**
112
- * Return the progress on the upload
113
- * @return int progress in bytes uploaded.
114
- */
115
- public function getProgress()
116
- {
117
- return $this->progress;
118
- }
119
-
120
- /**
121
- * Send the next part of the file to upload.
122
- * @param string|bool $chunk Optional. The next set of bytes to send. If false will
123
- * use $data passed at construct time.
124
- */
125
- public function nextChunk($chunk = false)
126
- {
127
- $resumeUri = $this->getResumeUri();
128
-
129
- if (false == $chunk) {
130
- $chunk = substr($this->data, $this->progress, $this->chunkSize);
131
  }
132
 
133
- $lastBytePos = $this->progress + strlen($chunk) - 1;
134
- $headers = array(
135
- 'content-range' => "bytes $this->progress-$lastBytePos/$this->size",
136
- 'content-length' => strlen($chunk),
137
- 'expect' => '',
138
- );
139
-
140
- $request = new Request(
141
- 'PUT',
142
- $resumeUri,
143
- $headers,
144
- Psr7\stream_for($chunk)
145
- );
146
-
147
- return $this->makePutRequest($request);
148
- }
149
-
150
- /**
151
- * Return the HTTP result code from the last call made.
152
- * @return int code
153
- */
154
- public function getHttpResultCode()
155
- {
156
- return $this->httpResultCode;
157
- }
158
-
159
- /**
160
- * Sends a PUT-Request to google drive and parses the response,
161
- * setting the appropiate variables from the response()
162
- *
163
- * @param RequestInterface $request the Request which will be send
164
- *
165
- * @return false|mixed false when the upload is unfinished or the decoded http response
166
- *
167
- */
168
- private function makePutRequest(RequestInterface $request)
169
- {
170
- $response = $this->client->execute($request);
171
- $this->httpResultCode = $response->getStatusCode();
172
-
173
- if (308 == $this->httpResultCode) {
174
- // Track the amount uploaded.
175
- $range = $response->getHeaderLine('range');
176
- if ($range) {
177
- $range_array = explode('-', $range);
178
- $this->progress = $range_array[1] + 1;
179
- }
180
-
181
- // Allow for changing upload URLs.
182
- $location = $response->getHeaderLine('location');
183
- if ($location) {
184
- $this->resumeUri = $location;
185
- }
186
-
187
- // No problems, but upload not complete.
188
- return false;
189
  }
190
 
191
- return REST::decodeHttpResponse($response, $this->request);
192
- }
193
-
194
- /**
195
- * Resume a previously unfinished upload
196
- * @param $resumeUri the resume-URI of the unfinished, resumable upload.
197
- */
198
- public function resume($resumeUri)
199
- {
200
- $this->resumeUri = $resumeUri;
201
- $headers = array(
202
- 'content-range' => "bytes */$this->size",
203
- 'content-length' => 0,
204
- );
205
- $httpRequest = new Request(
206
- 'PUT',
207
- $this->resumeUri,
208
- $headers
209
- );
210
-
211
- return $this->makePutRequest($httpRequest);
212
- }
213
-
214
- /**
215
- * @return RequestInterface
216
- * @visible for testing
217
- */
218
- private function process()
219
- {
220
- $this->transformToUploadUrl();
221
- $request = $this->request;
222
-
223
- $postBody = '';
224
- $contentType = false;
225
-
226
- $meta = (string) $request->getBody();
227
- $meta = is_string($meta) ? json_decode($meta, true) : $meta;
228
-
229
- $uploadType = $this->getUploadType($meta);
230
- $request = $request->withUri(
231
- Uri::withQueryValue($request->getUri(), 'uploadType', $uploadType)
232
- );
233
-
234
- $mimeType = $this->mimeType ?: $request->getHeaderLine('content-type');
235
-
236
- if (self::UPLOAD_RESUMABLE_TYPE == $uploadType) {
237
- $contentType = $mimeType;
238
- $postBody = is_string($meta) ? $meta : json_encode($meta);
239
- } else if (self::UPLOAD_MEDIA_TYPE == $uploadType) {
240
- $contentType = $mimeType;
241
- $postBody = $this->data;
242
- } else if (self::UPLOAD_MULTIPART_TYPE == $uploadType) {
243
- // This is a multipart/related upload.
244
- $boundary = $this->boundary ?: mt_rand();
245
- $boundary = str_replace('"', '', $boundary);
246
- $contentType = 'multipart/related; boundary=' . $boundary;
247
- $related = "--$boundary\r\n";
248
- $related .= "Content-Type: application/json; charset=UTF-8\r\n";
249
- $related .= "\r\n" . json_encode($meta) . "\r\n";
250
- $related .= "--$boundary\r\n";
251
- $related .= "Content-Type: $mimeType\r\n";
252
- $related .= "Content-Transfer-Encoding: base64\r\n";
253
- $related .= "\r\n" . base64_encode($this->data) . "\r\n";
254
- $related .= "--$boundary--";
255
- $postBody = $related;
256
  }
257
 
258
- $request = $request->withBody(Psr7\stream_for($postBody));
259
-
260
- if (isset($contentType) && $contentType) {
261
- $request = $request->withHeader('content-type', $contentType);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  }
263
 
264
- return $this->request = $request;
265
- }
266
-
267
- /**
268
- * Valid upload types:
269
- * - resumable (UPLOAD_RESUMABLE_TYPE)
270
- * - media (UPLOAD_MEDIA_TYPE)
271
- * - multipart (UPLOAD_MULTIPART_TYPE)
272
- * @param $meta
273
- * @return string
274
- * @visible for testing
275
- */
276
- public function getUploadType($meta)
277
- {
278
- if ($this->resumable) {
279
- return self::UPLOAD_RESUMABLE_TYPE;
280
  }
281
 
282
- if (false == $meta && $this->data) {
283
- return self::UPLOAD_MEDIA_TYPE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  }
285
 
286
- return self::UPLOAD_MULTIPART_TYPE;
287
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
 
289
- public function getResumeUri()
290
- {
291
- if (null === $this->resumeUri) {
292
- $this->resumeUri = $this->fetchResumeUri();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  }
294
 
295
- return $this->resumeUri;
296
- }
297
-
298
- private function fetchResumeUri()
299
- {
300
- $body = $this->request->getBody();
301
- if ($body) {
302
- $headers = array(
303
- 'content-type' => 'application/json; charset=UTF-8',
304
- 'content-length' => $body->getSize(),
305
- 'x-upload-content-type' => $this->mimeType,
306
- 'x-upload-content-length' => $this->size,
307
- 'expect' => '',
308
- );
309
- foreach ($headers as $key => $value) {
310
- $this->request = $this->request->withHeader($key, $value);
311
- }
 
 
 
312
  }
313
 
314
- $response = $this->client->execute($this->request, false);
315
- $location = $response->getHeaderLine('location');
316
- $code = $response->getStatusCode();
 
 
317
 
318
- if (200 == $code && true == $location) {
319
- return $location;
320
  }
321
 
322
- $message = $code;
323
- $body = json_decode((string) $this->request->getBody(), true);
324
- if (isset($body['error']['errors'])) {
325
- $message .= ': ';
326
- foreach ($body['error']['errors'] as $error) {
327
- $message .= "{$error['domain']}, {$error['message']};";
328
- }
329
- $message = rtrim($message, ';');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  }
331
 
332
- $error = "Failed to start the resumable upload (HTTP {$message})";
333
- $this->client->getLogger()->error($error);
 
 
 
 
 
 
 
 
334
 
335
- throw new GoogleException($error);
336
- }
 
 
337
 
338
- private function transformToUploadUrl()
339
- {
340
- $parts = parse_url((string) $this->request->getUri());
341
- if (!isset($parts['path'])) {
342
- $parts['path'] = '';
343
  }
344
- $parts['path'] = '/upload' . $parts['path'];
345
- $uri = Uri::fromParts($parts);
346
- $this->request = $this->request->withUri($uri);
347
- }
348
-
349
- public function setChunkSize($chunkSize)
350
- {
351
- $this->chunkSize = $chunkSize;
352
- }
353
-
354
- public function getRequest()
355
- {
356
- return $this->request;
357
- }
358
  }
18
  namespace Google\Http;
19
 
20
  use Google\Client;
 
21
  use Google\Exception as GoogleException;
22
  use GuzzleHttp\Psr7;
23
  use GuzzleHttp\Psr7\Request;
30
  */
31
  class MediaFileUpload
32
  {
33
+ const UPLOAD_MEDIA_TYPE = 'media';
34
+ const UPLOAD_MULTIPART_TYPE = 'multipart';
35
+ const UPLOAD_RESUMABLE_TYPE = 'resumable';
36
 
37
+ /** @var string $mimeType */
38
+ private $mimeType;
39
 
40
+ /** @var string $data */
41
+ private $data;
42
 
43
+ /** @var bool $resumable */
44
+ private $resumable;
45
 
46
+ /** @var int $chunkSize */
47
+ private $chunkSize;
48
 
49
+ /** @var int $size */
50
+ private $size;
51
 
52
+ /** @var string $resumeUri */
53
+ private $resumeUri;
54
 
55
+ /** @var int $progress */
56
+ private $progress;
57
 
58
+ /** @var Client */
59
+ private $client;
60
 
61
+ /** @var RequestInterface */
62
+ private $request;
63
 
64
+ /** @var string */
65
+ private $boundary; // @phpstan-ignore-line
66
 
67
+ /**
68
  * Result code from last HTTP call
69
  * @var int
70
  */
71
+ private $httpResultCode;
72
+
73
+ /**
74
+ * @param Client $client
75
+ * @param RequestInterface $request
76
+ * @param string $mimeType
77
+ * @param string $data The bytes you want to upload.
78
+ * @param bool $resumable
79
+ * @param int $chunkSize File will be uploaded in chunks of this many bytes.
80
+ * only used if resumable=True
81
+ */
82
+ public function __construct(
83
+ Client $client,
84
+ RequestInterface $request,
85
+ $mimeType,
86
+ $data,
87
+ $resumable = false,
88
+ $chunkSize = 0
89
+ ) {
90
+ $this->client = $client;
91
+ $this->request = $request;
92
+ $this->mimeType = $mimeType;
93
+ $this->data = $data;
94
+ $this->resumable = $resumable;
95
+ $this->chunkSize = $chunkSize;
96
+ $this->progress = 0;
97
+
98
+ $this->process();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
 
101
+ /**
102
+ * Set the size of the file that is being uploaded.
103
+ * @param int $size - int file size in bytes
104
+ */
105
+ public function setFileSize($size)
106
+ {
107
+ $this->size = $size;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
 
110
+ /**
111
+ * Return the progress on the upload
112
+ * @return int progress in bytes uploaded.
113
+ */
114
+ public function getProgress()
115
+ {
116
+ return $this->progress;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  }
118
 
119
+ /**
120
+ * Send the next part of the file to upload.
121
+ * @param string|bool $chunk Optional. The next set of bytes to send. If false will
122
+ * use $data passed at construct time.
123
+ */
124
+ public function nextChunk($chunk = false)
125
+ {
126
+ $resumeUri = $this->getResumeUri();
127
+
128
+ if (false == $chunk) {
129
+ $chunk = substr($this->data, $this->progress, $this->chunkSize);
130
+ }
131
+
132
+ $lastBytePos = $this->progress + strlen($chunk) - 1;
133
+ $headers = [
134
+ 'content-range' => "bytes $this->progress-$lastBytePos/$this->size",
135
+ 'content-length' => (string) strlen($chunk),
136
+ 'expect' => '',
137
+ ];
138
+
139
+ $request = new Request(
140
+ 'PUT',
141
+ $resumeUri,
142
+ $headers,
143
+ Psr7\Utils::streamFor($chunk)
144
+ );
145
+
146
+ return $this->makePutRequest($request);
147
  }
148
 
149
+ /**
150
+ * Return the HTTP result code from the last call made.
151
+ * @return int code
152
+ */
153
+ public function getHttpResultCode()
154
+ {
155
+ return $this->httpResultCode;
 
 
 
 
 
 
 
 
 
156
  }
157
 
158
+ /**
159
+ * Sends a PUT-Request to google drive and parses the response,
160
+ * setting the appropiate variables from the response()
161
+ *
162
+ * @param RequestInterface $request the Request which will be send
163
+ *
164
+ * @return false|mixed false when the upload is unfinished or the decoded http response
165
+ *
166
+ */
167
+ private function makePutRequest(RequestInterface $request)
168
+ {
169
+ $response = $this->client->execute($request);
170
+ $this->httpResultCode = $response->getStatusCode();
171
+
172
+ if (308 == $this->httpResultCode) {
173
+ // Track the amount uploaded.
174
+ $range = $response->getHeaderLine('range');
175
+ if ($range) {
176
+ $range_array = explode('-', $range);
177
+ $this->progress = ((int) $range_array[1]) + 1;
178
+ }
179
+
180
+ // Allow for changing upload URLs.
181
+ $location = $response->getHeaderLine('location');
182
+ if ($location) {
183
+ $this->resumeUri = $location;
184
+ }
185
+
186
+ // No problems, but upload not complete.
187
+ return false;
188
+ }
189
+
190
+ return REST::decodeHttpResponse($response, $this->request);
191
  }
192
 
193
+ /**
194
+ * Resume a previously unfinished upload
195
+ * @param string $resumeUri the resume-URI of the unfinished, resumable upload.
196
+ */
197
+ public function resume($resumeUri)
198
+ {
199
+ $this->resumeUri = $resumeUri;
200
+ $headers = [
201
+ 'content-range' => "bytes */$this->size",
202
+ 'content-length' => '0',
203
+ ];
204
+ $httpRequest = new Request(
205
+ 'PUT',
206
+ $this->resumeUri,
207
+ $headers
208
+ );
209
+ return $this->makePutRequest($httpRequest);
210
+ }
211
 
212
+ /**
213
+ * @return RequestInterface
214
+ * @visible for testing
215
+ */
216
+ private function process()
217
+ {
218
+ $this->transformToUploadUrl();
219
+ $request = $this->request;
220
+
221
+ $postBody = '';
222
+ $contentType = false;
223
+
224
+ $meta = json_decode((string) $request->getBody(), true);
225
+
226
+ $uploadType = $this->getUploadType($meta);
227
+ $request = $request->withUri(
228
+ Uri::withQueryValue($request->getUri(), 'uploadType', $uploadType)
229
+ );
230
+
231
+ $mimeType = $this->mimeType ?: $request->getHeaderLine('content-type');
232
+
233
+ if (self::UPLOAD_RESUMABLE_TYPE == $uploadType) {
234
+ $contentType = $mimeType;
235
+ $postBody = is_string($meta) ? $meta : json_encode($meta);
236
+ } elseif (self::UPLOAD_MEDIA_TYPE == $uploadType) {
237
+ $contentType = $mimeType;
238
+ $postBody = $this->data;
239
+ } elseif (self::UPLOAD_MULTIPART_TYPE == $uploadType) {
240
+ // This is a multipart/related upload.
241
+ $boundary = $this->boundary ?: mt_rand();
242
+ $boundary = str_replace('"', '', $boundary);
243
+ $contentType = 'multipart/related; boundary=' . $boundary;
244
+ $related = "--$boundary\r\n";
245
+ $related .= "Content-Type: application/json; charset=UTF-8\r\n";
246
+ $related .= "\r\n" . json_encode($meta) . "\r\n";
247
+ $related .= "--$boundary\r\n";
248
+ $related .= "Content-Type: $mimeType\r\n";
249
+ $related .= "Content-Transfer-Encoding: base64\r\n";
250
+ $related .= "\r\n" . base64_encode($this->data) . "\r\n";
251
+ $related .= "--$boundary--";
252
+ $postBody = $related;
253
+ }
254
+
255
+ $request = $request->withBody(Psr7\Utils::streamFor($postBody));
256
+
257
+ if ($contentType) {
258
+ $request = $request->withHeader('content-type', $contentType);
259
+ }
260
+
261
+ return $this->request = $request;
262
  }
263
 
264
+ /**
265
+ * Valid upload types:
266
+ * - resumable (UPLOAD_RESUMABLE_TYPE)
267
+ * - media (UPLOAD_MEDIA_TYPE)
268
+ * - multipart (UPLOAD_MULTIPART_TYPE)
269
+ * @param string|false $meta
270
+ * @return string
271
+ * @visible for testing
272
+ */
273
+ public function getUploadType($meta)
274
+ {
275
+ if ($this->resumable) {
276
+ return self::UPLOAD_RESUMABLE_TYPE;
277
+ }
278
+
279
+ if (false == $meta && $this->data) {
280
+ return self::UPLOAD_MEDIA_TYPE;
281
+ }
282
+
283
+ return self::UPLOAD_MULTIPART_TYPE;
284
  }
285
 
286
+ public function getResumeUri()
287
+ {
288
+ if (null === $this->resumeUri) {
289
+ $this->resumeUri = $this->fetchResumeUri();
290
+ }
291
 
292
+ return $this->resumeUri;
 
293
  }
294
 
295
+ private function fetchResumeUri()
296
+ {
297
+ $body = $this->request->getBody();
298
+ $headers = [
299
+ 'content-type' => 'application/json; charset=UTF-8',
300
+ 'content-length' => $body->getSize(),
301
+ 'x-upload-content-type' => $this->mimeType,
302
+ 'x-upload-content-length' => $this->size,
303
+ 'expect' => '',
304
+ ];
305
+ foreach ($headers as $key => $value) {
306
+ $this->request = $this->request->withHeader($key, $value);
307
+ }
308
+
309
+ $response = $this->client->execute($this->request, null);
310
+ $location = $response->getHeaderLine('location');
311
+ $code = $response->getStatusCode();
312
+
313
+ if (200 == $code && true == $location) {
314
+ return $location;
315
+ }
316
+
317
+ $message = $code;
318
+ $body = json_decode((string) $this->request->getBody(), true);
319
+ if (isset($body['error']['errors'])) {
320
+ $message .= ': ';
321
+ foreach ($body['error']['errors'] as $error) {
322
+ $message .= "{$error['domain']}, {$error['message']};";
323
+ }
324
+ $message = rtrim($message, ';');
325
+ }
326
+
327
+ $error = "Failed to start the resumable upload (HTTP {$message})";
328
+ $this->client->getLogger()->error($error);
329
+
330
+ throw new GoogleException($error);
331
  }
332
 
333
+ private function transformToUploadUrl()
334
+ {
335
+ $parts = parse_url((string) $this->request->getUri());
336
+ if (!isset($parts['path'])) {
337
+ $parts['path'] = '';
338
+ }
339
+ $parts['path'] = '/upload' . $parts['path'];
340
+ $uri = Uri::fromParts($parts);
341
+ $this->request = $this->request->withUri($uri);
342
+ }
343
 
344
+ public function setChunkSize($chunkSize)
345
+ {
346
+ $this->chunkSize = $chunkSize;
347
+ }
348
 
349
+ public function getRequest()
350
+ {
351
+ return $this->request;
 
 
352
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  }
vendor/google/apiclient/src/Http/REST.php CHANGED
@@ -18,9 +18,8 @@
18
  namespace Google\Http;
19
 
20
  use Google\Auth\HttpHandler\HttpHandlerFactory;
21
- use Google\Client;
22
- use Google\Task\Runner;
23
  use Google\Service\Exception as GoogleServiceException;
 
24
  use GuzzleHttp\ClientInterface;
25
  use GuzzleHttp\Exception\RequestException;
26
  use GuzzleHttp\Psr7\Response;
@@ -32,161 +31,164 @@ use Psr\Http\Message\ResponseInterface;
32
  */
33
  class REST
34
  {
35
- /**
36
- * Executes a Psr\Http\Message\RequestInterface and (if applicable) automatically retries
37
- * when errors occur.
38
- *
39
- * @param Client $client
40
- * @param RequestInterface $req
41
- * @param string $expectedClass
42
- * @param array $config
43
- * @param array $retryMap
44
- * @return array decoded result
45
- * @throws \Google\Service\Exception on server side error (ie: not authenticated,
46
- * invalid or malformed post body, invalid url)
47
- */
48
- public static function execute(
49
- ClientInterface $client,
50
- RequestInterface $request,
51
- $expectedClass = null,
52
- $config = array(),
53
- $retryMap = null
54
- ) {
55
- $runner = new Runner(
56
- $config,
57
- sprintf('%s %s', $request->getMethod(), (string) $request->getUri()),
58
- array(get_class(), 'doExecute'),
59
- array($client, $request, $expectedClass)
60
- );
61
-
62
- if (null !== $retryMap) {
63
- $runner->setRetryMap($retryMap);
64
- }
65
-
66
- return $runner->run();
67
- }
68
-
69
- /**
70
- * Executes a Psr\Http\Message\RequestInterface
71
- *
72
- * @param Client $client
73
- * @param RequestInterface $request
74
- * @param string $expectedClass
75
- * @return array decoded result
76
- * @throws \Google\Service\Exception on server side error (ie: not authenticated,
77
- * invalid or malformed post body, invalid url)
78
- */
79
- public static function doExecute(ClientInterface $client, RequestInterface $request, $expectedClass = null)
80
- {
81
- try {
82
- $httpHandler = HttpHandlerFactory::build($client);
83
- $response = $httpHandler($request);
84
- } catch (RequestException $e) {
85
- // if Guzzle throws an exception, catch it and handle the response
86
- if (!$e->hasResponse()) {
87
- throw $e;
88
- }
89
-
90
- $response = $e->getResponse();
91
- // specific checking for Guzzle 5: convert to PSR7 response
92
- if ($response instanceof \GuzzleHttp\Message\ResponseInterface) {
93
- $response = new Response(
94
- $response->getStatusCode(),
95
- $response->getHeaders() ?: [],
96
- $response->getBody(),
97
- $response->getProtocolVersion(),
98
- $response->getReasonPhrase()
99
  );
100
- }
101
- }
102
 
103
- return self::decodeHttpResponse($response, $request, $expectedClass);
104
- }
105
-
106
- /**
107
- * Decode an HTTP Response.
108
- * @static
109
- * @throws \Google\Service\Exception
110
- * @param RequestInterface $response The http response to be decoded.
111
- * @param ResponseInterface $response
112
- * @param string $expectedClass
113
- * @return mixed|null
114
- */
115
- public static function decodeHttpResponse(
116
- ResponseInterface $response,
117
- RequestInterface $request = null,
118
- $expectedClass = null
119
- ) {
120
- $code = $response->getStatusCode();
121
-
122
- // retry strategy
123
- if (intVal($code) >= 400) {
124
- // if we errored out, it should be safe to grab the response body
125
- $body = (string) $response->getBody();
126
-
127
- // Check if we received errors, and add those to the Exception for convenience
128
- throw new GoogleServiceException($body, $code, null, self::getResponseErrors($body));
129
- }
130
 
131
- // Ensure we only pull the entire body into memory if the request is not
132
- // of media type
133
- $body = self::decodeBody($response, $request);
134
 
135
- if ($expectedClass = self::determineExpectedClass($expectedClass, $request)) {
136
- $json = json_decode($body, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
- return new $expectedClass($json);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
 
141
- return $response;
142
- }
 
 
 
 
143
 
144
- private static function decodeBody(ResponseInterface $response, RequestInterface $request = null)
145
- {
146
- if (self::isAltMedia($request)) {
147
- // don't decode the body, it's probably a really long string
148
- return '';
149
  }
150
 
151
- return (string) $response->getBody();
152
- }
 
 
 
 
153
 
154
- private static function determineExpectedClass($expectedClass, RequestInterface $request = null)
155
- {
156
- // "false" is used to explicitly prevent an expected class from being returned
157
- if (false === $expectedClass) {
158
- return null;
159
- }
160
 
161
- // if we don't have a request, we just use what's passed in
162
- if (null === $request) {
163
- return $expectedClass;
164
  }
165
 
166
- // return what we have in the request header if one was not supplied
167
- return $expectedClass ?: $request->getHeaderLine('X-Php-Expected-Class');
168
- }
169
 
170
- private static function getResponseErrors($body)
171
- {
172
- $json = json_decode($body, true);
173
 
174
- if (isset($json['error']['errors'])) {
175
- return $json['error']['errors'];
176
  }
177
 
178
- return null;
179
- }
 
 
 
 
 
 
180
 
181
- private static function isAltMedia(RequestInterface $request = null)
182
- {
183
- if ($request && $qs = $request->getUri()->getQuery()) {
184
- parse_str($qs, $query);
185
- if (isset($query['alt']) && $query['alt'] == 'media') {
186
- return true;
187
- }
188
  }
189
-
190
- return false;
191
- }
192
  }
18
  namespace Google\Http;
19
 
20
  use Google\Auth\HttpHandler\HttpHandlerFactory;
 
 
21
  use Google\Service\Exception as GoogleServiceException;
22
+ use Google\Task\Runner;
23
  use GuzzleHttp\ClientInterface;
24
  use GuzzleHttp\Exception\RequestException;
25
  use GuzzleHttp\Psr7\Response;
31
  */
32
  class REST
33
  {
34
+ /**
35
+ * Executes a Psr\Http\Message\RequestInterface and (if applicable) automatically retries
36
+ * when errors occur.
37
+ *
38
+ * @param ClientInterface $client
39
+ * @param RequestInterface $request
40
+ * @param string $expectedClass
41
+ * @param array $config
42
+ * @param array $retryMap
43
+ * @return mixed decoded result
44
+ * @throws \Google\Service\Exception on server side error (ie: not authenticated,
45
+ * invalid or malformed post body, invalid url)
46
+ */
47
+ public static function execute(
48
+ ClientInterface $client,
49
+ RequestInterface $request,
50
+ $expectedClass = null,
51
+ $config = [],
52
+ $retryMap = null
53
+ ) {
54
+ $runner = new Runner(
55
+ $config,
56
+ sprintf('%s %s', $request->getMethod(), (string) $request->getUri()),
57
+ [get_class(), 'doExecute'],
58
+ [$client, $request, $expectedClass]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  );
 
 
60
 
61
+ if (null !== $retryMap) {
62
+ $runner->setRetryMap($retryMap);
63
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
+ return $runner->run();
66
+ }
 
67
 
68
+ /**
69
+ * Executes a Psr\Http\Message\RequestInterface
70
+ *
71
+ * @param ClientInterface $client
72
+ * @param RequestInterface $request
73
+ * @param string $expectedClass
74
+ * @return array decoded result
75
+ * @throws \Google\Service\Exception on server side error (ie: not authenticated,
76
+ * invalid or malformed post body, invalid url)
77
+ */
78
+ public static function doExecute(ClientInterface $client, RequestInterface $request, $expectedClass = null)
79
+ {
80
+ try {
81
+ $httpHandler = HttpHandlerFactory::build($client);
82
+ $response = $httpHandler($request);
83
+ } catch (RequestException $e) {
84
+ // if Guzzle throws an exception, catch it and handle the response
85
+ if (!$e->hasResponse()) {
86
+ throw $e;
87
+ }
88
+
89
+ $response = $e->getResponse();
90
+ // specific checking for Guzzle 5: convert to PSR7 response
91
+ if (
92
+ interface_exists('\GuzzleHttp\Message\ResponseInterface')
93
+ && $response instanceof \GuzzleHttp\Message\ResponseInterface
94
+ ) {
95
+ $response = new Response(
96
+ $response->getStatusCode(),
97
+ $response->getHeaders() ?: [],
98
+ $response->getBody(),
99
+ $response->getProtocolVersion(),
100
+ $response->getReasonPhrase()
101
+ );
102
+ }
103
+ }
104
+
105
+ return self::decodeHttpResponse($response, $request, $expectedClass);
106
+ }
107
 
108
+ /**
109
+ * Decode an HTTP Response.
110
+ * @static
111
+ * @throws \Google\Service\Exception
112
+ * @param RequestInterface $response The http response to be decoded.
113
+ * @param ResponseInterface $response
114
+ * @param string $expectedClass
115
+ * @return mixed|null
116
+ */
117
+ public static function decodeHttpResponse(
118
+ ResponseInterface $response,
119
+ RequestInterface $request = null,
120
+ $expectedClass = null
121
+ ) {
122
+ $code = $response->getStatusCode();
123
+
124
+ // retry strategy
125
+ if (intVal($code) >= 400) {
126
+ // if we errored out, it should be safe to grab the response body
127
+ $body = (string) $response->getBody();
128
+
129
+ // Check if we received errors, and add those to the Exception for convenience
130
+ throw new GoogleServiceException($body, $code, null, self::getResponseErrors($body));
131
+ }
132
+
133
+ // Ensure we only pull the entire body into memory if the request is not
134
+ // of media type
135
+ $body = self::decodeBody($response, $request);
136
+
137
+ if ($expectedClass = self::determineExpectedClass($expectedClass, $request)) {
138
+ $json = json_decode($body, true);
139
+
140
+ return new $expectedClass($json);
141
+ }
142
+
143
+ return $response;
144
  }
145
 
146
+ private static function decodeBody(ResponseInterface $response, RequestInterface $request = null)
147
+ {
148
+ if (self::isAltMedia($request)) {
149
+ // don't decode the body, it's probably a really long string
150
+ return '';
151
+ }
152
 
153
+ return (string) $response->getBody();
 
 
 
 
154
  }
155
 
156
+ private static function determineExpectedClass($expectedClass, RequestInterface $request = null)
157
+ {
158
+ // "false" is used to explicitly prevent an expected class from being returned
159
+ if (false === $expectedClass) {
160
+ return null;
161
+ }
162
 
163
+ // if we don't have a request, we just use what's passed in
164
+ if (null === $request) {
165
+ return $expectedClass;
166
+ }
 
 
167
 
168
+ // return what we have in the request header if one was not supplied
169
+ return $expectedClass ?: $request->getHeaderLine('X-Php-Expected-Class');
 
170
  }
171
 
172
+ private static function getResponseErrors($body)
173
+ {
174
+ $json = json_decode($body, true);
175
 
176
+ if (isset($json['error']['errors'])) {
177
+ return $json['error']['errors'];
178
+ }
179
 
180
+ return null;
 
181
  }
182
 
183
+ private static function isAltMedia(RequestInterface $request = null)
184
+ {
185
+ if ($request && $qs = $request->getUri()->getQuery()) {
186
+ parse_str($qs, $query);
187
+ if (isset($query['alt']) && $query['alt'] == 'media') {
188
+ return true;
189
+ }
190
+ }
191
 
192
+ return false;
 
 
 
 
 
 
193
  }
 
 
 
194
  }
vendor/google/apiclient/src/Model.php CHANGED
@@ -30,295 +30,303 @@ use stdClass;
30
  */
31
  class Model implements \ArrayAccess
32
  {
33
- /**
34
- * If you need to specify a NULL JSON value, use Google\Model::NULL_VALUE
35
- * instead - it will be replaced when converting to JSON with a real null.
36
- */
37
- const NULL_VALUE = "{}gapi-php-null";
38
- protected $internal_gapi_mappings = array();
39
- protected $modelData = array();
40
- protected $processed = array();
41
 
42
- /**
43
- * Polymorphic - accepts a variable number of arguments dependent
44
- * on the type of the model subclass.
45
- */
46
- final public function __construct()
47
- {
48
- if (func_num_args() == 1 && is_array(func_get_arg(0))) {
49
- // Initialize the model with the array's contents.
50
- $array = func_get_arg(0);
51
- $this->mapTypes($array);
 
 
52
  }
53
- $this->gapiInit();
54
- }
55
 
56
- /**
57
- * Getter that handles passthrough access to the data array, and lazy object creation.
58
- * @param string $key Property name.
59
- * @return mixed The value if any, or null.
60
- */
61
- public function __get($key)
62
- {
63
- $keyType = $this->keyType($key);
64
- $keyDataType = $this->dataType($key);
65
- if ($keyType && !isset($this->processed[$key])) {
66
- if (isset($this->modelData[$key])) {
67
- $val = $this->modelData[$key];
68
- } elseif ($keyDataType == 'array' || $keyDataType == 'map') {
69
- $val = array();
70
- } else {
71
- $val = null;
72
- }
73
 
74
- if ($this->isAssociativeArray($val)) {
75
- if ($keyDataType && 'map' == $keyDataType) {
76
- foreach ($val as $arrayKey => $arrayItem) {
77
- $this->modelData[$key][$arrayKey] =
78
- new $keyType($arrayItem);
79
- }
80
- } else {
81
- $this->modelData[$key] = new $keyType($val);
82
- }
83
- } else if (is_array($val)) {
84
- $arrayObject = array();
85
- foreach ($val as $arrayIndex => $arrayItem) {
86
- $arrayObject[$arrayIndex] = new $keyType($arrayItem);
 
 
 
 
87
  }
88
- $this->modelData[$key] = $arrayObject;
89
- }
90
- $this->processed[$key] = true;
91
- }
92
 
93
- return isset($this->modelData[$key]) ? $this->modelData[$key] : null;
94
- }
95
 
96
- /**
97
- * Initialize this object's properties from an array.
98
- *
99
- * @param array $array Used to seed this object's properties.
100
- * @return void
101
- */
102
- protected function mapTypes($array)
103
- {
104
- // Hard initialise simple types, lazy load more complex ones.
105
- foreach ($array as $key => $val) {
106
- if ($keyType = $this->keyType($key)) {
107
- $dataType = $this->dataType($key);
108
- if ($dataType == 'array' || $dataType == 'map') {
109
- $this->$key = array();
110
- foreach ($val as $itemKey => $itemVal) {
111
- if ($itemVal instanceof $keyType) {
112
- $this->{$key}[$itemKey] = $itemVal;
113
- } else {
114
- $this->{$key}[$itemKey] = new $keyType($itemVal);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
116
- }
117
- } elseif ($val instanceof $keyType) {
118
- $this->$key = $val;
119
- } else {
120
- $this->$key = new $keyType($val);
121
  }
122
- unset($array[$key]);
123
- } elseif (property_exists($this, $key)) {
124
- $this->$key = $val;
125
- unset($array[$key]);
126
- } elseif (property_exists($this, $camelKey = $this->camelCase($key))) {
127
- // This checks if property exists as camelCase, leaving it in array as snake_case
128
- // in case of backwards compatibility issues.
129
- $this->$camelKey = $val;
130
- }
131
  }
132
- $this->modelData = $array;
133
- }
134
-
135
- /**
136
- * Blank initialiser to be used in subclasses to do post-construction initialisation - this
137
- * avoids the need for subclasses to have to implement the variadics handling in their
138
- * constructors.
139
- */
140
- protected function gapiInit()
141
- {
142
- return;
143
- }
144
-
145
- /**
146
- * Create a simplified object suitable for straightforward
147
- * conversion to JSON. This is relatively expensive
148
- * due to the usage of reflection, but shouldn't be called
149
- * a whole lot, and is the most straightforward way to filter.
150
- */
151
- public function toSimpleObject()
152
- {
153
- $object = new stdClass();
154
 
155
- // Process all other data.
156
- foreach ($this->modelData as $key => $val) {
157
- $result = $this->getSimpleValue($val);
158
- if ($result !== null) {
159
- $object->$key = $this->nullPlaceholderCheck($result);
160
- }
 
 
161
  }
162
 
163
- // Process all public properties.
164
- $reflect = new ReflectionObject($this);
165
- $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
166
- foreach ($props as $member) {
167
- $name = $member->getName();
168
- $result = $this->getSimpleValue($this->$name);
169
- if ($result !== null) {
170
- $name = $this->getMappedName($name);
171
- $object->$name = $this->nullPlaceholderCheck($result);
172
- }
173
- }
174
 
175
- return $object;
176
- }
 
 
 
 
 
177
 
178
- /**
179
- * Handle different types of values, primarily
180
- * other objects and map and array data types.
181
- */
182
- private function getSimpleValue($value)
183
- {
184
- if ($value instanceof Model) {
185
- return $value->toSimpleObject();
186
- } else if (is_array($value)) {
187
- $return = array();
188
- foreach ($value as $key => $a_value) {
189
- $a_value = $this->getSimpleValue($a_value);
190
- if ($a_value !== null) {
191
- $key = $this->getMappedName($key);
192
- $return[$key] = $this->nullPlaceholderCheck($a_value);
193
  }
194
- }
195
- return $return;
196
  }
197
- return $value;
198
- }
199
 
200
- /**
201
- * Check whether the value is the null placeholder and return true null.
202
- */
203
- private function nullPlaceholderCheck($value)
204
- {
205
- if ($value === self::NULL_VALUE) {
206
- return null;
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  }
208
- return $value;
209
- }
210
 
211
- /**
212
- * If there is an internal name mapping, use that.
213
- */
214
- private function getMappedName($key)
215
- {
216
- if (isset($this->internal_gapi_mappings, $this->internal_gapi_mappings[$key])) {
217
- $key = $this->internal_gapi_mappings[$key];
 
 
218
  }
219
- return $key;
220
- }
221
 
222
- /**
223
- * Returns true only if the array is associative.
224
- * @param array $array
225
- * @return bool True if the array is associative.
226
- */
227
- protected function isAssociativeArray($array)
228
- {
229
- if (!is_array($array)) {
230
- return false;
231
  }
232
- $keys = array_keys($array);
233
- foreach ($keys as $key) {
234
- if (is_string($key)) {
235
- return true;
236
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  }
238
- return false;
239
- }
240
 
241
- /**
242
- * Verify if $obj is an array.
243
- * @throws \Google\Exception Thrown if $obj isn't an array.
244
- * @param array $obj Items that should be validated.
245
- * @param string $method Method expecting an array as an argument.
246
- */
247
- public function assertIsArray($obj, $method)
248
- {
249
- if ($obj && !is_array($obj)) {
250
- throw new GoogleException(
251
- "Incorrect parameter type passed to $method(). Expected an array."
252
- );
 
253
  }
254
- }
255
 
256
- public function offsetExists($offset)
257
- {
258
- return isset($this->$offset) || isset($this->modelData[$offset]);
259
- }
 
 
260
 
261
- public function offsetGet($offset)
262
- {
263
- return isset($this->$offset) ?
 
 
264
  $this->$offset :
265
  $this->__get($offset);
266
- }
267
 
268
- public function offsetSet($offset, $value)
269
- {
270
- if (property_exists($this, $offset)) {
271
- $this->$offset = $value;
272
- } else {
273
- $this->modelData[$offset] = $value;
274
- $this->processed[$offset] = true;
 
 
 
275
  }
276
- }
277
 
278
- public function offsetUnset($offset)
279
- {
280
- unset($this->modelData[$offset]);
281
- }
 
 
282
 
283
- protected function keyType($key)
284
- {
285
- $keyType = $key . "Type";
286
 
287
- // ensure keyType is a valid class
288
- if (property_exists($this, $keyType) && class_exists($this->$keyType)) {
289
- return $this->$keyType;
 
290
  }
291
- }
292
 
293
- protected function dataType($key)
294
- {
295
- $dataType = $key . "DataType";
296
 
297
- if (property_exists($this, $dataType)) {
298
- return $this->$dataType;
 
299
  }
300
- }
301
 
302
- public function __isset($key)
303
- {
304
- return isset($this->modelData[$key]);
305
- }
306
 
307
- public function __unset($key)
308
- {
309
- unset($this->modelData[$key]);
310
- }
311
 
312
- /**
313
  * Convert a string to camelCase
314
  * @param string $value
315
  * @return string
316
  */
317
- private function camelCase($value)
318
- {
319
- $value = ucwords(str_replace(array('-', '_'), ' ', $value));
320
- $value = str_replace(' ', '', $value);
321
- $value[0] = strtolower($value[0]);
322
- return $value;
323
- }
324
  }
30
  */
31
  class Model implements \ArrayAccess
32
  {
33
+ /**
34
+ * If you need to specify a NULL JSON value, use Google\Model::NULL_VALUE
35
+ * instead - it will be replaced when converting to JSON with a real null.
36
+ */
37
+ const NULL_VALUE = "{}gapi-php-null";
38
+ protected $internal_gapi_mappings = [];
39
+ protected $modelData = [];
40
+ protected $processed = [];
41
 
42
+ /**
43
+ * Polymorphic - accepts a variable number of arguments dependent
44
+ * on the type of the model subclass.
45
+ */
46
+ final public function __construct()
47
+ {
48
+ if (func_num_args() == 1 && is_array(func_get_arg(0))) {
49
+ // Initialize the model with the array's contents.
50
+ $array = func_get_arg(0);
51
+ $this->mapTypes($array);
52
+ }
53
+ $this->gapiInit();
54
  }
 
 
55
 
56
+ /**
57
+ * Getter that handles passthrough access to the data array, and lazy object creation.
58
+ * @param string $key Property name.
59
+ * @return mixed The value if any, or null.
60
+ */
61
+ public function __get($key)
62
+ {
63
+ $keyType = $this->keyType($key);
64
+ $keyDataType = $this->dataType($key);
65
+ if ($keyType && !isset($this->processed[$key])) {
66
+ if (isset($this->modelData[$key])) {
67
+ $val = $this->modelData[$key];
68
+ } elseif ($keyDataType == 'array' || $keyDataType == 'map') {
69
+ $val = [];
70
+ } else {
71
+ $val = null;
72
+ }
73
 
74
+ if ($this->isAssociativeArray($val)) {
75
+ if ($keyDataType && 'map' == $keyDataType) {
76
+ foreach ($val as $arrayKey => $arrayItem) {
77
+ $this->modelData[$key][$arrayKey] =
78
+ new $keyType($arrayItem);
79
+ }
80
+ } else {
81
+ $this->modelData[$key] = new $keyType($val);
82
+ }
83
+ } elseif (is_array($val)) {
84
+ $arrayObject = [];
85
+ foreach ($val as $arrayIndex => $arrayItem) {
86
+ $arrayObject[$arrayIndex] = new $keyType($arrayItem);
87
+ }
88
+ $this->modelData[$key] = $arrayObject;
89
+ }
90
+ $this->processed[$key] = true;
91
  }
 
 
 
 
92
 
93
+ return isset($this->modelData[$key]) ? $this->modelData[$key] : null;
94
+ }
95
 
96
+ /**
97
+ * Initialize this object's properties from an array.
98
+ *
99
+ * @param array $array Used to seed this object's properties.
100
+ * @return void
101
+ */
102
+ protected function mapTypes($array)
103
+ {
104
+ // Hard initialise simple types, lazy load more complex ones.
105
+ foreach ($array as $key => $val) {
106
+ if ($keyType = $this->keyType($key)) {
107
+ $dataType = $this->dataType($key);
108
+ if ($dataType == 'array' || $dataType == 'map') {
109
+ $this->$key = [];
110
+ foreach ($val as $itemKey => $itemVal) {
111
+ if ($itemVal instanceof $keyType) {
112
+ $this->{$key}[$itemKey] = $itemVal;
113
+ } else {
114
+ $this->{$key}[$itemKey] = new $keyType($itemVal);
115
+ }
116
+ }
117
+ } elseif ($val instanceof $keyType) {
118
+ $this->$key = $val;
119
+ } else {
120
+ $this->$key = new $keyType($val);
121
+ }
122
+ unset($array[$key]);
123
+ } elseif (property_exists($this, $key)) {
124
+ $this->$key = $val;
125
+ unset($array[$key]);
126
+ } elseif (property_exists($this, $camelKey = $this->camelCase($key))) {
127
+ // This checks if property exists as camelCase, leaving it in array as snake_case
128
+ // in case of backwards compatibility issues.
129
+ $this->$camelKey = $val;
130
  }
 
 
 
 
 
131
  }
132
+ $this->modelData = $array;
 
 
 
 
 
 
 
 
133
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
+ /**
136
+ * Blank initialiser to be used in subclasses to do post-construction initialisation - this
137
+ * avoids the need for subclasses to have to implement the variadics handling in their
138
+ * constructors.
139
+ */
140
+ protected function gapiInit()
141
+ {
142
+ return;
143
  }
144
 
145
+ /**
146
+ * Create a simplified object suitable for straightforward
147
+ * conversion to JSON. This is relatively expensive
148
+ * due to the usage of reflection, but shouldn't be called
149
+ * a whole lot, and is the most straightforward way to filter.
150
+ */
151
+ public function toSimpleObject()
152
+ {
153
+ $object = new stdClass();
 
 
154
 
155
+ // Process all other data.
156
+ foreach ($this->modelData as $key => $val) {
157
+ $result = $this->getSimpleValue($val);
158
+ if ($result !== null) {
159
+ $object->$key = $this->nullPlaceholderCheck($result);
160
+ }
161
+ }
162
 
163
+ // Process all public properties.
164
+ $reflect = new ReflectionObject($this);
165
+ $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
166
+ foreach ($props as $member) {
167
+ $name = $member->getName();
168
+ $result = $this->getSimpleValue($this->$name);
169
+ if ($result !== null) {
170
+ $name = $this->getMappedName($name);
171
+ $object->$name = $this->nullPlaceholderCheck($result);
172
+ }
 
 
 
 
 
173
  }
174
+
175
+ return $object;
176
  }
 
 
177
 
178
+ /**
179
+ * Handle different types of values, primarily
180
+ * other objects and map and array data types.
181
+ */
182
+ private function getSimpleValue($value)
183
+ {
184
+ if ($value instanceof Model) {
185
+ return $value->toSimpleObject();
186
+ } elseif (is_array($value)) {
187
+ $return = [];
188
+ foreach ($value as $key => $a_value) {
189
+ $a_value = $this->getSimpleValue($a_value);
190
+ if ($a_value !== null) {
191
+ $key = $this->getMappedName($key);
192
+ $return[$key] = $this->nullPlaceholderCheck($a_value);
193
+ }
194
+ }
195
+ return $return;
196
+ }
197
+ return $value;
198
  }
 
 
199
 
200
+ /**
201
+ * Check whether the value is the null placeholder and return true null.
202
+ */
203
+ private function nullPlaceholderCheck($value)
204
+ {
205
+ if ($value === self::NULL_VALUE) {
206
+ return null;
207
+ }
208
+ return $value;
209
  }
 
 
210
 
211
+ /**
212
+ * If there is an internal name mapping, use that.
213
+ */
214
+ private function getMappedName($key)
215
+ {
216
+ if (isset($this->internal_gapi_mappings, $this->internal_gapi_mappings[$key])) {
217
+ $key = $this->internal_gapi_mappings[$key];
218
+ }
219
+ return $key;
220
  }
221
+
222
+ /**
223
+ * Returns true only if the array is associative.
224
+ * @param array $array
225
+ * @return bool True if the array is associative.
226
+ */
227
+ protected function isAssociativeArray($array)
228
+ {
229
+ if (!is_array($array)) {
230
+ return false;
231
+ }
232
+ $keys = array_keys($array);
233
+ foreach ($keys as $key) {
234
+ if (is_string($key)) {
235
+ return true;
236
+ }
237
+ }
238
+ return false;
239
  }
 
 
240
 
241
+ /**
242
+ * Verify if $obj is an array.
243
+ * @throws \Google\Exception Thrown if $obj isn't an array.
244
+ * @param array $obj Items that should be validated.
245
+ * @param string $method Method expecting an array as an argument.
246
+ */
247
+ public function assertIsArray($obj, $method)
248
+ {
249
+ if ($obj && !is_array($obj)) {
250
+ throw new GoogleException(
251
+ "Incorrect parameter type passed to $method(). Expected an array."
252
+ );
253
+ }
254
  }
 
255
 
256
+ /** @return bool */
257
+ #[\ReturnTypeWillChange]
258
+ public function offsetExists($offset)
259
+ {
260
+ return isset($this->$offset) || isset($this->modelData[$offset]);
261
+ }
262
 
263
+ /** @return mixed */
264
+ #[\ReturnTypeWillChange]
265
+ public function offsetGet($offset)
266
+ {
267
+ return isset($this->$offset) ?
268
  $this->$offset :
269
  $this->__get($offset);
270
+ }
271
 
272
+ /** @return void */
273
+ #[\ReturnTypeWillChange]
274
+ public function offsetSet($offset, $value)
275
+ {
276
+ if (property_exists($this, $offset)) {
277
+ $this->$offset = $value;
278
+ } else {
279
+ $this->modelData[$offset] = $value;
280
+ $this->processed[$offset] = true;
281
+ }
282
  }
 
283
 
284
+ /** @return void */
285
+ #[\ReturnTypeWillChange]
286
+ public function offsetUnset($offset)
287
+ {
288
+ unset($this->modelData[$offset]);
289
+ }
290
 
291
+ protected function keyType($key)
292
+ {
293
+ $keyType = $key . "Type";
294
 
295
+ // ensure keyType is a valid class
296
+ if (property_exists($this, $keyType) && class_exists($this->$keyType)) {
297
+ return $this->$keyType;
298
+ }
299
  }
 
300
 
301
+ protected function dataType($key)
302
+ {
303
+ $dataType = $key . "DataType";
304
 
305
+ if (property_exists($this, $dataType)) {
306
+ return $this->$dataType;
307
+ }
308
  }
 
309
 
310
+ public function __isset($key)
311
+ {
312
+ return isset($this->modelData[$key]);
313
+ }
314
 
315
+ public function __unset($key)
316
+ {
317
+ unset($this->modelData[$key]);
318
+ }
319
 
320
+ /**
321
  * Convert a string to camelCase
322
  * @param string $value
323
  * @return string
324
  */
325
+ private function camelCase($value)
326
+ {
327
+ $value = ucwords(str_replace(['-', '_'], ' ', $value));
328
+ $value = str_replace(' ', '', $value);
329
+ $value[0] = strtolower($value[0]);
330
+ return $value;
331
+ }
332
  }
vendor/google/apiclient/src/Service.php CHANGED
@@ -22,50 +22,51 @@ use TypeError;
22
 
23
  class Service
24
  {
25
- public $batchPath;
26
- public $rootUrl;
27
- public $version;
28
- public $servicePath;
29
- public $availableScopes;
30
- public $resource;
31
- private $client;
 
32
 
33
- public function __construct($clientOrConfig = [])
34
- {
35
- if ($clientOrConfig instanceof Client) {
36
- $this->client = $clientOrConfig;
37
- } elseif (is_array($clientOrConfig)) {
38
- $this->client = new Client($clientOrConfig ?: []);
39
- } else {
40
- $errorMessage = 'constructor must be array or instance of Google\Client';
41
- if (class_exists('TypeError')) {
42
- throw new TypeError($errorMessage);
43
- }
44
- trigger_error($errorMessage, E_USER_ERROR);
 
45
  }
46
- }
47
 
48
- /**
49
  * Return the associated Google\Client class.
50
  * @return \Google\Client
51
  */
52
- public function getClient()
53
- {
54
- return $this->client;
55
- }
56
 
57
- /**
58
  * Create a new HTTP Batch handler for this service
59
  *
60
  * @return Batch
61
  */
62
- public function createBatch()
63
- {
64
- return new Batch(
65
- $this->client,
66
- false,
67
- $this->rootUrl,
68
- $this->batchPath
69
- );
70
- }
71
  }
22
 
23
  class Service
24
  {
25
+ public $batchPath;
26
+ public $rootUrl;
27
+ public $version;
28
+ public $servicePath;
29
+ public $serviceName;
30
+ public $availableScopes;
31
+ public $resource;
32
+ private $client;
33
 
34
+ public function __construct($clientOrConfig = [])
35
+ {
36
+ if ($clientOrConfig instanceof Client) {
37
+ $this->client = $clientOrConfig;
38
+ } elseif (is_array($clientOrConfig)) {
39
+ $this->client = new Client($clientOrConfig ?: []);
40
+ } else {
41
+ $errorMessage = 'constructor must be array or instance of Google\Client';
42
+ if (class_exists('TypeError')) {
43
+ throw new TypeError($errorMessage);
44
+ }
45
+ trigger_error($errorMessage, E_USER_ERROR);
46
+ }
47
  }
 
48
 
49
+ /**
50
  * Return the associated Google\Client class.
51
  * @return \Google\Client
52
  */
53
+ public function getClient()
54
+ {
55
+ return $this->client;
56
+ }
57
 
58
+ /**
59
  * Create a new HTTP Batch handler for this service
60
  *
61
  * @return Batch
62
  */
63
+ public function createBatch()
64
+ {
65
+ return new Batch(
66
+ $this->client,
67
+ false,
68
+ $this->rootUrl,
69
+ $this->batchPath
70
+ );
71
+ }
72
  }
vendor/google/apiclient/src/Service/Exception.php CHANGED
@@ -21,51 +21,51 @@ use Google\Exception as GoogleException;
21
 
22
  class Exception extends GoogleException
23
  {
24
- /**
25
- * Optional list of errors returned in a JSON body of an HTTP error response.
26
- */
27
- protected $errors = array();
28
 
29
- /**
30
- * Override default constructor to add the ability to set $errors and a retry
31
- * map.
32
- *
33
- * @param string $message
34
- * @param int $code
35
- * @param \Exception|null $previous
36
- * @param [{string, string}] errors List of errors returned in an HTTP
37
- * response. Defaults to [].
38
- */
39
- public function __construct(
40
- $message,
41
- $code = 0,
42
- Exception $previous = null,
43
- $errors = array()
44
- ) {
45
- if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
46
- parent::__construct($message, $code, $previous);
47
- } else {
48
- parent::__construct($message, $code);
49
- }
50
 
51
- $this->errors = $errors;
52
- }
53
 
54
- /**
55
- * An example of the possible errors returned.
56
- *
57
- * {
58
- * "domain": "global",
59
- * "reason": "authError",
60
- * "message": "Invalid Credentials",
61
- * "locationType": "header",
62
- * "location": "Authorization",
63
- * }
64
- *
65
- * @return [{string, string}] List of errors return in an HTTP response or [].
66
- */
67
- public function getErrors()
68
- {
69
- return $this->errors;
70
- }
71
  }
21
 
22
  class Exception extends GoogleException
23
  {
24
+ /**
25
+ * Optional list of errors returned in a JSON body of an HTTP error response.
26
+ */
27
+ protected $errors = [];
28
 
29
+ /**
30
+ * Override default constructor to add the ability to set $errors and a retry
31
+ * map.
32
+ *
33
+ * @param string $message
34
+ * @param int $code
35
+ * @param Exception|null $previous
36
+ * @param array<string,string> $errors List of errors returned in an HTTP
37
+ * response. Defaults to [].
38
+ */
39
+ public function __construct(
40
+ $message,
41
+ $code = 0,
42
+ Exception $previous = null,
43
+ $errors = []
44
+ ) {
45
+ if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
46
+ parent::__construct($message, $code, $previous);
47
+ } else {
48
+ parent::__construct($message, $code);
49
+ }
50
 
51
+ $this->errors = $errors;
52
+ }
53
 
54
+ /**
55
+ * An example of the possible errors returned.
56
+ *
57
+ * {
58
+ * "domain": "global",
59
+ * "reason": "authError",
60
+ * "message": "Invalid Credentials",
61
+ * "locationType": "header",
62
+ * "location": "Authorization",
63
+ * }
64
+ *
65
+ * @return array<string,string> List of errors return in an HTTP response or [].
66
+ */
67
+ public function getErrors()
68
+ {
69
+ return $this->errors;
70
+ }
71
  }
vendor/google/apiclient/src/Service/Resource.php CHANGED
@@ -17,9 +17,9 @@
17
 
18
  namespace Google\Service;
19
 
20
- use Google\Model;
21
- use Google\Http\MediaFileUpload;
22
  use Google\Exception as GoogleException;
 
 
23
  use Google\Utils\UriTemplate;
24
  use GuzzleHttp\Psr7\Request;
25
 
@@ -31,278 +31,278 @@ use GuzzleHttp\Psr7\Request;
31
  */
32
  class Resource
33
  {
34
- // Valid query parameters that work, but don't appear in discovery.
35
- private $stackParameters = array(
36
- 'alt' => array('type' => 'string', 'location' => 'query'),
37
- 'fields' => array('type' => 'string', 'location' => 'query'),
38
- 'trace' => array('type' => 'string', 'location' => 'query'),
39
- 'userIp' => array('type' => 'string', 'location' => 'query'),
40
- 'quotaUser' => array('type' => 'string', 'location' => 'query'),
41
- 'data' => array('type' => 'string', 'location' => 'body'),
42
- 'mimeType' => array('type' => 'string', 'location' => 'header'),
43
- 'uploadType' => array('type' => 'string', 'location' => 'query'),
44
- 'mediaUpload' => array('type' => 'complex', 'location' => 'query'),
45
- 'prettyPrint' => array('type' => 'string', 'location' => 'query'),
46
- );
47
-
48
- /** @var string $rootUrl */
49
- private $rootUrl;
50
-
51
- /** @var \Google\Client $client */
52
- private $client;
53
-
54
- /** @var string $serviceName */
55
- private $serviceName;
56
-
57
- /** @var string $servicePath */
58
- private $servicePath;
59
-
60
- /** @var string $resourceName */
61
- private $resourceName;
62
-
63
- /** @var array $methods */
64
- private $methods;
65
-
66
- public function __construct($service, $serviceName, $resourceName, $resource)
67
- {
68
- $this->rootUrl = $service->rootUrl;
69
- $this->client = $service->getClient();
70
- $this->servicePath = $service->servicePath;
71
- $this->serviceName = $serviceName;
72
- $this->resourceName = $resourceName;
73
- $this->methods = is_array($resource) && isset($resource['methods']) ?
74
  $resource['methods'] :
75
- array($resourceName => $resource);
76
- }
77
-
78
- /**
79
- * TODO: This function needs simplifying.
80
- * @param $name
81
- * @param $arguments
82
- * @param $expectedClass - optional, the expected class name
83
- * @return Request|$expectedClass
84
- * @throws \Google\Exception
85
- */
86
- public function call($name, $arguments, $expectedClass = null)
87
- {
88
- if (! isset($this->methods[$name])) {
89
- $this->client->getLogger()->error(
90
- 'Service method unknown',
91
- array(
92
- 'service' => $this->serviceName,
93
- 'resource' => $this->resourceName,
94
- 'method' => $name
95
- )
96
- );
97
-
98
- throw new GoogleException(
99
- "Unknown function: " .
100
- "{$this->serviceName}->{$this->resourceName}->{$name}()"
101
- );
102
- }
103
- $method = $this->methods[$name];
104
- $parameters = $arguments[0];
105
-
106
- // postBody is a special case since it's not defined in the discovery
107
- // document as parameter, but we abuse the param entry for storing it.
108
- $postBody = null;
109
- if (isset($parameters['postBody'])) {
110
- if ($parameters['postBody'] instanceof Model) {
111
- // In the cases the post body is an existing object, we want
112
- // to use the smart method to create a simple object for
113
- // for JSONification.
114
- $parameters['postBody'] = $parameters['postBody']->toSimpleObject();
115
- } else if (is_object($parameters['postBody'])) {
116
- // If the post body is another kind of object, we will try and
117
- // wrangle it into a sensible format.
118
- $parameters['postBody'] =
119
- $this->convertToArrayAndStripNulls($parameters['postBody']);
120
- }
121
- $postBody = (array) $parameters['postBody'];
122
- unset($parameters['postBody']);
123
  }
124
 
125
- // TODO: optParams here probably should have been
126
- // handled already - this may well be redundant code.
127
- if (isset($parameters['optParams'])) {
128
- $optParams = $parameters['optParams'];
129
- unset($parameters['optParams']);
130
- $parameters = array_merge($parameters, $optParams);
131
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
- if (!isset($method['parameters'])) {
134
- $method['parameters'] = array();
135
- }
 
 
 
 
136
 
137
- $method['parameters'] = array_merge(
138
- $this->stackParameters,
139
- $method['parameters']
140
- );
141
 
142
- foreach ($parameters as $key => $val) {
143
- if ($key != 'postBody' && ! isset($method['parameters'][$key])) {
144
- $this->client->getLogger()->error(
145
- 'Service parameter unknown',
146
- array(
147
- 'service' => $this->serviceName,
148
- 'resource' => $this->resourceName,
149
- 'method' => $name,
150
- 'parameter' => $key
151
- )
152
  );
153
- throw new GoogleException("($name) unknown parameter: '$key'");
154
- }
155
- }
156
 
157
- foreach ($method['parameters'] as $paramName => $paramSpec) {
158
- if (isset($paramSpec['required']) &&
159
- $paramSpec['required'] &&
160
- ! isset($parameters[$paramName])
161
- ) {
162
- $this->client->getLogger()->error(
163
- 'Service parameter missing',
164
- array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  'service' => $this->serviceName,
166
  'resource' => $this->resourceName,
167
  'method' => $name,
168
- 'parameter' => $paramName
169
- )
170
  );
171
- throw new GoogleException("($name) missing required param: '$paramName'");
172
- }
173
- if (isset($parameters[$paramName])) {
174
- $value = $parameters[$paramName];
175
- $parameters[$paramName] = $paramSpec;
176
- $parameters[$paramName]['value'] = $value;
177
- unset($parameters[$paramName]['required']);
178
- } else {
179
- // Ensure we don't pass nulls.
180
- unset($parameters[$paramName]);
181
- }
182
- }
183
 
184
- $this->client->getLogger()->info(
185
- 'Service Call',
186
- array(
187
- 'service' => $this->serviceName,
188
- 'resource' => $this->resourceName,
189
- 'method' => $name,
190
- 'arguments' => $parameters,
191
- )
192
- );
193
-
194
- // build the service uri
195
- $url = $this->createRequestUri(
196
- $method['path'],
197
- $parameters
198
- );
199
-
200
- // NOTE: because we're creating the request by hand,
201
- // and because the service has a rootUrl property
202
- // the "base_uri" of the Http Client is not accounted for
203
- $request = new Request(
204
- $method['httpMethod'],
205
- $url,
206
- ['content-type' => 'application/json'],
207
- $postBody ? json_encode($postBody) : ''
208
- );
209
-
210
- // support uploads
211
- if (isset($parameters['data'])) {
212
- $mimeType = isset($parameters['mimeType'])
213
- ? $parameters['mimeType']['value']
214
- : 'application/octet-stream';
215
- $data = $parameters['data']['value'];
216
- $upload = new MediaFileUpload($this->client, $request, $mimeType, $data);
217
-
218
- // pull down the modified request
219
- $request = $upload->getRequest();
220
- }
221
 
222
- // if this is a media type, we will return the raw response
223
- // rather than using an expected class
224
- if (isset($parameters['alt']) && $parameters['alt']['value'] == 'media') {
225
- $expectedClass = null;
226
- }
 
 
227
 
228
- // if the client is marked for deferring, rather than
229
- // execute the request, return the response
230
- if ($this->client->shouldDefer()) {
231
- // @TODO find a better way to do this
232
- $request = $request
233
- ->withHeader('X-Php-Expected-Class', $expectedClass);
234
 
235
- return $request;
236
- }
 
 
 
237
 
238
- return $this->client->execute($request, $expectedClass);
239
- }
240
-
241
- protected function convertToArrayAndStripNulls($o)
242
- {
243
- $o = (array) $o;
244
- foreach ($o as $k => $v) {
245
- if ($v === null) {
246
- unset($o[$k]);
247
- } elseif (is_object($v) || is_array($v)) {
248
- $o[$k] = $this->convertToArrayAndStripNulls($o[$k]);
249
- }
250
- }
251
- return $o;
252
- }
253
-
254
- /**
255
- * Parse/expand request parameters and create a fully qualified
256
- * request uri.
257
- * @static
258
- * @param string $restPath
259
- * @param array $params
260
- * @return string $requestUrl
261
- */
262
- public function createRequestUri($restPath, $params)
263
- {
264
- // Override the default servicePath address if the $restPath use a /
265
- if ('/' == substr($restPath, 0, 1)) {
266
- $requestUrl = substr($restPath, 1);
267
- } else {
268
- $requestUrl = $this->servicePath . $restPath;
269
  }
270
 
271
- // code for leading slash
272
- if ($this->rootUrl) {
273
- if ('/' !== substr($this->rootUrl, -1) && '/' !== substr($requestUrl, 0, 1)) {
274
- $requestUrl = '/' . $requestUrl;
275
- }
276
- $requestUrl = $this->rootUrl . $requestUrl;
 
 
 
 
 
277
  }
278
- $uriTemplateVars = array();
279
- $queryVars = array();
280
- foreach ($params as $paramName => $paramSpec) {
281
- if ($paramSpec['type'] == 'boolean') {
282
- $paramSpec['value'] = $paramSpec['value'] ? 'true' : 'false';
283
- }
284
- if ($paramSpec['location'] == 'path') {
285
- $uriTemplateVars[$paramName] = $paramSpec['value'];
286
- } else if ($paramSpec['location'] == 'query') {
287
- if (is_array($paramSpec['value'])) {
288
- foreach ($paramSpec['value'] as $value) {
289
- $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($value));
290
- }
 
291
  } else {
292
- $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($paramSpec['value']));
293
  }
294
- }
295
- }
296
 
297
- if (count($uriTemplateVars)) {
298
- $uriTemplateParser = new UriTemplate();
299
- $requestUrl = $uriTemplateParser->parse($requestUrl, $uriTemplateVars);
300
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
 
302
- if (count($queryVars)) {
303
- $requestUrl .= '?' . implode('&', $queryVars);
304
- }
 
305
 
306
- return $requestUrl;
307
- }
 
 
 
 
308
  }
17
 
18
  namespace Google\Service;
19
 
 
 
20
  use Google\Exception as GoogleException;
21
+ use Google\Http\MediaFileUpload;
22
+ use Google\Model;
23
  use Google\Utils\UriTemplate;
24
  use GuzzleHttp\Psr7\Request;
25
 
31
  */
32
  class Resource
33
  {
34
+ // Valid query parameters that work, but don't appear in discovery.
35
+ private $stackParameters = [
36
+ 'alt' => ['type' => 'string', 'location' => 'query'],
37
+ 'fields' => ['type' => 'string', 'location' => 'query'],
38
+ 'trace' => ['type' => 'string', 'location' => 'query'],
39
+ 'userIp' => ['type' => 'string', 'location' => 'query'],
40
+ 'quotaUser' => ['type' => 'string', 'location' => 'query'],
41
+ 'data' => ['type' => 'string', 'location' => 'body'],
42
+ 'mimeType' => ['type' => 'string', 'location' => 'header'],
43
+ 'uploadType' => ['type' => 'string', 'location' => 'query'],
44
+ 'mediaUpload' => ['type' => 'complex', 'location' => 'query'],
45
+ 'prettyPrint' => ['type' => 'string', 'location' => 'query'],
46
+ ];
47
+
48
+ /** @var string $rootUrl */
49
+ private $rootUrl;
50
+
51
+ /** @var \Google\Client $client */
52
+ private $client;
53
+
54
+ /** @var string $serviceName */
55
+ private $serviceName;
56
+
57
+ /** @var string $servicePath */
58
+ private $servicePath;
59
+
60
+ /** @var string $resourceName */
61
+ private $resourceName;
62
+
63
+ /** @var array $methods */
64
+ private $methods;
65
+
66
+ public function __construct($service, $serviceName, $resourceName, $resource)
67
+ {
68
+ $this->rootUrl = $service->rootUrl;
69
+ $this->client = $service->getClient();
70
+ $this->servicePath = $service->servicePath;
71
+ $this->serviceName = $serviceName;
72
+ $this->resourceName = $resourceName;
73
+ $this->methods = is_array($resource) && isset($resource['methods']) ?
74
  $resource['methods'] :
75
+ [$resourceName => $resource];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
 
78
+ /**
79
+ * TODO: This function needs simplifying.
80
+ *
81
+ * @template T
82
+ * @param string $name
83
+ * @param array $arguments
84
+ * @param class-string<T> $expectedClass - optional, the expected class name
85
+ * @return mixed|T|ResponseInterface|RequestInterface
86
+ * @throws \Google\Exception
87
+ */
88
+ public function call($name, $arguments, $expectedClass = null)
89
+ {
90
+ if (! isset($this->methods[$name])) {
91
+ $this->client->getLogger()->error(
92
+ 'Service method unknown',
93
+ [
94
+ 'service' => $this->serviceName,
95
+ 'resource' => $this->resourceName,
96
+ 'method' => $name
97
+ ]
98
+ );
99
+
100
+ throw new GoogleException(
101
+ "Unknown function: " .
102
+ "{$this->serviceName}->{$this->resourceName}->{$name}()"
103
+ );
104
+ }
105
+ $method = $this->methods[$name];
106
+ $parameters = $arguments[0];
107
+
108
+ // postBody is a special case since it's not defined in the discovery
109
+ // document as parameter, but we abuse the param entry for storing it.
110
+ $postBody = null;
111
+ if (isset($parameters['postBody'])) {
112
+ if ($parameters['postBody'] instanceof Model) {
113
+ // In the cases the post body is an existing object, we want
114
+ // to use the smart method to create a simple object for
115
+ // for JSONification.
116
+ $parameters['postBody'] = $parameters['postBody']->toSimpleObject();
117
+ } elseif (is_object($parameters['postBody'])) {
118
+ // If the post body is another kind of object, we will try and
119
+ // wrangle it into a sensible format.
120
+ $parameters['postBody'] =
121
+ $this->convertToArrayAndStripNulls($parameters['postBody']);
122
+ }
123
+ $postBody = (array) $parameters['postBody'];
124
+ unset($parameters['postBody']);
125
+ }
126
 
127
+ // TODO: optParams here probably should have been
128
+ // handled already - this may well be redundant code.
129
+ if (isset($parameters['optParams'])) {
130
+ $optParams = $parameters['optParams'];
131
+ unset($parameters['optParams']);
132
+ $parameters = array_merge($parameters, $optParams);
133
+ }
134
 
135
+ if (!isset($method['parameters'])) {
136
+ $method['parameters'] = [];
137
+ }
 
138
 
139
+ $method['parameters'] = array_merge(
140
+ $this->stackParameters,
141
+ $method['parameters']
 
 
 
 
 
 
 
142
  );
 
 
 
143
 
144
+ foreach ($parameters as $key => $val) {
145
+ if ($key != 'postBody' && !isset($method['parameters'][$key])) {
146
+ $this->client->getLogger()->error(
147
+ 'Service parameter unknown',
148
+ [
149
+ 'service' => $this->serviceName,
150
+ 'resource' => $this->resourceName,
151
+ 'method' => $name,
152
+ 'parameter' => $key
153
+ ]
154
+ );
155
+ throw new GoogleException("($name) unknown parameter: '$key'");
156
+ }
157
+ }
158
+
159
+ foreach ($method['parameters'] as $paramName => $paramSpec) {
160
+ if (
161
+ isset($paramSpec['required']) &&
162
+ $paramSpec['required'] &&
163
+ ! isset($parameters[$paramName])
164
+ ) {
165
+ $this->client->getLogger()->error(
166
+ 'Service parameter missing',
167
+ [
168
+ 'service' => $this->serviceName,
169
+ 'resource' => $this->resourceName,
170
+ 'method' => $name,
171
+ 'parameter' => $paramName
172
+ ]
173
+ );
174
+ throw new GoogleException("($name) missing required param: '$paramName'");
175
+ }
176
+ if (isset($parameters[$paramName])) {
177
+ $value = $parameters[$paramName];
178
+ $parameters[$paramName] = $paramSpec;
179
+ $parameters[$paramName]['value'] = $value;
180
+ unset($parameters[$paramName]['required']);
181
+ } else {
182
+ // Ensure we don't pass nulls.
183
+ unset($parameters[$paramName]);
184
+ }
185
+ }
186
+
187
+ $this->client->getLogger()->info(
188
+ 'Service Call',
189
+ [
190
  'service' => $this->serviceName,
191
  'resource' => $this->resourceName,
192
  'method' => $name,
193
+ 'arguments' => $parameters,
194
+ ]
195
  );
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
+ // build the service uri
198
+ $url = $this->createRequestUri($method['path'], $parameters);
199
+
200
+ // NOTE: because we're creating the request by hand,
201
+ // and because the service has a rootUrl property
202
+ // the "base_uri" of the Http Client is not accounted for
203
+ $request = new Request(
204
+ $method['httpMethod'],
205
+ $url,
206
+ ['content-type' => 'application/json'],
207
+ $postBody ? json_encode($postBody) : ''
208
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
 
210
+ // support uploads
211
+ if (isset($parameters['data'])) {
212
+ $mimeType = isset($parameters['mimeType'])
213
+ ? $parameters['mimeType']['value']
214
+ : 'application/octet-stream';
215
+ $data = $parameters['data']['value'];
216
+ $upload = new MediaFileUpload($this->client, $request, $mimeType, $data);
217
 
218
+ // pull down the modified request
219
+ $request = $upload->getRequest();
220
+ }
 
 
 
221
 
222
+ // if this is a media type, we will return the raw response
223
+ // rather than using an expected class
224
+ if (isset($parameters['alt']) && $parameters['alt']['value'] == 'media') {
225
+ $expectedClass = null;
226
+ }
227
 
228
+ // if the client is marked for deferring, rather than
229
+ // execute the request, return the response
230
+ if ($this->client->shouldDefer()) {
231
+ // @TODO find a better way to do this
232
+ $request = $request
233
+ ->withHeader('X-Php-Expected-Class', $expectedClass);
234
+
235
+ return $request;
236
+ }
237
+
238
+ return $this->client->execute($request, $expectedClass);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  }
240
 
241
+ protected function convertToArrayAndStripNulls($o)
242
+ {
243
+ $o = (array) $o;
244
+ foreach ($o as $k => $v) {
245
+ if ($v === null) {
246
+ unset($o[$k]);
247
+ } elseif (is_object($v) || is_array($v)) {
248
+ $o[$k] = $this->convertToArrayAndStripNulls($o[$k]);
249
+ }
250
+ }
251
+ return $o;
252
  }
253
+
254
+ /**
255
+ * Parse/expand request parameters and create a fully qualified
256
+ * request uri.
257
+ * @static
258
+ * @param string $restPath
259
+ * @param array $params
260
+ * @return string $requestUrl
261
+ */
262
+ public function createRequestUri($restPath, $params)
263
+ {
264
+ // Override the default servicePath address if the $restPath use a /
265
+ if ('/' == substr($restPath, 0, 1)) {
266
+ $requestUrl = substr($restPath, 1);
267
  } else {
268
+ $requestUrl = $this->servicePath . $restPath;
269
  }
 
 
270
 
271
+ // code for leading slash
272
+ if ($this->rootUrl) {
273
+ if ('/' !== substr($this->rootUrl, -1) && '/' !== substr($requestUrl, 0, 1)) {
274
+ $requestUrl = '/' . $requestUrl;
275
+ }
276
+ $requestUrl = $this->rootUrl . $requestUrl;
277
+ }
278
+ $uriTemplateVars = [];
279
+ $queryVars = [];
280
+ foreach ($params as $paramName => $paramSpec) {
281
+ if ($paramSpec['type'] == 'boolean') {
282
+ $paramSpec['value'] = $paramSpec['value'] ? 'true' : 'false';
283
+ }
284
+ if ($paramSpec['location'] == 'path') {
285
+ $uriTemplateVars[$paramName] = $paramSpec['value'];
286
+ } elseif ($paramSpec['location'] == 'query') {
287
+ if (is_array($paramSpec['value'])) {
288
+ foreach ($paramSpec['value'] as $value) {
289
+ $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($value));
290
+ }
291
+ } else {
292
+ $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($paramSpec['value']));
293
+ }
294
+ }
295
+ }
296
 
297
+ if (count($uriTemplateVars)) {
298
+ $uriTemplateParser = new UriTemplate();
299
+ $requestUrl = $uriTemplateParser->parse($requestUrl, $uriTemplateVars);
300
+ }
301
 
302
+ if (count($queryVars)) {
303
+ $requestUrl .= '?' . implode('&', $queryVars);
304
+ }
305
+
306
+ return $requestUrl;
307
+ }
308
  }
vendor/google/apiclient/src/Task/Composer.php CHANGED
@@ -18,98 +18,96 @@
18
  namespace Google\Task;
19
 
20
  use Composer\Script\Event;
 
21
  use Symfony\Component\Filesystem\Filesystem;
22
  use Symfony\Component\Finder\Finder;
23
- use InvalidArgumentException;
24
 
25
  class Composer
26
  {
27
- /**
28
- * @param Event $event Composer event passed in for any script method
29
- * @param Filesystem $filesystem Optional. Used for testing.
30
- */
31
- public static function cleanup(
32
- Event $event,
33
- Filesystem $filesystem = null
34
- ) {
35
- $composer = $event->getComposer();
36
- $extra = $composer->getPackage()->getExtra();
37
- $servicesToKeep = isset($extra['google/apiclient-services']) ?
38
- $extra['google/apiclient-services'] : [];
39
- if ($servicesToKeep) {
40
- $vendorDir = $composer->getConfig()->get('vendor-dir');
41
- $serviceDir = sprintf(
42
- '%s/google/apiclient-services/src/Google/Service',
43
- $vendorDir
44
- );
45
- if (!is_dir($serviceDir)) {
46
- // path for google/apiclient-services >= 0.200.0
47
- $serviceDir = sprintf(
48
- '%s/google/apiclient-services/src',
49
- $vendorDir
50
- );
51
- }
52
- self::verifyServicesToKeep($serviceDir, $servicesToKeep);
53
- $finder = self::getServicesToRemove($serviceDir, $servicesToKeep);
54
- $filesystem = $filesystem ?: new Filesystem();
55
- if (0 !== $count = count($finder)) {
56
- $event->getIO()->write(
57
- sprintf(
58
- 'Removing %s google services',
59
- $count
60
- )
61
- );
62
- foreach ($finder as $file) {
63
- $realpath = $file->getRealPath();
64
- $filesystem->remove($realpath);
65
- $filesystem->remove($realpath . '.php');
66
  }
67
- }
68
  }
69
- }
70
 
71
- /**
72
- * @throws InvalidArgumentException when the service doesn't exist
73
- */
74
- private static function verifyServicesToKeep(
75
- $serviceDir,
76
- array $servicesToKeep
77
- ) {
78
- $finder = (new Finder())
79
- ->directories()
80
- ->depth('== 0');
81
 
82
- foreach ($servicesToKeep as $service) {
83
- if (!preg_match('/^[a-zA-Z0-9]*$/', $service)) {
84
- throw new InvalidArgumentException(
85
- sprintf(
86
- 'Invalid Google service name "%s"',
87
- $service
88
- )
89
- );
90
- }
91
- try {
92
- $finder->in($serviceDir . '/' . $service);
93
- } catch (InvalidArgumentException $e) {
94
- throw new InvalidArgumentException(
95
- sprintf(
96
- 'Google service "%s" does not exist or was removed previously',
97
- $service
98
- )
99
- );
100
- }
 
101
  }
102
- }
103
 
104
- private static function getServicesToRemove(
105
- $serviceDir,
106
- array $servicesToKeep
107
- ) {
108
- // find all files in the current directory
109
- return (new Finder())
110
- ->directories()
111
- ->depth('== 0')
112
- ->in($serviceDir)
113
- ->exclude($servicesToKeep);
114
- }
115
  }
18
  namespace Google\Task;
19
 
20
  use Composer\Script\Event;
21
+ use InvalidArgumentException;
22
  use Symfony\Component\Filesystem\Filesystem;
23
  use Symfony\Component\Finder\Finder;
 
24
 
25
  class Composer
26
  {
27
+ /**
28
+ * @param Event $event Composer event passed in for any script method
29
+ * @param Filesystem $filesystem Optional. Used for testing.
30
+ */
31
+ public static function cleanup(
32
+ Event $event,
33
+ Filesystem $filesystem = null
34
+ ) {
35
+ $composer = $event->getComposer();
36
+ $extra = $composer->getPackage()->getExtra();
37
+ $servicesToKeep = isset($extra['google/apiclient-services'])
38
+ ? $extra['google/apiclient-services']
39
+ : [];
40
+ if ($servicesToKeep) {
41
+ $vendorDir = $composer->getConfig()->get('vendor-dir');
42
+ $serviceDir = sprintf(
43
+ '%s/google/apiclient-services/src/Google/Service',
44
+ $vendorDir
45
+ );
46
+ if (!is_dir($serviceDir)) {
47
+ // path for google/apiclient-services >= 0.200.0
48
+ $serviceDir = sprintf(
49
+ '%s/google/apiclient-services/src',
50
+ $vendorDir
51
+ );
52
+ }
53
+ self::verifyServicesToKeep($serviceDir, $servicesToKeep);
54
+ $finder = self::getServicesToRemove($serviceDir, $servicesToKeep);
55
+ $filesystem = $filesystem ?: new Filesystem();
56
+ if (0 !== $count = count($finder)) {
57
+ $event->getIO()->write(
58
+ sprintf('Removing %s google services', $count)
59
+ );
60
+ foreach ($finder as $file) {
61
+ $realpath = $file->getRealPath();
62
+ $filesystem->remove($realpath);
63
+ $filesystem->remove($realpath . '.php');
64
+ }
65
+ }
66
  }
 
67
  }
 
68
 
69
+ /**
70
+ * @throws InvalidArgumentException when the service doesn't exist
71
+ */
72
+ private static function verifyServicesToKeep(
73
+ $serviceDir,
74
+ array $servicesToKeep
75
+ ) {
76
+ $finder = (new Finder())
77
+ ->directories()
78
+ ->depth('== 0');
79
 
80
+ foreach ($servicesToKeep as $service) {
81
+ if (!preg_match('/^[a-zA-Z0-9]*$/', $service)) {
82
+ throw new InvalidArgumentException(
83
+ sprintf(
84
+ 'Invalid Google service name "%s"',
85
+ $service
86
+ )
87
+ );
88
+ }
89
+ try {
90
+ $finder->in($serviceDir . '/' . $service);
91
+ } catch (InvalidArgumentException $e) {
92
+ throw new InvalidArgumentException(
93
+ sprintf(
94
+ 'Google service "%s" does not exist or was removed previously',
95
+ $service
96
+ )
97
+ );
98
+ }
99
+ }
100
  }
 
101
 
102
+ private static function getServicesToRemove(
103
+ $serviceDir,
104
+ array $servicesToKeep
105
+ ) {
106
+ // find all files in the current directory
107
+ return (new Finder())
108
+ ->directories()
109
+ ->depth('== 0')
110
+ ->in($serviceDir)
111
+ ->exclude($servicesToKeep);
112
+ }
113
  }
vendor/google/apiclient/src/Task/Runner.php CHANGED
@@ -27,261 +27,267 @@ use Google\Task\Exception as GoogleTaskException;
27
  */
28
  class Runner
29
  {
30
- const TASK_RETRY_NEVER = 0;
31
- const TASK_RETRY_ONCE = 1;
32
- const TASK_RETRY_ALWAYS = -1;
33
-
34
- /**
35
- * @var integer $maxDelay The max time (in seconds) to wait before a retry.
36
- */
37
- private $maxDelay = 60;
38
- /**
39
- * @var integer $delay The previous delay from which the next is calculated.
40
- */
41
- private $delay = 1;
42
-
43
- /**
44
- * @var integer $factor The base number for the exponential back off.
45
- */
46
- private $factor = 2;
47
- /**
48
- * @var float $jitter A random number between -$jitter and $jitter will be
49
- * added to $factor on each iteration to allow for a better distribution of
50
- * retries.
51
- */
52
- private $jitter = 0.5;
53
-
54
- /**
55
- * @var integer $attempts The number of attempts that have been tried so far.
56
- */
57
- private $attempts = 0;
58
- /**
59
- * @var integer $maxAttempts The max number of attempts allowed.
60
- */
61
- private $maxAttempts = 1;
62
-
63
- /**
64
- * @var callable $action The task to run and possibly retry.
65
- */
66
- private $action;
67
- /**
68
- * @var array $arguments The task arguments.
69
- */
70
- private $arguments;
71
-
72
- /**
73
- * @var array $retryMap Map of errors with retry counts.
74
- */
75
- protected $retryMap = [
76
- '500' => self::TASK_RETRY_ALWAYS,
77
- '503' => self::TASK_RETRY_ALWAYS,
78
- 'rateLimitExceeded' => self::TASK_RETRY_ALWAYS,
79
- 'userRateLimitExceeded' => self::TASK_RETRY_ALWAYS,
80
- 6 => self::TASK_RETRY_ALWAYS, // CURLE_COULDNT_RESOLVE_HOST
81
- 7 => self::TASK_RETRY_ALWAYS, // CURLE_COULDNT_CONNECT
82
- 28 => self::TASK_RETRY_ALWAYS, // CURLE_OPERATION_TIMEOUTED
83
- 35 => self::TASK_RETRY_ALWAYS, // CURLE_SSL_CONNECT_ERROR
84
- 52 => self::TASK_RETRY_ALWAYS, // CURLE_GOT_NOTHING
85
- 'lighthouseError' => self::TASK_RETRY_NEVER
86
- ];
87
-
88
- /**
89
- * Creates a new task runner with exponential backoff support.
90
- *
91
- * @param array $config The task runner config
92
- * @param string $name The name of the current task (used for logging)
93
- * @param callable $action The task to run and possibly retry
94
- * @param array $arguments The task arguments
95
- * @throws \Google\Task\Exception when misconfigured
96
- */
97
- public function __construct(
98
- $config,
99
- $name,
100
- $action,
101
- array $arguments = array()
102
- ) {
103
- if (isset($config['initial_delay'])) {
104
- if ($config['initial_delay'] < 0) {
105
- throw new GoogleTaskException(
106
- 'Task configuration `initial_delay` must not be negative.'
107
- );
108
- }
109
-
110
- $this->delay = $config['initial_delay'];
111
- }
 
 
 
 
 
112
 
113
- if (isset($config['max_delay'])) {
114
- if ($config['max_delay'] <= 0) {
115
- throw new GoogleTaskException(
116
- 'Task configuration `max_delay` must be greater than 0.'
117
- );
118
- }
119
 
120
- $this->maxDelay = $config['max_delay'];
121
- }
122
 
123
- if (isset($config['factor'])) {
124
- if ($config['factor'] <= 0) {
125
- throw new GoogleTaskException(
126
- 'Task configuration `factor` must be greater than 0.'
127
- );
128
- }
129
 
130
- $this->factor = $config['factor'];
131
- }
132
 
133
- if (isset($config['jitter'])) {
134
- if ($config['jitter'] <= 0) {
135
- throw new GoogleTaskException(
136
- 'Task configuration `jitter` must be greater than 0.'
137
- );
138
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
- $this->jitter = $config['jitter'];
 
141
  }
142
 
143
- if (isset($config['retries'])) {
144
- if ($config['retries'] < 0) {
145
- throw new GoogleTaskException(
146
- 'Task configuration `retries` must not be negative.'
147
- );
148
- }
149
- $this->maxAttempts += $config['retries'];
 
150
  }
151
 
152
- if (!is_callable($action)) {
153
- throw new GoogleTaskException(
154
- 'Task argument `$action` must be a valid callable.'
155
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
 
158
- $this->action = $action;
159
- $this->arguments = $arguments;
160
- }
161
-
162
- /**
163
- * Checks if a retry can be attempted.
164
- *
165
- * @return boolean
166
- */
167
- public function canAttempt()
168
- {
169
- return $this->attempts < $this->maxAttempts;
170
- }
171
-
172
- /**
173
- * Runs the task and (if applicable) automatically retries when errors occur.
174
- *
175
- * @return mixed
176
- * @throws \Google\Service\Exception on failure when no retries are available.
177
- */
178
- public function run()
179
- {
180
- while ($this->attempt()) {
181
- try {
182
- return call_user_func_array($this->action, $this->arguments);
183
- } catch (GoogleServiceException $exception) {
184
- $allowedRetries = $this->allowedRetries(
185
- $exception->getCode(),
186
- $exception->getErrors()
187
- );
188
-
189
- if (!$this->canAttempt() || !$allowedRetries) {
190
- throw $exception;
191
  }
192
 
193
- if ($allowedRetries > 0) {
194
- $this->maxAttempts = min(
195
- $this->maxAttempts,
196
- $this->attempts + $allowedRetries
197
- );
198
  }
199
- }
200
- }
201
- }
202
-
203
- /**
204
- * Runs a task once, if possible. This is useful for bypassing the `run()`
205
- * loop.
206
- *
207
- * NOTE: If this is not the first attempt, this function will sleep in
208
- * accordance to the backoff configurations before running the task.
209
- *
210
- * @return boolean
211
- */
212
- public function attempt()
213
- {
214
- if (!$this->canAttempt()) {
215
- return false;
216
  }
217
 
218
- if ($this->attempts > 0) {
219
- $this->backOff();
 
 
 
 
 
 
220
  }
221
 
222
- $this->attempts++;
223
- return true;
224
- }
225
-
226
- /**
227
- * Sleeps in accordance to the backoff configurations.
228
- */
229
- private function backOff()
230
- {
231
- $delay = $this->getDelay();
232
-
233
- usleep($delay * 1000000);
234
- }
235
-
236
- /**
237
- * Gets the delay (in seconds) for the current backoff period.
238
- *
239
- * @return float
240
- */
241
- private function getDelay()
242
- {
243
- $jitter = $this->getJitter();
244
- $factor = $this->attempts > 1 ? $this->factor + $jitter : 1 + abs($jitter);
245
-
246
- return $this->delay = min($this->maxDelay, $this->delay * $factor);
247
- }
248
-
249
- /**
250
- * Gets the current jitter (random number between -$this->jitter and
251
- * $this->jitter).
252
- *
253
- * @return float
254
- */
255
- private function getJitter()
256
- {
257
- return $this->jitter * 2 * mt_rand() / mt_getrandmax() - $this->jitter;
258
- }
259
-
260
- /**
261
- * Gets the number of times the associated task can be retried.
262
- *
263
- * NOTE: -1 is returned if the task can be retried indefinitely
264
- *
265
- * @return integer
266
- */
267
- public function allowedRetries($code, $errors = array())
268
- {
269
- if (isset($this->retryMap[$code])) {
270
- return $this->retryMap[$code];
271
  }
272
 
273
- if (
274
- !empty($errors) &&
275
- isset($errors[0]['reason'], $this->retryMap[$errors[0]['reason']])
276
- ) {
277
- return $this->retryMap[$errors[0]['reason']];
 
 
 
 
278
  }
279
 
280
- return 0;
281
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
 
283
- public function setRetryMap($retryMap)
284
- {
285
- $this->retryMap = $retryMap;
286
- }
 
 
 
287
  }
27
  */
28
  class Runner
29
  {
30
+ const TASK_RETRY_NEVER = 0;
31
+ const TASK_RETRY_ONCE = 1;
32
+ const TASK_RETRY_ALWAYS = -1;
33
+
34
+ /**
35
+ * @var integer $maxDelay The max time (in seconds) to wait before a retry.
36
+ */
37
+ private $maxDelay = 60;
38
+
39
+ /**
40
+ * @var integer $delay The previous delay from which the next is calculated.
41
+ */
42
+ private $delay = 1;
43
+
44
+ /**
45
+ * @var integer $factor The base number for the exponential back off.
46
+ */
47
+ private $factor = 2;
48
+
49
+ /**
50
+ * @var float $jitter A random number between -$jitter and $jitter will be
51
+ * added to $factor on each iteration to allow for a better distribution of
52
+ * retries.
53
+ */
54
+ private $jitter = 0.5;
55
+
56
+ /**
57
+ * @var integer $attempts The number of attempts that have been tried so far.
58
+ */
59
+ private $attempts = 0;
60
+
61
+ /**
62
+ * @var integer $maxAttempts The max number of attempts allowed.
63
+ */
64
+ private $maxAttempts = 1;
65
+
66
+ /**
67
+ * @var callable $action The task to run and possibly retry.
68
+ */
69
+ private $action;
70
+
71
+ /**
72
+ * @var array $arguments The task arguments.
73
+ */
74
+ private $arguments;
75
+
76
+ /**
77
+ * @var array $retryMap Map of errors with retry counts.
78
+ */
79
+ protected $retryMap = [
80
+ '500' => self::TASK_RETRY_ALWAYS,
81
+ '503' => self::TASK_RETRY_ALWAYS,
82
+ 'rateLimitExceeded' => self::TASK_RETRY_ALWAYS,
83
+ 'userRateLimitExceeded' => self::TASK_RETRY_ALWAYS,
84
+ 6 => self::TASK_RETRY_ALWAYS, // CURLE_COULDNT_RESOLVE_HOST
85
+ 7 => self::TASK_RETRY_ALWAYS, // CURLE_COULDNT_CONNECT
86
+ 28 => self::TASK_RETRY_ALWAYS, // CURLE_OPERATION_TIMEOUTED
87
+ 35 => self::TASK_RETRY_ALWAYS, // CURLE_SSL_CONNECT_ERROR
88
+ 52 => self::TASK_RETRY_ALWAYS, // CURLE_GOT_NOTHING
89
+ 'lighthouseError' => self::TASK_RETRY_NEVER
90
+ ];
91
+
92
+ /**
93
+ * Creates a new task runner with exponential backoff support.
94
+ *
95
+ * @param array $config The task runner config
96
+ * @param string $name The name of the current task (used for logging)
97
+ * @param callable $action The task to run and possibly retry
98
+ * @param array $arguments The task arguments
99
+ * @throws \Google\Task\Exception when misconfigured
100
+ */
101
+ // @phpstan-ignore-next-line
102
+ public function __construct(
103
+ $config,
104
+ $name,
105
+ $action,
106
+ array $arguments = []
107
+ ) {
108
+ if (isset($config['initial_delay'])) {
109
+ if ($config['initial_delay'] < 0) {
110
+ throw new GoogleTaskException(
111
+ 'Task configuration `initial_delay` must not be negative.'
112
+ );
113
+ }
114
+
115
+ $this->delay = $config['initial_delay'];
116
+ }
117
 
118
+ if (isset($config['max_delay'])) {
119
+ if ($config['max_delay'] <= 0) {
120
+ throw new GoogleTaskException(
121
+ 'Task configuration `max_delay` must be greater than 0.'
122
+ );
123
+ }
124
 
125
+ $this->maxDelay = $config['max_delay'];
126
+ }
127
 
128
+ if (isset($config['factor'])) {
129
+ if ($config['factor'] <= 0) {
130
+ throw new GoogleTaskException(
131
+ 'Task configuration `factor` must be greater than 0.'
132
+ );
133
+ }
134
 
135
+ $this->factor = $config['factor'];
136
+ }
137
 
138
+ if (isset($config['jitter'])) {
139
+ if ($config['jitter'] <= 0) {
140
+ throw new GoogleTaskException(
141
+ 'Task configuration `jitter` must be greater than 0.'
142
+ );
143
+ }
144
+
145
+ $this->jitter = $config['jitter'];
146
+ }
147
+
148
+ if (isset($config['retries'])) {
149
+ if ($config['retries'] < 0) {
150
+ throw new GoogleTaskException(
151
+ 'Task configuration `retries` must not be negative.'
152
+ );
153
+ }
154
+ $this->maxAttempts += $config['retries'];
155
+ }
156
+
157
+ if (!is_callable($action)) {
158
+ throw new GoogleTaskException(
159
+ 'Task argument `$action` must be a valid callable.'
160
+ );
161
+ }
162
 
163
+ $this->action = $action;
164
+ $this->arguments = $arguments;
165
  }
166
 
167
+ /**
168
+ * Checks if a retry can be attempted.
169
+ *
170
+ * @return boolean
171
+ */
172
+ public function canAttempt()
173
+ {
174
+ return $this->attempts < $this->maxAttempts;
175
  }
176
 
177
+ /**
178
+ * Runs the task and (if applicable) automatically retries when errors occur.
179
+ *
180
+ * @return mixed
181
+ * @throws \Google\Service\Exception on failure when no retries are available.
182
+ */
183
+ public function run()
184
+ {
185
+ while ($this->attempt()) {
186
+ try {
187
+ return call_user_func_array($this->action, $this->arguments);
188
+ } catch (GoogleServiceException $exception) {
189
+ $allowedRetries = $this->allowedRetries(
190
+ $exception->getCode(),
191
+ $exception->getErrors()
192
+ );
193
+
194
+ if (!$this->canAttempt() || !$allowedRetries) {
195
+ throw $exception;
196
+ }
197
+
198
+ if ($allowedRetries > 0) {
199
+ $this->maxAttempts = min(
200
+ $this->maxAttempts,
201
+ $this->attempts + $allowedRetries
202
+ );
203
+ }
204
+ }
205
+ }
206
  }
207
 
208
+ /**
209
+ * Runs a task once, if possible. This is useful for bypassing the `run()`
210
+ * loop.
211
+ *
212
+ * NOTE: If this is not the first attempt, this function will sleep in
213
+ * accordance to the backoff configurations before running the task.
214
+ *
215
+ * @return boolean
216
+ */
217
+ public function attempt()
218
+ {
219
+ if (!$this->canAttempt()) {
220
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  }
222
 
223
+ if ($this->attempts > 0) {
224
+ $this->backOff();
 
 
 
225
  }
226
+
227
+ $this->attempts++;
228
+
229
+ return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  }
231
 
232
+ /**
233
+ * Sleeps in accordance to the backoff configurations.
234
+ */
235
+ private function backOff()
236
+ {
237
+ $delay = $this->getDelay();
238
+
239
+ usleep((int) ($delay * 1000000));
240
  }
241
 
242
+ /**
243
+ * Gets the delay (in seconds) for the current backoff period.
244
+ *
245
+ * @return int
246
+ */
247
+ private function getDelay()
248
+ {
249
+ $jitter = $this->getJitter();
250
+ $factor = $this->attempts > 1 ? $this->factor + $jitter : 1 + abs($jitter);
251
+
252
+ return $this->delay = min($this->maxDelay, $this->delay * $factor);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  }
254
 
255
+ /**
256
+ * Gets the current jitter (random number between -$this->jitter and
257
+ * $this->jitter).
258
+ *
259
+ * @return float
260
+ */
261
+ private function getJitter()
262
+ {
263
+ return $this->jitter * 2 * mt_rand() / mt_getrandmax() - $this->jitter;
264
  }
265
 
266
+ /**
267
+ * Gets the number of times the associated task can be retried.
268
+ *
269
+ * NOTE: -1 is returned if the task can be retried indefinitely
270
+ *
271
+ * @return integer
272
+ */
273
+ public function allowedRetries($code, $errors = [])
274
+ {
275
+ if (isset($this->retryMap[$code])) {
276
+ return $this->retryMap[$code];
277
+ }
278
+
279
+ if (
280
+ !empty($errors) &&
281
+ isset($errors[0]['reason'], $this->retryMap[$errors[0]['reason']])
282
+ ) {
283
+ return $this->retryMap[$errors[0]['reason']];
284
+ }
285
 
286
+ return 0;
287
+ }
288
+
289
+ public function setRetryMap($retryMap)
290
+ {
291
+ $this->retryMap = $retryMap;
292
+ }
293
  }
vendor/google/apiclient/src/Utils/UriTemplate.php CHANGED
@@ -23,313 +23,312 @@ namespace Google\Utils;
23
  */
24
  class UriTemplate
25
  {
26
- const TYPE_MAP = "1";
27
- const TYPE_LIST = "2";
28
- const TYPE_SCALAR = "4";
29
 
30
- /**
31
- * @var $operators array
32
- * These are valid at the start of a template block to
33
- * modify the way in which the variables inside are
34
- * processed.
35
- */
36
- private $operators = array(
37
- "+" => "reserved",
38
- "/" => "segments",
39
- "." => "dotprefix",
40
- "#" => "fragment",
41
- ";" => "semicolon",
42
- "?" => "form",
43
- "&" => "continuation"
44
- );
45
 
46
- /**
47
- * @var reserved array
48
- * These are the characters which should not be URL encoded in reserved
49
- * strings.
50
- */
51
- private $reserved = array(
52
- "=", ",", "!", "@", "|", ":", "/", "?", "#",
53
- "[", "]",'$', "&", "'", "(", ")", "*", "+", ";"
54
- );
55
- private $reservedEncoded = array(
56
- "%3D", "%2C", "%21", "%40", "%7C", "%3A", "%2F", "%3F",
57
- "%23", "%5B", "%5D", "%24", "%26", "%27", "%28", "%29",
58
- "%2A", "%2B", "%3B"
59
- );
60
 
61
- public function parse($string, array $parameters)
62
- {
63
- return $this->resolveNextSection($string, $parameters);
64
- }
65
-
66
- /**
67
- * This function finds the first matching {...} block and
68
- * executes the replacement. It then calls itself to find
69
- * subsequent blocks, if any.
70
- */
71
- private function resolveNextSection($string, $parameters)
72
- {
73
- $start = strpos($string, "{");
74
- if ($start === false) {
75
- return $string;
76
- }
77
- $end = strpos($string, "}");
78
- if ($end === false) {
79
- return $string;
80
  }
81
- $string = $this->replace($string, $start, $end, $parameters);
82
- return $this->resolveNextSection($string, $parameters);
83
- }
84
 
85
- private function replace($string, $start, $end, $parameters)
86
- {
87
- // We know a data block will have {} round it, so we can strip that.
88
- $data = substr($string, $start + 1, $end - $start - 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
- // If the first character is one of the reserved operators, it effects
91
- // the processing of the stream.
92
- if (isset($this->operators[$data[0]])) {
93
- $op = $this->operators[$data[0]];
94
- $data = substr($data, 1);
95
- $prefix = "";
96
- $prefix_on_missing = false;
97
 
98
- switch ($op) {
99
- case "reserved":
100
- // Reserved means certain characters should not be URL encoded
101
- $data = $this->replaceVars($data, $parameters, ",", null, true);
102
- break;
103
- case "fragment":
104
- // Comma separated with fragment prefix. Bare values only.
105
- $prefix = "#";
106
- $prefix_on_missing = true;
107
- $data = $this->replaceVars($data, $parameters, ",", null, true);
108
- break;
109
- case "segments":
110
- // Slash separated data. Bare values only.
111
- $prefix = "/";
112
- $data =$this->replaceVars($data, $parameters, "/");
113
- break;
114
- case "dotprefix":
115
- // Dot separated data. Bare values only.
116
- $prefix = ".";
117
- $prefix_on_missing = true;
118
- $data = $this->replaceVars($data, $parameters, ".");
119
- break;
120
- case "semicolon":
121
- // Semicolon prefixed and separated. Uses the key name
122
- $prefix = ";";
123
- $data = $this->replaceVars($data, $parameters, ";", "=", false, true, false);
124
- break;
125
- case "form":
126
- // Standard URL format. Uses the key name
127
- $prefix = "?";
128
- $data = $this->replaceVars($data, $parameters, "&", "=");
129
- break;
130
- case "continuation":
131
- // Standard URL, but with leading ampersand. Uses key name.
132
- $prefix = "&";
133
- $data = $this->replaceVars($data, $parameters, "&", "=");
134
- break;
135
- }
136
 
137
- // Add the initial prefix character if data is valid.
138
- if ($data || ($data !== false && $prefix_on_missing)) {
139
- $data = $prefix . $data;
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
- } else {
143
- // If no operator we replace with the defaults.
144
- $data = $this->replaceVars($data, $parameters);
 
 
 
 
 
 
 
145
  }
146
- // This is chops out the {...} and replaces with the new section.
147
- return substr($string, 0, $start) . $data . substr($string, $end + 1);
148
- }
149
 
150
- private function replaceVars(
151
- $section,
152
- $parameters,
153
- $sep = ",",
154
- $combine = null,
155
- $reserved = false,
156
- $tag_empty = false,
157
- $combine_on_empty = true
158
- ) {
159
- if (strpos($section, ",") === false) {
160
- // If we only have a single value, we can immediately process.
161
- return $this->combine(
162
- $section,
163
- $parameters,
164
- $sep,
165
- $combine,
166
- $reserved,
167
- $tag_empty,
168
- $combine_on_empty
169
- );
170
- } else {
171
- // If we have multiple values, we need to split and loop over them.
172
- // Each is treated individually, then glued together with the
173
- // separator character.
174
- $vars = explode(",", $section);
175
- return $this->combineList(
176
- $vars,
177
- $sep,
178
- $parameters,
179
- $combine,
180
- $reserved,
181
- false, // Never emit empty strings in multi-param replacements
182
- $combine_on_empty
183
- );
 
184
  }
185
- }
186
 
187
- public function combine(
188
- $key,
189
- $parameters,
190
- $sep,
191
- $combine,
192
- $reserved,
193
- $tag_empty,
194
- $combine_on_empty
195
- ) {
196
- $length = false;
197
- $explode = false;
198
- $skip_final_combine = false;
199
- $value = false;
200
 
201
- // Check for length restriction.
202
- if (strpos($key, ":") !== false) {
203
- list($key, $length) = explode(":", $key);
204
- }
205
 
206
- // Check for explode parameter.
207
- if ($key[strlen($key) - 1] == "*") {
208
- $explode = true;
209
- $key = substr($key, 0, -1);
210
- $skip_final_combine = true;
211
- }
212
 
213
- // Define the list separator.
214
- $list_sep = $explode ? $sep : ",";
215
 
216
- if (isset($parameters[$key])) {
217
- $data_type = $this->getDataType($parameters[$key]);
218
- switch ($data_type) {
219
- case self::TYPE_SCALAR:
220
- $value = $this->getValue($parameters[$key], $length);
221
- break;
222
- case self::TYPE_LIST:
223
- $values = array();
224
- foreach ($parameters[$key] as $pkey => $pvalue) {
225
- $pvalue = $this->getValue($pvalue, $length);
226
- if ($combine && $explode) {
227
- $values[$pkey] = $key . $combine . $pvalue;
228
- } else {
229
- $values[$pkey] = $pvalue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  }
231
- }
232
- $value = implode($list_sep, $values);
233
- if ($value == '') {
234
- return '';
235
- }
236
- break;
237
- case self::TYPE_MAP:
238
- $values = array();
239
- foreach ($parameters[$key] as $pkey => $pvalue) {
240
- $pvalue = $this->getValue($pvalue, $length);
241
- if ($explode) {
242
- $pkey = $this->getValue($pkey, $length);
243
- $values[] = $pkey . "=" . $pvalue; // Explode triggers = combine.
244
- } else {
245
- $values[] = $pkey;
246
- $values[] = $pvalue;
247
- }
248
- }
249
- $value = implode($list_sep, $values);
250
- if ($value == '') {
251
  return false;
252
- }
253
- break;
254
- }
255
- } else if ($tag_empty) {
256
- // If we are just indicating empty values with their key name, return that.
257
- return $key;
258
- } else {
259
- // Otherwise we can skip this variable due to not being defined.
260
- return false;
261
- }
262
 
263
- if ($reserved) {
264
- $value = str_replace($this->reservedEncoded, $this->reserved, $value);
265
- }
266
 
267
- // If we do not need to include the key name, we just return the raw
268
- // value.
269
- if (!$combine || $skip_final_combine) {
270
- return $value;
271
- }
272
 
273
- // Else we combine the key name: foo=bar, if value is not the empty string.
274
- return $key . ($value != '' || $combine_on_empty ? $combine . $value : '');
275
- }
276
 
277
- /**
278
- * Return the type of a passed in value
279
- */
280
- private function getDataType($data)
281
- {
282
- if (is_array($data)) {
283
- reset($data);
284
- if (key($data) !== 0) {
285
- return self::TYPE_MAP;
286
- }
287
- return self::TYPE_LIST;
 
 
288
  }
289
- return self::TYPE_SCALAR;
290
- }
291
 
292
- /**
293
- * Utility function that merges multiple combine calls
294
- * for multi-key templates.
295
- */
296
- private function combineList(
297
- $vars,
298
- $sep,
299
- $parameters,
300
- $combine,
301
- $reserved,
302
- $tag_empty,
303
- $combine_on_empty
304
- ) {
305
- $ret = array();
306
- foreach ($vars as $var) {
307
- $response = $this->combine(
308
- $var,
309
- $parameters,
310
- $sep,
311
- $combine,
312
- $reserved,
313
- $tag_empty,
314
- $combine_on_empty
315
- );
316
- if ($response === false) {
317
- continue;
318
- }
319
- $ret[] = $response;
 
 
320
  }
321
- return implode($sep, $ret);
322
- }
323
 
324
- /**
325
- * Utility function to encode and trim values
326
- */
327
- private function getValue($value, $length)
328
- {
329
- if ($length) {
330
- $value = substr($value, 0, $length);
 
 
 
331
  }
332
- $value = rawurlencode($value);
333
- return $value;
334
- }
335
  }
23
  */
24
  class UriTemplate
25
  {
26
+ const TYPE_MAP = "1";
27
+ const TYPE_LIST = "2";
28
+ const TYPE_SCALAR = "4";
29
 
30
+ /**
31
+ * @var array $operators
32
+ * These are valid at the start of a template block to
33
+ * modify the way in which the variables inside are
34
+ * processed.
35
+ */
36
+ private $operators = [
37
+ "+" => "reserved",
38
+ "/" => "segments",
39
+ "." => "dotprefix",
40
+ "#" => "fragment",
41
+ ";" => "semicolon",
42
+ "?" => "form",
43
+ "&" => "continuation"
44
+ ];
45
 
46
+ /**
47
+ * @var array<string>
48
+ * These are the characters which should not be URL encoded in reserved
49
+ * strings.
50
+ */
51
+ private $reserved = [
52
+ "=", ",", "!", "@", "|", ":", "/", "?", "#",
53
+ "[", "]", '$', "&", "'", "(", ")", "*", "+", ";"
54
+ ];
55
+ private $reservedEncoded = [
56
+ "%3D", "%2C", "%21", "%40", "%7C", "%3A", "%2F", "%3F",
57
+ "%23", "%5B", "%5D", "%24", "%26", "%27", "%28", "%29",
58
+ "%2A", "%2B", "%3B"
59
+ ];
60
 
61
+ public function parse($string, array $parameters)
62
+ {
63
+ return $this->resolveNextSection($string, $parameters);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
 
 
 
65
 
66
+ /**
67
+ * This function finds the first matching {...} block and
68
+ * executes the replacement. It then calls itself to find
69
+ * subsequent blocks, if any.
70
+ */
71
+ private function resolveNextSection($string, $parameters)
72
+ {
73
+ $start = strpos($string, "{");
74
+ if ($start === false) {
75
+ return $string;
76
+ }
77
+ $end = strpos($string, "}");
78
+ if ($end === false) {
79
+ return $string;
80
+ }
81
+ $string = $this->replace($string, $start, $end, $parameters);
82
+ return $this->resolveNextSection($string, $parameters);
83
+ }
84
 
85
+ private function replace($string, $start, $end, $parameters)
86
+ {
87
+ // We know a data block will have {} round it, so we can strip that.
88
+ $data = substr($string, $start + 1, $end - $start - 1);
 
 
 
89
 
90
+ // If the first character is one of the reserved operators, it effects
91
+ // the processing of the stream.
92
+ if (isset($this->operators[$data[0]])) {
93
+ $op = $this->operators[$data[0]];
94
+ $data = substr($data, 1);
95
+ $prefix = "";
96
+ $prefix_on_missing = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
+ switch ($op) {
99
+ case "reserved":
100
+ // Reserved means certain characters should not be URL encoded
101
+ $data = $this->replaceVars($data, $parameters, ",", null, true);
102
+ break;
103
+ case "fragment":
104
+ // Comma separated with fragment prefix. Bare values only.
105
+ $prefix = "#";
106
+ $prefix_on_missing = true;
107
+ $data = $this->replaceVars($data, $parameters, ",", null, true);
108
+ break;
109
+ case "segments":
110
+ // Slash separated data. Bare values only.
111
+ $prefix = "/";
112
+ $data =$this->replaceVars($data, $parameters, "/");
113
+ break;
114
+ case "dotprefix":
115
+ // Dot separated data. Bare values only.
116
+ $prefix = ".";
117
+ $prefix_on_missing = true;
118
+ $data = $this->replaceVars($data, $parameters, ".");
119
+ break;
120
+ case "semicolon":
121
+ // Semicolon prefixed and separated. Uses the key name
122
+ $prefix = ";";
123
+ $data = $this->replaceVars($data, $parameters, ";", "=", false, true, false);
124
+ break;
125
+ case "form":
126
+ // Standard URL format. Uses the key name
127
+ $prefix = "?";
128
+ $data = $this->replaceVars($data, $parameters, "&", "=");
129
+ break;
130
+ case "continuation":
131
+ // Standard URL, but with leading ampersand. Uses key name.
132
+ $prefix = "&";
133
+ $data = $this->replaceVars($data, $parameters, "&", "=");
134
+ break;
135
+ }
136
 
137
+ // Add the initial prefix character if data is valid.
138
+ if ($data || ($data !== false && $prefix_on_missing)) {
139
+ $data = $prefix . $data;
140
+ }
141
+ } else {
142
+ // If no operator we replace with the defaults.
143
+ $data = $this->replaceVars($data, $parameters);
144
+ }
145
+ // This is chops out the {...} and replaces with the new section.
146
+ return substr($string, 0, $start) . $data . substr($string, $end + 1);
147
  }
 
 
 
148
 
149
+ private function replaceVars(
150
+ $section,
151
+ $parameters,
152
+ $sep = ",",
153
+ $combine = null,
154
+ $reserved = false,
155
+ $tag_empty = false,
156
+ $combine_on_empty = true
157
+ ) {
158
+ if (strpos($section, ",") === false) {
159
+ // If we only have a single value, we can immediately process.
160
+ return $this->combine(
161
+ $section,
162
+ $parameters,
163
+ $sep,
164
+ $combine,
165
+ $reserved,
166
+ $tag_empty,
167
+ $combine_on_empty
168
+ );
169
+ } else {
170
+ // If we have multiple values, we need to split and loop over them.
171
+ // Each is treated individually, then glued together with the
172
+ // separator character.
173
+ $vars = explode(",", $section);
174
+ return $this->combineList(
175
+ $vars,
176
+ $sep,
177
+ $parameters,
178
+ $combine,
179
+ $reserved,
180
+ false, // Never emit empty strings in multi-param replacements
181
+ $combine_on_empty
182
+ );
183
+ }
184
  }
 
185
 
186
+ public function combine(
187
+ $key,
188
+ $parameters,
189
+ $sep,
190
+ $combine,
191
+ $reserved,
192
+ $tag_empty,
193
+ $combine_on_empty
194
+ ) {
195
+ $length = false;
196
+ $explode = false;
197
+ $skip_final_combine = false;
198
+ $value = false;
199
 
200
+ // Check for length restriction.
201
+ if (strpos($key, ":") !== false) {
202
+ list($key, $length) = explode(":", $key);
203
+ }
204
 
205
+ // Check for explode parameter.
206
+ if ($key[strlen($key) - 1] == "*") {
207
+ $explode = true;
208
+ $key = substr($key, 0, -1);
209
+ $skip_final_combine = true;
210
+ }
211
 
212
+ // Define the list separator.
213
+ $list_sep = $explode ? $sep : ",";
214
 
215
+ if (isset($parameters[$key])) {
216
+ $data_type = $this->getDataType($parameters[$key]);
217
+ switch ($data_type) {
218
+ case self::TYPE_SCALAR:
219
+ $value = $this->getValue($parameters[$key], $length);
220
+ break;
221
+ case self::TYPE_LIST:
222
+ $values = [];
223
+ foreach ($parameters[$key] as $pkey => $pvalue) {
224
+ $pvalue = $this->getValue($pvalue, $length);
225
+ if ($combine && $explode) {
226
+ $values[$pkey] = $key . $combine . $pvalue;
227
+ } else {
228
+ $values[$pkey] = $pvalue;
229
+ }
230
+ }
231
+ $value = implode($list_sep, $values);
232
+ if ($value == '') {
233
+ return '';
234
+ }
235
+ break;
236
+ case self::TYPE_MAP:
237
+ $values = [];
238
+ foreach ($parameters[$key] as $pkey => $pvalue) {
239
+ $pvalue = $this->getValue($pvalue, $length);
240
+ if ($explode) {
241
+ $pkey = $this->getValue($pkey, $length);
242
+ $values[] = $pkey . "=" . $pvalue; // Explode triggers = combine.
243
+ } else {
244
+ $values[] = $pkey;
245
+ $values[] = $pvalue;
246
+ }
247
+ }
248
+ $value = implode($list_sep, $values);
249
+ if ($value == '') {
250
+ return false;
251
+ }
252
+ break;
253
  }
254
+ } elseif ($tag_empty) {
255
+ // If we are just indicating empty values with their key name, return that.
256
+ return $key;
257
+ } else {
258
+ // Otherwise we can skip this variable due to not being defined.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  return false;
260
+ }
 
 
 
 
 
 
 
 
 
261
 
262
+ if ($reserved) {
263
+ $value = str_replace($this->reservedEncoded, $this->reserved, $value);
264
+ }
265
 
266
+ // If we do not need to include the key name, we just return the raw
267
+ // value.
268
+ if (!$combine || $skip_final_combine) {
269
+ return $value;
270
+ }
271
 
272
+ // Else we combine the key name: foo=bar, if value is not the empty string.
273
+ return $key . ($value != '' || $combine_on_empty ? $combine . $value : '');
274
+ }
275
 
276
+ /**
277
+ * Return the type of a passed in value
278
+ */
279
+ private function getDataType($data)
280
+ {
281
+ if (is_array($data)) {
282
+ reset($data);
283
+ if (key($data) !== 0) {
284
+ return self::TYPE_MAP;
285
+ }
286
+ return self::TYPE_LIST;
287
+ }
288
+ return self::TYPE_SCALAR;
289
  }
 
 
290
 
291
+ /**
292
+ * Utility function that merges multiple combine calls
293
+ * for multi-key templates.
294
+ */
295
+ private function combineList(
296
+ $vars,
297
+ $sep,
298
+ $parameters,
299
+ $combine,
300
+ $reserved,
301
+ $tag_empty,
302
+ $combine_on_empty
303
+ ) {
304
+ $ret = [];
305
+ foreach ($vars as $var) {
306
+ $response = $this->combine(
307
+ $var,
308
+ $parameters,
309
+ $sep,
310
+ $combine,
311
+ $reserved,
312
+ $tag_empty,
313
+ $combine_on_empty
314
+ );
315
+ if ($response === false) {
316
+ continue;
317
+ }
318
+ $ret[] = $response;
319
+ }
320
+ return implode($sep, $ret);
321
  }
 
 
322
 
323
+ /**
324
+ * Utility function to encode and trim values
325
+ */
326
+ private function getValue($value, $length)
327
+ {
328
+ if ($length) {
329
+ $value = substr($value, 0, $length);
330
+ }
331
+ $value = rawurlencode($value);
332
+ return $value;
333
  }
 
 
 
334
  }
vendor/google/apiclient/src/aliases.php CHANGED
@@ -41,25 +41,66 @@ class Google_Task_Composer extends \Google\Task\Composer
41
  {
42
  }
43
 
 
44
  if (\false) {
45
- class Google_AccessToken_Revoke extends \Google\AccessToken\Revoke {}
46
- class Google_AccessToken_Verify extends \Google\AccessToken\Verify {}
47
- class Google_AuthHandler_AuthHandlerFactory extends \Google\AuthHandler\AuthHandlerFactory {}
48
- class Google_AuthHandler_Guzzle5AuthHandler extends \Google\AuthHandler\Guzzle5AuthHandler {}
49
- class Google_AuthHandler_Guzzle6AuthHandler extends \Google\AuthHandler\Guzzle6AuthHandler {}
50
- class Google_AuthHandler_Guzzle7AuthHandler extends \Google\AuthHandler\Guzzle7AuthHandler {}
51
- class Google_Client extends \Google\Client {}
52
- class Google_Collection extends \Google\Collection {}
53
- class Google_Exception extends \Google\Exception {}
54
- class Google_Http_Batch extends \Google\Http\Batch {}
55
- class Google_Http_MediaFileUpload extends \Google\Http\MediaFileUpload {}
56
- class Google_Http_REST extends \Google\Http\REST {}
57
- class Google_Model extends \Google\Model {}
58
- class Google_Service extends \Google\Service {}
59
- class Google_Service_Exception extends \Google\Service\Exception {}
60
- class Google_Service_Resource extends \Google\Service\Resource {}
61
- class Google_Task_Exception extends \Google\Task\Exception {}
62
- interface Google_Task_Retryable extends \Google\Task\Retryable {}
63
- class Google_Task_Runner extends \Google\Task\Runner {}
64
- class Google_Utils_UriTemplate extends \Google\Utils\UriTemplate {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
41
  {
42
  }
43
 
44
+ /** @phpstan-ignore-next-line */
45
  if (\false) {
46
+ class Google_AccessToken_Revoke extends \Google\AccessToken\Revoke
47
+ {
48
+ }
49
+ class Google_AccessToken_Verify extends \Google\AccessToken\Verify
50
+ {
51
+ }
52
+ class Google_AuthHandler_AuthHandlerFactory extends \Google\AuthHandler\AuthHandlerFactory
53
+ {
54
+ }
55
+ class Google_AuthHandler_Guzzle5AuthHandler extends \Google\AuthHandler\Guzzle5AuthHandler
56
+ {
57
+ }
58
+ class Google_AuthHandler_Guzzle6AuthHandler extends \Google\AuthHandler\Guzzle6AuthHandler
59
+ {
60
+ }
61
+ class Google_AuthHandler_Guzzle7AuthHandler extends \Google\AuthHandler\Guzzle7AuthHandler
62
+ {
63
+ }
64
+ class Google_Client extends \Google\Client
65
+ {
66
+ }
67
+ class Google_Collection extends \Google\Collection
68
+ {
69
+ }
70
+ class Google_Exception extends \Google\Exception
71
+ {
72
+ }
73
+ class Google_Http_Batch extends \Google\Http\Batch
74
+ {
75
+ }
76
+ class Google_Http_MediaFileUpload extends \Google\Http\MediaFileUpload
77
+ {
78
+ }
79
+ class Google_Http_REST extends \Google\Http\REST
80
+ {
81
+ }
82
+ class Google_Model extends \Google\Model
83
+ {
84
+ }
85
+ class Google_Service extends \Google\Service
86
+ {
87
+ }
88
+ class Google_Service_Exception extends \Google\Service\Exception
89
+ {
90
+ }
91
+ class Google_Service_Resource extends \Google\Service\Resource
92
+ {
93
+ }
94
+ class Google_Task_Exception extends \Google\Task\Exception
95
+ {
96
+ }
97
+ interface Google_Task_Retryable extends \Google\Task\Retryable
98
+ {
99
+ }
100
+ class Google_Task_Runner extends \Google\Task\Runner
101
+ {
102
+ }
103
+ class Google_Utils_UriTemplate extends \Google\Utils\UriTemplate
104
+ {
105
+ }
106
  }
vendor/google/auth/phpstan.neon.dist ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ parameters:
2
+ treatPhpDocTypesAsCertain: false
3
+ level: 7
4
+ paths:
5
+ - src
6
+ featureToggles:
7
+ disableRuntimeReflectionProvider: true
8
+ excludePaths:
9
+ - src/HttpHandler/Guzzle5HttpHandler.php
10
+ - src/Cache/Item.php
vendor/google/auth/renovate.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": [
3
- "config:base",
4
- ":preserveSemverRanges"
5
- ]
6
- }
 
 
 
 
 
 
vendor/google/auth/src/AccessToken.php CHANGED
@@ -25,8 +25,8 @@ use Firebase\JWT\SignatureInvalidException;
25
  use Google\Auth\Cache\MemoryCacheItemPool;
26
  use Google\Auth\HttpHandler\HttpClientCache;
27
  use Google\Auth\HttpHandler\HttpHandlerFactory;
28
- use GuzzleHttp\Psr7;
29
  use GuzzleHttp\Psr7\Request;
 
30
  use InvalidArgumentException;
31
  use phpseclib\Crypt\RSA;
32
  use phpseclib\Math\BigInteger;
@@ -82,20 +82,22 @@ class AccessToken
82
  * accepted. By default, the id token must have been issued to this OAuth2 client.
83
  *
84
  * @param string $token The JSON Web Token to be verified.
85
- * @param array $options [optional] Configuration options.
86
- * @param string $options.audience The indended recipient of the token.
87
- * @param string $options.issuer The intended issuer of the token.
88
- * @param string $options.cacheKey The cache key of the cached certs. Defaults to
 
89
  * the sha1 of $certsLocation if provided, otherwise is set to
90
  * "federated_signon_certs_v3".
91
- * @param string $options.certsLocation The location (remote or local) from which
92
  * to retrieve certificates, if not cached. This value should only be
93
  * provided in limited circumstances in which you are sure of the
94
  * behavior.
95
- * @param bool $options.throwException Whether the function should throw an
96
  * exception if the verification fails. This is useful for
97
  * determining the reason verification failed.
98
- * @return array|bool the token payload, if successful, or false if not.
 
99
  * @throws InvalidArgumentException If certs could not be retrieved from a local file.
100
  * @throws InvalidArgumentException If received certs are in an invalid format.
101
  * @throws InvalidArgumentException If the cert alg is not supported.
@@ -134,12 +136,10 @@ class AccessToken
134
  return $this->verifyRs256($token, $certs, $audience, $issuer);
135
  }
136
  return $this->verifyEs256($token, $certs, $audience, $issuer);
137
- } catch (ExpiredException $e) { // firebase/php-jwt 3+
138
- } catch (\ExpiredException $e) { // firebase/php-jwt 2
139
- } catch (SignatureInvalidException $e) { // firebase/php-jwt 3+
140
- } catch (\SignatureInvalidException $e) { // firebase/php-jwt 2
141
  } catch (InvalidTokenException $e) { // simplejwt
142
- } catch (DomainException $e) {
143
  } catch (InvalidArgumentException $e) {
144
  } catch (UnexpectedValueException $e) {
145
  }
@@ -155,7 +155,7 @@ class AccessToken
155
  * Identifies the expected algorithm to verify by looking at the "alg" key
156
  * of the provided certs.
157
  *
158
- * @param array $certs Certificate array according to the JWK spec (see
159
  * https://tools.ietf.org/html/rfc7517).
160
  * @return string The expected algorithm, such as "ES256" or "RS256".
161
  */
@@ -183,13 +183,13 @@ class AccessToken
183
  * Verifies an ES256-signed JWT.
184
  *
185
  * @param string $token The JSON Web Token to be verified.
186
- * @param array $certs Certificate array according to the JWK spec (see
187
  * https://tools.ietf.org/html/rfc7517).
188
  * @param string|null $audience If set, returns false if the provided
189
  * audience does not match the "aud" claim on the JWT.
190
  * @param string|null $issuer If set, returns false if the provided
191
  * issuer does not match the "iss" claim on the JWT.
192
- * @return array|bool the token payload, if successful, or false if not.
193
  */
194
  private function verifyEs256($token, array $certs, $audience = null, $issuer = null)
195
  {
@@ -204,8 +204,8 @@ class AccessToken
204
  $jwt = $this->callSimpleJwtDecode([$token, $jwkset, 'ES256']);
205
  $payload = $jwt->getClaims();
206
 
207
- if (isset($payload['aud'])) {
208
- if ($audience && $payload['aud'] != $audience) {
209
  throw new UnexpectedValueException('Audience does not match');
210
  }
211
  }
@@ -223,13 +223,13 @@ class AccessToken
223
  * Verifies an RS256-signed JWT.
224
  *
225
  * @param string $token The JSON Web Token to be verified.
226
- * @param array $certs Certificate array according to the JWK spec (see
227
  * https://tools.ietf.org/html/rfc7517).
228
  * @param string|null $audience If set, returns false if the provided
229
  * audience does not match the "aud" claim on the JWT.
230
  * @param string|null $issuer If set, returns false if the provided
231
  * issuer does not match the "iss" claim on the JWT.
232
- * @return array|bool the token payload, if successful, or false if not.
233
  */
234
  private function verifyRs256($token, array $certs, $audience = null, $issuer = null)
235
  {
@@ -266,8 +266,8 @@ class AccessToken
266
  ['RS256']
267
  ]);
268
 
269
- if (property_exists($payload, 'aud')) {
270
- if ($audience && $payload->aud != $audience) {
271
  throw new UnexpectedValueException('Audience does not match');
272
  }
273
  }
@@ -286,8 +286,8 @@ class AccessToken
286
  * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
287
  * token, if a token isn't provided.
288
  *
289
- * @param string|array $token The token (access token or a refresh token) that should be revoked.
290
- * @param array $options [optional] Configuration options.
291
  * @return bool Returns True if the revocation was successful, otherwise False.
292
  */
293
  public function revoke($token, array $options = [])
@@ -300,7 +300,7 @@ class AccessToken
300
  }
301
  }
302
 
303
- $body = Psr7\stream_for(http_build_query(['token' => $token]));
304
  $request = new Request('POST', self::OAUTH2_REVOKE_URI, [
305
  'Cache-Control' => 'no-store',
306
  'Content-Type' => 'application/x-www-form-urlencoded',
@@ -320,14 +320,14 @@ class AccessToken
320
  *
321
  * @param string $location The location from which to retrieve certs.
322
  * @param string $cacheKey The key under which to cache the retrieved certs.
323
- * @param array $options [optional] Configuration options.
324
- * @return array
325
  * @throws InvalidArgumentException If received certs are in an invalid format.
326
  */
327
  private function getCerts($location, $cacheKey, array $options = [])
328
  {
329
  $cacheItem = $this->cache->getItem($cacheKey);
330
- $certs = $cacheItem ? $cacheItem->get() : null;
331
 
332
  $gotNewCerts = false;
333
  if (!$certs) {
@@ -361,9 +361,9 @@ class AccessToken
361
  /**
362
  * Retrieve and cache a certificates file.
363
  *
364
- * @param $url string location
365
- * @param array $options [optional] Configuration options.
366
- * @return array certificates
367
  * @throws InvalidArgumentException If certs could not be retrieved from a local file.
368
  * @throws RuntimeException If certs could not be retrieved from a remote location.
369
  */
@@ -378,7 +378,7 @@ class AccessToken
378
  ));
379
  }
380
 
381
- return json_decode(file_get_contents($url), true);
382
  }
383
 
384
  $httpHandler = $this->httpHandler;
@@ -394,6 +394,9 @@ class AccessToken
394
  ), $response->getStatusCode());
395
  }
396
 
 
 
 
397
  private function checkAndInitializePhpsec()
398
  {
399
  // @codeCoverageIgnoreStart
@@ -405,10 +408,13 @@ class AccessToken
405
  $this->setPhpsecConstants();
406
  }
407
 
 
 
 
408
  private function checkSimpleJwt()
409
  {
410
  // @codeCoverageIgnoreStart
411
- if (!class_exists('SimpleJWT\JWT')) {
412
  throw new RuntimeException('Please require kelvinmo/simplejwt ^0.2 to use this utility.');
413
  }
414
  // @codeCoverageIgnoreEnd
@@ -422,6 +428,8 @@ class AccessToken
422
  * @see phpseclib/Math/BigInteger
423
  * @see https://github.com/GoogleCloudPlatform/getting-started-php/issues/85
424
  * @codeCoverageIgnore
 
 
425
  */
426
  private function setPhpsecConstants()
427
  {
@@ -439,26 +447,23 @@ class AccessToken
439
  * Provide a hook to mock calls to the JWT static methods.
440
  *
441
  * @param string $method
442
- * @param array $args
443
  * @return mixed
444
  */
445
  protected function callJwtStatic($method, array $args = [])
446
  {
447
- $class = class_exists('Firebase\JWT\JWT')
448
- ? 'Firebase\JWT\JWT'
449
- : 'JWT';
450
- return call_user_func_array([$class, $method], $args);
451
  }
452
 
453
  /**
454
  * Provide a hook to mock calls to the JWT static methods.
455
  *
456
- * @param array $args
457
  * @return mixed
458
  */
459
  protected function callSimpleJwtDecode(array $args = [])
460
  {
461
- return call_user_func_array(['SimpleJWT\JWT', 'decode'], $args);
462
  }
463
 
464
  /**
25
  use Google\Auth\Cache\MemoryCacheItemPool;
26
  use Google\Auth\HttpHandler\HttpClientCache;
27
  use Google\Auth\HttpHandler\HttpHandlerFactory;
 
28
  use GuzzleHttp\Psr7\Request;
29
+ use GuzzleHttp\Psr7\Utils;
30
  use InvalidArgumentException;
31
  use phpseclib\Crypt\RSA;
32
  use phpseclib\Math\BigInteger;
82
  * accepted. By default, the id token must have been issued to this OAuth2 client.
83
  *
84
  * @param string $token The JSON Web Token to be verified.
85
+ * @param array<mixed> $options [optional] {
86
+ * Configuration options.
87
+ * @type string $audience The indended recipient of the token.
88
+ * @type string $issuer The intended issuer of the token.
89
+ * @type string $cacheKey The cache key of the cached certs. Defaults to
90
  * the sha1 of $certsLocation if provided, otherwise is set to
91
  * "federated_signon_certs_v3".
92
+ * @type string $certsLocation The location (remote or local) from which
93
  * to retrieve certificates, if not cached. This value should only be
94
  * provided in limited circumstances in which you are sure of the
95
  * behavior.
96
+ * @type bool $throwException Whether the function should throw an
97
  * exception if the verification fails. This is useful for
98
  * determining the reason verification failed.
99
+ * }
100
+ * @return array<mixed>|false the token payload, if successful, or false if not.
101
  * @throws InvalidArgumentException If certs could not be retrieved from a local file.
102
  * @throws InvalidArgumentException If received certs are in an invalid format.
103
  * @throws InvalidArgumentException If the cert alg is not supported.
136
  return $this->verifyRs256($token, $certs, $audience, $issuer);
137
  }
138
  return $this->verifyEs256($token, $certs, $audience, $issuer);
139
+ } catch (ExpiredException $e) { // firebase/php-jwt 5+
140
+ } catch (SignatureInvalidException $e) { // firebase/php-jwt 5+
 
 
141
  } catch (InvalidTokenException $e) { // simplejwt
142
+ } catch (DomainException $e) { // @phpstan-ignore-line
143
  } catch (InvalidArgumentException $e) {
144
  } catch (UnexpectedValueException $e) {
145
  }
155
  * Identifies the expected algorithm to verify by looking at the "alg" key
156
  * of the provided certs.
157
  *
158
+ * @param array<mixed> $certs Certificate array according to the JWK spec (see
159
  * https://tools.ietf.org/html/rfc7517).
160
  * @return string The expected algorithm, such as "ES256" or "RS256".
161
  */
183
  * Verifies an ES256-signed JWT.
184
  *
185
  * @param string $token The JSON Web Token to be verified.
186
+ * @param array<mixed> $certs Certificate array according to the JWK spec (see
187
  * https://tools.ietf.org/html/rfc7517).
188
  * @param string|null $audience If set, returns false if the provided
189
  * audience does not match the "aud" claim on the JWT.
190
  * @param string|null $issuer If set, returns false if the provided
191
  * issuer does not match the "iss" claim on the JWT.
192
+ * @return array<mixed> the token payload, if successful, or false if not.
193
  */
194
  private function verifyEs256($token, array $certs, $audience = null, $issuer = null)
195
  {
204
  $jwt = $this->callSimpleJwtDecode([$token, $jwkset, 'ES256']);
205
  $payload = $jwt->getClaims();
206
 
207
+ if ($audience) {
208
+ if (!isset($payload['aud']) || $payload['aud'] != $audience) {
209
  throw new UnexpectedValueException('Audience does not match');
210
  }
211
  }
223
  * Verifies an RS256-signed JWT.
224
  *
225
  * @param string $token The JSON Web Token to be verified.
226
+ * @param array<mixed> $certs Certificate array according to the JWK spec (see
227
  * https://tools.ietf.org/html/rfc7517).
228
  * @param string|null $audience If set, returns false if the provided
229
  * audience does not match the "aud" claim on the JWT.
230
  * @param string|null $issuer If set, returns false if the provided
231
  * issuer does not match the "iss" claim on the JWT.
232
+ * @return array<mixed> the token payload, if successful, or false if not.
233
  */
234
  private function verifyRs256($token, array $certs, $audience = null, $issuer = null)
235
  {
266
  ['RS256']
267
  ]);
268
 
269
+ if ($audience) {
270
+ if (!property_exists($payload, 'aud') || $payload->aud != $audience) {
271
  throw new UnexpectedValueException('Audience does not match');
272
  }
273
  }
286
  * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
287
  * token, if a token isn't provided.
288
  *
289
+ * @param string|array<mixed> $token The token (access token or a refresh token) that should be revoked.
290
+ * @param array<mixed> $options [optional] Configuration options.
291
  * @return bool Returns True if the revocation was successful, otherwise False.
292
  */
293
  public function revoke($token, array $options = [])
300
  }
301
  }
302
 
303
+ $body = Utils::streamFor(http_build_query(['token' => $token]));
304
  $request = new Request('POST', self::OAUTH2_REVOKE_URI, [
305
  'Cache-Control' => 'no-store',
306
  'Content-Type' => 'application/x-www-form-urlencoded',
320
  *
321
  * @param string $location The location from which to retrieve certs.
322
  * @param string $cacheKey The key under which to cache the retrieved certs.
323
+ * @param array<mixed> $options [optional] Configuration options.
324
+ * @return array<mixed>
325
  * @throws InvalidArgumentException If received certs are in an invalid format.
326
  */
327
  private function getCerts($location, $cacheKey, array $options = [])
328
  {
329
  $cacheItem = $this->cache->getItem($cacheKey);
330
+ $certs = $cacheItem ? $cacheItem->get() : null; // @phpstan-ignore-line
331
 
332
  $gotNewCerts = false;
333
  if (!$certs) {
361
  /**
362
  * Retrieve and cache a certificates file.
363
  *
364
+ * @param string $url location
365
+ * @param array<mixed> $options [optional] Configuration options.
366
+ * @return array<mixed> certificates
367
  * @throws InvalidArgumentException If certs could not be retrieved from a local file.
368
  * @throws RuntimeException If certs could not be retrieved from a remote location.
369
  */
378
  ));
379
  }
380
 
381
+ return json_decode((string) file_get_contents($url), true);
382
  }
383
 
384
  $httpHandler = $this->httpHandler;
394
  ), $response->getStatusCode());
395
  }
396
 
397
+ /**
398
+ * @return void
399
+ */
400
  private function checkAndInitializePhpsec()
401
  {
402
  // @codeCoverageIgnoreStart
408
  $this->setPhpsecConstants();
409
  }
410
 
411
+ /**
412
+ * @return void
413
+ */
414
  private function checkSimpleJwt()
415
  {
416
  // @codeCoverageIgnoreStart
417
+ if (!class_exists(SimpleJwt::class)) {
418
  throw new RuntimeException('Please require kelvinmo/simplejwt ^0.2 to use this utility.');
419
  }
420
  // @codeCoverageIgnoreEnd
428
  * @see phpseclib/Math/BigInteger
429
  * @see https://github.com/GoogleCloudPlatform/getting-started-php/issues/85
430
  * @codeCoverageIgnore
431
+ *
432
+ * @return void
433
  */
434
  private function setPhpsecConstants()
435
  {
447
  * Provide a hook to mock calls to the JWT static methods.
448
  *
449
  * @param string $method
450
+ * @param array<mixed> $args
451
  * @return mixed
452
  */
453
  protected function callJwtStatic($method, array $args = [])
454
  {
455
+ return call_user_func_array([JWT::class, $method], $args); // @phpstan-ignore-line
 
 
 
456
  }
457
 
458
  /**
459
  * Provide a hook to mock calls to the JWT static methods.
460
  *
461
+ * @param array<mixed> $args
462
  * @return mixed
463
  */
464
  protected function callSimpleJwtDecode(array $args = [])
465
  {
466
+ return call_user_func_array([SimpleJwt::class, 'decode'], $args);
467
  }
468
 
469
  /**
vendor/google/auth/src/ApplicationDefaultCredentials.php CHANGED
@@ -24,6 +24,7 @@ use Google\Auth\Credentials\ServiceAccountCredentials;
24
  use Google\Auth\HttpHandler\HttpClientCache;
25
  use Google\Auth\HttpHandler\HttpHandlerFactory;
26
  use Google\Auth\Middleware\AuthTokenMiddleware;
 
27
  use Google\Auth\Subscriber\AuthTokenSubscriber;
28
  use GuzzleHttp\Client;
29
  use InvalidArgumentException;
@@ -69,22 +70,24 @@ use Psr\Cache\CacheItemPoolInterface;
69
  class ApplicationDefaultCredentials
70
  {
71
  /**
 
 
72
  * Obtains an AuthTokenSubscriber that uses the default FetchAuthTokenInterface
73
  * implementation to use in this environment.
74
  *
75
  * If supplied, $scope is used to in creating the credentials instance if
76
  * this does not fallback to the compute engine defaults.
77
  *
78
- * @param string|array scope the scope of the access request, expressed
79
  * either as an Array or as a space-delimited String.
80
  * @param callable $httpHandler callback which delivers psr7 request
81
- * @param array $cacheConfig configuration for the cache when it's present
82
  * @param CacheItemPoolInterface $cache A cache implementation, may be
83
  * provided if you have one already available for use.
84
  * @return AuthTokenSubscriber
85
  * @throws DomainException if no implementation can be obtained.
86
  */
87
- public static function getSubscriber(
88
  $scope = null,
89
  callable $httpHandler = null,
90
  array $cacheConfig = null,
@@ -92,6 +95,7 @@ class ApplicationDefaultCredentials
92
  ) {
93
  $creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);
94
 
 
95
  return new AuthTokenSubscriber($creds, $httpHandler);
96
  }
97
 
@@ -102,10 +106,10 @@ class ApplicationDefaultCredentials
102
  * If supplied, $scope is used to in creating the credentials instance if
103
  * this does not fallback to the compute engine defaults.
104
  *
105
- * @param string|array scope the scope of the access request, expressed
106
  * either as an Array or as a space-delimited String.
107
  * @param callable $httpHandler callback which delivers psr7 request
108
- * @param array $cacheConfig configuration for the cache when it's present
109
  * @param CacheItemPoolInterface $cache A cache implementation, may be
110
  * provided if you have one already available for use.
111
  * @param string $quotaProject specifies a project to bill for access
@@ -126,26 +130,22 @@ class ApplicationDefaultCredentials
126
  }
127
 
128
  /**
129
- * Obtains an AuthTokenMiddleware which will fetch an access token to use in
130
- * the Authorization header. The middleware is configured with the default
131
- * FetchAuthTokenInterface implementation to use in this environment.
132
- *
133
- * If supplied, $scope is used to in creating the credentials instance if
134
- * this does not fallback to the Compute Engine defaults.
135
  *
136
- * @param string|array $scope the scope of the access request, expressed
137
  * either as an Array or as a space-delimited String.
138
  * @param callable $httpHandler callback which delivers psr7 request
139
- * @param array $cacheConfig configuration for the cache when it's present
140
  * @param CacheItemPoolInterface $cache A cache implementation, may be
141
  * provided if you have one already available for use.
142
  * @param string $quotaProject specifies a project to bill for access
143
  * charges associated with the request.
144
- * @param string|array $defaultScope The default scope to use if no
145
  * user-defined scopes exist, expressed either as an Array or as a
146
  * space-delimited string.
147
  *
148
- * @return CredentialsLoader
149
  * @throws DomainException if no implementation can be obtained.
150
  */
151
  public static function getCredentials(
@@ -204,7 +204,7 @@ class ApplicationDefaultCredentials
204
  *
205
  * @param string $targetAudience The audience for the ID token.
206
  * @param callable $httpHandler callback which delivers psr7 request
207
- * @param array $cacheConfig configuration for the cache when it's present
208
  * @param CacheItemPoolInterface $cache A cache implementation, may be
209
  * provided if you have one already available for use.
210
  * @return AuthTokenMiddleware
@@ -221,6 +221,33 @@ class ApplicationDefaultCredentials
221
  return new AuthTokenMiddleware($creds, $httpHandler);
222
  }
223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  /**
225
  * Obtains the default FetchAuthTokenInterface implementation to use
226
  * in this environment, configured with a $targetAudience for fetching an ID
@@ -228,10 +255,10 @@ class ApplicationDefaultCredentials
228
  *
229
  * @param string $targetAudience The audience for the ID token.
230
  * @param callable $httpHandler callback which delivers psr7 request
231
- * @param array $cacheConfig configuration for the cache when it's present
232
  * @param CacheItemPoolInterface $cache A cache implementation, may be
233
  * provided if you have one already available for use.
234
- * @return CredentialsLoader
235
  * @throws DomainException if no implementation can be obtained.
236
  * @throws InvalidArgumentException if JSON "type" key is invalid
237
  */
@@ -281,6 +308,9 @@ class ApplicationDefaultCredentials
281
  return $creds;
282
  }
283
 
 
 
 
284
  private static function notFound()
285
  {
286
  $msg = 'Could not load the default credentials. Browse to ';
@@ -291,6 +321,12 @@ class ApplicationDefaultCredentials
291
  return $msg;
292
  }
293
 
 
 
 
 
 
 
294
  private static function onGce(
295
  callable $httpHandler = null,
296
  array $cacheConfig = null,
24
  use Google\Auth\HttpHandler\HttpClientCache;
25
  use Google\Auth\HttpHandler\HttpHandlerFactory;
26
  use Google\Auth\Middleware\AuthTokenMiddleware;
27
+ use Google\Auth\Middleware\ProxyAuthTokenMiddleware;
28
  use Google\Auth\Subscriber\AuthTokenSubscriber;
29
  use GuzzleHttp\Client;
30
  use InvalidArgumentException;
70
  class ApplicationDefaultCredentials
71
  {
72
  /**
73
+ * @deprecated
74
+ *
75
  * Obtains an AuthTokenSubscriber that uses the default FetchAuthTokenInterface
76
  * implementation to use in this environment.
77
  *
78
  * If supplied, $scope is used to in creating the credentials instance if
79
  * this does not fallback to the compute engine defaults.
80
  *
81
+ * @param string|string[] $scope the scope of the access request, expressed
82
  * either as an Array or as a space-delimited String.
83
  * @param callable $httpHandler callback which delivers psr7 request
84
+ * @param array<mixed> $cacheConfig configuration for the cache when it's present
85
  * @param CacheItemPoolInterface $cache A cache implementation, may be
86
  * provided if you have one already available for use.
87
  * @return AuthTokenSubscriber
88
  * @throws DomainException if no implementation can be obtained.
89
  */
90
+ public static function getSubscriber(// @phpstan-ignore-line
91
  $scope = null,
92
  callable $httpHandler = null,
93
  array $cacheConfig = null,
95
  ) {
96
  $creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);
97
 
98
+ /** @phpstan-ignore-next-line */
99
  return new AuthTokenSubscriber($creds, $httpHandler);
100
  }
101
 
106
  * If supplied, $scope is used to in creating the credentials instance if
107
  * this does not fallback to the compute engine defaults.
108
  *
109
+ * @param string|string[] $scope the scope of the access request, expressed
110
  * either as an Array or as a space-delimited String.
111
  * @param callable $httpHandler callback which delivers psr7 request
112
+ * @param array<mixed> $cacheConfig configuration for the cache when it's present
113
  * @param CacheItemPoolInterface $cache A cache implementation, may be
114
  * provided if you have one already available for use.
115
  * @param string $quotaProject specifies a project to bill for access
130
  }
131
 
132
  /**
133
+ * Obtains the default FetchAuthTokenInterface implementation to use
134
+ * in this environment.
 
 
 
 
135
  *
136
+ * @param string|string[] $scope the scope of the access request, expressed
137
  * either as an Array or as a space-delimited String.
138
  * @param callable $httpHandler callback which delivers psr7 request
139
+ * @param array<mixed> $cacheConfig configuration for the cache when it's present
140
  * @param CacheItemPoolInterface $cache A cache implementation, may be
141
  * provided if you have one already available for use.
142
  * @param string $quotaProject specifies a project to bill for access
143
  * charges associated with the request.
144
+ * @param string|string[] $defaultScope The default scope to use if no
145
  * user-defined scopes exist, expressed either as an Array or as a
146
  * space-delimited string.
147
  *
148
+ * @return FetchAuthTokenInterface
149
  * @throws DomainException if no implementation can be obtained.
150
  */
151
  public static function getCredentials(
204
  *
205
  * @param string $targetAudience The audience for the ID token.
206
  * @param callable $httpHandler callback which delivers psr7 request
207
+ * @param array<mixed> $cacheConfig configuration for the cache when it's present
208
  * @param CacheItemPoolInterface $cache A cache implementation, may be
209
  * provided if you have one already available for use.
210
  * @return AuthTokenMiddleware
221
  return new AuthTokenMiddleware($creds, $httpHandler);
222
  }
223
 
224
+ /**
225
+ * Obtains an ProxyAuthTokenMiddleware which will fetch an ID token to use in the
226
+ * Authorization header. The middleware is configured with the default
227
+ * FetchAuthTokenInterface implementation to use in this environment.
228
+ *
229
+ * If supplied, $targetAudience is used to set the "aud" on the resulting
230
+ * ID token.
231
+ *
232
+ * @param string $targetAudience The audience for the ID token.
233
+ * @param callable $httpHandler callback which delivers psr7 request
234
+ * @param array<mixed> $cacheConfig configuration for the cache when it's present
235
+ * @param CacheItemPoolInterface $cache A cache implementation, may be
236
+ * provided if you have one already available for use.
237
+ * @return ProxyAuthTokenMiddleware
238
+ * @throws DomainException if no implementation can be obtained.
239
+ */
240
+ public static function getProxyIdTokenMiddleware(
241
+ $targetAudience,
242
+ callable $httpHandler = null,
243
+ array $cacheConfig = null,
244
+ CacheItemPoolInterface $cache = null
245
+ ) {
246
+ $creds = self::getIdTokenCredentials($targetAudience, $httpHandler, $cacheConfig, $cache);
247
+
248
+ return new ProxyAuthTokenMiddleware($creds, $httpHandler);
249
+ }
250
+
251
  /**
252
  * Obtains the default FetchAuthTokenInterface implementation to use
253
  * in this environment, configured with a $targetAudience for fetching an ID
255
  *
256
  * @param string $targetAudience The audience for the ID token.
257
  * @param callable $httpHandler callback which delivers psr7 request
258
+ * @param array<mixed> $cacheConfig configuration for the cache when it's present
259
  * @param CacheItemPoolInterface $cache A cache implementation, may be
260
  * provided if you have one already available for use.
261
+ * @return FetchAuthTokenInterface
262
  * @throws DomainException if no implementation can be obtained.
263
  * @throws InvalidArgumentException if JSON "type" key is invalid
264
  */
308
  return $creds;
309
  }
310
 
311
+ /**
312
+ * @return string
313
+ */
314
  private static function notFound()
315
  {
316
  $msg = 'Could not load the default credentials. Browse to ';
321
  return $msg;
322
  }
323
 
324
+ /**
325
+ * @param callable $httpHandler
326
+ * @param array<mixed> $cacheConfig
327
+ * @param CacheItemPoolInterface $cache
328
+ * @return bool
329
+ */
330
  private static function onGce(
331
  callable $httpHandler = null,
332
  array $cacheConfig = null,
vendor/google/auth/src/Cache/Item.php CHANGED
@@ -17,7 +17,11 @@
17
 
18
  namespace Google\Auth\Cache;
19
 
 
 
 
20
  use Psr\Cache\CacheItemInterface;
 
21
 
22
  /**
23
  * A cache item.
@@ -35,7 +39,7 @@ final class Item implements CacheItemInterface
35
  private $value;
36
 
37
  /**
38
- * @var \DateTime|null
39
  */
40
  private $expiration;
41
 
@@ -106,18 +110,13 @@ final class Item implements CacheItemInterface
106
  return $this;
107
  }
108
 
109
- $implementationMessage = interface_exists('DateTimeInterface')
110
- ? 'implement interface DateTimeInterface'
111
- : 'be an instance of DateTime';
112
-
113
  $error = sprintf(
114
- 'Argument 1 passed to %s::expiresAt() must %s, %s given',
115
  get_class($this),
116
- $implementationMessage,
117
  gettype($expiration)
118
  );
119
 
120
- $this->handleError($error);
121
  }
122
 
123
  /**
@@ -136,27 +135,12 @@ final class Item implements CacheItemInterface
136
  'instance of DateInterval or of the type integer, %s given';
137
  $error = sprintf($message, get_class($this), gettype($time));
138
 
139
- $this->handleError($error);
140
  }
141
 
142
  return $this;
143
  }
144
 
145
- /**
146
- * Handles an error.
147
- *
148
- * @param string $error
149
- * @throws \TypeError
150
- */
151
- private function handleError($error)
152
- {
153
- if (class_exists('TypeError')) {
154
- throw new \TypeError($error);
155
- }
156
-
157
- trigger_error($error, E_USER_ERROR);
158
- }
159
-
160
  /**
161
  * Determines if an expiration is valid based on the rules defined by PSR6.
162
  *
@@ -169,22 +153,18 @@ final class Item implements CacheItemInterface
169
  return true;
170
  }
171
 
172
- // We test for two types here due to the fact the DateTimeInterface
173
- // was not introduced until PHP 5.5. Checking for the DateTime type as
174
- // well allows us to support 5.4.
175
- if ($expiration instanceof \DateTimeInterface) {
176
- return true;
177
- }
178
-
179
- if ($expiration instanceof \DateTime) {
180
  return true;
181
  }
182
 
183
  return false;
184
  }
185
 
 
 
 
186
  protected function currentTime()
187
  {
188
- return new \DateTime('now', new \DateTimeZone('UTC'));
189
  }
190
  }
17
 
18
  namespace Google\Auth\Cache;
19
 
20
+ use DateTime;
21
+ use DateTimeInterface;
22
+ use DateTimeZone;
23
  use Psr\Cache\CacheItemInterface;
24
+ use TypeError;
25
 
26
  /**
27
  * A cache item.
39
  private $value;
40
 
41
  /**
42
+ * @var DateTimeInterface|null
43
  */
44
  private $expiration;
45
 
110
  return $this;
111
  }
112
 
 
 
 
 
113
  $error = sprintf(
114
+ 'Argument 1 passed to %s::expiresAt() must implement interface DateTimeInterface, %s given',
115
  get_class($this),
 
116
  gettype($expiration)
117
  );
118
 
119
+ throw new TypeError($error);
120
  }
121
 
122
  /**
135
  'instance of DateInterval or of the type integer, %s given';
136
  $error = sprintf($message, get_class($this), gettype($time));
137
 
138
+ throw new TypeError($error);
139
  }
140
 
141
  return $this;
142
  }
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  /**
145
  * Determines if an expiration is valid based on the rules defined by PSR6.
146
  *
153
  return true;
154
  }
155
 
156
+ if ($expiration instanceof DateTimeInterface) {
 
 
 
 
 
 
 
157
  return true;
158
  }
159
 
160
  return false;
161
  }
162
 
163
+ /**
164
+ * @return DateTime
165
+ */
166
  protected function currentTime()
167
  {
168
+ return new DateTime('now', new DateTimeZone('UTC'));
169
  }
170
  }
vendor/google/auth/src/Cache/MemoryCacheItemPool.php CHANGED
@@ -37,21 +37,29 @@ final class MemoryCacheItemPool implements CacheItemPoolInterface
37
 
38
  /**
39
  * {@inheritdoc}
 
 
40
  */
41
- public function getItem($key)
42
  {
43
- return current($this->getItems([$key]));
44
  }
45
 
46
  /**
47
  * {@inheritdoc}
 
 
 
 
 
 
48
  */
49
- public function getItems(array $keys = [])
50
  {
51
  $items = [];
52
-
53
  foreach ($keys as $key) {
54
- $items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new Item($key);
55
  }
56
 
57
  return $items;
@@ -59,8 +67,11 @@ final class MemoryCacheItemPool implements CacheItemPoolInterface
59
 
60
  /**
61
  * {@inheritdoc}
 
 
 
62
  */
63
- public function hasItem($key)
64
  {
65
  $this->isValidKey($key);
66
 
@@ -69,8 +80,11 @@ final class MemoryCacheItemPool implements CacheItemPoolInterface
69
 
70
  /**
71
  * {@inheritdoc}
 
 
 
72
  */
73
- public function clear()
74
  {
75
  $this->items = [];
76
  $this->deferredItems = [];
@@ -80,16 +94,22 @@ final class MemoryCacheItemPool implements CacheItemPoolInterface
80
 
81
  /**
82
  * {@inheritdoc}
 
 
 
83
  */
84
- public function deleteItem($key)
85
  {
86
  return $this->deleteItems([$key]);
87
  }
88
 
89
  /**
90
  * {@inheritdoc}
 
 
 
91
  */
92
- public function deleteItems(array $keys)
93
  {
94
  array_walk($keys, [$this, 'isValidKey']);
95
 
@@ -102,8 +122,11 @@ final class MemoryCacheItemPool implements CacheItemPoolInterface
102
 
103
  /**
104
  * {@inheritdoc}
 
 
 
105
  */
106
- public function save(CacheItemInterface $item)
107
  {
108
  $this->items[$item->getKey()] = $item;
109
 
@@ -112,8 +135,11 @@ final class MemoryCacheItemPool implements CacheItemPoolInterface
112
 
113
  /**
114
  * {@inheritdoc}
 
 
 
115
  */
116
- public function saveDeferred(CacheItemInterface $item)
117
  {
118
  $this->deferredItems[$item->getKey()] = $item;
119
 
@@ -122,8 +148,11 @@ final class MemoryCacheItemPool implements CacheItemPoolInterface
122
 
123
  /**
124
  * {@inheritdoc}
 
 
 
125
  */
126
- public function commit()
127
  {
128
  foreach ($this->deferredItems as $item) {
129
  $this->save($item);
37
 
38
  /**
39
  * {@inheritdoc}
40
+ *
41
+ * @return CacheItemInterface The corresponding Cache Item.
42
  */
43
+ public function getItem($key): CacheItemInterface
44
  {
45
+ return current($this->getItems([$key])); // @phpstan-ignore-line
46
  }
47
 
48
  /**
49
  * {@inheritdoc}
50
+ *
51
+ * @return iterable<CacheItemInterface>
52
+ * A traversable collection of Cache Items keyed by the cache keys of
53
+ * each item. A Cache item will be returned for each key, even if that
54
+ * key is not found. However, if no keys are specified then an empty
55
+ * traversable MUST be returned instead.
56
  */
57
+ public function getItems(array $keys = []): iterable
58
  {
59
  $items = [];
60
+ $itemClass = \PHP_VERSION_ID >= 80000 ? TypedItem::class : Item::class;
61
  foreach ($keys as $key) {
62
+ $items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new $itemClass($key);
63
  }
64
 
65
  return $items;
67
 
68
  /**
69
  * {@inheritdoc}
70
+ *
71
+ * @return bool
72
+ * True if item exists in the cache, false otherwise.
73
  */
74
+ public function hasItem($key): bool
75
  {
76
  $this->isValidKey($key);
77
 
80
 
81
  /**
82
  * {@inheritdoc}
83
+ *
84
+ * @return bool
85
+ * True if the pool was successfully cleared. False if there was an error.
86
  */
87
+ public function clear(): bool
88
  {
89
  $this->items = [];
90
  $this->deferredItems = [];
94
 
95
  /**
96
  * {@inheritdoc}
97
+ *
98
+ * @return bool
99
+ * True if the item was successfully removed. False if there was an error.
100
  */
101
+ public function deleteItem($key): bool
102
  {
103
  return $this->deleteItems([$key]);
104
  }
105
 
106
  /**
107
  * {@inheritdoc}
108
+ *
109
+ * @return bool
110
+ * True if the items were successfully removed. False if there was an error.
111
  */
112
+ public function deleteItems(array $keys): bool
113
  {
114
  array_walk($keys, [$this, 'isValidKey']);
115
 
122
 
123
  /**
124
  * {@inheritdoc}
125
+ *
126
+ * @return bool
127
+ * True if the item was successfully persisted. False if there was an error.
128
  */
129
+ public function save(CacheItemInterface $item): bool
130
  {
131
  $this->items[$item->getKey()] = $item;
132
 
135
 
136
  /**
137
  * {@inheritdoc}
138
+ *
139
+ * @return bool
140
+ * False if the item could not be queued or if a commit was attempted and failed. True otherwise.
141
  */
142
+ public function saveDeferred(CacheItemInterface $item): bool
143
  {
144
  $this->deferredItems[$item->getKey()] = $item;
145
 
148
 
149
  /**
150
  * {@inheritdoc}
151
+ *
152
+ * @return bool
153
+ * True if all not-yet-saved items were successfully saved or there were none. False otherwise.
154
  */
155
+ public function commit(): bool
156
  {
157
  foreach ($this->deferredItems as $item) {
158
  $this->save($item);
vendor/google/auth/src/Cache/SysVCacheItemPool.php CHANGED
@@ -36,7 +36,9 @@ class SysVCacheItemPool implements CacheItemPoolInterface
36
 
37
  const DEFAULT_PERM = 0600;
38
 
39
- /** @var int */
 
 
40
  private $sysvKey;
41
 
42
  /**
@@ -50,11 +52,11 @@ class SysVCacheItemPool implements CacheItemPoolInterface
50
  private $deferredItems;
51
 
52
  /**
53
- * @var array
54
  */
55
  private $options;
56
 
57
- /*
58
  * @var bool
59
  */
60
  private $hasLoadedItems = false;
@@ -62,15 +64,14 @@ class SysVCacheItemPool implements CacheItemPoolInterface
62
  /**
63
  * Create a SystemV shared memory based CacheItemPool.
64
  *
65
- * @param array $options [optional] Configuration options.
66
- * @param int $options.variableKey The variable key for getting the data from
67
- * the shared memory. **Defaults to** 1.
68
- * @param $options.proj string The project identifier for ftok. This needs to
69
- * be a one character string. **Defaults to** 'A'.
70
- * @param $options.memsize int The memory size in bytes for shm_attach.
71
- * **Defaults to** 10000.
72
- * @param $options.perm int The permission for shm_attach. **Defaults to**
73
- * 0600.
74
  */
75
  public function __construct($options = [])
76
  {
@@ -90,23 +91,29 @@ class SysVCacheItemPool implements CacheItemPoolInterface
90
  $this->sysvKey = ftok(__FILE__, $this->options['proj']);
91
  }
92
 
93
- public function getItem($key)
 
 
 
 
94
  {
95
  $this->loadItems();
96
- return current($this->getItems([$key]));
97
  }
98
 
99
  /**
100
- * {@inheritdoc}
 
101
  */
102
- public function getItems(array $keys = [])
103
  {
104
  $this->loadItems();
105
  $items = [];
 
106
  foreach ($keys as $key) {
107
  $items[$key] = $this->hasItem($key) ?
108
  clone $this->items[$key] :
109
- new Item($key);
110
  }
111
  return $items;
112
  }
@@ -114,7 +121,7 @@ class SysVCacheItemPool implements CacheItemPoolInterface
114
  /**
115
  * {@inheritdoc}
116
  */
117
- public function hasItem($key)
118
  {
119
  $this->loadItems();
120
  return isset($this->items[$key]) && $this->items[$key]->isHit();
@@ -123,7 +130,7 @@ class SysVCacheItemPool implements CacheItemPoolInterface
123
  /**
124
  * {@inheritdoc}
125
  */
126
- public function clear()
127
  {
128
  $this->items = [];
129
  $this->deferredItems = [];
@@ -133,7 +140,7 @@ class SysVCacheItemPool implements CacheItemPoolInterface
133
  /**
134
  * {@inheritdoc}
135
  */
136
- public function deleteItem($key)
137
  {
138
  return $this->deleteItems([$key]);
139
  }
@@ -141,7 +148,7 @@ class SysVCacheItemPool implements CacheItemPoolInterface
141
  /**
142
  * {@inheritdoc}
143
  */
144
- public function deleteItems(array $keys)
145
  {
146
  if (!$this->hasLoadedItems) {
147
  $this->loadItems();
@@ -156,7 +163,7 @@ class SysVCacheItemPool implements CacheItemPoolInterface
156
  /**
157
  * {@inheritdoc}
158
  */
159
- public function save(CacheItemInterface $item)
160
  {
161
  if (!$this->hasLoadedItems) {
162
  $this->loadItems();
@@ -169,7 +176,7 @@ class SysVCacheItemPool implements CacheItemPoolInterface
169
  /**
170
  * {@inheritdoc}
171
  */
172
- public function saveDeferred(CacheItemInterface $item)
173
  {
174
  $this->deferredItems[$item->getKey()] = $item;
175
  return true;
@@ -178,7 +185,7 @@ class SysVCacheItemPool implements CacheItemPoolInterface
178
  /**
179
  * {@inheritdoc}
180
  */
181
- public function commit()
182
  {
183
  foreach ($this->deferredItems as $item) {
184
  if ($this->save($item) === false) {
36
 
37
  const DEFAULT_PERM = 0600;
38
 
39
+ /**
40
+ * @var int
41
+ */
42
  private $sysvKey;
43
 
44
  /**
52
  private $deferredItems;
53
 
54
  /**
55
+ * @var array<mixed>
56
  */
57
  private $options;
58
 
59
+ /**
60
  * @var bool
61
  */
62
  private $hasLoadedItems = false;
64
  /**
65
  * Create a SystemV shared memory based CacheItemPool.
66
  *
67
+ * @param array<mixed> $options {
68
+ * [optional] Configuration options.
69
+ *
70
+ * @type int $variableKey The variable key for getting the data from the shared memory. **Defaults to** 1.
71
+ * @type string $proj The project identifier for ftok. This needs to be a one character string. **Defaults to** 'A'.
72
+ * @type int $memsize The memory size in bytes for shm_attach. **Defaults to** 10000.
73
+ * @type int $perm The permission for shm_attach. **Defaults to** 0600.
74
+ * }
 
75
  */
76
  public function __construct($options = [])
77
  {
91
  $this->sysvKey = ftok(__FILE__, $this->options['proj']);
92
  }
93
 
94
+ /**
95
+ * @param mixed $key
96
+ * @return CacheItemInterface
97
+ */
98
+ public function getItem($key): CacheItemInterface
99
  {
100
  $this->loadItems();
101
+ return current($this->getItems([$key])); // @phpstan-ignore-line
102
  }
103
 
104
  /**
105
+ * @param array<mixed> $keys
106
+ * @return iterable<CacheItemInterface>
107
  */
108
+ public function getItems(array $keys = []): iterable
109
  {
110
  $this->loadItems();
111
  $items = [];
112
+ $itemClass = \PHP_VERSION_ID >= 80000 ? TypedItem::class : Item::class;
113
  foreach ($keys as $key) {
114
  $items[$key] = $this->hasItem($key) ?
115
  clone $this->items[$key] :
116
+ new $itemClass($key);
117
  }
118
  return $items;
119
  }
121
  /**
122
  * {@inheritdoc}
123
  */
124
+ public function hasItem($key): bool
125
  {
126
  $this->loadItems();
127
  return isset($this->items[$key]) && $this->items[$key]->isHit();
130
  /**
131
  * {@inheritdoc}
132
  */
133
+ public function clear(): bool
134
  {
135
  $this->items = [];
136
  $this->deferredItems = [];
140
  /**
141
  * {@inheritdoc}
142
  */
143
+ public function deleteItem($key): bool
144
  {
145
  return $this->deleteItems([$key]);
146
  }
148
  /**
149
  * {@inheritdoc}
150
  */
151
+ public function deleteItems(array $keys): bool
152
  {
153
  if (!$this->hasLoadedItems) {
154
  $this->loadItems();
163
  /**
164
  * {@inheritdoc}
165
  */
166
+ public function save(CacheItemInterface $item): bool
167
  {
168
  if (!$this->hasLoadedItems) {
169
  $this->loadItems();
176
  /**
177
  * {@inheritdoc}
178
  */
179
+ public function saveDeferred(CacheItemInterface $item): bool
180
  {
181
  $this->deferredItems[$item->getKey()] = $item;
182
  return true;
185
  /**
186
  * {@inheritdoc}
187
  */
188
+ public function commit(): bool
189
  {
190
  foreach ($this->deferredItems as $item) {
191
  if ($this->save($item) === false) {
vendor/google/auth/src/Cache/TypedItem.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2022 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ namespace Google\Auth\Cache;
19
+
20
+ use Psr\Cache\CacheItemInterface;
21
+
22
+ /**
23
+ * A cache item.
24
+ */
25
+ final class TypedItem implements CacheItemInterface
26
+ {
27
+ /**
28
+ * @var mixed
29
+ */
30
+ private mixed $value;
31
+
32
+ /**
33
+ * @var \DateTimeInterface|null
34
+ */
35
+ private ?\DateTimeInterface $expiration;
36
+
37
+ /**
38
+ * @var bool
39
+ */
40
+ private bool $isHit = false;
41
+
42
+ /**
43
+ * @param string $key
44
+ */
45
+ public function __construct(
46
+ private string $key
47
+ ) {
48
+ $this->key = $key;
49
+ $this->expiration = null;
50
+ }
51
+
52
+ /**
53
+ * {@inheritdoc}
54
+ */
55
+ public function getKey(): string
56
+ {
57
+ return $this->key;
58
+ }
59
+
60
+ /**
61
+ * {@inheritdoc}
62
+ */
63
+ public function get(): mixed
64
+ {
65
+ return $this->isHit() ? $this->value : null;
66
+ }
67
+
68
+ /**
69
+ * {@inheritdoc}
70
+ */
71
+ public function isHit(): bool
72
+ {
73
+ if (!$this->isHit) {
74
+ return false;
75
+ }
76
+
77
+ if ($this->expiration === null) {
78
+ return true;
79
+ }
80
+
81
+ return $this->currentTime()->getTimestamp() < $this->expiration->getTimestamp();
82
+ }
83
+
84
+ /**
85
+ * {@inheritdoc}
86
+ */
87
+ public function set(mixed $value): static
88
+ {
89
+ $this->isHit = true;
90
+ $this->value = $value;
91
+
92
+ return $this;
93
+ }
94
+
95
+ /**
96
+ * {@inheritdoc}
97
+ */
98
+ public function expiresAt($expiration): static
99
+ {
100
+ if ($this->isValidExpiration($expiration)) {
101
+ $this->expiration = $expiration;
102
+
103
+ return $this;
104
+ }
105
+
106
+ $error = sprintf(
107
+ 'Argument 1 passed to %s::expiresAt() must implement interface DateTimeInterface, %s given',
108
+ get_class($this),
109
+ gettype($expiration)
110
+ );
111
+
112
+ throw new \TypeError($error);
113
+ }
114
+
115
+ /**
116
+ * {@inheritdoc}
117
+ */
118
+ public function expiresAfter($time): static
119
+ {
120
+ if (is_int($time)) {
121
+ $this->expiration = $this->currentTime()->add(new \DateInterval("PT{$time}S"));
122
+ } elseif ($time instanceof \DateInterval) {
123
+ $this->expiration = $this->currentTime()->add($time);
124
+ } elseif ($time === null) {
125
+ $this->expiration = $time;
126
+ } else {
127
+ $message = 'Argument 1 passed to %s::expiresAfter() must be an ' .
128
+ 'instance of DateInterval or of the type integer, %s given';
129
+ $error = sprintf($message, get_class($this), gettype($time));
130
+
131
+ throw new \TypeError($error);
132
+ }
133
+
134
+ return $this;
135
+ }
136
+
137
+ /**
138
+ * Determines if an expiration is valid based on the rules defined by PSR6.
139
+ *
140
+ * @param mixed $expiration
141
+ * @return bool
142
+ */
143
+ private function isValidExpiration($expiration)
144
+ {
145
+ if ($expiration === null) {
146
+ return true;
147
+ }
148
+
149
+ // We test for two types here due to the fact the DateTimeInterface
150
+ // was not introduced until PHP 5.5. Checking for the DateTime type as
151
+ // well allows us to support 5.4.
152
+ if ($expiration instanceof \DateTimeInterface) {
153
+ return true;
154
+ }
155
+
156
+ return false;
157
+ }
158
+
159
+ /**
160
+ * @return \DateTime
161
+ */
162
+ protected function currentTime()
163
+ {
164
+ return new \DateTime('now', new \DateTimeZone('UTC'));
165
+ }
166
+ }
vendor/google/auth/src/CacheTrait.php CHANGED
@@ -17,23 +17,42 @@
17
 
18
  namespace Google\Auth;
19
 
 
 
20
  trait CacheTrait
21
  {
 
 
 
22
  private $maxKeyLength = 64;
23
 
 
 
 
 
 
 
 
 
 
 
24
  /**
25
  * Gets the cached value if it is present in the cache when that is
26
  * available.
 
 
 
 
27
  */
28
  private function getCachedValue($k)
29
  {
30
  if (is_null($this->cache)) {
31
- return;
32
  }
33
 
34
  $key = $this->getFullCacheKey($k);
35
  if (is_null($key)) {
36
- return;
37
  }
38
 
39
  $cacheItem = $this->cache->getItem($key);
@@ -44,16 +63,20 @@ trait CacheTrait
44
 
45
  /**
46
  * Saves the value in the cache when that is available.
 
 
 
 
47
  */
48
  private function setCachedValue($k, $v)
49
  {
50
  if (is_null($this->cache)) {
51
- return;
52
  }
53
 
54
  $key = $this->getFullCacheKey($k);
55
  if (is_null($key)) {
56
- return;
57
  }
58
 
59
  $cacheItem = $this->cache->getItem($key);
@@ -62,10 +85,14 @@ trait CacheTrait
62
  return $this->cache->save($cacheItem);
63
  }
64
 
 
 
 
 
65
  private function getFullCacheKey($key)
66
  {
67
  if (is_null($key)) {
68
- return;
69
  }
70
 
71
  $key = $this->cacheConfig['prefix'] . $key;
17
 
18
  namespace Google\Auth;
19
 
20
+ use Psr\Cache\CacheItemPoolInterface;
21
+
22
  trait CacheTrait
23
  {
24
+ /**
25
+ * @var int
26
+ */
27
  private $maxKeyLength = 64;
28
 
29
+ /**
30
+ * @var array<mixed>
31
+ */
32
+ private $cacheConfig;
33
+
34
+ /**
35
+ * @var ?CacheItemPoolInterface
36
+ */
37
+ private $cache;
38
+
39
  /**
40
  * Gets the cached value if it is present in the cache when that is
41
  * available.
42
+ *
43
+ * @param mixed $k
44
+ *
45
+ * @return mixed
46
  */
47
  private function getCachedValue($k)
48
  {
49
  if (is_null($this->cache)) {
50
+ return null;
51
  }
52
 
53
  $key = $this->getFullCacheKey($k);
54
  if (is_null($key)) {
55
+ return null;
56
  }
57
 
58
  $cacheItem = $this->cache->getItem($key);
63
 
64
  /**
65
  * Saves the value in the cache when that is available.
66
+ *
67
+ * @param mixed $k
68
+ * @param mixed $v
69
+ * @return mixed
70
  */
71
  private function setCachedValue($k, $v)
72
  {
73
  if (is_null($this->cache)) {
74
+ return null;
75
  }
76
 
77
  $key = $this->getFullCacheKey($k);
78
  if (is_null($key)) {
79
+ return null;
80
  }
81
 
82
  $cacheItem = $this->cache->getItem($key);
85
  return $this->cache->save($cacheItem);
86
  }
87
 
88
+ /**
89
+ * @param null|string $key
90
+ * @return null|string
91
+ */
92
  private function getFullCacheKey($key)
93
  {
94
  if (is_null($key)) {
95
+ return null;
96
  }
97
 
98
  $key = $this->cacheConfig['prefix'] . $key;
vendor/google/auth/src/Credentials/AppIdentityCredentials.php CHANGED
@@ -28,6 +28,8 @@ use Google\Auth\ProjectIdProviderInterface;
28
  use Google\Auth\SignBlobInterface;
29
 
30
  /**
 
 
31
  * AppIdentityCredentials supports authorization on Google App Engine.
32
  *
33
  * It can be used to authorize requests using the AuthTokenMiddleware or
@@ -61,14 +63,14 @@ class AppIdentityCredentials extends CredentialsLoader implements
61
  /**
62
  * Result of fetchAuthToken.
63
  *
64
- * @var array
65
  */
66
  protected $lastReceivedToken;
67
 
68
  /**
69
  * Array of OAuth2 scopes to be requested.
70
  *
71
- * @var array
72
  */
73
  private $scope;
74
 
@@ -78,11 +80,11 @@ class AppIdentityCredentials extends CredentialsLoader implements
78
  private $clientName;
79
 
80
  /**
81
- * @param array $scope One or more scopes.
82
  */
83
- public function __construct($scope = array())
84
  {
85
- $this->scope = $scope;
86
  }
87
 
88
  /**
@@ -115,10 +117,12 @@ class AppIdentityCredentials extends CredentialsLoader implements
115
  * the GuzzleHttp\ClientInterface instance passed in will not be used.
116
  *
117
  * @param callable $httpHandler callback which delivers psr7 request
118
- * @return array A set of auth related metadata, containing the following
119
- * keys:
120
- * - access_token (string)
121
- * - expiration_time (string)
 
 
122
  */
123
  public function fetchAuthToken(callable $httpHandler = null)
124
  {
@@ -128,10 +132,8 @@ class AppIdentityCredentials extends CredentialsLoader implements
128
  return [];
129
  }
130
 
131
- // AppIdentityService expects an array when multiple scopes are supplied
132
- $scope = is_array($this->scope) ? $this->scope : explode(' ', $this->scope);
133
-
134
- $token = AppIdentityService::getAccessToken($scope);
135
  $this->lastReceivedToken = $token;
136
 
137
  return $token;
@@ -150,6 +152,7 @@ class AppIdentityCredentials extends CredentialsLoader implements
150
  {
151
  $this->checkAppEngineContext();
152
 
 
153
  return base64_encode(AppIdentityService::signForApp($stringToSign)['signature']);
154
  }
155
 
@@ -161,7 +164,7 @@ class AppIdentityCredentials extends CredentialsLoader implements
161
  * @param callable $httpHandler Not used by this type.
162
  * @return string|null
163
  */
164
- public function getProjectId(callable $httpHander = null)
165
  {
166
  try {
167
  $this->checkAppEngineContext();
@@ -169,6 +172,7 @@ class AppIdentityCredentials extends CredentialsLoader implements
169
  return null;
170
  }
171
 
 
172
  return AppIdentityService::getApplicationId();
173
  }
174
 
@@ -186,6 +190,7 @@ class AppIdentityCredentials extends CredentialsLoader implements
186
  $this->checkAppEngineContext();
187
 
188
  if (!$this->clientName) {
 
189
  $this->clientName = AppIdentityService::getServiceAccountName();
190
  }
191
 
@@ -193,7 +198,7 @@ class AppIdentityCredentials extends CredentialsLoader implements
193
  }
194
 
195
  /**
196
- * @return array|null
197
  */
198
  public function getLastReceivedToken()
199
  {
@@ -218,6 +223,9 @@ class AppIdentityCredentials extends CredentialsLoader implements
218
  return '';
219
  }
220
 
 
 
 
221
  private function checkAppEngineContext()
222
  {
223
  if (!self::onAppEngine() || !class_exists('google\appengine\api\app_identity\AppIdentityService')) {
28
  use Google\Auth\SignBlobInterface;
29
 
30
  /**
31
+ * @deprecated
32
+ *
33
  * AppIdentityCredentials supports authorization on Google App Engine.
34
  *
35
  * It can be used to authorize requests using the AuthTokenMiddleware or
63
  /**
64
  * Result of fetchAuthToken.
65
  *
66
+ * @var array<mixed>
67
  */
68
  protected $lastReceivedToken;
69
 
70
  /**
71
  * Array of OAuth2 scopes to be requested.
72
  *
73
+ * @var string[]
74
  */
75
  private $scope;
76
 
80
  private $clientName;
81
 
82
  /**
83
+ * @param string|string[] $scope One or more scopes.
84
  */
85
+ public function __construct($scope = [])
86
  {
87
+ $this->scope = is_array($scope) ? $scope : explode(' ', (string) $scope);
88
  }
89
 
90
  /**
117
  * the GuzzleHttp\ClientInterface instance passed in will not be used.
118
  *
119
  * @param callable $httpHandler callback which delivers psr7 request
120
+ * @return array<mixed> {
121
+ * A set of auth related metadata, containing the following
122
+ *
123
+ * @type string $access_token
124
+ * @type string $expiration_time
125
+ * }
126
  */
127
  public function fetchAuthToken(callable $httpHandler = null)
128
  {
132
  return [];
133
  }
134
 
135
+ /** @phpstan-ignore-next-line */
136
+ $token = AppIdentityService::getAccessToken($this->scope);
 
 
137
  $this->lastReceivedToken = $token;
138
 
139
  return $token;
152
  {
153
  $this->checkAppEngineContext();
154
 
155
+ /** @phpstan-ignore-next-line */
156
  return base64_encode(AppIdentityService::signForApp($stringToSign)['signature']);
157
  }
158
 
164
  * @param callable $httpHandler Not used by this type.
165
  * @return string|null
166
  */
167
+ public function getProjectId(callable $httpHandler = null)
168
  {
169
  try {
170
  $this->checkAppEngineContext();
172
  return null;
173
  }
174
 
175
+ /** @phpstan-ignore-next-line */
176
  return AppIdentityService::getApplicationId();
177
  }
178
 
190
  $this->checkAppEngineContext();
191
 
192
  if (!$this->clientName) {
193
+ /** @phpstan-ignore-next-line */
194
  $this->clientName = AppIdentityService::getServiceAccountName();
195
  }
196
 
198
  }
199
 
200
  /**
201
+ * @return array{access_token:string,expires_at:int}|null
202
  */
203
  public function getLastReceivedToken()
204
  {
223
  return '';
224
  }
225
 
226
+ /**
227
+ * @return void
228
+ */
229
  private function checkAppEngineContext()
230
  {
231
  if (!self::onAppEngine() || !class_exists('google\appengine\api\app_identity\AppIdentityService')) {
vendor/google/auth/src/Credentials/GCECredentials.php CHANGED
@@ -126,6 +126,8 @@ class GCECredentials extends CredentialsLoader implements
126
 
127
  /**
128
  * Result of fetchAuthToken.
 
 
129
  */
130
  protected $lastReceivedToken;
131
 
@@ -166,7 +168,7 @@ class GCECredentials extends CredentialsLoader implements
166
 
167
  /**
168
  * @param Iam $iam [optional] An IAM instance.
169
- * @param string|array $scope [optional] the scope of the access request,
170
  * expressed either as an array or as a space-delimited string.
171
  * @param string $targetAudience [optional] The audience for the ID token.
172
  * @param string $quotaProject [optional] Specifies a project to bill for access
@@ -197,10 +199,10 @@ class GCECredentials extends CredentialsLoader implements
197
 
198
  $scope = implode(',', $scope);
199
 
200
- $tokenUri = $tokenUri . '?scopes='. $scope;
201
  } elseif ($targetAudience) {
202
  $tokenUri = self::getIdTokenUri($serviceAccountIdentity);
203
- $tokenUri = $tokenUri . '?audience='. $targetAudience;
204
  $this->targetAudience = $targetAudience;
205
  }
206
 
@@ -297,7 +299,7 @@ class GCECredentials extends CredentialsLoader implements
297
  */
298
  public static function onAppEngineFlexible()
299
  {
300
- return substr(getenv('GAE_INSTANCE'), 0, 4) === 'aef-';
301
  }
302
 
303
  /**
@@ -351,15 +353,14 @@ class GCECredentials extends CredentialsLoader implements
351
  *
352
  * @param callable $httpHandler callback which delivers psr7 request
353
  *
354
- * @return array A set of auth related metadata, based on the token type.
355
- *
356
- * Access tokens have the following keys:
357
- * - access_token (string)
358
- * - expires_in (int)
359
- * - token_type (string)
360
- * ID tokens have the following keys:
361
- * - id_token (string)
362
  *
 
 
 
 
 
363
  * @throws \Exception
364
  */
365
  public function fetchAuthToken(callable $httpHandler = null)
@@ -402,7 +403,7 @@ class GCECredentials extends CredentialsLoader implements
402
  }
403
 
404
  /**
405
- * @return array|null
406
  */
407
  public function getLastReceivedToken()
408
  {
126
 
127
  /**
128
  * Result of fetchAuthToken.
129
+ *
130
+ * @var array<mixed>
131
  */
132
  protected $lastReceivedToken;
133
 
168
 
169
  /**
170
  * @param Iam $iam [optional] An IAM instance.
171
+ * @param string|string[] $scope [optional] the scope of the access request,
172
  * expressed either as an array or as a space-delimited string.
173
  * @param string $targetAudience [optional] The audience for the ID token.
174
  * @param string $quotaProject [optional] Specifies a project to bill for access
199
 
200
  $scope = implode(',', $scope);
201
 
202
+ $tokenUri = $tokenUri . '?scopes=' . $scope;
203
  } elseif ($targetAudience) {
204
  $tokenUri = self::getIdTokenUri($serviceAccountIdentity);
205
+ $tokenUri = $tokenUri . '?audience=' . $targetAudience;
206
  $this->targetAudience = $targetAudience;
207
  }
208
 
299
  */
300
  public static function onAppEngineFlexible()
301
  {
302
+ return substr((string) getenv('GAE_INSTANCE'), 0, 4) === 'aef-';
303
  }
304
 
305
  /**
353
  *
354
  * @param callable $httpHandler callback which delivers psr7 request
355
  *
356
+ * @return array<mixed> {
357
+ * A set of auth related metadata, based on the token type.
 
 
 
 
 
 
358
  *
359
+ * @type string $access_token for access tokens
360
+ * @type int $expires_in for access tokens
361
+ * @type string $token_type for access tokens
362
+ * @type string $id_token for ID tokens
363
+ * }
364
  * @throws \Exception
365
  */
366
  public function fetchAuthToken(callable $httpHandler = null)
403
  }
404
 
405
  /**
406
+ * @return array{access_token:string,expires_at:int}|null
407
  */
408
  public function getLastReceivedToken()
409
  {
vendor/google/auth/src/Credentials/IAMCredentials.php CHANGED
@@ -36,8 +36,8 @@ class IAMCredentials
36
  private $token;
37
 
38
  /**
39
- * @param $selector string the IAM selector
40
- * @param $token string the IAM token
41
  */
42
  public function __construct($selector, $token)
43
  {
@@ -59,7 +59,7 @@ class IAMCredentials
59
  /**
60
  * export a callback function which updates runtime metadata.
61
  *
62
- * @return array updateMetadata function
63
  */
64
  public function getUpdateMetadataFunc()
65
  {
@@ -69,13 +69,13 @@ class IAMCredentials
69
  /**
70
  * Updates metadata with the appropriate header metadata.
71
  *
72
- * @param array $metadata metadata hashmap
73
  * @param string $unusedAuthUri optional auth uri
74
  * @param callable $httpHandler callback which delivers psr7 request
75
  * Note: this param is unused here, only included here for
76
  * consistency with other credentials class
77
  *
78
- * @return array updated metadata hashmap
79
  */
80
  public function updateMetadata(
81
  $metadata,
36
  private $token;
37
 
38
  /**
39
+ * @param string $selector the IAM selector
40
+ * @param string $token the IAM token
41
  */
42
  public function __construct($selector, $token)
43
  {
59
  /**
60
  * export a callback function which updates runtime metadata.
61
  *
62
+ * @return callable updateMetadata function
63
  */
64
  public function getUpdateMetadataFunc()
65
  {
69
  /**
70
  * Updates metadata with the appropriate header metadata.
71
  *
72
+ * @param array<mixed> $metadata metadata hashmap
73
  * @param string $unusedAuthUri optional auth uri
74
  * @param callable $httpHandler callback which delivers psr7 request
75
  * Note: this param is unused here, only included here for
76
  * consistency with other credentials class
77
  *
78
+ * @return array<mixed> updated metadata hashmap
79
  */
80
  public function updateMetadata(
81
  $metadata,
vendor/google/auth/src/Credentials/InsecureCredentials.php CHANGED
@@ -27,7 +27,7 @@ use Google\Auth\FetchAuthTokenInterface;
27
  class InsecureCredentials implements FetchAuthTokenInterface
28
  {
29
  /**
30
- * @var array
31
  */
32
  private $token = [
33
  'access_token' => ''
@@ -37,9 +37,7 @@ class InsecureCredentials implements FetchAuthTokenInterface
37
  * Fetches the auth token. In this case it returns an empty string.
38
  *
39
  * @param callable $httpHandler
40
- * @return array A set of auth related metadata, containing the following
41
- * keys:
42
- * - access_token (string)
43
  */
44
  public function fetchAuthToken(callable $httpHandler = null)
45
  {
@@ -61,7 +59,7 @@ class InsecureCredentials implements FetchAuthTokenInterface
61
  * Fetches the last received token. In this case, it returns the same empty string
62
  * auth token.
63
  *
64
- * @return array
65
  */
66
  public function getLastReceivedToken()
67
  {
27
  class InsecureCredentials implements FetchAuthTokenInterface
28
  {
29
  /**
30
+ * @var array{access_token:string}
31
  */
32
  private $token = [
33
  'access_token' => ''
37
  * Fetches the auth token. In this case it returns an empty string.
38
  *
39
  * @param callable $httpHandler
40
+ * @return array{access_token:string} A set of auth related metadata
 
 
41
  */
42
  public function fetchAuthToken(callable $httpHandler = null)
43
  {
59
  * Fetches the last received token. In this case, it returns the same empty string
60
  * auth token.
61
  *
62
+ * @return array{access_token:string}
63
  */
64
  public function getLastReceivedToken()
65
  {
vendor/google/auth/src/Credentials/ServiceAccountCredentials.php CHANGED
@@ -79,22 +79,22 @@ class ServiceAccountCredentials extends CredentialsLoader implements
79
  */
80
  protected $quotaProject;
81
 
82
- /*
83
  * @var string|null
84
  */
85
  protected $projectId;
86
 
87
- /*
88
- * @var array|null
89
  */
90
  private $lastReceivedJwtAccessToken;
91
 
92
- /*
93
  * @var bool
94
  */
95
  private $useJwtAccessWithScope = false;
96
 
97
- /*
98
  * @var ServiceAccountJwtAccessCredentials|null
99
  */
100
  private $jwtAccessCredentials;
@@ -102,9 +102,9 @@ class ServiceAccountCredentials extends CredentialsLoader implements
102
  /**
103
  * Create a new ServiceAccountCredentials.
104
  *
105
- * @param string|array $scope the scope of the access request, expressed
106
  * either as an Array or as a space-delimited String.
107
- * @param string|array $jsonKey JSON credential file path or JSON credentials
108
  * as an associative array
109
  * @param string $sub an email address account to impersonate, in situations when
110
  * the service account has been delegated domain wide access.
@@ -121,7 +121,7 @@ class ServiceAccountCredentials extends CredentialsLoader implements
121
  throw new \InvalidArgumentException('file does not exist');
122
  }
123
  $jsonKeyStream = file_get_contents($jsonKey);
124
- if (!$jsonKey = json_decode($jsonKeyStream, true)) {
125
  throw new \LogicException('invalid json for auth config');
126
  }
127
  }
@@ -169,6 +169,8 @@ class ServiceAccountCredentials extends CredentialsLoader implements
169
  * even when only scopes are supplied. Otherwise,
170
  * ServiceAccountJwtAccessCredentials is only called when no scopes and an
171
  * authUrl (audience) is suppled.
 
 
172
  */
173
  public function useJwtAccessWithScope()
174
  {
@@ -178,15 +180,17 @@ class ServiceAccountCredentials extends CredentialsLoader implements
178
  /**
179
  * @param callable $httpHandler
180
  *
181
- * @return array A set of auth related metadata, containing the following
182
- * keys:
183
- * - access_token (string)
184
- * - expires_in (int)
185
- * - token_type (string)
 
 
186
  */
187
  public function fetchAuthToken(callable $httpHandler = null)
188
  {
189
- if ($this->useJwtAccessWithScope) {
190
  $jwtCreds = $this->createJwtAccessCredentials();
191
 
192
  $accessToken = $jwtCreds->fetchAuthToken($httpHandler);
@@ -215,7 +219,7 @@ class ServiceAccountCredentials extends CredentialsLoader implements
215
  }
216
 
217
  /**
218
- * @return array
219
  */
220
  public function getLastReceivedToken()
221
  {
@@ -242,10 +246,10 @@ class ServiceAccountCredentials extends CredentialsLoader implements
242
  /**
243
  * Updates metadata with the authorization token.
244
  *
245
- * @param array $metadata metadata hashmap
246
  * @param string $authUri optional auth uri
247
  * @param callable $httpHandler callback which delivers psr7 request
248
- * @return array updated metadata hashmap
249
  */
250
  public function updateMetadata(
251
  $metadata,
@@ -273,14 +277,17 @@ class ServiceAccountCredentials extends CredentialsLoader implements
273
  return $updatedMetadata;
274
  }
275
 
 
 
 
276
  private function createJwtAccessCredentials()
277
  {
278
  if (!$this->jwtAccessCredentials) {
279
  // Create credentials for self-signing a JWT (JwtAccess)
280
- $credJson = array(
281
  'private_key' => $this->auth->getSigningKey(),
282
  'client_email' => $this->auth->getIssuer(),
283
- );
284
  $this->jwtAccessCredentials = new ServiceAccountJwtAccessCredentials(
285
  $credJson,
286
  $this->auth->getScope()
@@ -293,6 +300,7 @@ class ServiceAccountCredentials extends CredentialsLoader implements
293
  /**
294
  * @param string $sub an email address account to impersonate, in situations when
295
  * the service account has been delegated domain wide access.
 
296
  */
297
  public function setSub($sub)
298
  {
@@ -322,9 +330,17 @@ class ServiceAccountCredentials extends CredentialsLoader implements
322
  return $this->quotaProject;
323
  }
324
 
 
 
 
325
  private function useSelfSignedJwt()
326
  {
327
- // When true, ServiceAccountCredentials will always use JwtAccess
 
 
 
 
 
328
  if ($this->useJwtAccessWithScope) {
329
  return true;
330
  }
79
  */
80
  protected $quotaProject;
81
 
82
+ /**
83
  * @var string|null
84
  */
85
  protected $projectId;
86
 
87
+ /**
88
+ * @var array<mixed>|null
89
  */
90
  private $lastReceivedJwtAccessToken;
91
 
92
+ /**
93
  * @var bool
94
  */
95
  private $useJwtAccessWithScope = false;
96
 
97
+ /**
98
  * @var ServiceAccountJwtAccessCredentials|null
99
  */
100
  private $jwtAccessCredentials;
102
  /**
103
  * Create a new ServiceAccountCredentials.
104
  *
105
+ * @param string|string[]|null $scope the scope of the access request, expressed
106
  * either as an Array or as a space-delimited String.
107
+ * @param string|array<mixed> $jsonKey JSON credential file path or JSON credentials
108
  * as an associative array
109
  * @param string $sub an email address account to impersonate, in situations when
110
  * the service account has been delegated domain wide access.
121
  throw new \InvalidArgumentException('file does not exist');
122
  }
123
  $jsonKeyStream = file_get_contents($jsonKey);
124
+ if (!$jsonKey = json_decode((string) $jsonKeyStream, true)) {
125
  throw new \LogicException('invalid json for auth config');
126
  }
127
  }
169
  * even when only scopes are supplied. Otherwise,
170
  * ServiceAccountJwtAccessCredentials is only called when no scopes and an
171
  * authUrl (audience) is suppled.
172
+ *
173
+ * @return void
174
  */
175
  public function useJwtAccessWithScope()
176
  {
180
  /**
181
  * @param callable $httpHandler
182
  *
183
+ * @return array<mixed> {
184
+ * A set of auth related metadata, containing the following
185
+ *
186
+ * @type string $access_token
187
+ * @type int $expires_in
188
+ * @type string $token_type
189
+ * }
190
  */
191
  public function fetchAuthToken(callable $httpHandler = null)
192
  {
193
+ if ($this->useSelfSignedJwt()) {
194
  $jwtCreds = $this->createJwtAccessCredentials();
195
 
196
  $accessToken = $jwtCreds->fetchAuthToken($httpHandler);
219
  }
220
 
221
  /**
222
+ * @return array<mixed>
223
  */
224
  public function getLastReceivedToken()
225
  {
246
  /**
247
  * Updates metadata with the authorization token.
248
  *
249
+ * @param array<mixed> $metadata metadata hashmap
250
  * @param string $authUri optional auth uri
251
  * @param callable $httpHandler callback which delivers psr7 request
252
+ * @return array<mixed> updated metadata hashmap
253
  */
254
  public function updateMetadata(
255
  $metadata,
277
  return $updatedMetadata;
278
  }
279
 
280
+ /**
281
+ * @return ServiceAccountJwtAccessCredentials
282
+ */
283
  private function createJwtAccessCredentials()
284
  {
285
  if (!$this->jwtAccessCredentials) {
286
  // Create credentials for self-signing a JWT (JwtAccess)
287
+ $credJson = [
288
  'private_key' => $this->auth->getSigningKey(),
289
  'client_email' => $this->auth->getIssuer(),
290
+ ];
291
  $this->jwtAccessCredentials = new ServiceAccountJwtAccessCredentials(
292
  $credJson,
293
  $this->auth->getScope()
300
  /**
301
  * @param string $sub an email address account to impersonate, in situations when
302
  * the service account has been delegated domain wide access.
303
+ * @return void
304
  */
305
  public function setSub($sub)
306
  {
330
  return $this->quotaProject;
331
  }
332
 
333
+ /**
334
+ * @return bool
335
+ */
336
  private function useSelfSignedJwt()
337
  {
338
+ // If claims are set, this call is for "id_tokens"
339
+ if ($this->auth->getAdditionalClaims()) {
340
+ return false;
341
+ }
342
+
343
+ // When true, ServiceAccountCredentials will always use JwtAccess for access tokens
344
  if ($this->useJwtAccessWithScope) {
345
  return true;
346
  }
vendor/google/auth/src/Credentials/ServiceAccountJwtAccessCredentials.php CHANGED
@@ -49,15 +49,22 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements
49
 
50
  /**
51
  * The quota project associated with the JSON credentials
 
 
52
  */
53
  protected $quotaProject;
54
 
 
 
 
 
 
55
  /**
56
  * Create a new ServiceAccountJwtAccessCredentials.
57
  *
58
- * @param string|array $jsonKey JSON credential file path or JSON credentials
59
  * as an associative array
60
- * @param string|array $scope the scope of the access request, expressed
61
  * either as an Array or as a space-delimited String.
62
  */
63
  public function __construct($jsonKey, $scope = null)
@@ -67,7 +74,7 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements
67
  throw new \InvalidArgumentException('file does not exist');
68
  }
69
  $jsonKeyStream = file_get_contents($jsonKey);
70
- if (!$jsonKey = json_decode($jsonKeyStream, true)) {
71
  throw new \LogicException('invalid json for auth config');
72
  }
73
  }
@@ -100,10 +107,10 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements
100
  /**
101
  * Updates metadata with the authorization token.
102
  *
103
- * @param array $metadata metadata hashmap
104
  * @param string $authUri optional auth uri
105
  * @param callable $httpHandler callback which delivers psr7 request
106
- * @return array updated metadata hashmap
107
  */
108
  public function updateMetadata(
109
  $metadata,
@@ -125,9 +132,7 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements
125
  *
126
  * @param callable $httpHandler
127
  *
128
- * @return array|void A set of auth related metadata, containing the
129
- * following keys:
130
- * - access_token (string)
131
  */
132
  public function fetchAuthToken(callable $httpHandler = null)
133
  {
@@ -148,7 +153,7 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements
148
  // Set the self-signed access token in OAuth2 for getLastReceivedToken
149
  $this->auth->setAccessToken($access_token);
150
 
151
- return array('access_token' => $access_token);
152
  }
153
 
154
  /**
@@ -160,7 +165,7 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements
160
  }
161
 
162
  /**
163
- * @return array
164
  */
165
  public function getLastReceivedToken()
166
  {
49
 
50
  /**
51
  * The quota project associated with the JSON credentials
52
+ *
53
+ * @var string
54
  */
55
  protected $quotaProject;
56
 
57
+ /**
58
+ * @var string
59
+ */
60
+ public $projectId;
61
+
62
  /**
63
  * Create a new ServiceAccountJwtAccessCredentials.
64
  *
65
+ * @param string|array<mixed> $jsonKey JSON credential file path or JSON credentials
66
  * as an associative array
67
+ * @param string|string[] $scope the scope of the access request, expressed
68
  * either as an Array or as a space-delimited String.
69
  */
70
  public function __construct($jsonKey, $scope = null)
74
  throw new \InvalidArgumentException('file does not exist');
75
  }
76
  $jsonKeyStream = file_get_contents($jsonKey);
77
+ if (!$jsonKey = json_decode((string) $jsonKeyStream, true)) {
78
  throw new \LogicException('invalid json for auth config');
79
  }
80
  }
107
  /**
108
  * Updates metadata with the authorization token.
109
  *
110
+ * @param array<mixed> $metadata metadata hashmap
111
  * @param string $authUri optional auth uri
112
  * @param callable $httpHandler callback which delivers psr7 request
113
+ * @return array<mixed> updated metadata hashmap
114
  */
115
  public function updateMetadata(
116
  $metadata,
132
  *
133
  * @param callable $httpHandler
134
  *
135
+ * @return null|array{access_token:string} A set of auth related metadata
 
 
136
  */
137
  public function fetchAuthToken(callable $httpHandler = null)
138
  {
153
  // Set the self-signed access token in OAuth2 for getLastReceivedToken
154
  $this->auth->setAccessToken($access_token);
155
 
156
+ return ['access_token' => $access_token];
157
  }
158
 
159
  /**
165
  }
166
 
167
  /**
168
+ * @return array<mixed>
169
  */
170
  public function getLastReceivedToken()
171
  {
vendor/google/auth/src/Credentials/UserRefreshCredentials.php CHANGED
@@ -43,15 +43,17 @@ class UserRefreshCredentials extends CredentialsLoader implements GetQuotaProjec
43
 
44
  /**
45
  * The quota project associated with the JSON credentials
 
 
46
  */
47
  protected $quotaProject;
48
 
49
  /**
50
  * Create a new UserRefreshCredentials.
51
  *
52
- * @param string|array $scope the scope of the access request, expressed
53
  * either as an Array or as a space-delimited String.
54
- * @param string|array $jsonKey JSON credential file path or JSON credentials
55
  * as an associative array
56
  */
57
  public function __construct(
@@ -62,8 +64,8 @@ class UserRefreshCredentials extends CredentialsLoader implements GetQuotaProjec
62
  if (!file_exists($jsonKey)) {
63
  throw new \InvalidArgumentException('file does not exist');
64
  }
65
- $jsonKeyStream = file_get_contents($jsonKey);
66
- if (!$jsonKey = json_decode($jsonKeyStream, true)) {
67
  throw new \LogicException('invalid json for auth config');
68
  }
69
  }
@@ -97,13 +99,15 @@ class UserRefreshCredentials extends CredentialsLoader implements GetQuotaProjec
97
  /**
98
  * @param callable $httpHandler
99
  *
100
- * @return array A set of auth related metadata, containing the following
101
- * keys:
102
- * - access_token (string)
103
- * - expires_in (int)
104
- * - scope (string)
105
- * - token_type (string)
106
- * - id_token (string)
 
 
107
  */
108
  public function fetchAuthToken(callable $httpHandler = null)
109
  {
@@ -119,7 +123,7 @@ class UserRefreshCredentials extends CredentialsLoader implements GetQuotaProjec
119
  }
120
 
121
  /**
122
- * @return array
123
  */
124
  public function getLastReceivedToken()
125
  {
43
 
44
  /**
45
  * The quota project associated with the JSON credentials
46
+ *
47
+ * @var string
48
  */
49
  protected $quotaProject;
50
 
51
  /**
52
  * Create a new UserRefreshCredentials.
53
  *
54
+ * @param string|string[] $scope the scope of the access request, expressed
55
  * either as an Array or as a space-delimited String.
56
+ * @param string|array<mixed> $jsonKey JSON credential file path or JSON credentials
57
  * as an associative array
58
  */
59
  public function __construct(
64
  if (!file_exists($jsonKey)) {
65
  throw new \InvalidArgumentException('file does not exist');
66
  }
67
+ $json = file_get_contents($jsonKey);
68
+ if (!$jsonKey = json_decode((string) $json, true)) {
69
  throw new \LogicException('invalid json for auth config');
70
  }
71
  }
99
  /**
100
  * @param callable $httpHandler
101
  *
102
+ * @return array<mixed> {
103
+ * A set of auth related metadata, containing the following
104
+ *
105
+ * @type string $access_token
106
+ * @type int $expires_in
107
+ * @type string $scope
108
+ * @type string $token_type
109
+ * @type string $id_token
110
+ * }
111
  */
112
  public function fetchAuthToken(callable $httpHandler = null)
113
  {
123
  }
124
 
125
  /**
126
+ * @return array<mixed>
127
  */
128
  public function getLastReceivedToken()
129
  {
vendor/google/auth/src/CredentialsLoader.php CHANGED
@@ -20,7 +20,8 @@ namespace Google\Auth;
20
  use Google\Auth\Credentials\InsecureCredentials;
21
  use Google\Auth\Credentials\ServiceAccountCredentials;
22
  use Google\Auth\Credentials\UserRefreshCredentials;
23
- use GuzzleHttp\ClientInterface;
 
24
 
25
  /**
26
  * CredentialsLoader contains the behaviour used to locate and find default
@@ -34,6 +35,8 @@ abstract class CredentialsLoader implements
34
  const ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS';
35
  const WELL_KNOWN_PATH = 'gcloud/application_default_credentials.json';
36
  const NON_WINDOWS_WELL_KNOWN_PATH_BASE = '.config';
 
 
37
 
38
  /**
39
  * @param string $cause
@@ -56,24 +59,6 @@ abstract class CredentialsLoader implements
56
  return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
57
  }
58
 
59
- /**
60
- * Returns the currently available major Guzzle version.
61
- *
62
- * @return int
63
- */
64
- private static function getGuzzleMajorVersion()
65
- {
66
- if (defined('GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
67
- return ClientInterface::MAJOR_VERSION;
68
- }
69
-
70
- if (defined('GuzzleHttp\ClientInterface::VERSION')) {
71
- return (int) substr(ClientInterface::VERSION, 0, 1);
72
- }
73
-
74
- throw new \Exception('Version not supported');
75
- }
76
-
77
  /**
78
  * Load a JSON key from the path specified in the environment.
79
  *
@@ -81,20 +66,20 @@ abstract class CredentialsLoader implements
81
  * variable GOOGLE_APPLICATION_CREDENTIALS. Return null if
82
  * GOOGLE_APPLICATION_CREDENTIALS is not specified.
83
  *
84
- * @return array|null JSON key | null
85
  */
86
  public static function fromEnv()
87
  {
88
  $path = getenv(self::ENV_VAR);
89
  if (empty($path)) {
90
- return;
91
  }
92
  if (!file_exists($path)) {
93
  $cause = 'file ' . $path . ' does not exist';
94
  throw new \DomainException(self::unableToReadEnv($cause));
95
  }
96
  $jsonKey = file_get_contents($path);
97
- return json_decode($jsonKey, true);
98
  }
99
 
100
  /**
@@ -107,7 +92,7 @@ abstract class CredentialsLoader implements
107
  *
108
  * If the file does not exist, this returns null.
109
  *
110
- * @return array|null JSON key | null
111
  */
112
  public static function fromWellKnownFile()
113
  {
@@ -119,19 +104,19 @@ abstract class CredentialsLoader implements
119
  $path[] = self::WELL_KNOWN_PATH;
120
  $path = implode(DIRECTORY_SEPARATOR, $path);
121
  if (!file_exists($path)) {
122
- return;
123
  }
124
  $jsonKey = file_get_contents($path);
125
- return json_decode($jsonKey, true);
126
  }
127
 
128
  /**
129
  * Create a new Credentials instance.
130
  *
131
- * @param string|array $scope the scope of the access request, expressed
132
  * either as an Array or as a space-delimited String.
133
- * @param array $jsonKey the JSON credentials.
134
- * @param string|array $defaultScope The default scope to use if no
135
  * user-defined scopes exist, expressed either as an Array or as a
136
  * space-delimited string.
137
  *
@@ -163,7 +148,7 @@ abstract class CredentialsLoader implements
163
  * Create an authorized HTTP Client from an instance of FetchAuthTokenInterface.
164
  *
165
  * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
166
- * @param array $httpClientOptions (optional) Array of request options to apply.
167
  * @param callable $httpHandler (optional) http client to fetch the token.
168
  * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
169
  * @return \GuzzleHttp\Client
@@ -174,18 +159,6 @@ abstract class CredentialsLoader implements
174
  callable $httpHandler = null,
175
  callable $tokenCallback = null
176
  ) {
177
- if (self::getGuzzleMajorVersion() === 5) {
178
- $client = new \GuzzleHttp\Client($httpClientOptions);
179
- $client->setDefaultOption('auth', 'google_auth');
180
- $subscriber = new Subscriber\AuthTokenSubscriber(
181
- $fetcher,
182
- $httpHandler,
183
- $tokenCallback
184
- );
185
- $client->getEmitter()->attach($subscriber);
186
- return $client;
187
- }
188
-
189
  $middleware = new Middleware\AuthTokenMiddleware(
190
  $fetcher,
191
  $httpHandler,
@@ -213,7 +186,7 @@ abstract class CredentialsLoader implements
213
  /**
214
  * export a callback function which updates runtime metadata.
215
  *
216
- * @return array updateMetadata function
217
  * @deprecated
218
  */
219
  public function getUpdateMetadataFunc()
@@ -224,10 +197,10 @@ abstract class CredentialsLoader implements
224
  /**
225
  * Updates metadata with the authorization token.
226
  *
227
- * @param array $metadata metadata hashmap
228
  * @param string $authUri optional auth uri
229
  * @param callable $httpHandler callback which delivers psr7 request
230
- * @return array updated metadata hashmap
231
  */
232
  public function updateMetadata(
233
  $metadata,
@@ -247,4 +220,68 @@ abstract class CredentialsLoader implements
247
 
248
  return $metadata_copy;
249
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  }
20
  use Google\Auth\Credentials\InsecureCredentials;
21
  use Google\Auth\Credentials\ServiceAccountCredentials;
22
  use Google\Auth\Credentials\UserRefreshCredentials;
23
+ use RuntimeException;
24
+ use UnexpectedValueException;
25
 
26
  /**
27
  * CredentialsLoader contains the behaviour used to locate and find default
35
  const ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS';
36
  const WELL_KNOWN_PATH = 'gcloud/application_default_credentials.json';
37
  const NON_WINDOWS_WELL_KNOWN_PATH_BASE = '.config';
38
+ const MTLS_WELL_KNOWN_PATH = '.secureConnect/context_aware_metadata.json';
39
+ const MTLS_CERT_ENV_VAR = 'GOOGLE_API_USE_CLIENT_CERTIFICATE';
40
 
41
  /**
42
  * @param string $cause
59
  return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**
63
  * Load a JSON key from the path specified in the environment.
64
  *
66
  * variable GOOGLE_APPLICATION_CREDENTIALS. Return null if
67
  * GOOGLE_APPLICATION_CREDENTIALS is not specified.
68
  *
69
+ * @return array<mixed>|null JSON key | null
70
  */
71
  public static function fromEnv()
72
  {
73
  $path = getenv(self::ENV_VAR);
74
  if (empty($path)) {
75
+ return null;
76
  }
77
  if (!file_exists($path)) {
78
  $cause = 'file ' . $path . ' does not exist';
79
  throw new \DomainException(self::unableToReadEnv($cause));
80
  }
81
  $jsonKey = file_get_contents($path);
82
+ return json_decode((string) $jsonKey, true);
83
  }
84
 
85
  /**
92
  *
93
  * If the file does not exist, this returns null.
94
  *
95
+ * @return array<mixed>|null JSON key | null
96
  */
97
  public static function fromWellKnownFile()
98
  {
104
  $path[] = self::WELL_KNOWN_PATH;
105
  $path = implode(DIRECTORY_SEPARATOR, $path);
106
  if (!file_exists($path)) {
107
+ return null;
108
  }
109
  $jsonKey = file_get_contents($path);
110
+ return json_decode((string) $jsonKey, true);
111
  }
112
 
113
  /**
114
  * Create a new Credentials instance.
115
  *
116
+ * @param string|string[] $scope the scope of the access request, expressed
117
  * either as an Array or as a space-delimited String.
118
+ * @param array<mixed> $jsonKey the JSON credentials.
119
+ * @param string|string[] $defaultScope The default scope to use if no
120
  * user-defined scopes exist, expressed either as an Array or as a
121
  * space-delimited string.
122
  *
148
  * Create an authorized HTTP Client from an instance of FetchAuthTokenInterface.
149
  *
150
  * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
151
+ * @param array<mixed> $httpClientOptions (optional) Array of request options to apply.
152
  * @param callable $httpHandler (optional) http client to fetch the token.
153
  * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
154
  * @return \GuzzleHttp\Client
159
  callable $httpHandler = null,
160
  callable $tokenCallback = null
161
  ) {
 
 
 
 
 
 
 
 
 
 
 
 
162
  $middleware = new Middleware\AuthTokenMiddleware(
163
  $fetcher,
164
  $httpHandler,
186
  /**
187
  * export a callback function which updates runtime metadata.
188
  *
189
+ * @return callable updateMetadata function
190
  * @deprecated
191
  */
192
  public function getUpdateMetadataFunc()
197
  /**
198
  * Updates metadata with the authorization token.
199
  *
200
+ * @param array<mixed> $metadata metadata hashmap
201
  * @param string $authUri optional auth uri
202
  * @param callable $httpHandler callback which delivers psr7 request
203
+ * @return array<mixed> updated metadata hashmap
204
  */
205
  public function updateMetadata(
206
  $metadata,
220
 
221
  return $metadata_copy;
222
  }
223
+
224
+ /**
225
+ * Gets a callable which returns the default device certification.
226
+ *
227
+ * @throws UnexpectedValueException
228
+ * @return callable|null
229
+ */
230
+ public static function getDefaultClientCertSource()
231
+ {
232
+ if (!$clientCertSourceJson = self::loadDefaultClientCertSourceFile()) {
233
+ return null;
234
+ }
235
+ $clientCertSourceCmd = $clientCertSourceJson['cert_provider_command'];
236
+
237
+ return function () use ($clientCertSourceCmd) {
238
+ $cmd = array_map('escapeshellarg', $clientCertSourceCmd);
239
+ exec(implode(' ', $cmd), $output, $returnVar);
240
+
241
+ if (0 === $returnVar) {
242
+ return implode(PHP_EOL, $output);
243
+ }
244
+ throw new RuntimeException(
245
+ '"cert_provider_command" failed with a nonzero exit code'
246
+ );
247
+ };
248
+ }
249
+
250
+ /**
251
+ * Determines whether or not the default device certificate should be loaded.
252
+ *
253
+ * @return bool
254
+ */
255
+ public static function shouldLoadClientCertSource()
256
+ {
257
+ return filter_var(getenv(self::MTLS_CERT_ENV_VAR), FILTER_VALIDATE_BOOLEAN);
258
+ }
259
+
260
+ /**
261
+ * @return array{cert_provider_command:string[]}|null
262
+ */
263
+ private static function loadDefaultClientCertSourceFile()
264
+ {
265
+ $rootEnv = self::isOnWindows() ? 'APPDATA' : 'HOME';
266
+ $path = sprintf('%s/%s', getenv($rootEnv), self::MTLS_WELL_KNOWN_PATH);
267
+ if (!file_exists($path)) {
268
+ return null;
269
+ }
270
+ $jsonKey = file_get_contents($path);
271
+ $clientCertSourceJson = json_decode((string) $jsonKey, true);
272
+ if (!$clientCertSourceJson) {
273
+ throw new UnexpectedValueException('Invalid client cert source JSON');
274
+ }
275
+ if (!isset($clientCertSourceJson['cert_provider_command'])) {
276
+ throw new UnexpectedValueException(
277
+ 'cert source requires "cert_provider_command"'
278
+ );
279
+ }
280
+ if (!is_array($clientCertSourceJson['cert_provider_command'])) {
281
+ throw new UnexpectedValueException(
282
+ 'cert source expects "cert_provider_command" to be an array'
283
+ );
284
+ }
285
+ return $clientCertSourceJson;
286
+ }
287
  }
vendor/google/auth/src/FetchAuthTokenCache.php CHANGED
@@ -37,19 +37,9 @@ class FetchAuthTokenCache implements
37
  */
38
  private $fetcher;
39
 
40
- /**
41
- * @var array
42
- */
43
- private $cacheConfig;
44
-
45
- /**
46
- * @var CacheItemPoolInterface
47
- */
48
- private $cache;
49
-
50
  /**
51
  * @param FetchAuthTokenInterface $fetcher A credentials fetcher
52
- * @param array $cacheConfig Configuration for the cache
53
  * @param CacheItemPoolInterface $cache
54
  */
55
  public function __construct(
@@ -72,7 +62,7 @@ class FetchAuthTokenCache implements
72
  * from the supplied fetcher.
73
  *
74
  * @param callable $httpHandler callback which delivers psr7 request
75
- * @return array the response
76
  * @throws \Exception
77
  */
78
  public function fetchAuthToken(callable $httpHandler = null)
@@ -97,7 +87,7 @@ class FetchAuthTokenCache implements
97
  }
98
 
99
  /**
100
- * @return array|null
101
  */
102
  public function getLastReceivedToken()
103
  {
@@ -118,7 +108,7 @@ class FetchAuthTokenCache implements
118
  'Google\Auth\SignBlobInterface'
119
  );
120
  }
121
-
122
  return $this->fetcher->getClientName($httpHandler);
123
  }
124
 
@@ -164,6 +154,8 @@ class FetchAuthTokenCache implements
164
  if ($this->fetcher instanceof GetQuotaProjectInterface) {
165
  return $this->fetcher->getQuotaProject();
166
  }
 
 
167
  }
168
 
169
  /*
@@ -189,10 +181,10 @@ class FetchAuthTokenCache implements
189
  /**
190
  * Updates metadata with the authorization token.
191
  *
192
- * @param array $metadata metadata hashmap
193
  * @param string $authUri optional auth uri
194
  * @param callable $httpHandler callback which delivers psr7 request
195
- * @return array updated metadata hashmap
196
  * @throws \RuntimeException If the fetcher does not implement
197
  * `Google\Auth\UpdateMetadataInterface`.
198
  */
@@ -233,6 +225,10 @@ class FetchAuthTokenCache implements
233
  return $newMetadata;
234
  }
235
 
 
 
 
 
236
  private function fetchAuthTokenFromCache($authUri = null)
237
  {
238
  // Use the cached value if its available.
@@ -263,6 +259,11 @@ class FetchAuthTokenCache implements
263
  return null;
264
  }
265
 
 
 
 
 
 
266
  private function saveAuthTokenInCache($authToken, $authUri = null)
267
  {
268
  if (isset($authToken['access_token']) ||
37
  */
38
  private $fetcher;
39
 
 
 
 
 
 
 
 
 
 
 
40
  /**
41
  * @param FetchAuthTokenInterface $fetcher A credentials fetcher
42
+ * @param array<mixed> $cacheConfig Configuration for the cache
43
  * @param CacheItemPoolInterface $cache
44
  */
45
  public function __construct(
62
  * from the supplied fetcher.
63
  *
64
  * @param callable $httpHandler callback which delivers psr7 request
65
+ * @return array<mixed> the response
66
  * @throws \Exception
67
  */
68
  public function fetchAuthToken(callable $httpHandler = null)
87
  }
88
 
89
  /**
90
+ * @return array<mixed>|null
91
  */
92
  public function getLastReceivedToken()
93
  {
108
  'Google\Auth\SignBlobInterface'
109
  );
110
  }
111
+
112
  return $this->fetcher->getClientName($httpHandler);
113
  }
114
 
154
  if ($this->fetcher instanceof GetQuotaProjectInterface) {
155
  return $this->fetcher->getQuotaProject();
156
  }
157
+
158
+ return null;
159
  }
160
 
161
  /*
181
  /**
182
  * Updates metadata with the authorization token.
183
  *
184
+ * @param array<mixed> $metadata metadata hashmap
185
  * @param string $authUri optional auth uri
186
  * @param callable $httpHandler callback which delivers psr7 request
187
+ * @return array<mixed> updated metadata hashmap
188
  * @throws \RuntimeException If the fetcher does not implement
189
  * `Google\Auth\UpdateMetadataInterface`.
190
  */
225
  return $newMetadata;
226
  }
227
 
228
+ /**
229
+ * @param string|null $authUri
230
+ * @return array<mixed>|null
231
+ */
232
  private function fetchAuthTokenFromCache($authUri = null)
233
  {
234
  // Use the cached value if its available.
259
  return null;
260
  }
261
 
262
+ /**
263
+ * @param array<mixed> $authToken
264
+ * @param string|null $authUri
265
+ * @return void
266
+ */
267
  private function saveAuthTokenInCache($authToken, $authUri = null)
268
  {
269
  if (isset($authToken['access_token']) ||
vendor/google/auth/src/FetchAuthTokenInterface.php CHANGED
@@ -26,7 +26,7 @@ interface FetchAuthTokenInterface
26
  * Fetches the auth tokens based on the current state.
27
  *
28
  * @param callable $httpHandler callback which delivers psr7 request
29
- * @return array a hash of auth tokens
30
  */
31
  public function fetchAuthToken(callable $httpHandler = null);
32
 
@@ -43,11 +43,11 @@ interface FetchAuthTokenInterface
43
  * Returns an associative array with the token and
44
  * expiration time.
45
  *
46
- * @return null|array {
47
- * The last received access token.
48
  *
49
- * @var string $access_token The access token string.
50
- * @var int $expires_at The time the token expires as a UNIX timestamp.
51
  * }
52
  */
53
  public function getLastReceivedToken();
26
  * Fetches the auth tokens based on the current state.
27
  *
28
  * @param callable $httpHandler callback which delivers psr7 request
29
+ * @return array<mixed> a hash of auth tokens
30
  */
31
  public function fetchAuthToken(callable $httpHandler = null);
32
 
43
  * Returns an associative array with the token and
44
  * expiration time.
45
  *
46
+ * @return null|array<mixed> {
47
+ * The last received access token.
48
  *
49
+ * @type string $access_token The access token string.
50
+ * @type int $expires_at The time the token expires as a UNIX timestamp.
51
  * }
52
  */
53
  public function getLastReceivedToken();
vendor/google/auth/src/GCECache.php CHANGED
@@ -42,17 +42,7 @@ class GCECache
42
  use CacheTrait;
43
 
44
  /**
45
- * @var array
46
- */
47
- private $cacheConfig;
48
-
49
- /**
50
- * @var CacheItemPoolInterface
51
- */
52
- private $cache;
53
-
54
- /**
55
- * @param array $cacheConfig Configuration for the cache
56
  * @param CacheItemPoolInterface $cache
57
  */
58
  public function __construct(
42
  use CacheTrait;
43
 
44
  /**
45
+ * @param array<mixed> $cacheConfig Configuration for the cache
 
 
 
 
 
 
 
 
 
 
46
  * @param CacheItemPoolInterface $cache
47
  */
48
  public function __construct(
vendor/google/auth/src/HttpHandler/Guzzle5HttpHandler.php CHANGED
@@ -25,6 +25,9 @@ use GuzzleHttp\Psr7\Response;
25
  use Psr\Http\Message\RequestInterface;
26
  use Psr\Http\Message\ResponseInterface;
27
 
 
 
 
28
  class Guzzle5HttpHandler
29
  {
30
  /**
25
  use Psr\Http\Message\RequestInterface;
26
  use Psr\Http\Message\ResponseInterface;
27
 
28
+ /**
29
+ * @deprecated
30
+ */
31
  class Guzzle5HttpHandler
32
  {
33
  /**
vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php CHANGED
@@ -39,7 +39,7 @@ class Guzzle6HttpHandler
39
  * Accepts a PSR-7 request and an array of options and returns a PSR-7 response.
40
  *
41
  * @param RequestInterface $request
42
- * @param array $options
43
  * @return ResponseInterface
44
  */
45
  public function __invoke(RequestInterface $request, array $options = [])
@@ -51,7 +51,7 @@ class Guzzle6HttpHandler
51
  * Accepts a PSR-7 request and an array of options and returns a PromiseInterface
52
  *
53
  * @param RequestInterface $request
54
- * @param array $options
55
  *
56
  * @return \GuzzleHttp\Promise\PromiseInterface
57
  */
39
  * Accepts a PSR-7 request and an array of options and returns a PSR-7 response.
40
  *
41
  * @param RequestInterface $request
42
+ * @param array<mixed> $options
43
  * @return ResponseInterface
44
  */
45
  public function __invoke(RequestInterface $request, array $options = [])
51
  * Accepts a PSR-7 request and an array of options and returns a PromiseInterface
52
  *
53
  * @param RequestInterface $request
54
+ * @param array<mixed> $options
55
  *
56
  * @return \GuzzleHttp\Promise\PromiseInterface
57
  */
vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php CHANGED
@@ -36,6 +36,7 @@ class HttpHandlerFactory
36
  if (defined('GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
37
  $version = ClientInterface::MAJOR_VERSION;
38
  } elseif (defined('GuzzleHttp\ClientInterface::VERSION')) {
 
39
  $version = (int) substr(ClientInterface::VERSION, 0, 1);
40
  }
41
 
36
  if (defined('GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
37
  $version = ClientInterface::MAJOR_VERSION;
38
  } elseif (defined('GuzzleHttp\ClientInterface::VERSION')) {
39
+ /** @phpstan-ignore-next-line */
40
  $version = (int) substr(ClientInterface::VERSION, 0, 1);
41
  }
42
 
vendor/google/auth/src/Iam.php CHANGED
@@ -20,6 +20,7 @@ namespace Google\Auth;
20
  use Google\Auth\HttpHandler\HttpClientCache;
21
  use Google\Auth\HttpHandler\HttpHandlerFactory;
22
  use GuzzleHttp\Psr7;
 
23
 
24
  /**
25
  * Tools for using the IAM API.
@@ -56,7 +57,7 @@ class Iam
56
  * @param string $email The service account email.
57
  * @param string $accessToken An access token from the service account.
58
  * @param string $stringToSign The string to be signed.
59
- * @param array $delegates [optional] A list of service account emails to
60
  * add to the delegate chain. If omitted, the value of `$email` will
61
  * be used.
62
  * @return string The signed string, base64-encoded.
@@ -88,7 +89,7 @@ class Iam
88
  'POST',
89
  $uri,
90
  $headers,
91
- Psr7\stream_for(json_encode($body))
92
  );
93
 
94
  $res = $httpHandler($request);
20
  use Google\Auth\HttpHandler\HttpClientCache;
21
  use Google\Auth\HttpHandler\HttpHandlerFactory;
22
  use GuzzleHttp\Psr7;
23
+ use GuzzleHttp\Psr7\Utils;
24
 
25
  /**
26
  * Tools for using the IAM API.
57
  * @param string $email The service account email.
58
  * @param string $accessToken An access token from the service account.
59
  * @param string $stringToSign The string to be signed.
60
+ * @param array<string> $delegates [optional] A list of service account emails to
61
  * add to the delegate chain. If omitted, the value of `$email` will
62
  * be used.
63
  * @return string The signed string, base64-encoded.
89
  'POST',
90
  $uri,
91
  $headers,
92
+ Utils::streamFor(json_encode($body))
93
  );
94
 
95
  $res = $httpHandler($request);
vendor/google/auth/src/Middleware/AuthTokenMiddleware.php CHANGED
@@ -35,7 +35,7 @@ use Psr\Http\Message\RequestInterface;
35
  class AuthTokenMiddleware
36
  {
37
  /**
38
- * @var callback
39
  */
40
  private $httpHandler;
41
 
@@ -45,7 +45,7 @@ class AuthTokenMiddleware
45
  private $fetcher;
46
 
47
  /**
48
- * @var callable
49
  */
50
  private $tokenCallback;
51
 
@@ -115,7 +115,7 @@ class AuthTokenMiddleware
115
  /**
116
  * Call fetcher to fetch the token.
117
  *
118
- * @return string
119
  */
120
  private function fetchToken()
121
  {
@@ -137,12 +137,19 @@ class AuthTokenMiddleware
137
  if (array_key_exists('id_token', $auth_tokens)) {
138
  return $auth_tokens['id_token'];
139
  }
 
 
140
  }
141
 
 
 
 
142
  private function getQuotaProject()
143
  {
144
  if ($this->fetcher instanceof GetQuotaProjectInterface) {
145
  return $this->fetcher->getQuotaProject();
146
  }
 
 
147
  }
148
  }
35
  class AuthTokenMiddleware
36
  {
37
  /**
38
+ * @var callable
39
  */
40
  private $httpHandler;
41
 
45
  private $fetcher;
46
 
47
  /**
48
+ * @var ?callable
49
  */
50
  private $tokenCallback;
51
 
115
  /**
116
  * Call fetcher to fetch the token.
117
  *
118
+ * @return string|null
119
  */
120
  private function fetchToken()
121
  {
137
  if (array_key_exists('id_token', $auth_tokens)) {
138
  return $auth_tokens['id_token'];
139
  }
140
+
141
+ return null;
142
  }
143
 
144
+ /**
145
+ * @return string|null
146
+ */
147
  private function getQuotaProject()
148
  {
149
  if ($this->fetcher instanceof GetQuotaProjectInterface) {
150
  return $this->fetcher->getQuotaProject();
151
  }
152
+
153
+ return null;
154
  }
155
  }
vendor/google/auth/src/Middleware/ProxyAuthTokenMiddleware.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ namespace Google\Auth\Middleware;
19
+
20
+ use Google\Auth\FetchAuthTokenInterface;
21
+ use Google\Auth\GetQuotaProjectInterface;
22
+ use Psr\Http\Message\RequestInterface;
23
+
24
+ /**
25
+ * ProxyAuthTokenMiddleware is a Guzzle Middleware that adds an Authorization header
26
+ * provided by an object implementing FetchAuthTokenInterface.
27
+ *
28
+ * The FetchAuthTokenInterface#fetchAuthToken is used to obtain a hash; one of
29
+ * the values value in that hash is added as the authorization header.
30
+ *
31
+ * Requests will be accessed with the authorization header:
32
+ *
33
+ * 'proxy-authorization' 'Bearer <value of auth_token>'
34
+ */
35
+ class ProxyAuthTokenMiddleware
36
+ {
37
+ /**
38
+ * @var callable
39
+ */
40
+ private $httpHandler;
41
+
42
+ /**
43
+ * @var FetchAuthTokenInterface
44
+ */
45
+ private $fetcher;
46
+
47
+ /**
48
+ * @var ?callable
49
+ */
50
+ private $tokenCallback;
51
+
52
+ /**
53
+ * Creates a new ProxyAuthTokenMiddleware.
54
+ *
55
+ * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
56
+ * @param callable $httpHandler (optional) callback which delivers psr7 request
57
+ * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
58
+ */
59
+ public function __construct(
60
+ FetchAuthTokenInterface $fetcher,
61
+ callable $httpHandler = null,
62
+ callable $tokenCallback = null
63
+ ) {
64
+ $this->fetcher = $fetcher;
65
+ $this->httpHandler = $httpHandler;
66
+ $this->tokenCallback = $tokenCallback;
67
+ }
68
+
69
+ /**
70
+ * Updates the request with an Authorization header when auth is 'google_auth'.
71
+ *
72
+ * use Google\Auth\Middleware\ProxyAuthTokenMiddleware;
73
+ * use Google\Auth\OAuth2;
74
+ * use GuzzleHttp\Client;
75
+ * use GuzzleHttp\HandlerStack;
76
+ *
77
+ * $config = [..<oauth config param>.];
78
+ * $oauth2 = new OAuth2($config)
79
+ * $middleware = new ProxyAuthTokenMiddleware($oauth2);
80
+ * $stack = HandlerStack::create();
81
+ * $stack->push($middleware);
82
+ *
83
+ * $client = new Client([
84
+ * 'handler' => $stack,
85
+ * 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
86
+ * 'proxy_auth' => 'google_auth' // authorize all requests
87
+ * ]);
88
+ *
89
+ * $res = $client->get('myproject/taskqueues/myqueue');
90
+ *
91
+ * @param callable $handler
92
+ * @return \Closure
93
+ */
94
+ public function __invoke(callable $handler)
95
+ {
96
+ return function (RequestInterface $request, array $options) use ($handler) {
97
+ // Requests using "proxy_auth"="google_auth" will be authorized.
98
+ if (!isset($options['proxy_auth']) || $options['proxy_auth'] !== 'google_auth') {
99
+ return $handler($request, $options);
100
+ }
101
+
102
+ $request = $request->withHeader('proxy-authorization', 'Bearer ' . $this->fetchToken());
103
+
104
+ if ($quotaProject = $this->getQuotaProject()) {
105
+ $request = $request->withHeader(
106
+ GetQuotaProjectInterface::X_GOOG_USER_PROJECT_HEADER,
107
+ $quotaProject
108
+ );
109
+ }
110
+
111
+ return $handler($request, $options);
112
+ };
113
+ }
114
+
115
+ /**
116
+ * Call fetcher to fetch the token.
117
+ *
118
+ * @return string|null
119
+ */
120
+ private function fetchToken()
121
+ {
122
+ $auth_tokens = $this->fetcher->fetchAuthToken($this->httpHandler);
123
+
124
+ if (array_key_exists('access_token', $auth_tokens)) {
125
+ // notify the callback if applicable
126
+ if ($this->tokenCallback) {
127
+ call_user_func(
128
+ $this->tokenCallback,
129
+ $this->fetcher->getCacheKey(),
130
+ $auth_tokens['access_token']
131
+ );
132
+ }
133
+
134
+ return $auth_tokens['access_token'];
135
+ }
136
+
137
+ if (array_key_exists('id_token', $auth_tokens)) {
138
+ return $auth_tokens['id_token'];
139
+ }
140
+
141
+ return null;
142
+ }
143
+
144
+ /**
145
+ * @return string|null;
146
+ */
147
+ private function getQuotaProject()
148
+ {
149
+ if ($this->fetcher instanceof GetQuotaProjectInterface) {
150
+ return $this->fetcher->getQuotaProject();
151
+ }
152
+
153
+ return null;
154
+ }
155
+ }
vendor/google/auth/src/Middleware/ScopedAccessTokenMiddleware.php CHANGED
@@ -39,23 +39,13 @@ class ScopedAccessTokenMiddleware
39
 
40
  const DEFAULT_CACHE_LIFETIME = 1500;
41
 
42
- /**
43
- * @var CacheItemPoolInterface
44
- */
45
- private $cache;
46
-
47
- /**
48
- * @var array configuration
49
- */
50
- private $cacheConfig;
51
-
52
  /**
53
  * @var callable
54
  */
55
  private $tokenFunc;
56
 
57
  /**
58
- * @var array|string
59
  */
60
  private $scopes;
61
 
@@ -63,8 +53,8 @@ class ScopedAccessTokenMiddleware
63
  * Creates a new ScopedAccessTokenMiddleware.
64
  *
65
  * @param callable $tokenFunc a token generator function
66
- * @param array|string $scopes the token authentication scopes
67
- * @param array $cacheConfig configuration for the cache when it's present
68
  * @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
69
  */
70
  public function __construct(
39
 
40
  const DEFAULT_CACHE_LIFETIME = 1500;
41
 
 
 
 
 
 
 
 
 
 
 
42
  /**
43
  * @var callable
44
  */
45
  private $tokenFunc;
46
 
47
  /**
48
+ * @var array<string>|string
49
  */
50
  private $scopes;
51
 
53
  * Creates a new ScopedAccessTokenMiddleware.
54
  *
55
  * @param callable $tokenFunc a token generator function
56
+ * @param array<string>|string $scopes the token authentication scopes
57
+ * @param array<mixed> $cacheConfig configuration for the cache when it's present
58
  * @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
59
  */
60
  public function __construct(
vendor/google/auth/src/Middleware/SimpleMiddleware.php CHANGED
@@ -17,7 +17,7 @@
17
 
18
  namespace Google\Auth\Middleware;
19
 
20
- use GuzzleHttp\Psr7;
21
  use Psr\Http\Message\RequestInterface;
22
 
23
  /**
@@ -29,7 +29,7 @@ use Psr\Http\Message\RequestInterface;
29
  class SimpleMiddleware
30
  {
31
  /**
32
- * @var array
33
  */
34
  private $config;
35
 
@@ -39,7 +39,7 @@ class SimpleMiddleware
39
  * The configuration array expects one option
40
  * - key: required, otherwise InvalidArgumentException is thrown
41
  *
42
- * @param array $config Configuration array
43
  */
44
  public function __construct(array $config)
45
  {
@@ -81,9 +81,9 @@ class SimpleMiddleware
81
  return $handler($request, $options);
82
  }
83
 
84
- $query = Psr7\parse_query($request->getUri()->getQuery());
85
  $params = array_merge($query, $this->config);
86
- $uri = $request->getUri()->withQuery(Psr7\build_query($params));
87
  $request = $request->withUri($uri);
88
 
89
  return $handler($request, $options);
17
 
18
  namespace Google\Auth\Middleware;
19
 
20
+ use GuzzleHttp\Psr7\Query;
21
  use Psr\Http\Message\RequestInterface;
22
 
23
  /**
29
  class SimpleMiddleware
30
  {
31
  /**
32
+ * @var array<mixed>
33
  */
34
  private $config;
35
 
39
  * The configuration array expects one option
40
  * - key: required, otherwise InvalidArgumentException is thrown
41
  *
42
+ * @param array<mixed> $config Configuration array
43
  */
44
  public function __construct(array $config)
45
  {
81
  return $handler($request, $options);
82
  }
83
 
84
+ $query = Query::parse($request->getUri()->getQuery());
85
  $params = array_merge($query, $this->config);
86
+ $uri = $request->getUri()->withQuery(Query::build($params));
87
  $request = $request->withUri($uri);
88
 
89
  return $handler($request, $options);
vendor/google/auth/src/OAuth2.php CHANGED
@@ -17,10 +17,13 @@
17
 
18
  namespace Google\Auth;
19
 
 
 
20
  use Google\Auth\HttpHandler\HttpClientCache;
21
  use Google\Auth\HttpHandler\HttpHandlerFactory;
22
- use GuzzleHttp\Psr7;
23
  use GuzzleHttp\Psr7\Request;
 
24
  use InvalidArgumentException;
25
  use Psr\Http\Message\RequestInterface;
26
  use Psr\Http\Message\ResponseInterface;
@@ -41,6 +44,8 @@ class OAuth2 implements FetchAuthTokenInterface
41
 
42
  /**
43
  * TODO: determine known methods from the keys of JWT::methods.
 
 
44
  */
45
  public static $knownSigningAlgorithms = array(
46
  'HS256',
@@ -52,7 +57,7 @@ class OAuth2 implements FetchAuthTokenInterface
52
  /**
53
  * The well known grant types.
54
  *
55
- * @var array
56
  */
57
  public static $knownGrantTypes = array(
58
  'authorization_code',
@@ -66,7 +71,7 @@ class OAuth2 implements FetchAuthTokenInterface
66
  * The authorization server's HTTP endpoint capable of
67
  * authenticating the end-user and obtaining authorization.
68
  *
69
- * @var UriInterface
70
  */
71
  private $authorizationUri;
72
 
@@ -82,7 +87,7 @@ class OAuth2 implements FetchAuthTokenInterface
82
  /**
83
  * The redirection URI used in the initial request.
84
  *
85
- * @var string
86
  */
87
  private $redirectUri;
88
 
@@ -105,14 +110,14 @@ class OAuth2 implements FetchAuthTokenInterface
105
  /**
106
  * The resource owner's username.
107
  *
108
- * @var string
109
  */
110
  private $username;
111
 
112
  /**
113
  * The resource owner's password.
114
  *
115
- * @var string
116
  */
117
  private $password;
118
 
@@ -120,7 +125,7 @@ class OAuth2 implements FetchAuthTokenInterface
120
  * The scope of the access request, expressed either as an Array or as a
121
  * space-delimited string.
122
  *
123
- * @var array
124
  */
125
  private $scope;
126
 
@@ -136,14 +141,14 @@ class OAuth2 implements FetchAuthTokenInterface
136
  *
137
  * Only used by the authorization code access grant type.
138
  *
139
- * @var string
140
  */
141
  private $code;
142
 
143
  /**
144
  * The issuer ID when using assertion profile.
145
  *
146
- * @var string
147
  */
148
  private $issuer;
149
 
@@ -171,7 +176,7 @@ class OAuth2 implements FetchAuthTokenInterface
171
  /**
172
  * The signing key when using assertion profile.
173
  *
174
- * @var string
175
  */
176
  private $signingKey;
177
 
@@ -185,14 +190,14 @@ class OAuth2 implements FetchAuthTokenInterface
185
  /**
186
  * The signing algorithm when using an assertion profile.
187
  *
188
- * @var string
189
  */
190
  private $signingAlgorithm;
191
 
192
  /**
193
  * The refresh token associated with the access token to be refreshed.
194
  *
195
- * @var string
196
  */
197
  private $refreshToken;
198
 
@@ -213,7 +218,7 @@ class OAuth2 implements FetchAuthTokenInterface
213
  /**
214
  * The lifetime in seconds of the current access token.
215
  *
216
- * @var int
217
  */
218
  private $expiresIn;
219
 
@@ -221,7 +226,7 @@ class OAuth2 implements FetchAuthTokenInterface
221
  * The expiration time of the access token as a number of seconds since the
222
  * unix epoch.
223
  *
224
- * @var int
225
  */
226
  private $expiresAt;
227
 
@@ -229,26 +234,30 @@ class OAuth2 implements FetchAuthTokenInterface
229
  * The issue time of the access token as a number of seconds since the unix
230
  * epoch.
231
  *
232
- * @var int
233
  */
234
  private $issuedAt;
235
 
236
  /**
237
  * The current grant type.
238
  *
239
- * @var string
240
  */
241
  private $grantType;
242
 
243
  /**
244
  * When using an extension grant type, this is the set of parameters used by
245
  * that extension.
 
 
246
  */
247
  private $extensionParams;
248
 
249
  /**
250
  * When using the toJwt function, these claims will be added to the JWT
251
  * payload.
 
 
252
  */
253
  private $additionalClaims;
254
 
@@ -318,7 +327,7 @@ class OAuth2 implements FetchAuthTokenInterface
318
  * When using an extension grant type, this is the set of parameters used
319
  * by that extension.
320
  *
321
- * @param array $config Configuration array
322
  */
323
  public function __construct(array $config)
324
  {
@@ -372,20 +381,21 @@ class OAuth2 implements FetchAuthTokenInterface
372
  * - otherwise returns the payload in the idtoken as a PHP object.
373
  *
374
  * The behavior of this method varies depending on the version of
375
- * `firebase/php-jwt` you are using. In versions lower than 3.0.0, if
376
- * `$publicKey` is null, the key is decoded without being verified. In
377
- * newer versions, if a public key is not given, this method will throw an
378
- * `\InvalidArgumentException`.
379
  *
380
- * @param string $publicKey The public key to use to authenticate the token
381
- * @param array $allowed_algs List of supported verification algorithms
 
382
  * @throws \DomainException if the token is missing an audience.
383
  * @throws \DomainException if the audience does not match the one set in
384
  * the OAuth2 class instance.
385
  * @throws \UnexpectedValueException If the token is invalid
386
- * @throws SignatureInvalidException If the signature is invalid.
387
- * @throws BeforeValidException If the token is not yet valid.
388
- * @throws ExpiredException If the token has expired.
 
389
  * @return null|object
390
  */
391
  public function verifyIdToken($publicKey = null, $allowed_algs = array())
@@ -409,7 +419,7 @@ class OAuth2 implements FetchAuthTokenInterface
409
  /**
410
  * Obtains the encoded jwt from the instance data.
411
  *
412
- * @param array $config array optional configuration parameters
413
  * @return string
414
  */
415
  public function toJwt(array $config = [])
@@ -453,7 +463,7 @@ class OAuth2 implements FetchAuthTokenInterface
453
  }
454
  $assertion += $this->getAdditionalClaims();
455
 
456
- return $this->jwtEncode(
457
  $assertion,
458
  $this->getSigningKey(),
459
  $this->getSigningAlgorithm(),
@@ -515,7 +525,7 @@ class OAuth2 implements FetchAuthTokenInterface
515
  'POST',
516
  $uri,
517
  $headers,
518
- Psr7\build_query($params)
519
  );
520
  }
521
 
@@ -523,7 +533,7 @@ class OAuth2 implements FetchAuthTokenInterface
523
  * Fetches the auth tokens based on the current state.
524
  *
525
  * @param callable $httpHandler callback which delivers psr7 request
526
- * @return array the response
527
  */
528
  public function fetchAuthToken(callable $httpHandler = null)
529
  {
@@ -543,7 +553,7 @@ class OAuth2 implements FetchAuthTokenInterface
543
  *
544
  * The key is derived from the scopes.
545
  *
546
- * @return string a key that may be used to cache the auth token.
547
  */
548
  public function getCacheKey()
549
  {
@@ -563,7 +573,7 @@ class OAuth2 implements FetchAuthTokenInterface
563
  * Parses the fetched tokens.
564
  *
565
  * @param ResponseInterface $resp the response.
566
- * @return array the tokens parsed from the response body.
567
  * @throws \Exception
568
  */
569
  public function parseTokenResponse(ResponseInterface $resp)
@@ -598,7 +608,7 @@ class OAuth2 implements FetchAuthTokenInterface
598
  * ]);
599
  * ```
600
  *
601
- * @param array $config
602
  * The configuration parameters related to the token.
603
  *
604
  * - refresh_token
@@ -619,6 +629,7 @@ class OAuth2 implements FetchAuthTokenInterface
619
  *
620
  * - issued_at
621
  * The timestamp that the token was issued at.
 
622
  */
623
  public function updateToken(array $config)
624
  {
@@ -652,7 +663,7 @@ class OAuth2 implements FetchAuthTokenInterface
652
  /**
653
  * Builds the authorization Uri that the user should be redirected to.
654
  *
655
- * @param array $config configuration options that customize the return url
656
  * @return UriInterface the authorization Url.
657
  * @throws InvalidArgumentException
658
  */
@@ -690,10 +701,10 @@ class OAuth2 implements FetchAuthTokenInterface
690
 
691
  // Construct the uri object; return it if it is valid.
692
  $result = clone $this->authorizationUri;
693
- $existingParams = Psr7\parse_query($result->getQuery());
694
 
695
  $result = $result->withQuery(
696
- Psr7\build_query(array_merge($existingParams, $params))
697
  );
698
 
699
  if ($result->getScheme() != 'https') {
@@ -710,6 +721,7 @@ class OAuth2 implements FetchAuthTokenInterface
710
  * the end-user and obtaining authorization.
711
  *
712
  * @param string $uri
 
713
  */
714
  public function setAuthorizationUri($uri)
715
  {
@@ -720,7 +732,7 @@ class OAuth2 implements FetchAuthTokenInterface
720
  * Gets the authorization server's HTTP endpoint capable of authenticating
721
  * the end-user and obtaining authorization.
722
  *
723
- * @return UriInterface
724
  */
725
  public function getAuthorizationUri()
726
  {
@@ -731,7 +743,7 @@ class OAuth2 implements FetchAuthTokenInterface
731
  * Gets the authorization server's HTTP endpoint capable of issuing tokens
732
  * and refreshing expired tokens.
733
  *
734
- * @return string
735
  */
736
  public function getTokenCredentialUri()
737
  {
@@ -743,6 +755,7 @@ class OAuth2 implements FetchAuthTokenInterface
743
  * and refreshing expired tokens.
744
  *
745
  * @param string $uri
 
746
  */
747
  public function setTokenCredentialUri($uri)
748
  {
@@ -752,7 +765,7 @@ class OAuth2 implements FetchAuthTokenInterface
752
  /**
753
  * Gets the redirection URI used in the initial request.
754
  *
755
- * @return string
756
  */
757
  public function getRedirectUri()
758
  {
@@ -762,7 +775,8 @@ class OAuth2 implements FetchAuthTokenInterface
762
  /**
763
  * Sets the redirection URI used in the initial request.
764
  *
765
- * @param string $uri
 
766
  */
767
  public function setRedirectUri($uri)
768
  {
@@ -787,7 +801,7 @@ class OAuth2 implements FetchAuthTokenInterface
787
  /**
788
  * Gets the scope of the access requests as a space-delimited String.
789
  *
790
- * @return string
791
  */
792
  public function getScope()
793
  {
@@ -802,7 +816,8 @@ class OAuth2 implements FetchAuthTokenInterface
802
  * Sets the scope of the access request, expressed either as an Array or as
803
  * a space-delimited String.
804
  *
805
- * @param string|array $scope
 
806
  * @throws InvalidArgumentException
807
  */
808
  public function setScope($scope)
@@ -831,7 +846,7 @@ class OAuth2 implements FetchAuthTokenInterface
831
  /**
832
  * Gets the current grant type.
833
  *
834
- * @return string
835
  */
836
  public function getGrantType()
837
  {
@@ -863,7 +878,8 @@ class OAuth2 implements FetchAuthTokenInterface
863
  /**
864
  * Sets the current grant type.
865
  *
866
- * @param $grantType
 
867
  * @throws InvalidArgumentException
868
  */
869
  public function setGrantType($grantType)
@@ -895,6 +911,7 @@ class OAuth2 implements FetchAuthTokenInterface
895
  * Sets an arbitrary string designed to allow the client to maintain state.
896
  *
897
  * @param string $state
 
898
  */
899
  public function setState($state)
900
  {
@@ -903,6 +920,8 @@ class OAuth2 implements FetchAuthTokenInterface
903
 
904
  /**
905
  * Gets the authorization code issued to this client.
 
 
906
  */
907
  public function getCode()
908
  {
@@ -913,6 +932,7 @@ class OAuth2 implements FetchAuthTokenInterface
913
  * Sets the authorization code issued to this client.
914
  *
915
  * @param string $code
 
916
  */
917
  public function setCode($code)
918
  {
@@ -921,6 +941,8 @@ class OAuth2 implements FetchAuthTokenInterface
921
 
922
  /**
923
  * Gets the resource owner's username.
 
 
924
  */
925
  public function getUsername()
926
  {
@@ -931,6 +953,7 @@ class OAuth2 implements FetchAuthTokenInterface
931
  * Sets the resource owner's username.
932
  *
933
  * @param string $username
 
934
  */
935
  public function setUsername($username)
936
  {
@@ -939,6 +962,8 @@ class OAuth2 implements FetchAuthTokenInterface
939
 
940
  /**
941
  * Gets the resource owner's password.
 
 
942
  */
943
  public function getPassword()
944
  {
@@ -948,7 +973,8 @@ class OAuth2 implements FetchAuthTokenInterface
948
  /**
949
  * Sets the resource owner's password.
950
  *
951
- * @param $password
 
952
  */
953
  public function setPassword($password)
954
  {
@@ -958,6 +984,8 @@ class OAuth2 implements FetchAuthTokenInterface
958
  /**
959
  * Sets a unique identifier issued to the client to identify itself to the
960
  * authorization server.
 
 
961
  */
962
  public function getClientId()
963
  {
@@ -968,7 +996,8 @@ class OAuth2 implements FetchAuthTokenInterface
968
  * Sets a unique identifier issued to the client to identify itself to the
969
  * authorization server.
970
  *
971
- * @param $clientId
 
972
  */
973
  public function setClientId($clientId)
974
  {
@@ -978,6 +1007,8 @@ class OAuth2 implements FetchAuthTokenInterface
978
  /**
979
  * Gets a shared symmetric secret issued by the authorization server, which
980
  * is used to authenticate the client.
 
 
981
  */
982
  public function getClientSecret()
983
  {
@@ -988,7 +1019,8 @@ class OAuth2 implements FetchAuthTokenInterface
988
  * Sets a shared symmetric secret issued by the authorization server, which
989
  * is used to authenticate the client.
990
  *
991
- * @param $clientSecret
 
992
  */
993
  public function setClientSecret($clientSecret)
994
  {
@@ -997,6 +1029,8 @@ class OAuth2 implements FetchAuthTokenInterface
997
 
998
  /**
999
  * Gets the Issuer ID when using assertion profile.
 
 
1000
  */
1001
  public function getIssuer()
1002
  {
@@ -1007,6 +1041,7 @@ class OAuth2 implements FetchAuthTokenInterface
1007
  * Sets the Issuer ID when using assertion profile.
1008
  *
1009
  * @param string $issuer
 
1010
  */
1011
  public function setIssuer($issuer)
1012
  {
@@ -1015,6 +1050,8 @@ class OAuth2 implements FetchAuthTokenInterface
1015
 
1016
  /**
1017
  * Gets the target sub when issuing assertions.
 
 
1018
  */
1019
  public function getSub()
1020
  {
@@ -1025,6 +1062,7 @@ class OAuth2 implements FetchAuthTokenInterface
1025
  * Sets the target sub when issuing assertions.
1026
  *
1027
  * @param string $sub
 
1028
  */
1029
  public function setSub($sub)
1030
  {
@@ -1033,6 +1071,8 @@ class OAuth2 implements FetchAuthTokenInterface
1033
 
1034
  /**
1035
  * Gets the target audience when issuing assertions.
 
 
1036
  */
1037
  public function getAudience()
1038
  {
@@ -1043,6 +1083,7 @@ class OAuth2 implements FetchAuthTokenInterface
1043
  * Sets the target audience when issuing assertions.
1044
  *
1045
  * @param string $audience
 
1046
  */
1047
  public function setAudience($audience)
1048
  {
@@ -1051,6 +1092,8 @@ class OAuth2 implements FetchAuthTokenInterface
1051
 
1052
  /**
1053
  * Gets the signing key when using an assertion profile.
 
 
1054
  */
1055
  public function getSigningKey()
1056
  {
@@ -1061,6 +1104,7 @@ class OAuth2 implements FetchAuthTokenInterface
1061
  * Sets the signing key when using an assertion profile.
1062
  *
1063
  * @param string $signingKey
 
1064
  */
1065
  public function setSigningKey($signingKey)
1066
  {
@@ -1070,7 +1114,7 @@ class OAuth2 implements FetchAuthTokenInterface
1070
  /**
1071
  * Gets the signing key id when using an assertion profile.
1072
  *
1073
- * @return string
1074
  */
1075
  public function getSigningKeyId()
1076
  {
@@ -1081,6 +1125,7 @@ class OAuth2 implements FetchAuthTokenInterface
1081
  * Sets the signing key id when using an assertion profile.
1082
  *
1083
  * @param string $signingKeyId
 
1084
  */
1085
  public function setSigningKeyId($signingKeyId)
1086
  {
@@ -1090,7 +1135,7 @@ class OAuth2 implements FetchAuthTokenInterface
1090
  /**
1091
  * Gets the signing algorithm when using an assertion profile.
1092
  *
1093
- * @return string
1094
  */
1095
  public function getSigningAlgorithm()
1096
  {
@@ -1100,7 +1145,8 @@ class OAuth2 implements FetchAuthTokenInterface
1100
  /**
1101
  * Sets the signing algorithm when using an assertion profile.
1102
  *
1103
- * @param string $signingAlgorithm
 
1104
  */
1105
  public function setSigningAlgorithm($signingAlgorithm)
1106
  {
@@ -1116,6 +1162,8 @@ class OAuth2 implements FetchAuthTokenInterface
1116
  /**
1117
  * Gets the set of parameters used by extension when using an extension
1118
  * grant type.
 
 
1119
  */
1120
  public function getExtensionParams()
1121
  {
@@ -1126,7 +1174,8 @@ class OAuth2 implements FetchAuthTokenInterface
1126
  * Sets the set of parameters used by extension when using an extension
1127
  * grant type.
1128
  *
1129
- * @param $extensionParams
 
1130
  */
1131
  public function setExtensionParams($extensionParams)
1132
  {
@@ -1135,6 +1184,8 @@ class OAuth2 implements FetchAuthTokenInterface
1135
 
1136
  /**
1137
  * Gets the number of seconds assertions are valid for.
 
 
1138
  */
1139
  public function getExpiry()
1140
  {
@@ -1145,6 +1196,7 @@ class OAuth2 implements FetchAuthTokenInterface
1145
  * Sets the number of seconds assertions are valid for.
1146
  *
1147
  * @param int $expiry
 
1148
  */
1149
  public function setExpiry($expiry)
1150
  {
@@ -1153,6 +1205,8 @@ class OAuth2 implements FetchAuthTokenInterface
1153
 
1154
  /**
1155
  * Gets the lifetime of the access token in seconds.
 
 
1156
  */
1157
  public function getExpiresIn()
1158
  {
@@ -1162,7 +1216,8 @@ class OAuth2 implements FetchAuthTokenInterface
1162
  /**
1163
  * Sets the lifetime of the access token in seconds.
1164
  *
1165
- * @param int $expiresIn
 
1166
  */
1167
  public function setExpiresIn($expiresIn)
1168
  {
@@ -1178,7 +1233,7 @@ class OAuth2 implements FetchAuthTokenInterface
1178
  /**
1179
  * Gets the time the current access token expires at.
1180
  *
1181
- * @return int
1182
  */
1183
  public function getExpiresAt()
1184
  {
@@ -1210,6 +1265,7 @@ class OAuth2 implements FetchAuthTokenInterface
1210
  * Sets the time the current access token expires at.
1211
  *
1212
  * @param int $expiresAt
 
1213
  */
1214
  public function setExpiresAt($expiresAt)
1215
  {
@@ -1218,6 +1274,8 @@ class OAuth2 implements FetchAuthTokenInterface
1218
 
1219
  /**
1220
  * Gets the time the current access token was issued at.
 
 
1221
  */
1222
  public function getIssuedAt()
1223
  {
@@ -1228,6 +1286,7 @@ class OAuth2 implements FetchAuthTokenInterface
1228
  * Sets the time the current access token was issued at.
1229
  *
1230
  * @param int $issuedAt
 
1231
  */
1232
  public function setIssuedAt($issuedAt)
1233
  {
@@ -1236,6 +1295,8 @@ class OAuth2 implements FetchAuthTokenInterface
1236
 
1237
  /**
1238
  * Gets the current access token.
 
 
1239
  */
1240
  public function getAccessToken()
1241
  {
@@ -1246,6 +1307,7 @@ class OAuth2 implements FetchAuthTokenInterface
1246
  * Sets the current access token.
1247
  *
1248
  * @param string $accessToken
 
1249
  */
1250
  public function setAccessToken($accessToken)
1251
  {
@@ -1254,6 +1316,8 @@ class OAuth2 implements FetchAuthTokenInterface
1254
 
1255
  /**
1256
  * Gets the current ID token.
 
 
1257
  */
1258
  public function getIdToken()
1259
  {
@@ -1263,7 +1327,8 @@ class OAuth2 implements FetchAuthTokenInterface
1263
  /**
1264
  * Sets the current ID token.
1265
  *
1266
- * @param $idToken
 
1267
  */
1268
  public function setIdToken($idToken)
1269
  {
@@ -1272,6 +1337,8 @@ class OAuth2 implements FetchAuthTokenInterface
1272
 
1273
  /**
1274
  * Gets the refresh token associated with the current access token.
 
 
1275
  */
1276
  public function getRefreshToken()
1277
  {
@@ -1281,7 +1348,8 @@ class OAuth2 implements FetchAuthTokenInterface
1281
  /**
1282
  * Sets the refresh token associated with the current access token.
1283
  *
1284
- * @param $refreshToken
 
1285
  */
1286
  public function setRefreshToken($refreshToken)
1287
  {
@@ -1291,7 +1359,8 @@ class OAuth2 implements FetchAuthTokenInterface
1291
  /**
1292
  * Sets additional claims to be included in the JWT token
1293
  *
1294
- * @param array $additionalClaims
 
1295
  */
1296
  public function setAdditionalClaims(array $additionalClaims)
1297
  {
@@ -1301,7 +1370,7 @@ class OAuth2 implements FetchAuthTokenInterface
1301
  /**
1302
  * Gets the additional claims to be included in the JWT token.
1303
  *
1304
- * @return array
1305
  */
1306
  public function getAdditionalClaims()
1307
  {
@@ -1311,7 +1380,7 @@ class OAuth2 implements FetchAuthTokenInterface
1311
  /**
1312
  * The expiration of the last received token.
1313
  *
1314
- * @return array|null
1315
  */
1316
  public function getLastReceivedToken()
1317
  {
@@ -1360,45 +1429,100 @@ class OAuth2 implements FetchAuthTokenInterface
1360
  /**
1361
  * @todo handle uri as array
1362
  *
1363
- * @param string $uri
1364
  * @return null|UriInterface
1365
  */
1366
  private function coerceUri($uri)
1367
  {
1368
  if (is_null($uri)) {
1369
- return;
1370
  }
1371
 
1372
- return Psr7\uri_for($uri);
1373
  }
1374
 
1375
  /**
1376
  * @param string $idToken
1377
- * @param string|array|null $publicKey
1378
- * @param array $allowedAlgs
1379
  * @return object
1380
  */
1381
  private function jwtDecode($idToken, $publicKey, $allowedAlgs)
1382
  {
1383
- if (class_exists('Firebase\JWT\JWT')) {
1384
- return \Firebase\JWT\JWT::decode($idToken, $publicKey, $allowedAlgs);
 
 
 
 
 
 
 
 
 
 
1385
  }
1386
-
1387
- return \JWT::decode($idToken, $publicKey, $allowedAlgs);
1388
  }
1389
 
1390
- private function jwtEncode($assertion, $signingKey, $signingAlgorithm, $signingKeyId = null)
 
 
 
 
 
1391
  {
1392
- if (class_exists('Firebase\JWT\JWT')) {
1393
- return \Firebase\JWT\JWT::encode(
1394
- $assertion,
1395
- $signingKey,
1396
- $signingAlgorithm,
1397
- $signingKeyId
1398
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1399
  }
1400
 
1401
- return \JWT::encode($assertion, $signingKey, $signingAlgorithm, $signingKeyId);
1402
  }
1403
 
1404
  /**
@@ -1416,8 +1540,8 @@ class OAuth2 implements FetchAuthTokenInterface
1416
  }
1417
 
1418
  /**
1419
- * @param array $params
1420
- * @return array
1421
  */
1422
  private function addClientCredentials(&$params)
1423
  {
17
 
18
  namespace Google\Auth;
19
 
20
+ use Firebase\JWT\JWT;
21
+ use Firebase\JWT\Key;
22
  use Google\Auth\HttpHandler\HttpClientCache;
23
  use Google\Auth\HttpHandler\HttpHandlerFactory;
24
+ use GuzzleHttp\Psr7\Query;
25
  use GuzzleHttp\Psr7\Request;
26
+ use GuzzleHttp\Psr7\Utils;
27
  use InvalidArgumentException;
28
  use Psr\Http\Message\RequestInterface;
29
  use Psr\Http\Message\ResponseInterface;
44
 
45
  /**
46
  * TODO: determine known methods from the keys of JWT::methods.
47
+ *
48
+ * @var array<string>
49
  */
50
  public static $knownSigningAlgorithms = array(
51
  'HS256',
57
  /**
58
  * The well known grant types.
59
  *
60
+ * @var array<string>
61
  */
62
  public static $knownGrantTypes = array(
63
  'authorization_code',
71
  * The authorization server's HTTP endpoint capable of
72
  * authenticating the end-user and obtaining authorization.
73
  *
74
+ * @var ?UriInterface
75
  */
76
  private $authorizationUri;
77
 
87
  /**
88
  * The redirection URI used in the initial request.
89
  *
90
+ * @var ?string
91
  */
92
  private $redirectUri;
93
 
110
  /**
111
  * The resource owner's username.
112
  *
113
+ * @var ?string
114
  */
115
  private $username;
116
 
117
  /**
118
  * The resource owner's password.
119
  *
120
+ * @var ?string
121
  */
122
  private $password;
123
 
125
  * The scope of the access request, expressed either as an Array or as a
126
  * space-delimited string.
127
  *
128
+ * @var ?array<string>
129
  */
130
  private $scope;
131
 
141
  *
142
  * Only used by the authorization code access grant type.
143
  *
144
+ * @var ?string
145
  */
146
  private $code;
147
 
148
  /**
149
  * The issuer ID when using assertion profile.
150
  *
151
+ * @var ?string
152
  */
153
  private $issuer;
154
 
176
  /**
177
  * The signing key when using assertion profile.
178
  *
179
+ * @var ?string
180
  */
181
  private $signingKey;
182
 
190
  /**
191
  * The signing algorithm when using an assertion profile.
192
  *
193
+ * @var ?string
194
  */
195
  private $signingAlgorithm;
196
 
197
  /**
198
  * The refresh token associated with the access token to be refreshed.
199
  *
200
+ * @var ?string
201
  */
202
  private $refreshToken;
203
 
218
  /**
219
  * The lifetime in seconds of the current access token.
220
  *
221
+ * @var ?int
222
  */
223
  private $expiresIn;
224
 
226
  * The expiration time of the access token as a number of seconds since the
227
  * unix epoch.
228
  *
229
+ * @var ?int
230
  */
231
  private $expiresAt;
232
 
234
  * The issue time of the access token as a number of seconds since the unix
235
  * epoch.
236
  *
237
+ * @var ?int
238
  */
239
  private $issuedAt;
240
 
241
  /**
242
  * The current grant type.
243
  *
244
+ * @var ?string
245
  */
246
  private $grantType;
247
 
248
  /**
249
  * When using an extension grant type, this is the set of parameters used by
250
  * that extension.
251
+ *
252
+ * @var array<mixed>
253
  */
254
  private $extensionParams;
255
 
256
  /**
257
  * When using the toJwt function, these claims will be added to the JWT
258
  * payload.
259
+ *
260
+ * @var array<mixed>
261
  */
262
  private $additionalClaims;
263
 
327
  * When using an extension grant type, this is the set of parameters used
328
  * by that extension.
329
  *
330
+ * @param array<mixed> $config Configuration array
331
  */
332
  public function __construct(array $config)
333
  {
381
  * - otherwise returns the payload in the idtoken as a PHP object.
382
  *
383
  * The behavior of this method varies depending on the version of
384
+ * `firebase/php-jwt` you are using. In versions 6.0 and above, you cannot
385
+ * provide multiple $allowed_algs, and instead must provide an array of Key
386
+ * objects as the $publicKey.
 
387
  *
388
+ * @param string|Key|Key[] $publicKey The public key to use to authenticate the token
389
+ * @param string|array<string> $allowed_algs algorithm or array of supported verification algorithms.
390
+ * Providing more than one algorithm will throw an exception.
391
  * @throws \DomainException if the token is missing an audience.
392
  * @throws \DomainException if the audience does not match the one set in
393
  * the OAuth2 class instance.
394
  * @throws \UnexpectedValueException If the token is invalid
395
+ * @throws \InvalidArgumentException If more than one value for allowed_algs is supplied
396
+ * @throws \Firebase\JWT\SignatureInvalidException If the signature is invalid.
397
+ * @throws \Firebase\JWT\BeforeValidException If the token is not yet valid.
398
+ * @throws \Firebase\JWT\ExpiredException If the token has expired.
399
  * @return null|object
400
  */
401
  public function verifyIdToken($publicKey = null, $allowed_algs = array())
419
  /**
420
  * Obtains the encoded jwt from the instance data.
421
  *
422
+ * @param array<mixed> $config array optional configuration parameters
423
  * @return string
424
  */
425
  public function toJwt(array $config = [])
463
  }
464
  $assertion += $this->getAdditionalClaims();
465
 
466
+ return JWT::encode(
467
  $assertion,
468
  $this->getSigningKey(),
469
  $this->getSigningAlgorithm(),
525
  'POST',
526
  $uri,
527
  $headers,
528
+ Query::build($params)
529
  );
530
  }
531
 
533
  * Fetches the auth tokens based on the current state.
534
  *
535
  * @param callable $httpHandler callback which delivers psr7 request
536
+ * @return array<mixed> the response
537
  */
538
  public function fetchAuthToken(callable $httpHandler = null)
539
  {
553
  *
554
  * The key is derived from the scopes.
555
  *
556
+ * @return ?string a key that may be used to cache the auth token.
557
  */
558
  public function getCacheKey()
559
  {
573
  * Parses the fetched tokens.
574
  *
575
  * @param ResponseInterface $resp the response.
576
+ * @return array<mixed> the tokens parsed from the response body.
577
  * @throws \Exception
578
  */
579
  public function parseTokenResponse(ResponseInterface $resp)
608
  * ]);
609
  * ```
610
  *
611
+ * @param array<mixed> $config
612
  * The configuration parameters related to the token.
613
  *
614
  * - refresh_token
629
  *
630
  * - issued_at
631
  * The timestamp that the token was issued at.
632
+ * @return void
633
  */
634
  public function updateToken(array $config)
635
  {
663
  /**
664
  * Builds the authorization Uri that the user should be redirected to.
665
  *
666
+ * @param array<mixed> $config configuration options that customize the return url
667
  * @return UriInterface the authorization Url.
668
  * @throws InvalidArgumentException
669
  */
701
 
702
  // Construct the uri object; return it if it is valid.
703
  $result = clone $this->authorizationUri;
704
+ $existingParams = Query::parse($result->getQuery());
705
 
706
  $result = $result->withQuery(
707
+ Query::build(array_merge($existingParams, $params))
708
  );
709
 
710
  if ($result->getScheme() != 'https') {
721
  * the end-user and obtaining authorization.
722
  *
723
  * @param string $uri
724
+ * @return void
725
  */
726
  public function setAuthorizationUri($uri)
727
  {
732
  * Gets the authorization server's HTTP endpoint capable of authenticating
733
  * the end-user and obtaining authorization.
734
  *
735
+ * @return ?UriInterface
736
  */
737
  public function getAuthorizationUri()
738
  {
743
  * Gets the authorization server's HTTP endpoint capable of issuing tokens
744
  * and refreshing expired tokens.
745
  *
746
+ * @return ?UriInterface
747
  */
748
  public function getTokenCredentialUri()
749
  {
755
  * and refreshing expired tokens.
756
  *
757
  * @param string $uri
758
+ * @return void
759
  */
760
  public function setTokenCredentialUri($uri)
761
  {
765
  /**
766
  * Gets the redirection URI used in the initial request.
767
  *
768
+ * @return ?string
769
  */
770
  public function getRedirectUri()
771
  {
775
  /**
776
  * Sets the redirection URI used in the initial request.
777
  *
778
+ * @param ?string $uri
779
+ * @return void
780
  */
781
  public function setRedirectUri($uri)
782
  {
801
  /**
802
  * Gets the scope of the access requests as a space-delimited String.
803
  *
804
+ * @return ?string
805
  */
806
  public function getScope()
807
  {
816
  * Sets the scope of the access request, expressed either as an Array or as
817
  * a space-delimited String.
818
  *
819
+ * @param string|array<string>|null $scope
820
+ * @return void
821
  * @throws InvalidArgumentException
822
  */
823
  public function setScope($scope)
846
  /**
847
  * Gets the current grant type.
848
  *
849
+ * @return ?string
850
  */
851
  public function getGrantType()
852
  {
878
  /**
879
  * Sets the current grant type.
880
  *
881
+ * @param string $grantType
882
+ * @return void
883
  * @throws InvalidArgumentException
884
  */
885
  public function setGrantType($grantType)
911
  * Sets an arbitrary string designed to allow the client to maintain state.
912
  *
913
  * @param string $state
914
+ * @return void
915
  */
916
  public function setState($state)
917
  {
920
 
921
  /**
922
  * Gets the authorization code issued to this client.
923
+ *
924
+ * @return string
925
  */
926
  public function getCode()
927
  {
932
  * Sets the authorization code issued to this client.
933
  *
934
  * @param string $code
935
+ * @return void
936
  */
937
  public function setCode($code)
938
  {
941
 
942
  /**
943
  * Gets the resource owner's username.
944
+ *
945
+ * @return string
946
  */
947
  public function getUsername()
948
  {
953
  * Sets the resource owner's username.
954
  *
955
  * @param string $username
956
+ * @return void
957
  */
958
  public function setUsername($username)
959
  {
962
 
963
  /**
964
  * Gets the resource owner's password.
965
+ *
966
+ * @return string
967
  */
968
  public function getPassword()
969
  {
973
  /**
974
  * Sets the resource owner's password.
975
  *
976
+ * @param string $password
977
+ * @return void
978
  */
979
  public function setPassword($password)
980
  {
984
  /**
985
  * Sets a unique identifier issued to the client to identify itself to the
986
  * authorization server.
987
+ *
988
+ * @return string
989
  */
990
  public function getClientId()
991
  {
996
  * Sets a unique identifier issued to the client to identify itself to the
997
  * authorization server.
998
  *
999
+ * @param string $clientId
1000
+ * @return void
1001
  */
1002
  public function setClientId($clientId)
1003
  {
1007
  /**
1008
  * Gets a shared symmetric secret issued by the authorization server, which
1009
  * is used to authenticate the client.
1010
+ *
1011
+ * @return string
1012
  */
1013
  public function getClientSecret()
1014
  {
1019
  * Sets a shared symmetric secret issued by the authorization server, which
1020
  * is used to authenticate the client.
1021
  *
1022
+ * @param string $clientSecret
1023
+ * @return void
1024
  */
1025
  public function setClientSecret($clientSecret)
1026
  {
1029
 
1030
  /**
1031
  * Gets the Issuer ID when using assertion profile.
1032
+ *
1033
+ * @return ?string
1034
  */
1035
  public function getIssuer()
1036
  {
1041
  * Sets the Issuer ID when using assertion profile.
1042
  *
1043
  * @param string $issuer
1044
+ * @return void
1045
  */
1046
  public function setIssuer($issuer)
1047
  {
1050
 
1051
  /**
1052
  * Gets the target sub when issuing assertions.
1053
+ *
1054
+ * @return ?string
1055
  */
1056
  public function getSub()
1057
  {
1062
  * Sets the target sub when issuing assertions.
1063
  *
1064
  * @param string $sub
1065
+ * @return void
1066
  */
1067
  public function setSub($sub)
1068
  {
1071
 
1072
  /**
1073
  * Gets the target audience when issuing assertions.
1074
+ *
1075
+ * @return ?string
1076
  */
1077
  public function getAudience()
1078
  {
1083
  * Sets the target audience when issuing assertions.
1084
  *
1085
  * @param string $audience
1086
+ * @return void
1087
  */
1088
  public function setAudience($audience)
1089
  {
1092
 
1093
  /**
1094
  * Gets the signing key when using an assertion profile.
1095
+ *
1096
+ * @return ?string
1097
  */
1098
  public function getSigningKey()
1099
  {
1104
  * Sets the signing key when using an assertion profile.
1105
  *
1106
  * @param string $signingKey
1107
+ * @return void
1108
  */
1109
  public function setSigningKey($signingKey)
1110
  {
1114
  /**
1115
  * Gets the signing key id when using an assertion profile.
1116
  *
1117
+ * @return ?string
1118
  */
1119
  public function getSigningKeyId()
1120
  {
1125
  * Sets the signing key id when using an assertion profile.
1126
  *
1127
  * @param string $signingKeyId
1128
+ * @return void
1129
  */
1130
  public function setSigningKeyId($signingKeyId)
1131
  {
1135
  /**
1136
  * Gets the signing algorithm when using an assertion profile.
1137
  *
1138
+ * @return ?string
1139
  */
1140
  public function getSigningAlgorithm()
1141
  {
1145
  /**
1146
  * Sets the signing algorithm when using an assertion profile.
1147
  *
1148
+ * @param ?string $signingAlgorithm
1149
+ * @return void
1150
  */
1151
  public function setSigningAlgorithm($signingAlgorithm)
1152
  {
1162
  /**
1163
  * Gets the set of parameters used by extension when using an extension
1164
  * grant type.
1165
+ *
1166
+ * @return array<mixed>
1167
  */
1168
  public function getExtensionParams()
1169
  {
1174
  * Sets the set of parameters used by extension when using an extension
1175
  * grant type.
1176
  *
1177
+ * @param array<mixed> $extensionParams
1178
+ * @return void
1179
  */
1180
  public function setExtensionParams($extensionParams)
1181
  {
1184
 
1185
  /**
1186
  * Gets the number of seconds assertions are valid for.
1187
+ *
1188
+ * @return int
1189
  */
1190
  public function getExpiry()
1191
  {
1196
  * Sets the number of seconds assertions are valid for.
1197
  *
1198
  * @param int $expiry
1199
+ * @return void
1200
  */
1201
  public function setExpiry($expiry)
1202
  {
1205
 
1206
  /**
1207
  * Gets the lifetime of the access token in seconds.
1208
+ *
1209
+ * @return int
1210
  */
1211
  public function getExpiresIn()
1212
  {
1216
  /**
1217
  * Sets the lifetime of the access token in seconds.
1218
  *
1219
+ * @param ?int $expiresIn
1220
+ * @return void
1221
  */
1222
  public function setExpiresIn($expiresIn)
1223
  {
1233
  /**
1234
  * Gets the time the current access token expires at.
1235
  *
1236
+ * @return ?int
1237
  */
1238
  public function getExpiresAt()
1239
  {
1265
  * Sets the time the current access token expires at.
1266
  *
1267
  * @param int $expiresAt
1268
+ * @return void
1269
  */
1270
  public function setExpiresAt($expiresAt)
1271
  {
1274
 
1275
  /**
1276
  * Gets the time the current access token was issued at.
1277
+ *
1278
+ * @return ?int
1279
  */
1280
  public function getIssuedAt()
1281
  {
1286
  * Sets the time the current access token was issued at.
1287
  *
1288
  * @param int $issuedAt
1289
+ * @return void
1290
  */
1291
  public function setIssuedAt($issuedAt)
1292
  {
1295
 
1296
  /**
1297
  * Gets the current access token.
1298
+ *
1299
+ * @return ?string
1300
  */
1301
  public function getAccessToken()
1302
  {
1307
  * Sets the current access token.
1308
  *
1309
  * @param string $accessToken
1310
+ * @return void
1311
  */
1312
  public function setAccessToken($accessToken)
1313
  {
1316
 
1317
  /**
1318
  * Gets the current ID token.
1319
+ *
1320
+ * @return ?string
1321
  */
1322
  public function getIdToken()
1323
  {
1327
  /**
1328
  * Sets the current ID token.
1329
  *
1330
+ * @param string $idToken
1331
+ * @return void
1332
  */
1333
  public function setIdToken($idToken)
1334
  {
1337
 
1338
  /**
1339
  * Gets the refresh token associated with the current access token.
1340
+ *
1341
+ * @return ?string
1342
  */
1343
  public function getRefreshToken()
1344
  {
1348
  /**
1349
  * Sets the refresh token associated with the current access token.
1350
  *
1351
+ * @param string $refreshToken
1352
+ * @return void
1353
  */
1354
  public function setRefreshToken($refreshToken)
1355
  {
1359
  /**
1360
  * Sets additional claims to be included in the JWT token
1361
  *
1362
+ * @param array<mixed> $additionalClaims
1363
+ * @return void
1364
  */
1365
  public function setAdditionalClaims(array $additionalClaims)
1366
  {
1370
  /**
1371
  * Gets the additional claims to be included in the JWT token.
1372
  *
1373
+ * @return array<mixed>
1374
  */
1375
  public function getAdditionalClaims()
1376
  {
1380
  /**
1381
  * The expiration of the last received token.
1382
  *
1383
+ * @return array<mixed>|null
1384
  */
1385
  public function getLastReceivedToken()
1386
  {
1429
  /**
1430
  * @todo handle uri as array
1431
  *
1432
+ * @param ?string $uri
1433
  * @return null|UriInterface
1434
  */
1435
  private function coerceUri($uri)
1436
  {
1437
  if (is_null($uri)) {
1438
+ return null;
1439
  }
1440
 
1441
+ return Utils::uriFor($uri);
1442
  }
1443
 
1444
  /**
1445
  * @param string $idToken
1446
+ * @param Key|Key[]|string|string[] $publicKey
1447
+ * @param string|string[] $allowedAlgs
1448
  * @return object
1449
  */
1450
  private function jwtDecode($idToken, $publicKey, $allowedAlgs)
1451
  {
1452
+ $keys = $this->getFirebaseJwtKeys($publicKey, $allowedAlgs);
1453
+
1454
+ // Default exception if none are caught. We are using the same exception
1455
+ // class and message from firebase/php-jwt to preserve backwards
1456
+ // compatibility.
1457
+ $e = new \InvalidArgumentException('Key may not be empty');
1458
+ foreach ($keys as $key) {
1459
+ try {
1460
+ return JWT::decode($idToken, $key);
1461
+ } catch (\Exception $e) {
1462
+ // try next alg
1463
+ }
1464
  }
1465
+ throw $e;
 
1466
  }
1467
 
1468
+ /**
1469
+ * @param Key|Key[]|string|string[] $publicKey
1470
+ * @param string|string[] $allowedAlgs
1471
+ * @return Key[]
1472
+ */
1473
+ private function getFirebaseJwtKeys($publicKey, $allowedAlgs)
1474
  {
1475
+ // If $publicKey is instance of Key, return it
1476
+ if ($publicKey instanceof Key) {
1477
+ return [$publicKey];
1478
+ }
1479
+
1480
+ // If $allowedAlgs is empty, $publicKey must be Key or Key[].
1481
+ if (empty($allowedAlgs)) {
1482
+ $keys = [];
1483
+ foreach ((array) $publicKey as $kid => $pubKey) {
1484
+ if (!$pubKey instanceof Key) {
1485
+ throw new \InvalidArgumentException(sprintf(
1486
+ 'When allowed algorithms is empty, the public key must'
1487
+ . 'be an instance of %s or an array of %s objects',
1488
+ Key::class,
1489
+ Key::class
1490
+ ));
1491
+ }
1492
+ $keys[$kid] = $pubKey;
1493
+ }
1494
+ return $keys;
1495
+ }
1496
+
1497
+ $allowedAlg = null;
1498
+ if (is_string($allowedAlgs)) {
1499
+ $allowedAlg = $allowedAlg;
1500
+ } elseif (is_array($allowedAlgs)) {
1501
+ if (count($allowedAlgs) > 1) {
1502
+ throw new \InvalidArgumentException(
1503
+ 'To have multiple allowed algorithms, You must provide an'
1504
+ . ' array of Firebase\JWT\Key objects.'
1505
+ . ' See https://github.com/firebase/php-jwt for more information.');
1506
+ }
1507
+ $allowedAlg = array_pop($allowedAlgs);
1508
+ } else {
1509
+ throw new \InvalidArgumentException('allowed algorithms must be a string or array.');
1510
+ }
1511
+
1512
+ if (is_array($publicKey)) {
1513
+ // When publicKey is greater than 1, create keys with the single alg.
1514
+ $keys = [];
1515
+ foreach ($publicKey as $kid => $pubKey) {
1516
+ if ($pubKey instanceof Key) {
1517
+ $keys[$kid] = $pubKey;
1518
+ } else {
1519
+ $keys[$kid] = new Key($pubKey, $allowedAlg);
1520
+ }
1521
+ }
1522
+ return $keys;
1523
  }
1524
 
1525
+ return [new Key($publicKey, $allowedAlg)];
1526
  }
1527
 
1528
  /**
1540
  }
1541
 
1542
  /**
1543
+ * @param array<mixed> $params
1544
+ * @return array<mixed>
1545
  */
1546
  private function addClientCredentials(&$params)
1547
  {
vendor/google/auth/src/ServiceAccountSignerTrait.php CHANGED
@@ -38,7 +38,7 @@ trait ServiceAccountSignerTrait
38
 
39
  $signedString = '';
40
  if (class_exists('\\phpseclib\\Crypt\\RSA') && !$forceOpenssl) {
41
- $rsa = new RSA;
42
  $rsa->loadKey($privateKey);
43
  $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1);
44
  $rsa->setHash('sha256');
38
 
39
  $signedString = '';
40
  if (class_exists('\\phpseclib\\Crypt\\RSA') && !$forceOpenssl) {
41
+ $rsa = new RSA();
42
  $rsa->loadKey($privateKey);
43
  $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1);
44
  $rsa->setHash('sha256');
vendor/google/auth/src/Subscriber/AuthTokenSubscriber.php DELETED
@@ -1,136 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Subscriber;
19
-
20
- use Google\Auth\FetchAuthTokenInterface;
21
- use Google\Auth\GetQuotaProjectInterface;
22
- use GuzzleHttp\Event\BeforeEvent;
23
- use GuzzleHttp\Event\RequestEvents;
24
- use GuzzleHttp\Event\SubscriberInterface;
25
-
26
- /**
27
- * AuthTokenSubscriber is a Guzzle Subscriber that adds an Authorization header
28
- * provided by an object implementing FetchAuthTokenInterface.
29
- *
30
- * The FetchAuthTokenInterface#fetchAuthToken is used to obtain a hash; one of
31
- * the values value in that hash is added as the authorization header.
32
- *
33
- * Requests will be accessed with the authorization header:
34
- *
35
- * 'authorization' 'Bearer <value of auth_token>'
36
- */
37
- class AuthTokenSubscriber implements SubscriberInterface
38
- {
39
- /**
40
- * @var callable
41
- */
42
- private $httpHandler;
43
-
44
- /**
45
- * @var FetchAuthTokenInterface
46
- */
47
- private $fetcher;
48
-
49
- /**
50
- * @var callable
51
- */
52
- private $tokenCallback;
53
-
54
- /**
55
- * Creates a new AuthTokenSubscriber.
56
- *
57
- * @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
58
- * @param callable $httpHandler (optional) http client to fetch the token.
59
- * @param callable $tokenCallback (optional) function to be called when a new token is fetched.
60
- */
61
- public function __construct(
62
- FetchAuthTokenInterface $fetcher,
63
- callable $httpHandler = null,
64
- callable $tokenCallback = null
65
- ) {
66
- $this->fetcher = $fetcher;
67
- $this->httpHandler = $httpHandler;
68
- $this->tokenCallback = $tokenCallback;
69
- }
70
-
71
- /**
72
- * @return array
73
- */
74
- public function getEvents()
75
- {
76
- return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
77
- }
78
-
79
- /**
80
- * Updates the request with an Authorization header when auth is 'fetched_auth_token'.
81
- *
82
- * Example:
83
- * ```
84
- * use GuzzleHttp\Client;
85
- * use Google\Auth\OAuth2;
86
- * use Google\Auth\Subscriber\AuthTokenSubscriber;
87
- *
88
- * $config = [..<oauth config param>.];
89
- * $oauth2 = new OAuth2($config)
90
- * $subscriber = new AuthTokenSubscriber($oauth2);
91
- *
92
- * $client = new Client([
93
- * 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
94
- * 'defaults' => ['auth' => 'google_auth']
95
- * ]);
96
- * $client->getEmitter()->attach($subscriber);
97
- *
98
- * $res = $client->get('myproject/taskqueues/myqueue');
99
- * ```
100
- *
101
- * @param BeforeEvent $event
102
- */
103
- public function onBefore(BeforeEvent $event)
104
- {
105
- // Requests using "auth"="google_auth" will be authorized.
106
- $request = $event->getRequest();
107
- if ($request->getConfig()['auth'] != 'google_auth') {
108
- return;
109
- }
110
-
111
- // Fetch the auth token.
112
- $auth_tokens = $this->fetcher->fetchAuthToken($this->httpHandler);
113
- if (array_key_exists('access_token', $auth_tokens)) {
114
- $request->setHeader('authorization', 'Bearer ' . $auth_tokens['access_token']);
115
-
116
- // notify the callback if applicable
117
- if ($this->tokenCallback) {
118
- call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $auth_tokens['access_token']);
119
- }
120
- }
121
-
122
- if ($quotaProject = $this->getQuotaProject()) {
123
- $request->setHeader(
124
- GetQuotaProjectInterface::X_GOOG_USER_PROJECT_HEADER,
125
- $quotaProject
126
- );
127
- }
128
- }
129
-
130
- private function getQuotaProject()
131
- {
132
- if ($this->fetcher instanceof GetQuotaProjectInterface) {
133
- return $this->fetcher->getQuotaProject();
134
- }
135
- }
136
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/google/auth/src/Subscriber/ScopedAccessTokenSubscriber.php DELETED
@@ -1,180 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Subscriber;
19
-
20
- use Google\Auth\CacheTrait;
21
- use GuzzleHttp\Event\BeforeEvent;
22
- use GuzzleHttp\Event\RequestEvents;
23
- use GuzzleHttp\Event\SubscriberInterface;
24
- use Psr\Cache\CacheItemPoolInterface;
25
-
26
- /**
27
- * ScopedAccessTokenSubscriber is a Guzzle Subscriber that adds an Authorization
28
- * header provided by a closure.
29
- *
30
- * The closure returns an access token, taking the scope, either a single
31
- * string or an array of strings, as its value. If provided, a cache will be
32
- * used to preserve the access token for a given lifetime.
33
- *
34
- * Requests will be accessed with the authorization header:
35
- *
36
- * 'authorization' 'Bearer <access token obtained from the closure>'
37
- */
38
- class ScopedAccessTokenSubscriber implements SubscriberInterface
39
- {
40
- use CacheTrait;
41
-
42
- const DEFAULT_CACHE_LIFETIME = 1500;
43
-
44
- /**
45
- * @var CacheItemPoolInterface
46
- */
47
- private $cache;
48
-
49
- /**
50
- * @var callable The access token generator function
51
- */
52
- private $tokenFunc;
53
-
54
- /**
55
- * @var array|string The scopes used to generate the token
56
- */
57
- private $scopes;
58
-
59
- /**
60
- * @var array
61
- */
62
- private $cacheConfig;
63
-
64
- /**
65
- * Creates a new ScopedAccessTokenSubscriber.
66
- *
67
- * @param callable $tokenFunc a token generator function
68
- * @param array|string $scopes the token authentication scopes
69
- * @param array $cacheConfig configuration for the cache when it's present
70
- * @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
71
- */
72
- public function __construct(
73
- callable $tokenFunc,
74
- $scopes,
75
- array $cacheConfig = null,
76
- CacheItemPoolInterface $cache = null
77
- ) {
78
- $this->tokenFunc = $tokenFunc;
79
- if (!(is_string($scopes) || is_array($scopes))) {
80
- throw new \InvalidArgumentException(
81
- 'wants scope should be string or array'
82
- );
83
- }
84
- $this->scopes = $scopes;
85
-
86
- if (!is_null($cache)) {
87
- $this->cache = $cache;
88
- $this->cacheConfig = array_merge([
89
- 'lifetime' => self::DEFAULT_CACHE_LIFETIME,
90
- 'prefix' => '',
91
- ], $cacheConfig);
92
- }
93
- }
94
-
95
- /**
96
- * @return array
97
- */
98
- public function getEvents()
99
- {
100
- return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
101
- }
102
-
103
- /**
104
- * Updates the request with an Authorization header when auth is 'scoped'.
105
- *
106
- * E.g this could be used to authenticate using the AppEngine AppIdentityService.
107
- *
108
- * Example:
109
- * ```
110
- * use google\appengine\api\app_identity\AppIdentityService;
111
- * use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
112
- * use GuzzleHttp\Client;
113
- *
114
- * $scope = 'https://www.googleapis.com/auth/taskqueue'
115
- * $subscriber = new ScopedAccessToken(
116
- * 'AppIdentityService::getAccessToken',
117
- * $scope,
118
- * ['prefix' => 'Google\Auth\ScopedAccessToken::'],
119
- * $cache = new Memcache()
120
- * );
121
- *
122
- * $client = new Client([
123
- * 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
124
- * 'defaults' => ['auth' => 'scoped']
125
- * ]);
126
- * $client->getEmitter()->attach($subscriber);
127
- *
128
- * $res = $client->get('myproject/taskqueues/myqueue');
129
- * ```
130
- *
131
- * @param BeforeEvent $event
132
- */
133
- public function onBefore(BeforeEvent $event)
134
- {
135
- // Requests using "auth"="scoped" will be authorized.
136
- $request = $event->getRequest();
137
- if ($request->getConfig()['auth'] != 'scoped') {
138
- return;
139
- }
140
- $auth_header = 'Bearer ' . $this->fetchToken();
141
- $request->setHeader('authorization', $auth_header);
142
- }
143
-
144
- /**
145
- * @return string
146
- */
147
- private function getCacheKey()
148
- {
149
- $key = null;
150
-
151
- if (is_string($this->scopes)) {
152
- $key .= $this->scopes;
153
- } elseif (is_array($this->scopes)) {
154
- $key .= implode(':', $this->scopes);
155
- }
156
-
157
- return $key;
158
- }
159
-
160
- /**
161
- * Determine if token is available in the cache, if not call tokenFunc to
162
- * fetch it.
163
- *
164
- * @return string
165
- */
166
- private function fetchToken()
167
- {
168
- $cacheKey = $this->getCacheKey();
169
- $cached = $this->getCachedValue($cacheKey);
170
-
171
- if (!empty($cached)) {
172
- return $cached;
173
- }
174
-
175
- $token = call_user_func($this->tokenFunc, $this->scopes);
176
- $this->setCachedValue($cacheKey, $token);
177
-
178
- return $token;
179
- }
180
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/google/auth/src/Subscriber/SimpleSubscriber.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
- /*
3
- * Copyright 2015 Google Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- namespace Google\Auth\Subscriber;
19
-
20
- use GuzzleHttp\Event\BeforeEvent;
21
- use GuzzleHttp\Event\RequestEvents;
22
- use GuzzleHttp\Event\SubscriberInterface;
23
-
24
- /**
25
- * SimpleSubscriber is a Guzzle Subscriber that implements Google's Simple API
26
- * access.
27
- *
28
- * Requests are accessed using the Simple API access developer key.
29
- */
30
- class SimpleSubscriber implements SubscriberInterface
31
- {
32
- /**
33
- * @var array
34
- */
35
- private $config;
36
-
37
- /**
38
- * Create a new Simple plugin.
39
- *
40
- * The configuration array expects one option
41
- * - key: required, otherwise InvalidArgumentException is thrown
42
- *
43
- * @param array $config Configuration array
44
- */
45
- public function __construct(array $config)
46
- {
47
- if (!isset($config['key'])) {
48
- throw new \InvalidArgumentException('requires a key to have been set');
49
- }
50
-
51
- $this->config = array_merge([], $config);
52
- }
53
-
54
- /**
55
- * @return array
56
- */
57
- public function getEvents()
58
- {
59
- return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
60
- }
61
-
62
- /**
63
- * Updates the request query with the developer key if auth is set to simple.
64
- *
65
- * Example:
66
- * ```
67
- * use Google\Auth\Subscriber\SimpleSubscriber;
68
- * use GuzzleHttp\Client;
69
- *
70
- * $my_key = 'is not the same as yours';
71
- * $subscriber = new SimpleSubscriber(['key' => $my_key]);
72
- *
73
- * $client = new Client([
74
- * 'base_url' => 'https://www.googleapis.com/discovery/v1/',
75
- * 'defaults' => ['auth' => 'simple']
76
- * ]);
77
- * $client->getEmitter()->attach($subscriber);
78
- *
79
- * $res = $client->get('drive/v2/rest');
80
- * ```
81
- *
82
- * @param BeforeEvent $event
83
- */
84
- public function onBefore(BeforeEvent $event)
85
- {
86
- // Requests using "auth"="simple" with the developer key.
87
- $request = $event->getRequest();
88
- if ($request->getConfig()['auth'] != 'simple') {
89
- return;
90
- }
91
- $request->getQuery()->overwriteWith($this->config);
92
- }
93
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/google/auth/src/UpdateMetadataInterface.php CHANGED
@@ -28,10 +28,10 @@ interface UpdateMetadataInterface
28
  /**
29
  * Updates metadata with the authorization token.
30
  *
31
- * @param array $metadata metadata hashmap
32
  * @param string $authUri optional auth uri
33
  * @param callable $httpHandler callback which delivers psr7 request
34
- * @return array updated metadata hashmap
35
  */
36
  public function updateMetadata(
37
  $metadata,
28
  /**
29
  * Updates metadata with the authorization token.
30
  *
31
+ * @param array<mixed> $metadata metadata hashmap
32
  * @param string $authUri optional auth uri
33
  * @param callable $httpHandler callback which delivers psr7 request
34
+ * @return array<mixed> updated metadata hashmap
35
  */
36
  public function updateMetadata(
37
  $metadata,
vendor/guzzlehttp/guzzle/LICENSE CHANGED
@@ -1,4 +1,12 @@
1
- Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
 
 
 
 
 
 
 
 
2
 
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
  of this software and associated documentation files (the "Software"), to deal
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2011 Michael Dowling <mtdowling@gmail.com>
4
+ Copyright (c) 2012 Jeremy Lindblom <jeremeamia@gmail.com>
5
+ Copyright (c) 2014 Graham Campbell <hello@gjcampbell.co.uk>
6
+ Copyright (c) 2015 Márk Sági-Kazár <mark.sagikazar@gmail.com>
7
+ Copyright (c) 2015 Tobias Schultze <webmaster@tubo-world.de>
8
+ Copyright (c) 2016 Tobias Nyholm <tobias.nyholm@gmail.com>
9
+ Copyright (c) 2016 George Mponos <gmponos@gmail.com>
10
 
11
  Permission is hereby granted, free of charge, to any person obtaining a copy
12
  of this software and associated documentation files (the "Software"), to deal
vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php CHANGED
@@ -240,6 +240,11 @@ class CookieJar implements CookieJarInterface
240
  if (0 !== strpos($sc->getPath(), '/')) {
241
  $sc->setPath($this->getCookiePathFromRequest($request));
242
  }
 
 
 
 
 
243
  $this->setCookie($sc);
244
  }
245
  }
240
  if (0 !== strpos($sc->getPath(), '/')) {
241
  $sc->setPath($this->getCookiePathFromRequest($request));
242
  }
243
+ if (!$sc->matchesDomain($request->getUri()->getHost())) {
244
+ continue;
245
+ }
246
+ // Note: At this point `$sc->getDomain()` being a public suffix should
247
+ // be rejected, but we don't want to pull in the full PSL dependency.
248
  $this->setCookie($sc);
249
  }
250
  }
vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php CHANGED
@@ -333,12 +333,19 @@ class SetCookie
333
  */
334
  public function matchesDomain($domain)
335
  {
 
 
 
 
 
336
  // Remove the leading '.' as per spec in RFC 6265.
337
  // http://tools.ietf.org/html/rfc6265#section-5.2.3
338
- $cookieDomain = ltrim($this->getDomain(), '.');
 
 
339
 
340
  // Domain not set or exact match.
341
- if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) {
342
  return true;
343
  }
344
 
333
  */
334
  public function matchesDomain($domain)
335
  {
336
+ $cookieDomain = $this->getDomain();
337
+ if (null === $cookieDomain) {
338
+ return true;
339
+ }
340
+
341
  // Remove the leading '.' as per spec in RFC 6265.
342
  // http://tools.ietf.org/html/rfc6265#section-5.2.3
343
+ $cookieDomain = ltrim(strtolower($cookieDomain), '.');
344
+
345
+ $domain = strtolower($domain);
346
 
347
  // Domain not set or exact match.
348
+ if ('' === $cookieDomain || $domain === $cookieDomain) {
349
  return true;
350
  }
351
 
vendor/guzzlehttp/promises/LICENSE CHANGED
@@ -1,4 +1,9 @@
1
- Copyright (c) 2015-2016 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
 
 
 
 
 
2
 
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
  of this software and associated documentation files (the "Software"), to deal
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Michael Dowling <mtdowling@gmail.com>
4
+ Copyright (c) 2015 Graham Campbell <hello@gjcampbell.co.uk>
5
+ Copyright (c) 2017 Tobias Schultze <webmaster@tubo-world.de>
6
+ Copyright (c) 2020 Tobias Nyholm <tobias.nyholm@gmail.com>
7
 
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
9
  of this software and associated documentation files (the "Software"), to deal
vendor/guzzlehttp/promises/src/EachPromise.php CHANGED
@@ -79,9 +79,7 @@ class EachPromise implements PromisorInterface
79
  $this->createPromise();
80
  /** @psalm-assert Promise $this->aggregate */
81
  $this->iterable->rewind();
82
- if (!$this->checkIfFinished()) {
83
- $this->refillPending();
84
- }
85
  } catch (\Throwable $e) {
86
  /**
87
  * @psalm-suppress NullReference
@@ -107,6 +105,9 @@ class EachPromise implements PromisorInterface
107
  {
108
  $this->mutex = false;
109
  $this->aggregate = new Promise(function () {
 
 
 
110
  reset($this->pending);
111
  // Consume a potentially fluctuating list of promises while
112
  // ensuring that indexes are maintained (precluding array_shift).
79
  $this->createPromise();
80
  /** @psalm-assert Promise $this->aggregate */
81
  $this->iterable->rewind();
82
+ $this->refillPending();
 
 
83
  } catch (\Throwable $e) {
84
  /**
85
  * @psalm-suppress NullReference
105
  {
106
  $this->mutex = false;
107
  $this->aggregate = new Promise(function () {
108
+ if ($this->checkIfFinished()) {
109
+ return;
110
+ }
111
  reset($this->pending);
112
  // Consume a potentially fluctuating list of promises while
113
  // ensuring that indexes are maintained (precluding array_shift).
vendor/guzzlehttp/promises/src/Utils.php CHANGED
@@ -48,7 +48,9 @@ final class Utils
48
  $promise = new Promise([$queue, 'run']);
49
  $queue->add(function () use ($task, $promise) {
50
  try {
51
- $promise->resolve($task());
 
 
52
  } catch (\Throwable $e) {
53
  $promise->reject($e);
54
  } catch (\Exception $e) {
48
  $promise = new Promise([$queue, 'run']);
49
  $queue->add(function () use ($task, $promise) {
50
  try {
51
+ if (Is::pending($promise)) {
52
+ $promise->resolve($task());
53
+ }
54
  } catch (\Throwable $e) {
55
  $promise->reject($e);
56
  } catch (\Exception $e) {
vendor/guzzlehttp/psr7/LICENSE CHANGED
@@ -1,4 +1,11 @@
1
- Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
 
 
 
 
 
 
 
2
 
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
  of this software and associated documentation files (the "Software"), to deal
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Michael Dowling <mtdowling@gmail.com>
4
+ Copyright (c) 2015 Márk Sági-Kazár <mark.sagikazar@gmail.com>
5
+ Copyright (c) 2015 Graham Campbell <hello@gjcampbell.co.uk>
6
+ Copyright (c) 2016 Tobias Schultze <webmaster@tubo-world.de>
7
+ Copyright (c) 2016 George Mponos <gmponos@gmail.com>
8
+ Copyright (c) 2018 Tobias Nyholm <tobias.nyholm@gmail.com>
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
vendor/guzzlehttp/psr7/src/CachingStream.php CHANGED
@@ -36,7 +36,13 @@ class CachingStream implements StreamInterface
36
 
37
  public function getSize()
38
  {
39
- return max($this->stream->getSize(), $this->remoteStream->getSize());
 
 
 
 
 
 
40
  }
41
 
42
  public function rewind()
36
 
37
  public function getSize()
38
  {
39
+ $remoteSize = $this->remoteStream->getSize();
40
+
41
+ if (null === $remoteSize) {
42
+ return null;
43
+ }
44
+
45
+ return max($this->stream->getSize(), $remoteSize);
46
  }
47
 
48
  public function rewind()
vendor/guzzlehttp/psr7/src/MessageTrait.php CHANGED
@@ -157,17 +157,22 @@ trait MessageTrait
157
  }
158
  }
159
 
 
 
 
 
 
160
  private function normalizeHeaderValue($value)
161
  {
162
  if (!is_array($value)) {
163
- return $this->trimHeaderValues([$value]);
164
  }
165
 
166
  if (count($value) === 0) {
167
  throw new \InvalidArgumentException('Header value can not be an empty array.');
168
  }
169
 
170
- return $this->trimHeaderValues($value);
171
  }
172
 
173
  /**
@@ -178,13 +183,13 @@ trait MessageTrait
178
  * header-field = field-name ":" OWS field-value OWS
179
  * OWS = *( SP / HTAB )
180
  *
181
- * @param string[] $values Header values
182
  *
183
  * @return string[] Trimmed header values
184
  *
185
  * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
186
  */
187
- private function trimHeaderValues(array $values)
188
  {
189
  return array_map(function ($value) {
190
  if (!is_scalar($value) && null !== $value) {
@@ -194,10 +199,20 @@ trait MessageTrait
194
  ));
195
  }
196
 
197
- return trim((string) $value, " \t");
 
 
 
198
  }, array_values($values));
199
  }
200
 
 
 
 
 
 
 
 
201
  private function assertHeader($header)
202
  {
203
  if (!is_string($header)) {
@@ -210,5 +225,46 @@ trait MessageTrait
210
  if ($header === '') {
211
  throw new \InvalidArgumentException('Header name can not be empty.');
212
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  }
214
  }
157
  }
158
  }
159
 
160
+ /**
161
+ * @param mixed $value
162
+ *
163
+ * @return string[]
164
+ */
165
  private function normalizeHeaderValue($value)
166
  {
167
  if (!is_array($value)) {
168
+ return $this->trimAndValidateHeaderValues([$value]);
169
  }
170
 
171
  if (count($value) === 0) {
172
  throw new \InvalidArgumentException('Header value can not be an empty array.');
173
  }
174
 
175
+ return $this->trimAndValidateHeaderValues($value);
176
  }
177
 
178
  /**
183
  * header-field = field-name ":" OWS field-value OWS
184
  * OWS = *( SP / HTAB )
185
  *
186
+ * @param mixed[] $values Header values
187
  *
188
  * @return string[] Trimmed header values
189
  *
190
  * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
191
  */
192
+ private function trimAndValidateHeaderValues(array $values)
193
  {
194
  return array_map(function ($value) {
195
  if (!is_scalar($value) && null !== $value) {
199
  ));
200
  }
201
 
202
+ $trimmed = trim((string) $value, " \t");
203
+ $this->assertValue($trimmed);
204
+
205
+ return $trimmed;
206
  }, array_values($values));
207
  }
208
 
209
+ /**
210
+ * @see https://tools.ietf.org/html/rfc7230#section-3.2
211
+ *
212
+ * @param mixed $header
213
+ *
214
+ * @return void
215
+ */
216
  private function assertHeader($header)
217
  {
218
  if (!is_string($header)) {
225
  if ($header === '') {
226
  throw new \InvalidArgumentException('Header name can not be empty.');
227
  }
228
+
229
+ if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/', $header)) {
230
+ throw new \InvalidArgumentException(
231
+ sprintf(
232
+ '"%s" is not valid header name',
233
+ $header
234
+ )
235
+ );
236
+ }
237
+ }
238
+
239
+ /**
240
+ * @param string $value
241
+ *
242
+ * @return void
243
+ *
244
+ * @see https://tools.ietf.org/html/rfc7230#section-3.2
245
+ *
246
+ * field-value = *( field-content / obs-fold )
247
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
248
+ * field-vchar = VCHAR / obs-text
249
+ * VCHAR = %x21-7E
250
+ * obs-text = %x80-FF
251
+ * obs-fold = CRLF 1*( SP / HTAB )
252
+ */
253
+ private function assertValue($value)
254
+ {
255
+ // The regular expression intentionally does not support the obs-fold production, because as
256
+ // per RFC 7230#3.2.4:
257
+ //
258
+ // A sender MUST NOT generate a message that includes
259
+ // line folding (i.e., that has any field-value that contains a match to
260
+ // the obs-fold rule) unless the message is intended for packaging
261
+ // within the message/http media type.
262
+ //
263
+ // Clients must not send a request with line folding and a server sending folded headers is
264
+ // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
265
+ // folding is not likely to break any legitimate use case.
266
+ if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/', $value)) {
267
+ throw new \InvalidArgumentException(sprintf('"%s" is not valid header value', $value));
268
+ }
269
  }
270
  }
vendor/monolog/monolog/src/Monolog/Attribute/AsMonologProcessor.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php declare(strict_types=1);
2
+
3
+ /*
4
+ * This file is part of the Monolog package.
5
+ *
6
+ * (c) Jordi Boggiano <j.boggiano@seld.be>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Monolog\Attribute;
13
+
14
+ /**
15
+ * A reusable attribute to help configure a class or a method as a processor.
16
+ *
17
+ * Using it offers no guarantee: it needs to be leveraged by a Monolog third-party consumer.
18
+ *
19
+ * Using it with the Monolog library only has no effect at all: processors should still be turned into a callable if
20
+ * needed and manually pushed to the loggers and to the processable handlers.
21
+ */
22
+ #[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
23
+ class AsMonologProcessor
24
+ {
25
+ /** @var string|null */
26
+ public $channel = null;
27
+ /** @var string|null */
28
+ public $handler = null;
29
+ /** @var string|null */
30
+ public $method = null;
31
+
32
+ /**
33
+ * @param string|null $channel The logging channel the processor should be pushed to.
34
+ * @param string|null $handler The handler the processor should be pushed to.
35
+ * @param string|null $method The method that processes the records (if the attribute is used at the class level).
36
+ */
37
+ public function __construct(
38
+ ?string $channel = null,
39
+ ?string $handler = null,
40
+ ?string $method = null
41
+ ) {
42
+ $this->channel = $channel;
43
+ $this->handler = $handler;
44
+ $this->method = $method;
45
+ }
46
+ }
vendor/monolog/monolog/src/Monolog/ErrorHandler.php CHANGED
@@ -210,7 +210,7 @@ class ErrorHandler
210
  *
211
  * @param mixed[] $context
212
  */
213
- public function handleError(int $code, string $message, string $file = '', int $line = 0, array $context = []): bool
214
  {
215
  if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) {
216
  return false;
210
  *
211
  * @param mixed[] $context
212
  */
213
+ public function handleError(int $code, string $message, string $file = '', int $line = 0, ?array $context = []): bool
214
  {
215
  if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) {
216
  return false;
vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php CHANGED
@@ -67,6 +67,10 @@ class GelfMessageFormatter extends NormalizerFormatter
67
 
68
  public function __construct(?string $systemName = null, ?string $extraPrefix = null, string $contextPrefix = 'ctxt_', ?int $maxLength = null)
69
  {
 
 
 
 
70
  parent::__construct('U.u');
71
 
72
  $this->systemName = (is_null($systemName) || $systemName === '') ? (string) gethostname() : $systemName;
67
 
68
  public function __construct(?string $systemName = null, ?string $extraPrefix = null, string $contextPrefix = 'ctxt_', ?int $maxLength = null)
69
  {
70
+ if (!class_exists(Message::class)) {
71
+ throw new \RuntimeException('Composer package graylog2/gelf-php is required to use Monolog\'s GelfMessageFormatter');
72
+ }
73
+
74
  parent::__construct('U.u');
75
 
76
  $this->systemName = (is_null($systemName) || $systemName === '') ? (string) gethostname() : $systemName;
vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php CHANGED
@@ -39,11 +39,12 @@ class JsonFormatter extends NormalizerFormatter
39
  /**
40
  * @param self::BATCH_MODE_* $batchMode
41
  */
42
- public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = true, bool $ignoreEmptyContextAndExtra = false)
43
  {
44
  $this->batchMode = $batchMode;
45
  $this->appendNewline = $appendNewline;
46
  $this->ignoreEmptyContextAndExtra = $ignoreEmptyContextAndExtra;
 
47
 
48
  parent::__construct();
49
  }
@@ -109,11 +110,13 @@ class JsonFormatter extends NormalizerFormatter
109
  }
110
 
111
  /**
112
- * @return void
113
  */
114
- public function includeStacktraces(bool $include = true)
115
  {
116
  $this->includeStacktraces = $include;
 
 
117
  }
118
 
119
  /**
39
  /**
40
  * @param self::BATCH_MODE_* $batchMode
41
  */
42
+ public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = true, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
43
  {
44
  $this->batchMode = $batchMode;
45
  $this->appendNewline = $appendNewline;
46
  $this->ignoreEmptyContextAndExtra = $ignoreEmptyContextAndExtra;
47
+ $this->includeStacktraces = $includeStacktraces;
48
 
49
  parent::__construct();
50
  }
110
  }
111
 
112
  /**
113
+ * @return self
114
  */
115
+ public function includeStacktraces(bool $include = true): self
116
  {
117
  $this->includeStacktraces = $include;
118
+
119
+ return $this;
120
  }
121
 
122
  /**
vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php CHANGED
@@ -33,6 +33,8 @@ class LineFormatter extends NormalizerFormatter
33
  protected $ignoreEmptyContextAndExtra;
34
  /** @var bool */
35
  protected $includeStacktraces;
 
 
36
 
37
  /**
38
  * @param string|null $format The format of the message
@@ -40,30 +42,38 @@ class LineFormatter extends NormalizerFormatter
40
  * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries
41
  * @param bool $ignoreEmptyContextAndExtra
42
  */
43
- public function __construct(?string $format = null, ?string $dateFormat = null, bool $allowInlineLineBreaks = false, bool $ignoreEmptyContextAndExtra = false)
44
  {
45
  $this->format = $format === null ? static::SIMPLE_FORMAT : $format;
46
  $this->allowInlineLineBreaks = $allowInlineLineBreaks;
47
  $this->ignoreEmptyContextAndExtra = $ignoreEmptyContextAndExtra;
 
48
  parent::__construct($dateFormat);
49
  }
50
 
51
- public function includeStacktraces(bool $include = true): void
52
  {
53
  $this->includeStacktraces = $include;
54
  if ($this->includeStacktraces) {
55
  $this->allowInlineLineBreaks = true;
 
56
  }
 
 
57
  }
58
 
59
- public function allowInlineLineBreaks(bool $allow = true): void
60
  {
61
  $this->allowInlineLineBreaks = $allow;
 
 
62
  }
63
 
64
- public function ignoreEmptyContextAndExtra(bool $ignore = true): void
65
  {
66
  $this->ignoreEmptyContextAndExtra = $ignore;
 
 
67
  }
68
 
69
  /**
@@ -202,9 +212,25 @@ class LineFormatter extends NormalizerFormatter
202
  $str .= '): ' . $e->getMessage() . ' at ' . $e->getFile() . ':' . $e->getLine() . ')';
203
 
204
  if ($this->includeStacktraces) {
205
- $str .= "\n[stacktrace]\n" . $e->getTraceAsString() . "\n";
206
  }
207
 
208
  return $str;
209
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  }
33
  protected $ignoreEmptyContextAndExtra;
34
  /** @var bool */
35
  protected $includeStacktraces;
36
+ /** @var ?callable */
37
+ protected $stacktracesParser;
38
 
39
  /**
40
  * @param string|null $format The format of the message
42
  * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries
43
  * @param bool $ignoreEmptyContextAndExtra
44
  */
45
+ public function __construct(?string $format = null, ?string $dateFormat = null, bool $allowInlineLineBreaks = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
46
  {
47
  $this->format = $format === null ? static::SIMPLE_FORMAT : $format;
48
  $this->allowInlineLineBreaks = $allowInlineLineBreaks;
49
  $this->ignoreEmptyContextAndExtra = $ignoreEmptyContextAndExtra;
50
+ $this->includeStacktraces($includeStacktraces);
51
  parent::__construct($dateFormat);
52
  }
53
 
54
+ public function includeStacktraces(bool $include = true, ?callable $parser = null): self
55
  {
56
  $this->includeStacktraces = $include;
57
  if ($this->includeStacktraces) {
58
  $this->allowInlineLineBreaks = true;
59
+ $this->stacktracesParser = $parser;
60
  }
61
+
62
+ return $this;
63
  }
64
 
65
+ public function allowInlineLineBreaks(bool $allow = true): self
66
  {
67
  $this->allowInlineLineBreaks = $allow;
68
+
69
+ return $this;
70
  }
71
 
72
+ public function ignoreEmptyContextAndExtra(bool $ignore = true): self
73
  {
74
  $this->ignoreEmptyContextAndExtra = $ignore;
75
+
76
+ return $this;
77
  }
78
 
79
  /**
212
  $str .= '): ' . $e->getMessage() . ' at ' . $e->getFile() . ':' . $e->getLine() . ')';
213
 
214
  if ($this->includeStacktraces) {
215
+ $str .= $this->stacktracesParser($e);
216
  }
217
 
218
  return $str;
219
  }
220
+
221
+ private function stacktracesParser(\Throwable $e): string
222
+ {
223
+ $trace = $e->getTraceAsString();
224
+
225
+ if ($this->stacktracesParser) {
226
+ $trace = $this->stacktracesParserCustom($trace);
227
+ }
228
+
229
+ return "\n[stacktrace]\n" . $trace . "\n";
230
+ }
231
+
232
+ private function stacktracesParserCustom(string $trace): string
233
+ {
234
+ return implode("\n", array_filter(array_map($this->stacktracesParser, explode("\n", $trace))));
235
+ }
236
  }
vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php CHANGED
@@ -11,6 +11,7 @@
11
 
12
  namespace Monolog\Formatter;
13
 
 
14
  use MongoDB\BSON\UTCDateTime;
15
  use Monolog\Utils;
16
 
@@ -85,7 +86,7 @@ class MongoDBFormatter implements FormatterInterface
85
  $array[$name] = $this->formatException($value, $nestingLevel + 1);
86
  } elseif (is_array($value)) {
87
  $array[$name] = $this->formatArray($value, $nestingLevel + 1);
88
- } elseif (is_object($value)) {
89
  $array[$name] = $this->formatObject($value, $nestingLevel + 1);
90
  }
91
  }
11
 
12
  namespace Monolog\Formatter;
13
 
14
+ use MongoDB\BSON\Type;
15
  use MongoDB\BSON\UTCDateTime;
16
  use Monolog\Utils;
17
 
86
  $array[$name] = $this->formatException($value, $nestingLevel + 1);
87
  } elseif (is_array($value)) {
88
  $array[$name] = $this->formatArray($value, $nestingLevel + 1);
89
+ } elseif (is_object($value) && !$value instanceof Type) {
90
  $array[$name] = $this->formatObject($value, $nestingLevel + 1);
91
  }
92
  }
vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php CHANGED
@@ -267,13 +267,17 @@ class NormalizerFormatter implements FormatterInterface
267
  return $date->format($this->dateFormat);
268
  }
269
 
270
- public function addJsonEncodeOption(int $option): void
271
  {
272
  $this->jsonEncodeOptions |= $option;
 
 
273
  }
274
 
275
- public function removeJsonEncodeOption(int $option): void
276
  {
277
  $this->jsonEncodeOptions &= ~$option;
 
 
278
  }
279
  }
267
  return $date->format($this->dateFormat);
268
  }
269
 
270
+ public function addJsonEncodeOption(int $option): self
271
  {
272
  $this->jsonEncodeOptions |= $option;
273
+
274
+ return $this;
275
  }
276
 
277
+ public function removeJsonEncodeOption(int $option): self
278
  {
279
  $this->jsonEncodeOptions &= ~$option;
280
+
281
+ return $this;
282
  }
283
  }
vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php CHANGED
@@ -11,10 +11,17 @@
11
 
12
  namespace Monolog\Handler;
13
 
14
- use Monolog\Formatter\LineFormatter;
15
  use Monolog\Formatter\FormatterInterface;
 
16
  use Monolog\Utils;
17
 
 
 
 
 
 
 
 
18
  /**
19
  * Handler sending logs to browser's javascript console with no browser extension required
20
  *
@@ -29,6 +36,10 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
29
  /** @var FormattedRecord[] */
30
  protected static $records = [];
31
 
 
 
 
 
32
  /**
33
  * {@inheritDoc}
34
  *
@@ -65,14 +76,14 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
65
  public static function send(): void
66
  {
67
  $format = static::getResponseFormat();
68
- if ($format === 'unknown') {
69
  return;
70
  }
71
 
72
  if (count(static::$records)) {
73
- if ($format === 'html') {
74
  static::writeOutput('<script>' . static::generateScript() . '</script>');
75
- } elseif ($format === 'js') {
76
  static::writeOutput(static::generateScript());
77
  }
78
  static::resetStatic();
@@ -125,25 +136,37 @@ class BrowserConsoleHandler extends AbstractProcessingHandler
125
  * If Content-Type is anything else -> unknown
126
  *
127
  * @return string One of 'js', 'html' or 'unknown'
 
128
  */
129
  protected static function getResponseFormat(): string
130
  {
131
  // Check content type
132
  foreach (headers_list() as $header) {
133
  if (stripos($header, 'content-type:') === 0) {
134
- // This handler only works with HTML and javascript outputs
135
- // text/javascript is obsolete in favour of application/javascript, but still used
136
- if (stripos($header, 'application/javascript') !== false || stripos($header, 'text/javascript') !== false) {
137
- return 'js';
138
- }
139
- if (stripos($header, 'text/html') === false) {
140
- return 'unknown';
141
- }
142
- break;
143
  }
144
  }
145
 
146
- return 'html';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  }
148
 
149
  private static function generateScript(): string
11
 
12
  namespace Monolog\Handler;
13
 
 
14
  use Monolog\Formatter\FormatterInterface;
15
+ use Monolog\Formatter\LineFormatter;
16
  use Monolog\Utils;
17
 
18
+ use function count;
19
+ use function headers_list;
20
+ use function stripos;
21
+ use function trigger_error;
22
+
23
+ use const E_USER_DEPRECATED;
24
+
25
  /**
26
  * Handler sending logs to browser's javascript console with no browser extension required
27
  *
36
  /** @var FormattedRecord[] */
37
  protected static $records = [];
38
 
39
+ protected const FORMAT_HTML = 'html';
40
+ protected const FORMAT_JS = 'js';
41
+ protected const FORMAT_UNKNOWN = 'unknown';
42
+
43
  /**
44
  * {@inheritDoc}
45
  *
76
  public static function send(): void
77
  {
78
  $format = static::getResponseFormat();
79
+ if ($format === self::FORMAT_UNKNOWN) {
80
  return;
81
  }
82
 
83
  if (count(static::$records)) {
84
+ if ($format === self::FORMAT_HTML) {
85
  static::writeOutput('<script>' . static::generateScript() . '</script>');
86
+ } elseif ($format === self::FORMAT_JS) {
87
  static::writeOutput(static::generateScript());
88
  }
89
  static::resetStatic();
136
  * If Content-Type is anything else -> unknown
137
  *
138
  * @return string One of 'js', 'html' or 'unknown'
139
+ * @phpstan-return self::FORMAT_*
140
  */
141
  protected static function getResponseFormat(): string
142
  {
143
  // Check content type
144
  foreach (headers_list() as $header) {
145
  if (stripos($header, 'content-type:') === 0) {
146
+ return static::getResponseFormatFromContentType($header);
 
 
 
 
 
 
 
 
147
  }
148
  }
149
 
150
+ return self::FORMAT_HTML;
151
+ }
152
+
153
+ /**
154
+ * @return string One of 'js', 'html' or 'unknown'
155
+ * @phpstan-return self::FORMAT_*
156
+ */
157
+ protected static function getResponseFormatFromContentType(string $contentType): string
158
+ {
159
+ // This handler only works with HTML and javascript outputs
160
+ // text/javascript is obsolete in favour of application/javascript, but still used
161
+ if (stripos($contentType, 'application/javascript') !== false || stripos($contentType, 'text/javascript') !== false) {
162
+ return self::FORMAT_JS;
163
+ }
164
+
165
+ if (stripos($contentType, 'text/html') !== false) {
166
+ return self::FORMAT_HTML;
167
+ }
168
+
169
+ return self::FORMAT_UNKNOWN;
170
  }
171
 
172
  private static function generateScript(): string
vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php CHANGED
@@ -11,6 +11,7 @@
11
 
12
  namespace Monolog\Handler;
13
 
 
14
  use Throwable;
15
  use RuntimeException;
16
  use Monolog\Logger;
@@ -19,6 +20,8 @@ use Monolog\Formatter\ElasticsearchFormatter;
19
  use InvalidArgumentException;
20
  use Elasticsearch\Common\Exceptions\RuntimeException as ElasticsearchRuntimeException;
21
  use Elasticsearch\Client;
 
 
22
 
23
  /**
24
  * Elasticsearch handler
@@ -44,7 +47,7 @@ use Elasticsearch\Client;
44
  class ElasticsearchHandler extends AbstractProcessingHandler
45
  {
46
  /**
47
- * @var Client
48
  */
49
  protected $client;
50
 
@@ -54,11 +57,20 @@ class ElasticsearchHandler extends AbstractProcessingHandler
54
  protected $options = [];
55
 
56
  /**
57
- * @param Client $client Elasticsearch Client object
58
- * @param mixed[] $options Handler configuration
59
  */
60
- public function __construct(Client $client, array $options = [], $level = Logger::DEBUG, bool $bubble = true)
 
 
 
 
 
 
61
  {
 
 
 
 
62
  parent::__construct($level, $bubble);
63
  $this->client = $client;
64
  $this->options = array_merge(
@@ -69,6 +81,14 @@ class ElasticsearchHandler extends AbstractProcessingHandler
69
  ],
70
  $options
71
  );
 
 
 
 
 
 
 
 
72
  }
73
 
74
  /**
@@ -133,9 +153,11 @@ class ElasticsearchHandler extends AbstractProcessingHandler
133
 
134
  foreach ($records as $record) {
135
  $params['body'][] = [
136
- 'index' => [
137
  '_index' => $record['_index'],
138
  '_type' => $record['_type'],
 
 
139
  ],
140
  ];
141
  unset($record['_index'], $record['_type']);
@@ -143,6 +165,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
143
  $params['body'][] = $record;
144
  }
145
 
 
146
  $responses = $this->client->bulk($params);
147
 
148
  if ($responses['errors'] === true) {
@@ -160,9 +183,9 @@ class ElasticsearchHandler extends AbstractProcessingHandler
160
  *
161
  * Only the first error is converted into an exception.
162
  *
163
- * @param mixed[] $responses returned by $this->client->bulk()
164
  */
165
- protected function createExceptionFromResponses(array $responses): ElasticsearchRuntimeException
166
  {
167
  foreach ($responses['items'] ?? [] as $item) {
168
  if (isset($item['index']['error'])) {
@@ -170,6 +193,10 @@ class ElasticsearchHandler extends AbstractProcessingHandler
170
  }
171
  }
172
 
 
 
 
 
173
  return new ElasticsearchRuntimeException('Elasticsearch failed to index one or more records.');
174
  }
175
 
@@ -178,10 +205,14 @@ class ElasticsearchHandler extends AbstractProcessingHandler
178
  *
179
  * @param mixed[] $error
180
  */
181
- protected function createExceptionFromError(array $error): ElasticsearchRuntimeException
182
  {
183
  $previous = isset($error['caused_by']) ? $this->createExceptionFromError($error['caused_by']) : null;
184
 
 
 
 
 
185
  return new ElasticsearchRuntimeException($error['type'] . ': ' . $error['reason'], 0, $previous);
186
  }
187
  }
11
 
12
  namespace Monolog\Handler;
13
 
14
+ use Elastic\Elasticsearch\Response\Elasticsearch;
15
  use Throwable;
16
  use RuntimeException;
17
  use Monolog\Logger;
20
  use InvalidArgumentException;
21
  use Elasticsearch\Common\Exceptions\RuntimeException as ElasticsearchRuntimeException;
22
  use Elasticsearch\Client;
23
+ use Elastic\Elasticsearch\Exception\InvalidArgumentException as ElasticInvalidArgumentException;
24
+ use Elastic\Elasticsearch\Client as Client8;
25
 
26
  /**
27
  * Elasticsearch handler
47
  class ElasticsearchHandler extends AbstractProcessingHandler
48
  {
49
  /**
50
+ * @var Client|Client8
51
  */
52
  protected $client;
53
 
57
  protected $options = [];
58
 
59
  /**
60
+ * @var bool
 
61
  */
62
+ private $needsType;
63
+
64
+ /**
65
+ * @param Client|Client8 $client Elasticsearch Client object
66
+ * @param mixed[] $options Handler configuration
67
+ */
68
+ public function __construct($client, array $options = [], $level = Logger::DEBUG, bool $bubble = true)
69
  {
70
+ if (!$client instanceof Client && !$client instanceof Client8) {
71
+ throw new \TypeError('Elasticsearch\Client or Elastic\Elasticsearch\Client instance required');
72
+ }
73
+
74
  parent::__construct($level, $bubble);
75
  $this->client = $client;
76
  $this->options = array_merge(
81
  ],
82
  $options
83
  );
84
+
85
+ if ($client instanceof Client8 || $client::VERSION[0] === '7') {
86
+ $this->needsType = false;
87
+ // force the type to _doc for ES8/ES7
88
+ $this->options['type'] = '_doc';
89
+ } else {
90
+ $this->needsType = true;
91
+ }
92
  }
93
 
94
  /**
153
 
154
  foreach ($records as $record) {
155
  $params['body'][] = [
156
+ 'index' => $this->needsType ? [
157
  '_index' => $record['_index'],
158
  '_type' => $record['_type'],
159
+ ] : [
160
+ '_index' => $record['_index'],
161
  ],
162
  ];
163
  unset($record['_index'], $record['_type']);
165
  $params['body'][] = $record;
166
  }
167
 
168
+ /** @var Elasticsearch */
169
  $responses = $this->client->bulk($params);
170
 
171
  if ($responses['errors'] === true) {
183
  *
184
  * Only the first error is converted into an exception.
185
  *
186
+ * @param mixed[]|Elasticsearch $responses returned by $this->client->bulk()
187
  */
188
+ protected function createExceptionFromResponses($responses): Throwable
189
  {
190
  foreach ($responses['items'] ?? [] as $item) {
191
  if (isset($item['index']['error'])) {
193
  }
194
  }
195
 
196
+ if (class_exists(ElasticInvalidArgumentException::class)) {
197
+ return new ElasticInvalidArgumentException('Elasticsearch failed to index one or more records.');
198
+ }
199
+
200
  return new ElasticsearchRuntimeException('Elasticsearch failed to index one or more records.');
201
  }
202
 
205
  *
206
  * @param mixed[] $error
207
  */
208
+ protected function createExceptionFromError(array $error): Throwable
209
  {
210
  $previous = isset($error['caused_by']) ? $this->createExceptionFromError($error['caused_by']) : null;
211
 
212
+ if (class_exists(ElasticInvalidArgumentException::class)) {
213
+ return new ElasticInvalidArgumentException($error['type'] . ': ' . $error['reason'], 0, $previous);
214
+ }
215
+
216
  return new ElasticsearchRuntimeException($error['type'] . ': ' . $error['reason'], 0, $previous);
217
  }
218
  }
vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php CHANGED
@@ -44,7 +44,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
44
  * Minimum level for logs that are passed to handler
45
  *
46
  * @var int[]
47
- * @phpstan-var Level[]
48
  */
49
  protected $acceptedLevels;
50
 
@@ -78,7 +78,7 @@ class FilterHandler extends Handler implements ProcessableHandlerInterface, Rese
78
  }
79
 
80
  /**
81
- * @phpstan-return Level[]
82
  */
83
  public function getAcceptedLevels(): array
84
  {
44
  * Minimum level for logs that are passed to handler
45
  *
46
  * @var int[]
47
+ * @phpstan-var array<Level, int>
48
  */
49
  protected $acceptedLevels;
50
 
78
  }
79
 
80
  /**
81
+ * @phpstan-return array<int, Level>
82
  */
83
  public function getAcceptedLevels(): array
84
  {
vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php CHANGED
@@ -45,8 +45,16 @@ class FleepHookHandler extends SocketHandler
45
  * @param string $token Webhook token
46
  * @throws MissingExtensionException
47
  */
48
- public function __construct(string $token, $level = Logger::DEBUG, bool $bubble = true)
49
- {
 
 
 
 
 
 
 
 
50
  if (!extension_loaded('openssl')) {
51
  throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FleepHookHandler');
52
  }
@@ -54,7 +62,16 @@ class FleepHookHandler extends SocketHandler
54
  $this->token = $token;
55
 
56
  $connectionString = 'ssl://' . static::FLEEP_HOST . ':443';
57
- parent::__construct($connectionString, $level, $bubble);
 
 
 
 
 
 
 
 
 
58
  }
59
 
60
  /**
45
  * @param string $token Webhook token
46
  * @throws MissingExtensionException
47
  */
48
+ public function __construct(
49
+ string $token,
50
+ $level = Logger::DEBUG,
51
+ bool $bubble = true,
52
+ bool $persistent = false,
53
+ float $timeout = 0.0,
54
+ float $writingTimeout = 10.0,
55
+ ?float $connectionTimeout = null,
56
+ ?int $chunkSize = null
57
+ ) {
58
  if (!extension_loaded('openssl')) {
59
  throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FleepHookHandler');
60
  }
62
  $this->token = $token;
63
 
64
  $connectionString = 'ssl://' . static::FLEEP_HOST . ':443';
65
+ parent::__construct(
66
+ $connectionString,
67
+ $level,
68
+ $bubble,
69
+ $persistent,
70
+ $timeout,
71
+ $writingTimeout,
72
+ $connectionTimeout,
73
+ $chunkSize
74
+ );
75
  }
76
 
77
  /**
vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php CHANGED
@@ -39,13 +39,30 @@ class FlowdockHandler extends SocketHandler
39
  /**
40
  * @throws MissingExtensionException if OpenSSL is missing
41
  */
42
- public function __construct(string $apiToken, $level = Logger::DEBUG, bool $bubble = true)
43
- {
 
 
 
 
 
 
 
 
44
  if (!extension_loaded('openssl')) {
45
  throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FlowdockHandler');
46
  }
47
 
48
- parent::__construct('ssl://api.flowdock.com:443', $level, $bubble);
 
 
 
 
 
 
 
 
 
49
  $this->apiToken = $apiToken;
50
  }
51
 
39
  /**
40
  * @throws MissingExtensionException if OpenSSL is missing
41
  */
42
+ public function __construct(
43
+ string $apiToken,
44
+ $level = Logger::DEBUG,
45
+ bool $bubble = true,
46
+ bool $persistent = false,
47
+ float $timeout = 0.0,
48
+ float $writingTimeout = 10.0,
49
+ ?float $connectionTimeout = null,
50
+ ?int $chunkSize = null
51
+ ) {
52
  if (!extension_loaded('openssl')) {
53
  throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FlowdockHandler');
54
  }
55
 
56
+ parent::__construct(
57
+ 'ssl://api.flowdock.com:443',
58
+ $level,
59
+ $bubble,
60
+ $persistent,
61
+ $timeout,
62
+ $writingTimeout,
63
+ $connectionTimeout,
64
+ $chunkSize
65
+ );
66
  $this->apiToken = $apiToken;
67
  }
68
 
vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php CHANGED
@@ -38,6 +38,10 @@ class IFTTTHandler extends AbstractProcessingHandler
38
  */
39
  public function __construct(string $eventName, string $secretKey, $level = Logger::ERROR, bool $bubble = true)
40
  {
 
 
 
 
41
  $this->eventName = $eventName;
42
  $this->secretKey = $secretKey;
43
 
38
  */
39
  public function __construct(string $eventName, string $secretKey, $level = Logger::ERROR, bool $bubble = true)
40
  {
41
+ if (!extension_loaded('curl')) {
42
+ throw new MissingExtensionException('The curl extension is needed to use the IFTTTHandler');
43
+ }
44
+
45
  $this->eventName = $eventName;
46
  $this->secretKey = $secretKey;
47
 
vendor/monolog/monolog/src/Monolog/Handler/InsightOpsHandler.php CHANGED
@@ -33,8 +33,18 @@ class InsightOpsHandler extends SocketHandler
33
  *
34
  * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
35
  */
36
- public function __construct(string $token, string $region = 'us', bool $useSSL = true, $level = Logger::DEBUG, bool $bubble = true)
37
- {
 
 
 
 
 
 
 
 
 
 
38
  if ($useSSL && !extension_loaded('openssl')) {
39
  throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for InsightOpsHandler');
40
  }
@@ -43,7 +53,16 @@ class InsightOpsHandler extends SocketHandler
43
  ? 'ssl://' . $region . '.data.logs.insight.rapid7.com:443'
44
  : $region . '.data.logs.insight.rapid7.com:80';
45
 
46
- parent::__construct($endpoint, $level, $bubble);
 
 
 
 
 
 
 
 
 
47
  $this->logToken = $token;
48
  }
49
 
33
  *
34
  * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
35
  */
36
+ public function __construct(
37
+ string $token,
38
+ string $region = 'us',
39
+ bool $useSSL = true,
40
+ $level = Logger::DEBUG,
41
+ bool $bubble = true,
42
+ bool $persistent = false,
43
+ float $timeout = 0.0,
44
+ float $writingTimeout = 10.0,
45
+ ?float $connectionTimeout = null,
46
+ ?int $chunkSize = null
47
+ ) {
48
  if ($useSSL && !extension_loaded('openssl')) {
49
  throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for InsightOpsHandler');
50
  }
53
  ? 'ssl://' . $region . '.data.logs.insight.rapid7.com:443'
54
  : $region . '.data.logs.insight.rapid7.com:80';
55
 
56
+ parent::__construct(
57
+ $endpoint,
58
+ $level,
59
+ $bubble,
60
+ $persistent,
61
+ $timeout,
62
+ $writingTimeout,
63
+ $connectionTimeout,
64
+ $chunkSize
65
+ );
66
  $this->logToken = $token;
67
  }
68
 
vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php CHANGED
@@ -30,14 +30,33 @@ class LogEntriesHandler extends SocketHandler
30
  *
31
  * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
32
  */
33
- public function __construct(string $token, bool $useSSL = true, $level = Logger::DEBUG, bool $bubble = true, string $host = 'data.logentries.com')
34
- {
 
 
 
 
 
 
 
 
 
 
35
  if ($useSSL && !extension_loaded('openssl')) {
36
  throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler');
37
  }
38
 
39
  $endpoint = $useSSL ? 'ssl://' . $host . ':443' : $host . ':80';
40
- parent::__construct($endpoint, $level, $bubble);
 
 
 
 
 
 
 
 
 
41
  $this->logToken = $token;
42
  }
43
 
30
  *
31
  * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
32
  */
33
+ public function __construct(
34
+ string $token,
35
+ bool $useSSL = true,
36
+ $level = Logger::DEBUG,
37
+ bool $bubble = true,
38
+ string $host = 'data.logentries.com',
39
+ bool $persistent = false,
40
+ float $timeout = 0.0,
41
+ float $writingTimeout = 10.0,
42
+ ?float $connectionTimeout = null,
43
+ ?int $chunkSize = null
44
+ ) {
45
  if ($useSSL && !extension_loaded('openssl')) {
46
  throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler');
47
  }
48
 
49
  $endpoint = $useSSL ? 'ssl://' . $host . ':443' : $host . ':80';
50
+ parent::__construct(
51
+ $endpoint,
52
+ $level,
53
+ $bubble,
54
+ $persistent,
55
+ $timeout,
56
+ $writingTimeout,
57
+ $connectionTimeout,
58
+ $chunkSize
59
+ );
60
  $this->logToken = $token;
61
  }
62
 
vendor/monolog/monolog/src/Monolog/Handler/LogmaticHandler.php CHANGED
@@ -43,8 +43,19 @@ class LogmaticHandler extends SocketHandler
43
  *
44
  * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
45
  */
46
- public function __construct(string $token, string $hostname = '', string $appname = '', bool $useSSL = true, $level = Logger::DEBUG, bool $bubble = true)
47
- {
 
 
 
 
 
 
 
 
 
 
 
48
  if ($useSSL && !extension_loaded('openssl')) {
49
  throw new MissingExtensionException('The OpenSSL PHP extension is required to use SSL encrypted connection for LogmaticHandler');
50
  }
@@ -52,7 +63,16 @@ class LogmaticHandler extends SocketHandler
52
  $endpoint = $useSSL ? 'ssl://api.logmatic.io:10515' : 'api.logmatic.io:10514';
53
  $endpoint .= '/v1/';
54
 
55
- parent::__construct($endpoint, $level, $bubble);
 
 
 
 
 
 
 
 
 
56
 
57
  $this->logToken = $token;
58
  $this->hostname = $hostname;
43
  *
44
  * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
45
  */
46
+ public function __construct(
47
+ string $token,
48
+ string $hostname = '',
49
+ string $appname = '',
50
+ bool $useSSL = true,
51
+ $level = Logger::DEBUG,
52
+ bool $bubble = true,
53
+ bool $persistent = false,
54
+ float $timeout = 0.0,
55
+ float $writingTimeout = 10.0,
56
+ ?float $connectionTimeout = null,
57
+ ?int $chunkSize = null
58
+ ) {
59
  if ($useSSL && !extension_loaded('openssl')) {
60
  throw new MissingExtensionException('The OpenSSL PHP extension is required to use SSL encrypted connection for LogmaticHandler');
61
  }
63
  $endpoint = $useSSL ? 'ssl://api.logmatic.io:10515' : 'api.logmatic.io:10514';
64
  $endpoint .= '/v1/';
65
 
66
+ parent::__construct(
67
+ $endpoint,
68
+ $level,
69
+ $bubble,
70
+ $persistent,
71
+ $timeout,
72
+ $writingTimeout,
73
+ $connectionTimeout,
74
+ $chunkSize
75
+ );
76
 
77
  $this->logToken = $token;
78
  $this->hostname = $hostname;
vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php CHANGED
@@ -108,10 +108,24 @@ class PushoverHandler extends SocketHandler
108
  $highPriorityLevel = Logger::CRITICAL,
109
  $emergencyLevel = Logger::EMERGENCY,
110
  int $retry = 30,
111
- int $expire = 25200
 
 
 
 
 
112
  ) {
113
  $connectionString = $useSSL ? 'ssl://api.pushover.net:443' : 'api.pushover.net:80';
114
- parent::__construct($connectionString, $level, $bubble);
 
 
 
 
 
 
 
 
 
115
 
116
  $this->token = $token;
117
  $this->users = (array) $users;
108
  $highPriorityLevel = Logger::CRITICAL,
109
  $emergencyLevel = Logger::EMERGENCY,
110
  int $retry = 30,
111
+ int $expire = 25200,
112
+ bool $persistent = false,
113
+ float $timeout = 0.0,
114
+ float $writingTimeout = 10.0,
115
+ ?float $connectionTimeout = null,
116
+ ?int $chunkSize = null
117
  ) {
118
  $connectionString = $useSSL ? 'ssl://api.pushover.net:443' : 'api.pushover.net:80';
119
+ parent::__construct(
120
+ $connectionString,
121
+ $level,
122
+ $bubble,
123
+ $persistent,
124
+ $timeout,
125
+ $writingTimeout,
126
+ $connectionTimeout,
127
+ $chunkSize
128
+ );
129
 
130
  $this->token = $token;
131
  $this->users = (array) $users;
vendor/monolog/monolog/src/Monolog/Handler/SendGridHandler.php CHANGED
@@ -59,6 +59,10 @@ class SendGridHandler extends MailHandler
59
  */
60
  public function __construct(string $apiUser, string $apiKey, string $from, $to, string $subject, $level = Logger::ERROR, bool $bubble = true)
61
  {
 
 
 
 
62
  parent::__construct($level, $bubble);
63
  $this->apiUser = $apiUser;
64
  $this->apiKey = $apiKey;
59
  */
60
  public function __construct(string $apiUser, string $apiKey, string $from, $to, string $subject, $level = Logger::ERROR, bool $bubble = true)
61
  {
62
+ if (!extension_loaded('curl')) {
63
+ throw new MissingExtensionException('The curl extension is needed to use the SendGridHandler');
64
+ }
65
+
66
  parent::__construct($level, $bubble);
67
  $this->apiUser = $apiUser;
68
  $this->apiKey = $apiKey;
vendor/monolog/monolog/src/Monolog/Handler/Slack/SlackRecord.php CHANGED
@@ -146,12 +146,14 @@ class SlackRecord
146
 
147
  if ($this->useAttachment) {
148
  $attachment = array(
149
- 'fallback' => $message,
150
- 'text' => $message,
151
- 'color' => $this->getAttachmentColor($record['level']),
152
- 'fields' => array(),
153
- 'mrkdwn_in' => array('fields'),
154
- 'ts' => $record['datetime']->getTimestamp(),
 
 
155
  );
156
 
157
  if ($this->useShortAttachment) {
146
 
147
  if ($this->useAttachment) {
148
  $attachment = array(
149
+ 'fallback' => $message,
150
+ 'text' => $message,
151
+ 'color' => $this->getAttachmentColor($record['level']),
152
+ 'fields' => array(),
153
+ 'mrkdwn_in' => array('fields'),
154
+ 'ts' => $record['datetime']->getTimestamp(),
155
+ 'footer' => $this->username,
156
+ 'footer_icon' => $this->userIcon,
157
  );
158
 
159
  if ($this->useShortAttachment) {
vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php CHANGED
@@ -59,13 +59,27 @@ class SlackHandler extends SocketHandler
59
  bool $bubble = true,
60
  bool $useShortAttachment = false,
61
  bool $includeContextAndExtra = false,
62
- array $excludeFields = array()
 
 
 
 
 
63
  ) {
64
  if (!extension_loaded('openssl')) {
65
  throw new MissingExtensionException('The OpenSSL PHP extension is required to use the SlackHandler');
66
  }
67
 
68
- parent::__construct('ssl://slack.com:443', $level, $bubble);
 
 
 
 
 
 
 
 
 
69
 
70
  $this->slackRecord = new SlackRecord(
71
  $channel,
59
  bool $bubble = true,
60
  bool $useShortAttachment = false,
61
  bool $includeContextAndExtra = false,
62
+ array $excludeFields = array(),
63
+ bool $persistent = false,
64
+ float $timeout = 0.0,
65
+ float $writingTimeout = 10.0,
66
+ ?float $connectionTimeout = null,
67
+ ?int $chunkSize = null
68
  ) {
69
  if (!extension_loaded('openssl')) {
70
  throw new MissingExtensionException('The OpenSSL PHP extension is required to use the SlackHandler');
71
  }
72
 
73
+ parent::__construct(
74
+ 'ssl://slack.com:443',
75
+ $level,
76
+ $bubble,
77
+ $persistent,
78
+ $timeout,
79
+ $writingTimeout,
80
+ $connectionTimeout,
81
+ $chunkSize
82
+ );
83
 
84
  $this->slackRecord = new SlackRecord(
85
  $channel,
vendor/monolog/monolog/src/Monolog/Handler/SlackWebhookHandler.php CHANGED
@@ -58,6 +58,10 @@ class SlackWebhookHandler extends AbstractProcessingHandler
58
  bool $bubble = true,
59
  array $excludeFields = array()
60
  ) {
 
 
 
 
61
  parent::__construct($level, $bubble);
62
 
63
  $this->webhookUrl = $webhookUrl;
58
  bool $bubble = true,
59
  array $excludeFields = array()
60
  ) {
61
+ if (!extension_loaded('curl')) {
62
+ throw new MissingExtensionException('The curl extension is needed to use the SlackWebhookHandler');
63
+ }
64
+
65
  parent::__construct($level, $bubble);
66
 
67
  $this->webhookUrl = $webhookUrl;
vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php CHANGED
@@ -31,15 +31,15 @@ class SocketHandler extends AbstractProcessingHandler
31
  /** @var resource|null */
32
  private $resource;
33
  /** @var float */
34
- private $timeout = 0.0;
35
  /** @var float */
36
- private $writingTimeout = 10.0;
37
  /** @var ?int */
38
  private $lastSentBytes = null;
39
- /** @var int */
40
- private $chunkSize = null;
41
  /** @var bool */
42
- private $persistent = false;
43
  /** @var ?int */
44
  private $errno = null;
45
  /** @var ?string */
@@ -48,13 +48,40 @@ class SocketHandler extends AbstractProcessingHandler
48
  private $lastWritingAt = null;
49
 
50
  /**
51
- * @param string $connectionString Socket connection string
 
 
 
 
 
 
 
 
52
  */
53
- public function __construct(string $connectionString, $level = Logger::DEBUG, bool $bubble = true)
54
- {
 
 
 
 
 
 
 
 
55
  parent::__construct($level, $bubble);
56
  $this->connectionString = $connectionString;
57
- $this->connectionTimeout = (float) ini_get('default_socket_timeout');
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
 
60
  /**
@@ -197,7 +224,7 @@ class SocketHandler extends AbstractProcessingHandler
197
  /**
198
  * Get current chunk size
199
  */
200
- public function getChunkSize(): int
201
  {
202
  return $this->chunkSize;
203
  }
@@ -265,6 +292,10 @@ class SocketHandler extends AbstractProcessingHandler
265
  throw new \LogicException('streamSetChunkSize called but $this->resource is not a resource');
266
  }
267
 
 
 
 
 
268
  return stream_set_chunk_size($this->resource, $this->chunkSize);
269
  }
270
 
31
  /** @var resource|null */
32
  private $resource;
33
  /** @var float */
34
+ private $timeout;
35
  /** @var float */
36
+ private $writingTimeout;
37
  /** @var ?int */
38
  private $lastSentBytes = null;
39
+ /** @var ?int */
40
+ private $chunkSize;
41
  /** @var bool */
42
+ private $persistent;
43
  /** @var ?int */
44
  private $errno = null;
45
  /** @var ?string */
48
  private $lastWritingAt = null;
49
 
50
  /**
51
+ * @param string $connectionString Socket connection string
52
+ * @param bool $persistent Flag to enable/disable persistent connections
53
+ * @param float $timeout Socket timeout to wait until the request is being aborted
54
+ * @param float $writingTimeout Socket timeout to wait until the request should've been sent/written
55
+ * @param float|null $connectionTimeout Socket connect timeout to wait until the connection should've been
56
+ * established
57
+ * @param int|null $chunkSize Sets the chunk size. Only has effect during connection in the writing cycle
58
+ *
59
+ * @throws \InvalidArgumentException If an invalid timeout value (less than 0) is passed.
60
  */
61
+ public function __construct(
62
+ string $connectionString,
63
+ $level = Logger::DEBUG,
64
+ bool $bubble = true,
65
+ bool $persistent = false,
66
+ float $timeout = 0.0,
67
+ float $writingTimeout = 10.0,
68
+ ?float $connectionTimeout = null,
69
+ ?int $chunkSize = null
70
+ ) {
71
  parent::__construct($level, $bubble);
72
  $this->connectionString = $connectionString;
73
+
74
+ if ($connectionTimeout !== null) {
75
+ $this->validateTimeout($connectionTimeout);
76
+ }
77
+
78
+ $this->connectionTimeout = $connectionTimeout ?? (float) ini_get('default_socket_timeout');
79
+ $this->persistent = $persistent;
80
+ $this->validateTimeout($timeout);
81
+ $this->timeout = $timeout;
82
+ $this->validateTimeout($writingTimeout);
83
+ $this->writingTimeout = $writingTimeout;
84
+ $this->chunkSize = $chunkSize;
85
  }
86
 
87
  /**
224
  /**
225
  * Get current chunk size
226
  */
227
+ public function getChunkSize(): ?int
228
  {
229
  return $this->chunkSize;
230
  }
292
  throw new \LogicException('streamSetChunkSize called but $this->resource is not a resource');
293
  }
294
 
295
+ if (null === $this->chunkSize) {
296
+ throw new \LogicException('streamSetChunkSize called but $this->chunkSize is not set');
297
+ }
298
+
299
  return stream_set_chunk_size($this->resource, $this->chunkSize);
300
  }
301
 
vendor/monolog/monolog/src/Monolog/Handler/SqsHandler.php CHANGED
@@ -46,7 +46,7 @@ class SqsHandler extends AbstractProcessingHandler
46
  protected function write(array $record): void
47
  {
48
  if (!isset($record['formatted']) || 'string' !== gettype($record['formatted'])) {
49
- throw new \InvalidArgumentException('SqsHandler accepts only formatted records as a string');
50
  }
51
 
52
  $messageBody = $record['formatted'];
46
  protected function write(array $record): void
47
  {
48
  if (!isset($record['formatted']) || 'string' !== gettype($record['formatted'])) {
49
+ throw new \InvalidArgumentException('SqsHandler accepts only formatted records as a string' . Utils::getRecordMessageForException($record));
50
  }
51
 
52
  $messageBody = $record['formatted'];
vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php CHANGED
@@ -25,8 +25,12 @@ use Monolog\Utils;
25
  */
26
  class StreamHandler extends AbstractProcessingHandler
27
  {
 
28
  protected const MAX_CHUNK_SIZE = 2147483647;
29
-
 
 
 
30
  /** @var resource|null */
31
  protected $stream;
32
  /** @var ?string */
@@ -50,9 +54,24 @@ class StreamHandler extends AbstractProcessingHandler
50
  public function __construct($stream, $level = Logger::DEBUG, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false)
51
  {
52
  parent::__construct($level, $bubble);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  if (is_resource($stream)) {
54
  $this->stream = $stream;
55
- stream_set_chunk_size($this->stream, self::MAX_CHUNK_SIZE);
 
56
  } elseif (is_string($stream)) {
57
  $this->url = Utils::canonicalizePath($stream);
58
  } else {
@@ -95,6 +114,14 @@ class StreamHandler extends AbstractProcessingHandler
95
  return $this->url;
96
  }
97
 
 
 
 
 
 
 
 
 
98
  /**
99
  * {@inheritDoc}
100
  */
@@ -103,7 +130,7 @@ class StreamHandler extends AbstractProcessingHandler
103
  if (!is_resource($this->stream)) {
104
  $url = $this->url;
105
  if (null === $url || '' === $url) {
106
- throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
107
  }
108
  $this->createDir($url);
109
  $this->errorMessage = null;
@@ -116,15 +143,15 @@ class StreamHandler extends AbstractProcessingHandler
116
  if (!is_resource($stream)) {
117
  $this->stream = null;
118
 
119
- throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $url));
120
  }
121
- stream_set_chunk_size($stream, self::MAX_CHUNK_SIZE);
122
  $this->stream = $stream;
123
  }
124
 
125
  $stream = $this->stream;
126
  if (!is_resource($stream)) {
127
- throw new \LogicException('No stream was opened yet');
128
  }
129
 
130
  if ($this->useLocking) {
25
  */
26
  class StreamHandler extends AbstractProcessingHandler
27
  {
28
+ /** @const int */
29
  protected const MAX_CHUNK_SIZE = 2147483647;
30
+ /** @const int 10MB */
31
+ protected const DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024;
32
+ /** @var int */
33
+ protected $streamChunkSize;
34
  /** @var resource|null */
35
  protected $stream;
36
  /** @var ?string */
54
  public function __construct($stream, $level = Logger::DEBUG, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false)
55
  {
56
  parent::__construct($level, $bubble);
57
+
58
+ if (($phpMemoryLimit = Utils::expandIniShorthandBytes(ini_get('memory_limit'))) !== false) {
59
+ if ($phpMemoryLimit > 0) {
60
+ // use max 10% of allowed memory for the chunk size, and at least 100KB
61
+ $this->streamChunkSize = min(static::MAX_CHUNK_SIZE, max((int) ($phpMemoryLimit / 10), 100 * 1024));
62
+ } else {
63
+ // memory is unlimited, set to the default 10MB
64
+ $this->streamChunkSize = static::DEFAULT_CHUNK_SIZE;
65
+ }
66
+ } else {
67
+ // no memory limit information, set to the default 10MB
68
+ $this->streamChunkSize = static::DEFAULT_CHUNK_SIZE;
69
+ }
70
+
71
  if (is_resource($stream)) {
72
  $this->stream = $stream;
73
+
74
+ stream_set_chunk_size($this->stream, $this->streamChunkSize);
75
  } elseif (is_string($stream)) {
76
  $this->url = Utils::canonicalizePath($stream);
77
  } else {
114
  return $this->url;
115
  }
116
 
117
+ /**
118
+ * @return int
119
+ */
120
+ public function getStreamChunkSize(): int
121
+ {
122
+ return $this->streamChunkSize;
123
+ }
124
+
125
  /**
126
  * {@inheritDoc}
127
  */
130
  if (!is_resource($this->stream)) {
131
  $url = $this->url;
132
  if (null === $url || '' === $url) {
133
+ throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().' . Utils::getRecordMessageForException($record));
134
  }
135
  $this->createDir($url);
136
  $this->errorMessage = null;
143
  if (!is_resource($stream)) {
144
  $this->stream = null;
145
 
146
+ throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $url) . Utils::getRecordMessageForException($record));
147
  }
148
+ stream_set_chunk_size($stream, $this->streamChunkSize);
149
  $this->stream = $stream;
150
  }
151
 
152
  $stream = $this->stream;
153
  if (!is_resource($stream)) {
154
+ throw new \LogicException('No stream was opened yet' . Utils::getRecordMessageForException($record));
155
  }
156
 
157
  if ($this->useLocking) {
vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php CHANGED
@@ -12,6 +12,7 @@
12
  namespace Monolog\Handler;
13
 
14
  use Monolog\Logger;
 
15
  use Monolog\Formatter\FormatterInterface;
16
  use Monolog\Formatter\LineFormatter;
17
  use Swift_Message;
@@ -23,6 +24,7 @@ use Swift;
23
  * @author Gyula Sallai
24
  *
25
  * @phpstan-import-type Record from \Monolog\Logger
 
26
  */
27
  class SwiftMailerHandler extends MailHandler
28
  {
@@ -41,6 +43,8 @@ class SwiftMailerHandler extends MailHandler
41
  {
42
  parent::__construct($level, $bubble);
43
 
 
 
44
  $this->mailer = $mailer;
45
  $this->messageTemplate = $message;
46
  }
@@ -83,7 +87,8 @@ class SwiftMailerHandler extends MailHandler
83
  }
84
 
85
  if (!$message instanceof Swift_Message) {
86
- throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it');
 
87
  }
88
 
89
  if ($records) {
12
  namespace Monolog\Handler;
13
 
14
  use Monolog\Logger;
15
+ use Monolog\Utils;
16
  use Monolog\Formatter\FormatterInterface;
17
  use Monolog\Formatter\LineFormatter;
18
  use Swift_Message;
24
  * @author Gyula Sallai
25
  *
26
  * @phpstan-import-type Record from \Monolog\Logger
27
+ * @deprecated Since Monolog 2.6. Use SymfonyMailerHandler instead.
28
  */
29
  class SwiftMailerHandler extends MailHandler
30
  {
43
  {
44
  parent::__construct($level, $bubble);
45
 
46
+ @trigger_error('The SwiftMailerHandler is deprecated since Monolog 2.6. Use SymfonyMailerHandler instead.', E_USER_DEPRECATED);
47
+
48
  $this->mailer = $mailer;
49
  $this->messageTemplate = $message;
50
  }
87
  }
88
 
89
  if (!$message instanceof Swift_Message) {
90
+ $record = reset($records);
91
+ throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it' . ($record ? Utils::getRecordMessageForException($record) : ''));
92
  }
93
 
94
  if ($records) {
vendor/monolog/monolog/src/Monolog/Handler/SymfonyMailerHandler.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php declare(strict_types=1);
2
+
3
+ /*
4
+ * This file is part of the Monolog package.
5
+ *
6
+ * (c) Jordi Boggiano <j.boggiano@seld.be>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Monolog\Handler;
13
+
14
+ use Monolog\Logger;
15
+ use Monolog\Utils;
16
+ use Monolog\Formatter\FormatterInterface;
17
+ use Monolog\Formatter\LineFormatter;
18
+ use Symfony\Component\Mailer\MailerInterface;
19
+ use Symfony\Component\Mailer\Transport\TransportInterface;
20
+ use Symfony\Component\Mime\Email;
21
+
22
+ /**
23
+ * SymfonyMailerHandler uses Symfony's Mailer component to send the emails
24
+ *
25
+ * @author Jordi Boggiano <j.boggiano@seld.be>
26
+ *
27
+ * @phpstan-import-type Record from \Monolog\Logger
28
+ */
29
+ class SymfonyMailerHandler extends MailHandler
30
+ {
31
+ /** @var MailerInterface|TransportInterface */
32
+ protected $mailer;
33
+ /** @var Email|callable(string, Record[]): Email */
34
+ private $emailTemplate;
35
+
36
+ /**
37
+ * @psalm-param Email|callable(string, Record[]): Email $email
38
+ *
39
+ * @param MailerInterface|TransportInterface $mailer The mailer to use
40
+ * @param callable|Email $email An email template, the subject/body will be replaced
41
+ */
42
+ public function __construct($mailer, $email, $level = Logger::ERROR, bool $bubble = true)
43
+ {
44
+ parent::__construct($level, $bubble);
45
+
46
+ $this->mailer = $mailer;
47
+ $this->emailTemplate = $email;
48
+ }
49
+
50
+ /**
51
+ * {@inheritDoc}
52
+ */
53
+ protected function send(string $content, array $records): void
54
+ {
55
+ $this->mailer->send($this->buildMessage($content, $records));
56
+ }
57
+
58
+ /**
59
+ * Gets the formatter for the Swift_Message subject.
60
+ *
61
+ * @param string|null $format The format of the subject
62
+ */
63
+ protected function getSubjectFormatter(?string $format): FormatterInterface
64
+ {
65
+ return new LineFormatter($format);
66
+ }
67
+
68
+ /**
69
+ * Creates instance of Email to be sent
70
+ *
71
+ * @param string $content formatted email body to be sent
72
+ * @param array $records Log records that formed the content
73
+ *
74
+ * @phpstan-param Record[] $records
75
+ */
76
+ protected function buildMessage(string $content, array $records): Email
77
+ {
78
+ $message = null;
79
+ if ($this->emailTemplate instanceof Email) {
80
+ $message = clone $this->emailTemplate;
81
+ } elseif (is_callable($this->emailTemplate)) {
82
+ $message = ($this->emailTemplate)($content, $records);
83
+ }
84
+
85
+ if (!$message instanceof Email) {
86
+ $record = reset($records);
87
+ throw new \InvalidArgumentException('Could not resolve message as instance of Email or a callable returning it' . ($record ? Utils::getRecordMessageForException($record) : ''));
88
+ }
89
+
90
+ if ($records) {
91
+ $subjectFormatter = $this->getSubjectFormatter($message->getSubject());
92
+ $message->subject($subjectFormatter->format($this->getHighestRecord($records)));
93
+ }
94
+
95
+ if ($this->isHtmlBody($content)) {
96
+ if (null !== ($charset = $message->getHtmlCharset())) {
97
+ $message->html($content, $charset);
98
+ } else {
99
+ $message->html($content);
100
+ }
101
+ } else {
102
+ if (null !== ($charset = $message->getTextCharset())) {
103
+ $message->text($content, $charset);
104
+ } else {
105
+ $message->text($content);
106
+ }
107
+ }
108
+
109
+ return $message->date(new \DateTimeImmutable());
110
+ }
111
+ }
vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php CHANGED
@@ -12,6 +12,7 @@
12
  namespace Monolog\Handler;
13
 
14
  use Monolog\Logger;
 
15
 
16
  /**
17
  * Logs to syslog service.
@@ -60,7 +61,7 @@ class SyslogHandler extends AbstractSyslogHandler
60
  protected function write(array $record): void
61
  {
62
  if (!openlog($this->ident, $this->logopts, $this->facility)) {
63
- throw new \LogicException('Can\'t open syslog for ident "'.$this->ident.'" and facility "'.$this->facility.'"');
64
  }
65
  syslog($this->logLevels[$record['level']], (string) $record['formatted']);
66
  }
12
  namespace Monolog\Handler;
13
 
14
  use Monolog\Logger;
15
+ use Monolog\Utils;
16
 
17
  /**
18
  * Logs to syslog service.
61
  protected function write(array $record): void
62
  {
63
  if (!openlog($this->ident, $this->logopts, $this->facility)) {
64
+ throw new \LogicException('Can\'t open syslog for ident "'.$this->ident.'" and facility "'.$this->facility.'"' . Utils::getRecordMessageForException($record));
65
  }
66
  syslog($this->logLevels[$record['level']], (string) $record['formatted']);
67
  }
vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php CHANGED
@@ -23,20 +23,12 @@ class UdpSocket
23
  /** @var int */
24
  protected $port;
25
  /** @var resource|Socket|null */
26
- protected $socket;
27
 
28
  public function __construct(string $ip, int $port = 514)
29
  {
30
  $this->ip = $ip;
31
  $this->port = $port;
32
- $domain = AF_INET;
33
- $protocol = SOL_UDP;
34
- // Check if we are using unix sockets.
35
- if ($port === 0) {
36
- $domain = AF_UNIX;
37
- $protocol = IPPROTO_IP;
38
- }
39
- $this->socket = socket_create($domain, SOCK_DGRAM, $protocol) ?: null;
40
  }
41
 
42
  /**
@@ -57,12 +49,34 @@ class UdpSocket
57
  }
58
  }
59
 
60
- protected function send(string $chunk): void
 
 
 
61
  {
62
- if (!is_resource($this->socket) && !$this->socket instanceof Socket) {
63
- throw new \RuntimeException('The UdpSocket to '.$this->ip.':'.$this->port.' has been closed and can not be written to anymore');
64
  }
65
- socket_sendto($this->socket, $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
  protected function assembleMessage(string $line, string $header): string
23
  /** @var int */
24
  protected $port;
25
  /** @var resource|Socket|null */
26
+ protected $socket = null;
27
 
28
  public function __construct(string $ip, int $port = 514)
29
  {
30
  $this->ip = $ip;
31
  $this->port = $port;
 
 
 
 
 
 
 
 
32
  }
33
 
34
  /**
49
  }
50
  }
51
 
52
+ /**
53
+ * @return resource|Socket
54
+ */
55
+ protected function getSocket()
56
  {
57
+ if (null !== $this->socket) {
58
+ return $this->socket;
59
  }
60
+
61
+ $domain = AF_INET;
62
+ $protocol = SOL_UDP;
63
+ // Check if we are using unix sockets.
64
+ if ($this->port === 0) {
65
+ $domain = AF_UNIX;
66
+ $protocol = IPPROTO_IP;
67
+ }
68
+
69
+ $this->socket = socket_create($domain, SOCK_DGRAM, $protocol) ?: null;
70
+ if (null === $this->socket) {
71
+ throw new \RuntimeException('The UdpSocket to '.$this->ip.':'.$this->port.' could not be opened via socket_create');
72
+ }
73
+
74
+ return $this->socket;
75
+ }
76
+
77
+ protected function send(string $chunk): void
78
+ {
79
+ socket_sendto($this->getSocket(), $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port);
80
  }
81
 
82
  protected function assembleMessage(string $line, string $header): string
vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php CHANGED
@@ -49,11 +49,16 @@ class SyslogUdpHandler extends AbstractSyslogHandler
49
  * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
50
  * @param string $ident Program name or tag for each log message.
51
  * @param int $rfc RFC to format the message for.
 
52
  *
53
  * @phpstan-param self::RFC* $rfc
54
  */
55
  public function __construct(string $host, int $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, bool $bubble = true, string $ident = 'php', int $rfc = self::RFC5424)
56
  {
 
 
 
 
57
  parent::__construct($facility, $level, $bubble);
58
 
59
  $this->ident = $ident;
49
  * @param bool $bubble Whether the messages that are handled can bubble up the stack or not
50
  * @param string $ident Program name or tag for each log message.
51
  * @param int $rfc RFC to format the message for.
52
+ * @throws MissingExtensionException
53
  *
54
  * @phpstan-param self::RFC* $rfc
55
  */
56
  public function __construct(string $host, int $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, bool $bubble = true, string $ident = 'php', int $rfc = self::RFC5424)
57
  {
58
+ if (!extension_loaded('sockets')) {
59
+ throw new MissingExtensionException('The sockets extension is required to use the SyslogUdpHandler');
60
+ }
61
+
62
  parent::__construct($facility, $level, $bubble);
63
 
64
  $this->ident = $ident;
vendor/monolog/monolog/src/Monolog/Handler/TelegramBotHandler.php CHANGED
@@ -13,6 +13,7 @@ namespace Monolog\Handler;
13
 
14
  use RuntimeException;
15
  use Monolog\Logger;
 
16
 
17
  /**
18
  * Handler send logs to Telegram using Telegram Bot API.
@@ -43,6 +44,11 @@ class TelegramBotHandler extends AbstractProcessingHandler
43
  'Markdown', // legacy mode without underline and strikethrough, use MarkdownV2 instead
44
  ];
45
 
 
 
 
 
 
46
  /**
47
  * Telegram bot access token provided by BotFather.
48
  * Create telegram bot with https://telegram.me/BotFather and use access token from it.
@@ -78,18 +84,41 @@ class TelegramBotHandler extends AbstractProcessingHandler
78
  private $disableNotification;
79
 
80
  /**
81
- * @param string $apiKey Telegram bot access token provided by BotFather
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  * @param string $channel Telegram channel name
 
 
 
83
  */
84
  public function __construct(
85
  string $apiKey,
86
  string $channel,
87
- $level = Logger::DEBUG,
88
- bool $bubble = true,
89
  string $parseMode = null,
90
- bool $disableWebPagePreview = null,
91
- bool $disableNotification = null
92
- ) {
 
 
 
 
 
 
 
93
  parent::__construct($level, $bubble);
94
 
95
  $this->apiKey = $apiKey;
@@ -97,6 +126,8 @@ class TelegramBotHandler extends AbstractProcessingHandler
97
  $this->setParseMode($parseMode);
98
  $this->disableWebPagePreview($disableWebPagePreview);
99
  $this->disableNotification($disableNotification);
 
 
100
  }
101
 
102
  public function setParseMode(string $parseMode = null): self
@@ -124,6 +155,31 @@ class TelegramBotHandler extends AbstractProcessingHandler
124
  return $this;
125
  }
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  /**
128
  * {@inheritDoc}
129
  */
@@ -146,7 +202,7 @@ class TelegramBotHandler extends AbstractProcessingHandler
146
  }
147
 
148
  if (!empty($messages)) {
149
- $this->send((string) $this->getFormatter()->formatBatch($messages));
150
  }
151
  }
152
 
@@ -163,6 +219,19 @@ class TelegramBotHandler extends AbstractProcessingHandler
163
  * @param string $message
164
  */
165
  protected function send(string $message): void
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  {
167
  $ch = curl_init();
168
  $url = self::BOT_API . $this->apiKey . '/SendMessage';
@@ -187,4 +256,19 @@ class TelegramBotHandler extends AbstractProcessingHandler
187
  throw new RuntimeException('Telegram API error. Description: ' . $result['description']);
188
  }
189
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  }
13
 
14
  use RuntimeException;
15
  use Monolog\Logger;
16
+ use Monolog\Utils;
17
 
18
  /**
19
  * Handler send logs to Telegram using Telegram Bot API.
44
  'Markdown', // legacy mode without underline and strikethrough, use MarkdownV2 instead
45
  ];
46
 
47
+ /**
48
+ * The maximum number of characters allowed in a message according to the Telegram api documentation
49
+ */
50
+ private const MAX_MESSAGE_LENGTH = 4096;
51
+
52
  /**
53
  * Telegram bot access token provided by BotFather.
54
  * Create telegram bot with https://telegram.me/BotFather and use access token from it.
84
  private $disableNotification;
85
 
86
  /**
87
+ * True - split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages.
88
+ * False - truncates a message that is too long.
89
+ * @var bool
90
+ */
91
+ private $splitLongMessages;
92
+
93
+ /**
94
+ * Adds 1-second delay between sending a split message (according to Telegram API to avoid 429 Too Many Requests).
95
+ * @var bool
96
+ */
97
+ private $delayBetweenMessages;
98
+
99
+ /**
100
+ * @param string $apiKey Telegram bot access token provided by BotFather
101
  * @param string $channel Telegram channel name
102
+ * @param bool $splitLongMessages Split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages
103
+ * @param bool $delayBetweenMessages Adds delay between sending a split message according to Telegram API
104
+ * @throws MissingExtensionException
105
  */
106
  public function __construct(
107
  string $apiKey,
108
  string $channel,
109
+ $level = Logger::DEBUG,
110
+ bool $bubble = true,
111
  string $parseMode = null,
112
+ bool $disableWebPagePreview = null,
113
+ bool $disableNotification = null,
114
+ bool $splitLongMessages = false,
115
+ bool $delayBetweenMessages = false
116
+ )
117
+ {
118
+ if (!extension_loaded('curl')) {
119
+ throw new MissingExtensionException('The curl extension is needed to use the TelegramBotHandler');
120
+ }
121
+
122
  parent::__construct($level, $bubble);
123
 
124
  $this->apiKey = $apiKey;
126
  $this->setParseMode($parseMode);
127
  $this->disableWebPagePreview($disableWebPagePreview);
128
  $this->disableNotification($disableNotification);
129
+ $this->splitLongMessages($splitLongMessages);
130
+ $this->delayBetweenMessages($delayBetweenMessages);
131
  }
132
 
133
  public function setParseMode(string $parseMode = null): self
155
  return $this;
156
  }
157
 
158
+ /**
159
+ * True - split a message longer than MAX_MESSAGE_LENGTH into parts and send in multiple messages.
160
+ * False - truncates a message that is too long.
161
+ * @param bool $splitLongMessages
162
+ * @return $this
163
+ */
164
+ public function splitLongMessages(bool $splitLongMessages = false): self
165
+ {
166
+ $this->splitLongMessages = $splitLongMessages;
167
+
168
+ return $this;
169
+ }
170
+
171
+ /**
172
+ * Adds 1-second delay between sending a split message (according to Telegram API to avoid 429 Too Many Requests).
173
+ * @param bool $delayBetweenMessages
174
+ * @return $this
175
+ */
176
+ public function delayBetweenMessages(bool $delayBetweenMessages = false): self
177
+ {
178
+ $this->delayBetweenMessages = $delayBetweenMessages;
179
+
180
+ return $this;
181
+ }
182
+
183
  /**
184
  * {@inheritDoc}
185
  */
202
  }
203
 
204
  if (!empty($messages)) {
205
+ $this->send((string)$this->getFormatter()->formatBatch($messages));
206
  }
207
  }
208
 
219
  * @param string $message
220
  */
221
  protected function send(string $message): void
222
+ {
223
+ $messages = $this->handleMessageLength($message);
224
+
225
+ foreach ($messages as $key => $msg) {
226
+ if ($this->delayBetweenMessages && $key > 0) {
227
+ sleep(1);
228
+ }
229
+
230
+ $this->sendCurl($msg);
231
+ }
232
+ }
233
+
234
+ protected function sendCurl(string $message): void
235
  {
236
  $ch = curl_init();
237
  $url = self::BOT_API . $this->apiKey . '/SendMessage';
256
  throw new RuntimeException('Telegram API error. Description: ' . $result['description']);
257
  }
258
  }
259
+
260
+ /**
261
+ * Handle a message that is too long: truncates or splits into several
262
+ * @param string $message
263
+ * @return string[]
264
+ */
265
+ private function handleMessageLength(string $message): array
266
+ {
267
+ $truncatedMarker = ' (...truncated)';
268
+ if (!$this->splitLongMessages && strlen($message) > self::MAX_MESSAGE_LENGTH) {
269
+ return [Utils::substr($message, 0, self::MAX_MESSAGE_LENGTH - strlen($truncatedMarker)) . $truncatedMarker];
270
+ }
271
+
272
+ return str_split($message, self::MAX_MESSAGE_LENGTH);
273
+ }
274
  }
vendor/monolog/monolog/src/Monolog/LogRecord.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php declare(strict_types=1);
2
+
3
+ /*
4
+ * This file is part of the Monolog package.
5
+ *
6
+ * (c) Jordi Boggiano <j.boggiano@seld.be>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Monolog;
13
+
14
+ use ArrayAccess;
15
+
16
+ /**
17
+ * Monolog log record interface for forward compatibility with Monolog 3.0
18
+ *
19
+ * This is just present in Monolog 2.4+ to allow interoperable code to be written against
20
+ * both versions by type-hinting arguments as `array|\Monolog\LogRecord $record`
21
+ *
22
+ * Do not rely on this interface for other purposes, and do not implement it.
23
+ *
24
+ * @author Jordi Boggiano <j.boggiano@seld.be>
25
+ * @template-extends \ArrayAccess<'message'|'level'|'context'|'level_name'|'channel'|'datetime'|'extra'|'formatted', mixed>
26
+ * @phpstan-import-type Record from Logger
27
+ */
28
+ interface LogRecord extends \ArrayAccess
29
+ {
30
+ /**
31
+ * @phpstan-return Record
32
+ */
33
+ public function toArray(): array;
34
+ }
vendor/monolog/monolog/src/Monolog/Logger.php CHANGED
@@ -17,6 +17,7 @@ use Psr\Log\LoggerInterface;
17
  use Psr\Log\InvalidArgumentException;
18
  use Psr\Log\LogLevel;
19
  use Throwable;
 
20
 
21
  /**
22
  * Monolog log channel
@@ -146,6 +147,11 @@ class Logger implements LoggerInterface, ResettableInterface
146
  */
147
  protected $exceptionHandler;
148
 
 
 
 
 
 
149
  /**
150
  * @psalm-param array<callable(array): array> $processors
151
  *
@@ -271,9 +277,11 @@ class Logger implements LoggerInterface, ResettableInterface
271
  *
272
  * @param bool $micro True to use microtime() to create timestamps
273
  */
274
- public function useMicrosecondTimestamps(bool $micro): void
275
  {
276
  $this->microsecondTimestamps = $micro;
 
 
277
  }
278
 
279
  /**
@@ -288,31 +296,51 @@ class Logger implements LoggerInterface, ResettableInterface
288
  */
289
  public function addRecord(int $level, string $message, array $context = []): bool
290
  {
291
- $offset = 0;
292
- $record = null;
 
 
 
 
 
293
 
294
- foreach ($this->handlers as $handler) {
295
- if (null === $record) {
296
- // skip creating the record as long as no handler is going to handle it
297
- if (!$handler->isHandling(['level' => $level])) {
298
- continue;
299
- }
300
 
301
- $levelName = static::getLevelName($level);
 
 
 
 
 
302
 
303
- $record = [
304
- 'message' => $message,
305
- 'context' => $context,
306
- 'level' => $level,
307
- 'level_name' => $levelName,
308
- 'channel' => $this->name,
309
- 'datetime' => new DateTimeImmutable($this->microsecondTimestamps, $this->timezone),
310
- 'extra' => [],
311
- ];
 
 
 
 
 
 
 
 
 
 
 
 
 
312
 
 
313
  try {
314
- foreach ($this->processors as $processor) {
315
- $record = $processor($record);
316
  }
317
  } catch (Throwable $e) {
318
  $this->handleException($e, $record);
@@ -320,17 +348,8 @@ class Logger implements LoggerInterface, ResettableInterface
320
  return true;
321
  }
322
  }
323
-
324
- // once the record exists, send it to all handlers as long as the bubbling chain is not interrupted
325
- try {
326
- if (true === $handler->handle($record)) {
327
- break;
328
- }
329
- } catch (Throwable $e) {
330
- $this->handleException($e, $record);
331
-
332
- return true;
333
- }
334
  }
335
 
336
  return null !== $record;
@@ -382,6 +401,7 @@ class Logger implements LoggerInterface, ResettableInterface
382
  * Gets all supported logging levels.
383
  *
384
  * @return array<string, int> Assoc array with human-readable level names => level codes.
 
385
  */
386
  public static function getLevels(): array
387
  {
@@ -481,14 +501,18 @@ class Logger implements LoggerInterface, ResettableInterface
481
  *
482
  * This method allows for compatibility with common interfaces.
483
  *
484
- * @param int|string $level The log level
485
- * @param string $message The log message
486
- * @param mixed[] $context The log context
487
  *
488
  * @phpstan-param Level|LevelName|LogLevel::* $level
489
  */
490
  public function log($level, $message, array $context = []): void
491
  {
 
 
 
 
492
  $level = static::toMonologLevel($level);
493
 
494
  $this->addRecord($level, (string) $message, $context);
@@ -499,8 +523,8 @@ class Logger implements LoggerInterface, ResettableInterface
499
  *
500
  * This method allows for compatibility with common interfaces.
501
  *
502
- * @param string $message The log message
503
- * @param mixed[] $context The log context
504
  */
505
  public function debug($message, array $context = []): void
506
  {
@@ -512,8 +536,8 @@ class Logger implements LoggerInterface, ResettableInterface
512
  *
513
  * This method allows for compatibility with common interfaces.
514
  *
515
- * @param string $message The log message
516
- * @param mixed[] $context The log context
517
  */
518
  public function info($message, array $context = []): void
519
  {
@@ -525,8 +549,8 @@ class Logger implements LoggerInterface, ResettableInterface
525
  *
526
  * This method allows for compatibility with common interfaces.
527
  *
528
- * @param string $message The log message
529
- * @param mixed[] $context The log context
530
  */
531
  public function notice($message, array $context = []): void
532
  {
@@ -538,8 +562,8 @@ class Logger implements LoggerInterface, ResettableInterface
538
  *
539
  * This method allows for compatibility with common interfaces.
540
  *
541
- * @param string $message The log message
542
- * @param mixed[] $context The log context
543
  */
544
  public function warning($message, array $context = []): void
545
  {
@@ -551,8 +575,8 @@ class Logger implements LoggerInterface, ResettableInterface
551
  *
552
  * This method allows for compatibility with common interfaces.
553
  *
554
- * @param string $message The log message
555
- * @param mixed[] $context The log context
556
  */
557
  public function error($message, array $context = []): void
558
  {
@@ -564,8 +588,8 @@ class Logger implements LoggerInterface, ResettableInterface
564
  *
565
  * This method allows for compatibility with common interfaces.
566
  *
567
- * @param string $message The log message
568
- * @param mixed[] $context The log context
569
  */
570
  public function critical($message, array $context = []): void
571
  {
@@ -577,8 +601,8 @@ class Logger implements LoggerInterface, ResettableInterface
577
  *
578
  * This method allows for compatibility with common interfaces.
579
  *
580
- * @param string $message The log message
581
- * @param mixed[] $context The log context
582
  */
583
  public function alert($message, array $context = []): void
584
  {
@@ -590,8 +614,8 @@ class Logger implements LoggerInterface, ResettableInterface
590
  *
591
  * This method allows for compatibility with common interfaces.
592
  *
593
- * @param string $message The log message
594
- * @param mixed[] $context The log context
595
  */
596
  public function emergency($message, array $context = []): void
597
  {
17
  use Psr\Log\InvalidArgumentException;
18
  use Psr\Log\LogLevel;
19
  use Throwable;
20
+ use Stringable;
21
 
22
  /**
23
  * Monolog log channel
147
  */
148
  protected $exceptionHandler;
149
 
150
+ /**
151
+ * @var int Keeps track of depth to prevent infinite logging loops
152
+ */
153
+ private $logDepth = 0;
154
+
155
  /**
156
  * @psalm-param array<callable(array): array> $processors
157
  *
277
  *
278
  * @param bool $micro True to use microtime() to create timestamps
279
  */
280
+ public function useMicrosecondTimestamps(bool $micro): self
281
  {
282
  $this->microsecondTimestamps = $micro;
283
+
284
+ return $this;
285
  }
286
 
287
  /**
296
  */
297
  public function addRecord(int $level, string $message, array $context = []): bool
298
  {
299
+ $this->logDepth += 1;
300
+ if ($this->logDepth === 3) {
301
+ $this->warning('A possible infinite logging loop was detected and aborted. It appears some of your handler code is triggering logging, see the previous log record for a hint as to what may be the cause.');
302
+ return false;
303
+ } elseif ($this->logDepth >= 5) { // log depth 4 is let through so we can log the warning above
304
+ return false;
305
+ }
306
 
307
+ try {
308
+ $record = null;
 
 
 
 
309
 
310
+ foreach ($this->handlers as $handler) {
311
+ if (null === $record) {
312
+ // skip creating the record as long as no handler is going to handle it
313
+ if (!$handler->isHandling(['level' => $level])) {
314
+ continue;
315
+ }
316
 
317
+ $levelName = static::getLevelName($level);
318
+
319
+ $record = [
320
+ 'message' => $message,
321
+ 'context' => $context,
322
+ 'level' => $level,
323
+ 'level_name' => $levelName,
324
+ 'channel' => $this->name,
325
+ 'datetime' => new DateTimeImmutable($this->microsecondTimestamps, $this->timezone),
326
+ 'extra' => [],
327
+ ];
328
+
329
+ try {
330
+ foreach ($this->processors as $processor) {
331
+ $record = $processor($record);
332
+ }
333
+ } catch (Throwable $e) {
334
+ $this->handleException($e, $record);
335
+
336
+ return true;
337
+ }
338
+ }
339
 
340
+ // once the record exists, send it to all handlers as long as the bubbling chain is not interrupted
341
  try {
342
+ if (true === $handler->handle($record)) {
343
+ break;
344
  }
345
  } catch (Throwable $e) {
346
  $this->handleException($e, $record);
348
  return true;
349
  }
350
  }
351
+ } finally {
352
+ $this->logDepth--;
 
 
 
 
 
 
 
 
 
353
  }
354
 
355
  return null !== $record;
401
  * Gets all supported logging levels.
402
  *
403
  * @return array<string, int> Assoc array with human-readable level names => level codes.
404
+ * @phpstan-return array<LevelName, Level>
405
  */
406
  public static function getLevels(): array
407
  {
501
  *
502
  * This method allows for compatibility with common interfaces.
503
  *
504
+ * @param mixed $level The log level
505
+ * @param string|Stringable $message The log message
506
+ * @param mixed[] $context The log context
507
  *
508
  * @phpstan-param Level|LevelName|LogLevel::* $level
509
  */
510
  public function log($level, $message, array $context = []): void
511
  {
512
+ if (!is_int($level) && !is_string($level)) {
513
+ throw new \InvalidArgumentException('$level is expected to be a string or int');
514
+ }
515
+
516
  $level = static::toMonologLevel($level);
517
 
518
  $this->addRecord($level, (string) $message, $context);
523
  *
524
  * This method allows for compatibility with common interfaces.
525
  *
526
+ * @param string|Stringable $message The log message
527
+ * @param mixed[] $context The log context
528
  */
529
  public function debug($message, array $context = []): void
530
  {
536
  *
537
  * This method allows for compatibility with common interfaces.
538
  *
539
+ * @param string|Stringable $message The log message
540
+ * @param mixed[] $context The log context
541
  */
542
  public function info($message, array $context = []): void
543
  {
549
  *
550
  * This method allows for compatibility with common interfaces.
551
  *
552
+ * @param string|Stringable $message The log message
553
+ * @param mixed[] $context The log context
554
  */
555
  public function notice($message, array $context = []): void
556
  {
562
  *
563
  * This method allows for compatibility with common interfaces.
564
  *
565
+ * @param string|Stringable $message The log message
566
+ * @param mixed[] $context The log context
567
  */
568
  public function warning($message, array $context = []): void
569
  {
575
  *
576
  * This method allows for compatibility with common interfaces.
577
  *
578
+ * @param string|Stringable $message The log message
579
+ * @param mixed[] $context The log context
580
  */
581
  public function error($message, array $context = []): void
582
  {
588
  *
589
  * This method allows for compatibility with common interfaces.
590
  *
591
+ * @param string|Stringable $message The log message
592
+ * @param mixed[] $context The log context
593
  */
594
  public function critical($message, array $context = []): void
595
  {
601
  *
602
  * This method allows for compatibility with common interfaces.
603
  *
604
+ * @param string|Stringable $message The log message
605
+ * @param mixed[] $context The log context
606
  */
607
  public function alert($message, array $context = []): void
608
  {
614
  *
615
  * This method allows for compatibility with common interfaces.
616
  *
617
+ * @param string|Stringable $message The log message
618
+ * @param mixed[] $context The log context
619
  */
620
  public function emergency($message, array $context = []): void
621
  {
vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php CHANGED
@@ -101,6 +101,7 @@ class IntrospectionProcessor implements ProcessorInterface
101
  'file' => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null,
102
  'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null,
103
  'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null,
 
104
  'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
105
  ]
106
  );
101
  'file' => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null,
102
  'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null,
103
  'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null,
104
+ 'callType' => isset($trace[$i]['type']) ? $trace[$i]['type'] : null,
105
  'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
106
  ]
107
  );
vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php CHANGED
@@ -36,11 +36,12 @@ class WebProcessor implements ProcessorInterface
36
  'http_method' => 'REQUEST_METHOD',
37
  'server' => 'SERVER_NAME',
38
  'referrer' => 'HTTP_REFERER',
 
39
  ];
40
 
41
  /**
42
  * @param array<string, mixed>|\ArrayAccess<string, mixed>|null $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data
43
- * @param array<string, string>|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer
44
  */
45
  public function __construct($serverData = null, array $extraFields = null)
46
  {
@@ -52,20 +53,23 @@ class WebProcessor implements ProcessorInterface
52
  throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
53
  }
54
 
 
55
  if (isset($this->serverData['UNIQUE_ID'])) {
56
  $this->extraFields['unique_id'] = 'UNIQUE_ID';
 
57
  }
58
 
59
- if (null !== $extraFields) {
60
- if (isset($extraFields[0])) {
61
- foreach (array_keys($this->extraFields) as $fieldName) {
62
- if (!in_array($fieldName, $extraFields)) {
63
- unset($this->extraFields[$fieldName]);
64
- }
 
65
  }
66
- } else {
67
- $this->extraFields = $extraFields;
68
  }
 
 
69
  }
70
  }
71
 
36
  'http_method' => 'REQUEST_METHOD',
37
  'server' => 'SERVER_NAME',
38
  'referrer' => 'HTTP_REFERER',
39
+ 'user_agent' => 'HTTP_USER_AGENT',
40
  ];
41
 
42
  /**
43
  * @param array<string, mixed>|\ArrayAccess<string, mixed>|null $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data
44
+ * @param array<string, string>|array<string>|null $extraFields Field names and the related key inside $serverData to be added (or just a list of field names to use the default configured $serverData mapping). If not provided it defaults to: [url, ip, http_method, server, referrer] + unique_id if present in server data
45
  */
46
  public function __construct($serverData = null, array $extraFields = null)
47
  {
53
  throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.');
54
  }
55
 
56
+ $defaultEnabled = ['url', 'ip', 'http_method', 'server', 'referrer'];
57
  if (isset($this->serverData['UNIQUE_ID'])) {
58
  $this->extraFields['unique_id'] = 'UNIQUE_ID';
59
+ $defaultEnabled[] = 'unique_id';
60
  }
61
 
62
+ if (null === $extraFields) {
63
+ $extraFields = $defaultEnabled;
64
+ }
65
+ if (isset($extraFields[0])) {
66
+ foreach (array_keys($this->extraFields) as $fieldName) {
67
+ if (!in_array($fieldName, $extraFields)) {
68
+ unset($this->extraFields[$fieldName]);
69
  }
 
 
70
  }
71
+ } else {
72
+ $this->extraFields = $extraFields;
73
  }
74
  }
75
 
vendor/monolog/monolog/src/Monolog/Test/TestCase.php CHANGED
@@ -25,6 +25,15 @@ use Monolog\Formatter\FormatterInterface;
25
  */
26
  class TestCase extends \PHPUnit\Framework\TestCase
27
  {
 
 
 
 
 
 
 
 
 
28
  /**
29
  * @param mixed[] $context
30
  *
25
  */
26
  class TestCase extends \PHPUnit\Framework\TestCase
27
  {
28
+ public function tearDown(): void
29
+ {
30
+ parent::tearDown();
31
+
32
+ if (isset($this->handler)) {
33
+ unset($this->handler);
34
+ }
35
+ }
36
+
37
  /**
38
  * @param mixed[] $context
39
  *
vendor/monolog/monolog/src/Monolog/Utils.php CHANGED
@@ -226,4 +226,59 @@ final class Utils
226
  );
227
  }
228
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  }
226
  );
227
  }
228
  }
229
+
230
+ /**
231
+ * Converts a string with a valid 'memory_limit' format, to bytes.
232
+ *
233
+ * @param string|false $val
234
+ * @return int|false Returns an integer representing bytes. Returns FALSE in case of error.
235
+ */
236
+ public static function expandIniShorthandBytes($val)
237
+ {
238
+ if (!is_string($val)) {
239
+ return false;
240
+ }
241
+
242
+ // support -1
243
+ if ((int) $val < 0) {
244
+ return (int) $val;
245
+ }
246
+
247
+ if (!preg_match('/^\s*(?<val>\d+)(?:\.\d+)?\s*(?<unit>[gmk]?)\s*$/i', $val, $match)) {
248
+ return false;
249
+ }
250
+
251
+ $val = (int) $match['val'];
252
+ switch (strtolower($match['unit'] ?? '')) {
253
+ case 'g':
254
+ $val *= 1024;
255
+ case 'm':
256
+ $val *= 1024;
257
+ case 'k':
258
+ $val *= 1024;
259
+ }
260
+
261
+ return $val;
262
+ }
263
+
264
+ /**
265
+ * @param array<mixed> $record
266
+ */
267
+ public static function getRecordMessageForException(array $record): string
268
+ {
269
+ $context = '';
270
+ $extra = '';
271
+ try {
272
+ if ($record['context']) {
273
+ $context = "\nContext: " . json_encode($record['context']);
274
+ }
275
+ if ($record['extra']) {
276
+ $extra = "\nExtra: " . json_encode($record['extra']);
277
+ }
278
+ } catch (\Throwable $e) {
279
+ // noop
280
+ }
281
+
282
+ return "\nThe exception occurred while attempting to log: " . $record['message'] . $context . $extra;
283
+ }
284
  }
vendor/paragonie/constant_time_encoding/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
  The MIT License (MIT)
2
 
3
- Copyright (c) 2016 - 2020 Paragon Initiative Enterprises
4
 
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
  of this software and associated documentation files (the "Software"), to deal
1
  The MIT License (MIT)
2
 
3
+ Copyright (c) 2016 - 2022 Paragon Initiative Enterprises
4
 
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
  of this software and associated documentation files (the "Software"), to deal
vendor/paragonie/constant_time_encoding/psalm.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0"?>
2
- <psalm
3
- useDocblockTypes="true"
4
- totallyTyped="true"
5
- >
6
- <projectFiles>
7
- <directory name="src" />
8
- </projectFiles>
9
- </psalm>
 
 
 
 
 
 
 
 
 
vendor/paragonie/constant_time_encoding/src/Base32.php CHANGED
@@ -60,13 +60,13 @@ abstract class Base32 implements EncoderInterface
60
  /**
61
  * Encode into Base32 (RFC 4648)
62
  *
63
- * @param string $src
64
  * @return string
65
  * @throws \TypeError
66
  */
67
- public static function encode(string $src): string
68
  {
69
- return static::doEncode($src, false, true);
70
  }
71
  /**
72
  * Encode into Base32 (RFC 4648)
@@ -367,7 +367,6 @@ abstract class Base32 implements EncoderInterface
367
  $err |= ($c0) >> 8;
368
  }
369
  }
370
- /** @var bool $check */
371
  $check = ($err === 0);
372
  if (!$check) {
373
  throw new \RangeException(
60
  /**
61
  * Encode into Base32 (RFC 4648)
62
  *
63
+ * @param string $binString
64
  * @return string
65
  * @throws \TypeError
66
  */
67
+ public static function encode(string $binString): string
68
  {
69
+ return static::doEncode($binString, false, true);
70
  }
71
  /**
72
  * Encode into Base32 (RFC 4648)
367
  $err |= ($c0) >> 8;
368
  }
369
  }
 
370
  $check = ($err === 0);
371
  if (!$check) {
372
  throw new \RangeException(
vendor/paragonie/constant_time_encoding/src/Base64.php CHANGED
@@ -38,13 +38,13 @@ abstract class Base64 implements EncoderInterface
38
  *
39
  * Base64 character set "[A-Z][a-z][0-9]+/"
40
  *
41
- * @param string $src
42
  * @return string
43
  * @throws \TypeError
44
  */
45
- public static function encode(string $src): string
46
  {
47
- return static::doEncode($src, true);
48
  }
49
 
50
  /**
@@ -196,11 +196,10 @@ abstract class Base64 implements EncoderInterface
196
  ((($c0 << 2) | ($c1 >> 4)) & 0xff)
197
  );
198
  $err |= ($c0 | $c1) >> 8;
199
- } elseif ($i < $srcLen && $strictPadding) {
200
  $err |= 1;
201
  }
202
  }
203
- /** @var bool $check */
204
  $check = ($err === 0);
205
  if (!$check) {
206
  throw new \RangeException(
38
  *
39
  * Base64 character set "[A-Z][a-z][0-9]+/"
40
  *
41
+ * @param string $binString
42
  * @return string
43
  * @throws \TypeError
44
  */
45
+ public static function encode(string $binString): string
46
  {
47
+ return static::doEncode($binString, true);
48
  }
49
 
50
  /**
196
  ((($c0 << 2) | ($c1 >> 4)) & 0xff)
197
  );
198
  $err |= ($c0 | $c1) >> 8;
199
+ } elseif ($strictPadding) {
200
  $err |= 1;
201
  }
202
  }
 
203
  $check = ($err === 0);
204
  if (!$check) {
205
  throw new \RangeException(
vendor/paragonie/constant_time_encoding/src/Binary.php CHANGED
@@ -46,6 +46,8 @@ abstract class Binary
46
  public static function safeStrlen(string $str): int
47
  {
48
  if (\function_exists('mb_strlen')) {
 
 
49
  return (int) \mb_strlen($str, '8bit');
50
  } else {
51
  return \strlen($str);
@@ -60,7 +62,7 @@ abstract class Binary
60
  * @staticvar boolean $exists
61
  * @param string $str
62
  * @param int $start
63
- * @param int $length
64
  * @return string
65
  * @throws \TypeError
66
  */
46
  public static function safeStrlen(string $str): int
47
  {
48
  if (\function_exists('mb_strlen')) {
49
+ // mb_strlen in PHP 7.x can return false.
50
+ /** @psalm-suppress RedundantCast */
51
  return (int) \mb_strlen($str, '8bit');
52
  } else {
53
  return \strlen($str);
62
  * @staticvar boolean $exists
63
  * @param string $str
64
  * @param int $start
65
+ * @param ?int $length
66
  * @return string
67
  * @throws \TypeError
68
  */
vendor/paragonie/constant_time_encoding/src/Hex.php CHANGED
@@ -41,15 +41,12 @@ abstract class Hex implements EncoderInterface
41
  */
42
  public static function encode(string $binString): string
43
  {
44
- /** @var string $hex */
45
  $hex = '';
46
  $len = Binary::safeStrlen($binString);
47
  for ($i = 0; $i < $len; ++$i) {
48
  /** @var array<int, int> $chunk */
49
  $chunk = \unpack('C', Binary::safeSubstr($binString, $i, 1));
50
- /** @var int $c */
51
  $c = $chunk[1] & 0xf;
52
- /** @var int $b */
53
  $b = $chunk[1] >> 4;
54
 
55
  $hex .= pack(
@@ -71,17 +68,13 @@ abstract class Hex implements EncoderInterface
71
  */
72
  public static function encodeUpper(string $binString): string
73
  {
74
- /** @var string $hex */
75
  $hex = '';
76
- /** @var int $len */
77
  $len = Binary::safeStrlen($binString);
78
 
79
  for ($i = 0; $i < $len; ++$i) {
80
  /** @var array<int, int> $chunk */
81
  $chunk = \unpack('C', Binary::safeSubstr($binString, $i, 2));
82
- /** @var int $c */
83
  $c = $chunk[1] & 0xf;
84
- /** @var int $b */
85
  $b = $chunk[1] >> 4;
86
 
87
  $hex .= pack(
@@ -104,15 +97,10 @@ abstract class Hex implements EncoderInterface
104
  */
105
  public static function decode(string $encodedString, bool $strictPadding = false): string
106
  {
107
- /** @var int $hex_pos */
108
  $hex_pos = 0;
109
- /** @var string $bin */
110
  $bin = '';
111
- /** @var int $c_acc */
112
  $c_acc = 0;
113
- /** @var int $hex_len */
114
  $hex_len = Binary::safeStrlen($encodedString);
115
- /** @var int $state */
116
  $state = 0;
117
  if (($hex_len & 1) !== 0) {
118
  if ($strictPadding) {
@@ -129,15 +117,10 @@ abstract class Hex implements EncoderInterface
129
  $chunk = \unpack('C*', $encodedString);
130
  while ($hex_pos < $hex_len) {
131
  ++$hex_pos;
132
- /** @var int $c */
133
  $c = $chunk[$hex_pos];
134
- /** @var int $c_num */
135
  $c_num = $c ^ 48;
136
- /** @var int $c_num0 */
137
  $c_num0 = ($c_num - 10) >> 8;
138
- /** @var int $c_alpha */
139
  $c_alpha = ($c & ~32) - 55;
140
- /** @var int $c_alpha0 */
141
  $c_alpha0 = (($c_alpha - 10) ^ ($c_alpha - 16)) >> 8;
142
 
143
  if (($c_num0 | $c_alpha0) === 0) {
@@ -145,7 +128,6 @@ abstract class Hex implements EncoderInterface
145
  'Expected hexadecimal character'
146
  );
147
  }
148
- /** @var int $c_val */
149
  $c_val = ($c_num0 & $c_num) | ($c_alpha & $c_alpha0);
150
  if ($state === 0) {
151
  $c_acc = $c_val * 16;
41
  */
42
  public static function encode(string $binString): string
43
  {
 
44
  $hex = '';
45
  $len = Binary::safeStrlen($binString);
46
  for ($i = 0; $i < $len; ++$i) {
47
  /** @var array<int, int> $chunk */
48
  $chunk = \unpack('C', Binary::safeSubstr($binString, $i, 1));
 
49
  $c = $chunk[1] & 0xf;
 
50
  $b = $chunk[1] >> 4;
51
 
52
  $hex .= pack(
68
  */
69
  public static function encodeUpper(string $binString): string
70
  {
 
71
  $hex = '';
 
72
  $len = Binary::safeStrlen($binString);
73
 
74
  for ($i = 0; $i < $len; ++$i) {
75
  /** @var array<int, int> $chunk */
76
  $chunk = \unpack('C', Binary::safeSubstr($binString, $i, 2));
 
77
  $c = $chunk[1] & 0xf;
 
78
  $b = $chunk[1] >> 4;
79
 
80
  $hex .= pack(
97
  */
98
  public static function decode(string $encodedString, bool $strictPadding = false): string
99
  {
 
100
  $hex_pos = 0;
 
101
  $bin = '';
 
102
  $c_acc = 0;
 
103
  $hex_len = Binary::safeStrlen($encodedString);
 
104
  $state = 0;
105
  if (($hex_len & 1) !== 0) {
106
  if ($strictPadding) {
117
  $chunk = \unpack('C*', $encodedString);
118
  while ($hex_pos < $hex_len) {
119
  ++$hex_pos;
 
120
  $c = $chunk[$hex_pos];
 
121
  $c_num = $c ^ 48;
 
122
  $c_num0 = ($c_num - 10) >> 8;
 
123
  $c_alpha = ($c & ~32) - 55;
 
124
  $c_alpha0 = (($c_alpha - 10) ^ ($c_alpha - 16)) >> 8;
125
 
126
  if (($c_num0 | $c_alpha0) === 0) {
128
  'Expected hexadecimal character'
129
  );
130
  }
 
131
  $c_val = ($c_num0 & $c_num) | ($c_alpha & $c_alpha0);
132
  if ($state === 0) {
133
  $c_acc = $c_val * 16;
vendor/paragonie/constant_time_encoding/tests/Base32HexTest.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- use \ParagonIE\ConstantTime\Base32Hex;
3
-
4
- class Base32HexTest extends PHPUnit\Framework\TestCase
5
- {
6
- /**
7
- * @covers Base32Hex::encode()
8
- * @covers Base32Hex::decode()
9
- * @covers Base32Hex::encodeUpper()
10
- * @covers Base32Hex::decodeUpper()
11
- */
12
- public function testRandom()
13
- {
14
- for ($i = 1; $i < 32; ++$i) {
15
- for ($j = 0; $j < 50; ++$j) {
16
- $random = \random_bytes($i);
17
-
18
- $enc = Base32Hex::encode($random);
19
- $this->assertSame(
20
- $random,
21
- Base32Hex::decode($enc)
22
- );
23
- $unpadded = \rtrim($enc, '=');
24
- $this->assertSame(
25
- $unpadded,
26
- Base32Hex::encodeUnpadded($random)
27
- );
28
- $this->assertSame(
29
- $random,
30
- Base32Hex::decode($unpadded)
31
- );
32
-
33
- $enc = Base32Hex::encodeUpper($random);
34
- $this->assertSame(
35
- $random,
36
- Base32Hex::decodeUpper($enc)
37
- ); $unpadded = \rtrim($enc, '=');
38
- $this->assertSame(
39
- $unpadded,
40
- Base32Hex::encodeUpperUnpadded($random)
41
- );
42
- $this->assertSame(
43
- $random,
44
- Base32Hex::decodeUpper($unpadded)
45
- );
46
- }
47
- }
48
- }
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/constant_time_encoding/tests/Base32Test.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- use \ParagonIE\ConstantTime\Base32;
3
-
4
- class Base32Test extends PHPUnit\Framework\TestCase
5
- {
6
- /**
7
- * @covers Base32::encode()
8
- * @covers Base32::decode()
9
- * @covers Base32::encodeUpper()
10
- * @covers Base32::decodeUpper()
11
- */
12
- public function testRandom()
13
- {
14
- for ($i = 1; $i < 32; ++$i) {
15
- for ($j = 0; $j < 50; ++$j) {
16
- $random = \random_bytes($i);
17
-
18
- $enc = Base32::encode($random);
19
- $this->assertSame(
20
- $random,
21
- Base32::decode($enc)
22
- );
23
- $unpadded = \rtrim($enc, '=');
24
- $this->assertSame(
25
- $unpadded,
26
- Base32::encodeUnpadded($random)
27
- );
28
- $this->assertSame(
29
- $random,
30
- Base32::decode($unpadded)
31
- );
32
-
33
- $enc = Base32::encodeUpper($random);
34
- $this->assertSame(
35
- $random,
36
- Base32::decodeUpper($enc)
37
- );
38
- $unpadded = \rtrim($enc, '=');
39
- $this->assertSame(
40
- $unpadded,
41
- Base32::encodeUpperUnpadded($random)
42
- );
43
- $this->assertSame(
44
- $random,
45
- Base32::decodeUpper($unpadded)
46
- );
47
- }
48
- }
49
- }
50
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/constant_time_encoding/tests/Base64DotSlashOrderedTest.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- use \ParagonIE\ConstantTime\Base64DotSlashOrdered;
3
-
4
- class Base64DotSlashOrderedTest extends PHPUnit\Framework\TestCase
5
- {
6
- /**
7
- * @covers Base64DotSlashOrdered::encode()
8
- * @covers Base64DotSlashOrdered::decode()
9
- */
10
- public function testRandom()
11
- {
12
- for ($i = 1; $i < 32; ++$i) {
13
- for ($j = 0; $j < 50; ++$j) {
14
- $random = \random_bytes($i);
15
-
16
- $enc = Base64DotSlashOrdered::encode($random);
17
- $this->assertSame(
18
- $random,
19
- Base64DotSlashOrdered::decode($enc)
20
- );
21
-
22
- $unpadded = \rtrim($enc, '=');
23
- $this->assertSame(
24
- $random,
25
- Base64DotSlashOrdered::decode($unpadded)
26
- );
27
- $this->assertSame(
28
- $random,
29
- Base64DotSlashOrdered::decode($unpadded)
30
- );
31
- }
32
- }
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/constant_time_encoding/tests/Base64DotSlashTest.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- use \ParagonIE\ConstantTime\Base64DotSlash;
3
-
4
- class Base64DotSlashTest extends PHPUnit\Framework\TestCase
5
- {
6
- /**
7
- * @covers Base64DotSlash::encode()
8
- * @covers Base64DotSlash::decode()
9
- */
10
- public function testRandom()
11
- {
12
- for ($i = 1; $i < 32; ++$i) {
13
- for ($j = 0; $j < 50; ++$j) {
14
- $random = \random_bytes($i);
15
-
16
- $enc = Base64DotSlash::encode($random);
17
- $this->assertSame(
18
- $random,
19
- Base64DotSlash::decode($enc)
20
- );
21
-
22
- $unpadded = \rtrim($enc, '=');
23
- $this->assertSame(
24
- $random,
25
- Base64DotSlash::decode($unpadded)
26
- );
27
- $this->assertSame(
28
- $random,
29
- Base64DotSlash::decode($unpadded)
30
- );
31
- }
32
- }
33
- }
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/constant_time_encoding/tests/Base64Test.php DELETED
@@ -1,79 +0,0 @@
1
- <?php
2
- use \ParagonIE\ConstantTime\Base64;
3
-
4
- class Base64Test extends PHPUnit\Framework\TestCase
5
- {
6
- /**
7
- * @covers Base64::encode()
8
- * @covers Base64::decode()
9
- */
10
- public function testRandom()
11
- {
12
- for ($i = 1; $i < 32; ++$i) {
13
- for ($j = 0; $j < 50; ++$j) {
14
- $random = \random_bytes($i);
15
-
16
- $enc = Base64::encode($random);
17
- $this->assertSame(
18
- $random,
19
- Base64::decode($enc)
20
- );
21
- $this->assertSame(
22
- \base64_encode($random),
23
- $enc
24
- );
25
-
26
- $unpadded = \rtrim($enc, '=');
27
- $this->assertSame(
28
- $random,
29
- Base64::decode($unpadded)
30
- );
31
- $this->assertSame(
32
- $random,
33
- Base64::decode($unpadded)
34
- );
35
- }
36
- }
37
- $str = 'MIIFzzCCBLegAwIBAgIDAfdlMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNVBAYTAlBM' .
38
- 'MSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMSQwIgYDVQQ' .
39
- 'DDBtDT1BFIFNaQUZJUiAtIEt3YWxpZmlrb3dhbnkxFDASBgNVBAUTC05yIHdwaXN1Oi' .
40
- 'A2MB4XDTExMTEwOTA2MDAwMFoXDTEzMTEwOTA2MDAwMFowgdkxCzAJBgNVBAYTAlBMM' .
41
- 'RwwGgYDVQQKDBNVcnrEhWQgTWlhc3RhIEdkeW5pMRswGQYDVQQFExJQRVNFTDogNjEw' .
42
- 'NjA2MDMxMTgxGTAXBgNVBAMMEEplcnp5IFByemV3b3Jza2kxTzBNBgNVBBAwRgwiQWw' .
43
- 'uIE1hcnN6YcWCa2EgUGnFgnN1ZHNraWVnbyA1Mi81NAwNODEtMzgyIEdkeW5pYQwGUG' .
44
- '9sc2thDAlwb21vcnNraWUxDjAMBgNVBCoMBUplcnp5MRMwEQYDVQQEDApQcnpld29yc' .
45
- '2tpMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMm5vjGqHPthJCMqKpqssSISRo' .
46
- 's0PYDTcEQzyyurfX67EJWKtZj6HNwuDMEGJ02iBNZfjUl7r8dIi28bSKhNlsfycXZKY' .
47
- 'RcIjp0+r5RqtR2auo9GQ6veKb61DEAGIqaR+uLLcJVTHCu0w9oXLGbRlGth5eNoj03C' .
48
- 'xXVAH2IfhbNwIDAQABo4IChzCCAoMwDAYDVR0TAQH/BAIwADCCAUgGA1UdIAEB/wSCA' .
49
- 'TwwggE4MIIBNAYJKoRoAYb3IwEBMIIBJTCB3QYIKwYBBQUHAgIwgdAMgc1EZWtsYXJh' .
50
- 'Y2phIHRhIGplc3Qgb8Wbd2lhZGN6ZW5pZW0gd3lkYXdjeSwgxbxlIHRlbiBjZXJ0eWZ' .
51
- 'pa2F0IHpvc3RhxYIgd3lkYW55IGpha28gY2VydHlmaWthdCBrd2FsaWZpa293YW55IH' .
52
- 'pnb2RuaWUgeiB3eW1hZ2FuaWFtaSB1c3Rhd3kgbyBwb2RwaXNpZSBlbGVrdHJvbmlje' .
53
- 'm55bSBvcmF6IHRvd2FyenlzesSFY3ltaSBqZWogcm96cG9yesSFZHplbmlhbWkuMEMG' .
54
- 'CCsGAQUFBwIBFjdodHRwOi8vd3d3Lmtpci5jb20ucGwvY2VydHlmaWthY2phX2tsdWN' .
55
- '6eS9wb2xpdHlrYS5odG1sMAkGA1UdCQQCMAAwIQYDVR0RBBowGIEWai5wcnpld29yc2' .
56
- 'tpQGdkeW5pYS5wbDAOBgNVHQ8BAf8EBAMCBkAwgZ4GA1UdIwSBljCBk4AU3TGldJXip' .
57
- 'N4oGS3ZYmnBDMFs8gKhd6R1MHMxCzAJBgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dh' .
58
- 'IEl6YmEgUm96bGljemVuaW93YSBTLkEuMSQwIgYDVQQDDBtDT1BFIFNaQUZJUiAtIEt' .
59
- '3YWxpZmlrb3dhbnkxFDASBgNVBAUTC05yIHdwaXN1OiA2ggJb9jBIBgNVHR8EQTA/MD' .
60
- '2gO6A5hjdodHRwOi8vd3d3Lmtpci5jb20ucGwvY2VydHlmaWthY2phX2tsdWN6eS9DU' .
61
- 'kxfT1pLMzIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQBYPIqnAreyeql7/opJjcar/qWZ' .
62
- 'y9ruhB2q0lZFsJOhwgMnbQXzp/4vv93YJqcHGAXdHP6EO8FQX47mjo2ZKQmi+cIHJHL' .
63
- 'ONdX/3Im+M17V0iNAh7Z1lOSfTRT+iiwe/F8phcEaD5q2RmvYusR7zXZq/cLL0If0hX' .
64
- 'oPZ/EHQxjN8pxzxiUx6bJAgturnIMEfRNesxwghdr1dkUjOhGLf3kHVzgM6j3VAM7oF' .
65
- 'mMUb5y5s96Bzl10DodWitjOEH0vvnIcsppSxH1C1dCAi0o9f/1y2XuLNhBNHMAyTqpY' .
66
- 'PX8Yvav1c+Z50OMaSXHAnTa20zv8UtiHbaAhwlifCelUMj93S';
67
-
68
- try {
69
- Base64::decode($str, true);
70
- $this->fail('Strict padding not enforced');
71
- } catch (\Exception $ex) {
72
-
73
- $this->assertSame(
74
- Base64::decode($str),
75
- \base64_decode($str)
76
- );
77
- }
78
- }
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/constant_time_encoding/tests/Base64UrlSafeTest.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
-
3
- use ParagonIE\ConstantTime\Base64UrlSafe;
4
- use ParagonIE\ConstantTime\Binary;
5
-
6
- /**
7
- * Class Base64UrlSafeTest
8
- */
9
- class Base64UrlSafeTest extends PHPUnit\Framework\TestCase
10
- {
11
- /**
12
- * @covers Base64UrlSafe::encode()
13
- * @covers Base64UrlSafe::decode()
14
- *
15
- * @throws Exception
16
- * @throws TypeError
17
- */
18
- public function testRandom()
19
- {
20
- for ($i = 1; $i < 32; ++$i) {
21
- for ($j = 0; $j < 50; ++$j) {
22
- $random = \random_bytes($i);
23
-
24
- $enc = Base64UrlSafe::encode($random);
25
- $this->assertSame(
26
- $random,
27
- Base64UrlSafe::decode($enc)
28
- );
29
- $this->assertSame(
30
- \strtr(\base64_encode($random), '+/', '-_'),
31
- $enc
32
- );
33
-
34
- $unpadded = \rtrim($enc, '=');
35
- $this->assertSame(
36
- $unpadded,
37
- Base64UrlSafe::encodeUnpadded($random)
38
- );
39
- $this->assertSame(
40
- $random,
41
- Base64UrlSafe::decode($unpadded)
42
- );
43
- }
44
- }
45
-
46
- $random = \random_bytes(1 << 20);
47
- $enc = Base64UrlSafe::encode($random);
48
- $this->assertTrue(Binary::safeStrlen($enc) > 65536);
49
- $this->assertSame(
50
- $random,
51
- Base64UrlSafe::decode($enc)
52
- );
53
- $this->assertSame(
54
- \strtr(\base64_encode($random), '+/', '-_'),
55
- $enc
56
- );
57
- }
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/constant_time_encoding/tests/EncodingTest.php DELETED
@@ -1,307 +0,0 @@
1
- <?php
2
- use \ParagonIE\ConstantTime\Base32;
3
- use \ParagonIE\ConstantTime\Base32Hex;
4
- use \ParagonIE\ConstantTime\Base64;
5
- use \ParagonIE\ConstantTime\Base64DotSlash;
6
- use \ParagonIE\ConstantTime\Base64DotSlashOrdered;
7
- use \ParagonIE\ConstantTime\Base64UrlSafe;
8
- use \ParagonIE\ConstantTime\Encoding;
9
- use \ParagonIE\ConstantTime\Hex;
10
-
11
- class EncodingTest extends PHPUnit\Framework\TestCase
12
- {
13
- public function testBase32Encode()
14
- {
15
- $this->assertSame(
16
- Encoding::base32Encode("\x00"),
17
- 'aa======'
18
- );
19
- $this->assertSame(
20
- Encoding::base32Encode("\x00\x00"),
21
- 'aaaa===='
22
- );
23
- $this->assertSame(
24
- Encoding::base32Encode("\x00\x00\x00"),
25
- 'aaaaa==='
26
- );
27
- $this->assertSame(
28
- Encoding::base32Encode("\x00\x00\x00\x00"),
29
- 'aaaaaaa='
30
- );
31
- $this->assertSame(
32
- Encoding::base32Encode("\x00\x00\x00\x00\x00"),
33
- 'aaaaaaaa'
34
- );
35
- $this->assertSame(
36
- Encoding::base32Encode("\x00\x00\x0F\xFF\xFF"),
37
- 'aaaa7777'
38
- );
39
- $this->assertSame(
40
- Encoding::base32Encode("\xFF\xFF\xF0\x00\x00"),
41
- '7777aaaa'
42
- );
43
-
44
- $this->assertSame(
45
- Encoding::base32Encode("\xce\x73\x9c\xe7\x39"),
46
- 'zzzzzzzz'
47
- );
48
- $this->assertSame(
49
- Encoding::base32Encode("\xd6\xb5\xad\x6b\x5a"),
50
- '22222222'
51
- );
52
- $this->assertSame(
53
- Base32::encodeUpper("\x00"),
54
- 'AA======'
55
- );
56
- $this->assertSame(
57
- Base32::encodeUpper("\x00\x00"),
58
- 'AAAA===='
59
- );
60
- $this->assertSame(
61
- Base32::encodeUpper("\x00\x00\x00"),
62
- 'AAAAA==='
63
- );
64
- $this->assertSame(
65
- Base32::encodeUpper("\x00\x00\x00\x00"),
66
- 'AAAAAAA='
67
- );
68
- $this->assertSame(
69
- Base32::encodeUpper("\x00\x00\x00\x00\x00"),
70
- 'AAAAAAAA'
71
- );
72
- $this->assertSame(
73
- Base32::encodeUpper("\x00\x00\x0F\xFF\xFF"),
74
- 'AAAA7777'
75
- );
76
- $this->assertSame(
77
- Base32::encodeUpper("\xFF\xFF\xF0\x00\x00"),
78
- '7777AAAA'
79
- );
80
-
81
- $this->assertSame(
82
- Base32::encodeUpper("\xce\x73\x9c\xe7\x39"),
83
- 'ZZZZZZZZ'
84
- );
85
- $this->assertSame(
86
- Base32::encodeUpper("\xd6\xb5\xad\x6b\x5a"),
87
- '22222222'
88
- );
89
- }
90
-
91
- public function testBase32Hex()
92
- {
93
- $this->assertSame(
94
- Base32Hex::encode("\x00"),
95
- '00======'
96
- );
97
- $this->assertSame(
98
- Base32Hex::encode("\x00\x00"),
99
- '0000===='
100
- );
101
- $this->assertSame(
102
- Base32Hex::encode("\x00\x00\x00"),
103
- '00000==='
104
- );
105
- $this->assertSame(
106
- Base32Hex::encode("\x00\x00\x00\x00"),
107
- '0000000='
108
- );
109
- $this->assertSame(
110
- Base32Hex::encode("\x00\x00\x00\x00\x00"),
111
- '00000000'
112
- );
113
- $this->assertSame(
114
- Base32Hex::encode("\x00\x00\x0F\xFF\xFF"),
115
- '0000vvvv'
116
- );
117
- $this->assertSame(
118
- Base32Hex::encode("\xFF\xFF\xF0\x00\x00"),
119
- 'vvvv0000'
120
- );
121
-
122
-
123
- }
124
-
125
- /**
126
- * Based on test vectors from RFC 4648
127
- */
128
- public function testBase32Decode()
129
- {
130
- $this->assertSame(
131
- "\x00\x00\x00\x00\x00\x00",
132
- Encoding::base32Decode('aaaaaaaaaa======')
133
- );
134
- $this->assertSame(
135
- "\x00\x00\x00\x00\x00\x00\x00",
136
- Encoding::base32Decode('aaaaaaaaaaaa====')
137
- );
138
- $this->assertSame(
139
- "\x00\x00\x00\x00\x00\x00\x00\x00",
140
- Encoding::base32Decode('aaaaaaaaaaaaa===')
141
- );
142
- $this->assertSame(
143
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00",
144
- Encoding::base32Decode('aaaaaaaaaaaaaaa=')
145
- );
146
- $this->assertSame(
147
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
148
- Encoding::base32Decode('aaaaaaaaaaaaaaaa')
149
- );
150
- $this->assertSame(
151
- "\x00",
152
- Encoding::base32Decode('aa======')
153
- );
154
- $this->assertSame(
155
- "\x00\x00",
156
- Encoding::base32Decode('aaaa====')
157
- );
158
- $this->assertSame(
159
- "\x00\x00\x00",
160
- Encoding::base32Decode('aaaaa===')
161
- );
162
- $this->assertSame(
163
- "\x00\x00\x00\x00",
164
- Encoding::base32Decode('aaaaaaa=')
165
- );
166
- $this->assertSame(
167
- "\x00\x00\x00\x00\x00",
168
- Encoding::base32Decode('aaaaaaaa')
169
- );
170
- $this->assertSame(
171
- "\x00\x00\x0F\xFF\xFF",
172
- Encoding::base32Decode('aaaa7777')
173
- );
174
- $this->assertSame(
175
- "\xFF\xFF\xF0\x00\x00",
176
- Encoding::base32Decode('7777aaaa')
177
- );
178
- $this->assertSame(
179
- "\xce\x73\x9c\xe7\x39",
180
- Encoding::base32Decode('zzzzzzzz')
181
- );
182
- $this->assertSame(
183
- "\xd6\xb5\xad\x6b\x5a",
184
- Encoding::base32Decode('22222222')
185
- );
186
- $this->assertSame(
187
- 'foobar',
188
- Encoding::base32Decode('mzxw6ytboi======')
189
- );
190
-
191
- $rand = random_bytes(9);
192
- $enc = Encoding::base32Encode($rand);
193
-
194
- $this->assertSame(
195
- Encoding::base32Encode($rand),
196
- Encoding::base32Encode(Encoding::base32Decode($enc))
197
- );
198
- $this->assertSame(
199
- $rand,
200
- Encoding::base32Decode($enc)
201
- );
202
- }
203
-
204
- /**
205
- * @covers Encoding::hexDecode()
206
- * @covers Encoding::hexEncode()
207
- * @covers Encoding::base32Decode()
208
- * @covers Encoding::base32Encode()
209
- * @covers Encoding::base64Decode()
210
- * @covers Encoding::base64Encode()
211
- * @covers Encoding::base64DotSlashDecode()
212
- * @covers Encoding::base64DotSlashEncode()
213
- * @covers Encoding::base64DotSlashOrderedDecode()
214
- * @covers Encoding::base64DotSlashOrderedEncode()
215
- */
216
- public function testBasicEncoding()
217
- {
218
- // Re-run the test at least 3 times for each length
219
- for ($j = 0; $j < 3; ++$j) {
220
- for ($i = 1; $i < 84; ++$i) {
221
- $rand = random_bytes($i);
222
- $enc = Encoding::hexEncode($rand);
223
- $this->assertSame(
224
- \bin2hex($rand),
225
- $enc,
226
- "Hex Encoding - Length: " . $i
227
- );
228
- $this->assertSame(
229
- $rand,
230
- Encoding::hexDecode($enc),
231
- "Hex Encoding - Length: " . $i
232
- );
233
-
234
- // Uppercase variant:
235
- $enc = Hex::encodeUpper($rand);
236
- $this->assertSame(
237
- \strtoupper(\bin2hex($rand)),
238
- $enc,
239
- "Hex Encoding - Length: " . $i
240
- );
241
- $this->assertSame(
242
- $rand,
243
- Hex::decode($enc),
244
- "HexUpper Encoding - Length: " . $i
245
- );
246
-
247
- $enc = Encoding::base32Encode($rand);
248
- $this->assertSame(
249
- $rand,
250
- Encoding::base32Decode($enc),
251
- "Base32 Encoding - Length: " . $i
252
- );
253
-
254
- $enc = Encoding::base32EncodeUpper($rand);
255
- $this->assertSame(
256
- $rand,
257
- Encoding::base32DecodeUpper($enc),
258
- "Base32Upper Encoding - Length: " . $i
259
- );
260
-
261
- $enc = Encoding::base32HexEncode($rand);
262
- $this->assertSame(
263
- bin2hex($rand),
264
- bin2hex(Encoding::base32HexDecode($enc)),
265
- "Base32Hex Encoding - Length: " . $i
266
- );
267
-
268
- $enc = Encoding::base32HexEncodeUpper($rand);
269
- $this->assertSame(
270
- bin2hex($rand),
271
- bin2hex(Encoding::base32HexDecodeUpper($enc)),
272
- "Base32HexUpper Encoding - Length: " . $i
273
- );
274
-
275
- $enc = Encoding::base64Encode($rand);
276
- $this->assertSame(
277
- $rand,
278
- Encoding::base64Decode($enc),
279
- "Base64 Encoding - Length: " . $i
280
- );
281
-
282
- $enc = Encoding::base64EncodeDotSlash($rand);
283
- $this->assertSame(
284
- $rand,
285
- Encoding::base64DecodeDotSlash($enc),
286
- "Base64 DotSlash Encoding - Length: " . $i
287
- );
288
- $enc = Encoding::base64EncodeDotSlashOrdered($rand);
289
- $this->assertSame(
290
- $rand,
291
- Encoding::base64DecodeDotSlashOrdered($enc),
292
- "Base64 Ordered DotSlash Encoding - Length: " . $i
293
- );
294
-
295
- $enc = Base64UrlSafe::encode($rand);
296
- $this->assertSame(
297
- \strtr(\base64_encode($rand), '+/', '-_'),
298
- $enc
299
- );
300
- $this->assertSame(
301
- $rand,
302
- Base64UrlSafe::decode($enc)
303
- );
304
- }
305
- }
306
- }
307
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/constant_time_encoding/tests/HexTest.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- use \ParagonIE\ConstantTime\Hex;
3
-
4
- class HexTest extends PHPUnit\Framework\TestCase
5
- {
6
- /**
7
- * @covers Hex::encode()
8
- * @covers Hex::decode()
9
- * @covers Hex::encodeUpper()
10
- */
11
- public function testRandom()
12
- {
13
- for ($i = 1; $i < 32; ++$i) {
14
- for ($j = 0; $j < 50; ++$j) {
15
- $random = \random_bytes($i);
16
-
17
- $enc = Hex::encode($random);
18
- $this->assertSame(
19
- $random,
20
- Hex::decode($enc)
21
- );
22
- $this->assertSame(
23
- \bin2hex($random),
24
- $enc
25
- );
26
-
27
- $enc = Hex::encodeUpper($random);
28
- $this->assertSame(
29
- $random,
30
- Hex::decode($enc)
31
- );
32
- $this->assertSame(
33
- \strtoupper(\bin2hex($random)),
34
- $enc
35
- );
36
- }
37
- }
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/paragonie/constant_time_encoding/tests/RFC4648Test.php DELETED
@@ -1,84 +0,0 @@
1
- <?php
2
- use \ParagonIE\ConstantTime\Base32;
3
- use \ParagonIE\ConstantTime\Base32Hex;
4
- use \ParagonIE\ConstantTime\Base64;
5
- use \ParagonIE\ConstantTime\Base64DotSlash;
6
- use \ParagonIE\ConstantTime\Base64DotSlashOrdered;
7
- use \ParagonIE\ConstantTime\Encoding;
8
- use \ParagonIE\ConstantTime\Hex;
9
-
10
- /**
11
- * Class RFC4648Test
12
- *
13
- * @ref https://tools.ietf.org/html/rfc4648#section-10
14
- */
15
- class RFC4648Test extends PHPUnit\Framework\TestCase
16
- {
17
- public function testVectorBase64()
18
- {
19
- $this->assertSame(Base64::encode(''), '');
20
- $this->assertSame(Base64::encode('f'), 'Zg==');
21
- $this->assertSame(Base64::encode('fo'), 'Zm8=');
22
- $this->assertSame(Base64::encode('foo'), 'Zm9v');
23
- $this->assertSame(Base64::encode('foob'), 'Zm9vYg==');
24
- $this->assertSame(Base64::encode('fooba'), 'Zm9vYmE=');
25
- $this->assertSame(Base64::encode('foobar'), 'Zm9vYmFy');
26
- }
27
-
28
- public function testVectorBase32()
29
- {
30
- $this->assertSame(Base32::encode(''), '');
31
- $this->assertSame(Base32::encode('f'), 'my======');
32
- $this->assertSame(Base32::encode('fo'), 'mzxq====');
33
- $this->assertSame(Base32::encode('foo'), 'mzxw6===');
34
- $this->assertSame(Base32::encode('foob'), 'mzxw6yq=');
35
- $this->assertSame(Base32::encode('fooba'), 'mzxw6ytb');
36
- $this->assertSame(Base32::encode('foobar'), 'mzxw6ytboi======');
37
-
38
- $this->assertSame(Base32::encodeUpper(''), '');
39
- $this->assertSame(Base32::encodeUpper('f'), 'MY======');
40
- $this->assertSame(Base32::encodeUpper('fo'), 'MZXQ====');
41
- $this->assertSame(Base32::encodeUpper('foo'), 'MZXW6===');
42
- $this->assertSame(Base32::encodeUpper('foob'), 'MZXW6YQ=');
43
- $this->assertSame(Base32::encodeUpper('fooba'), 'MZXW6YTB');
44
- $this->assertSame(Base32::encodeUpper('foobar'), 'MZXW6YTBOI======');
45
- }
46
-
47
- public function testVectorBase32Hex()
48
- {
49
- $this->assertSame(Base32Hex::encode(''), '');
50
- $this->assertSame(Base32Hex::encode('f'), 'co======');
51
- $this->assertSame(Base32Hex::encode('fo'), 'cpng====');
52
- $this->assertSame(Base32Hex::encode('foo'), 'cpnmu===');
53
- $this->assertSame(Base32Hex::encode('foob'), 'cpnmuog=');
54
- $this->assertSame(Base32Hex::encode('fooba'), 'cpnmuoj1');
55
- $this->assertSame(Base32Hex::encode('foobar'), 'cpnmuoj1e8======');
56
-
57
- $this->assertSame(Base32Hex::encodeUpper(''), '');
58
- $this->assertSame(Base32Hex::encodeUpper('f'), 'CO======');
59
- $this->assertSame(Base32Hex::encodeUpper('fo'), 'CPNG====');
60
- $this->assertSame(Base32Hex::encodeUpper('foo'), 'CPNMU===');
61
- $this->assertSame(Base32Hex::encodeUpper('foob'), 'CPNMUOG=');
62
- $this->assertSame(Base32Hex::encodeUpper('fooba'), 'CPNMUOJ1');
63
- $this->assertSame(Base32Hex::encodeUpper('foobar'), 'CPNMUOJ1E8======');
64
- }
65
-
66
- public function testVectorBase16()
67
- {
68
- $this->assertSame(Hex::encode(''), '');
69
- $this->assertSame(Hex::encode('f'), '66');
70
- $this->assertSame(Hex::encode('fo'), '666f');
71
- $this->assertSame(Hex::encode('foo'), '666f6f');
72
- $this->assertSame(Hex::encode('foob'), '666f6f62');
73
- $this->assertSame(Hex::encode('fooba'), '666f6f6261');
74
- $this->assertSame(Hex::encode('foobar'), '666f6f626172');
75
-
76
- $this->assertSame(Hex::encodeUpper(''), '');
77
- $this->assertSame(Hex::encodeUpper('f'), '66');
78
- $this->assertSame(Hex::encodeUpper('fo'), '666F');
79
- $this->assertSame(Hex::encodeUpper('foo'), '666F6F');
80
- $this->assertSame(Hex::encodeUpper('foob'), '666F6F62');
81
- $this->assertSame(Hex::encodeUpper('fooba'), '666F6F6261');
82
- $this->assertSame(Hex::encodeUpper('foobar'), '666F6F626172');
83
- }
84
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpseclib/phpseclib/appveyor.yml DELETED
@@ -1,27 +0,0 @@
1
- build: false
2
- shallow_clone: false
3
- platform:
4
- - x86
5
- - x64
6
- clone_folder: C:\projects\phpseclib
7
-
8
- install:
9
- - cinst -y OpenSSL.Light
10
- - SET PATH=C:\Program Files\OpenSSL;%PATH%
11
- - sc config wuauserv start= auto
12
- - net start wuauserv
13
- - cinst -y php --version 5.6.30
14
- - cd c:\tools\php56
15
- - copy php.ini-production php.ini
16
- - echo date.timezone="UTC" >> php.ini
17
- - echo extension_dir=ext >> php.ini
18
- - echo extension=php_openssl.dll >> php.ini
19
- - echo extension=php_gmp.dll >> php.ini
20
- - cd C:\projects\phpseclib
21
- - SET PATH=C:\tools\php56;%PATH%
22
- - php.exe -r "readfile('http://getcomposer.org/installer');" | php.exe
23
- - php.exe composer.phar install --prefer-source --no-interaction
24
-
25
- test_script:
26
- - cd C:\projects\phpseclib
27
- - vendor\bin\phpunit.bat tests/Windows32Test.php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/phpseclib/phpseclib/phpseclib/Common/Functions/Strings.php CHANGED
@@ -70,6 +70,7 @@ abstract class Strings
70
  * C = byte
71
  * b = boolean (true/false)
72
  * N = uint32
 
73
  * s = string
74
  * i = mpint
75
  * L = name-list
@@ -100,6 +101,12 @@ abstract class Strings
100
  throw new \LengthException('At least four byte needs to be present for successful N / i / s / L decodes');
101
  }
102
  break;
 
 
 
 
 
 
103
  default:
104
  throw new \InvalidArgumentException('$format contains an invalid character');
105
  }
@@ -114,6 +121,19 @@ abstract class Strings
114
  list(, $temp) = unpack('N', self::shift($data, 4));
115
  $result[] = $temp;
116
  continue 2;
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  }
118
  list(, $length) = unpack('N', self::shift($data, 4));
119
  if (strlen($data) < $length) {
@@ -138,14 +158,14 @@ abstract class Strings
138
  /**
139
  * Create SSH2-style string
140
  *
141
- * @param string[] ...$elements
 
142
  * @access public
143
- * @return mixed
144
  */
145
- public static function packSSH2(...$elements)
146
  {
147
- $format = self::formatPack($elements[0]);
148
- array_shift($elements);
149
  if (strlen($format) != count($elements)) {
150
  throw new \InvalidArgumentException('There must be as many arguments as there are characters in the $format string');
151
  }
@@ -157,13 +177,20 @@ abstract class Strings
157
  if (!is_int($element)) {
158
  throw new \InvalidArgumentException('Bytes must be represented as an integer between 0 and 255, inclusive.');
159
  }
160
- $result.= pack('C', $element);
161
  break;
162
  case 'b':
163
  if (!is_bool($element)) {
164
  throw new \InvalidArgumentException('A boolean parameter was expected.');
165
  }
166
- $result.= $element ? "\1" : "\0";
 
 
 
 
 
 
 
167
  break;
168
  case 'N':
169
  if (is_float($element)) {
@@ -172,27 +199,27 @@ abstract class Strings
172
  if (!is_int($element)) {
173
  throw new \InvalidArgumentException('An integer was expected.');
174
  }
175
- $result.= pack('N', $element);
176
  break;
177
  case 's':
178
  if (!self::is_stringable($element)) {
179
  throw new \InvalidArgumentException('A string was expected.');
180
  }
181
- $result.= pack('Na*', strlen($element), $element);
182
  break;
183
  case 'i':
184
  if (!$element instanceof BigInteger && !$element instanceof FiniteField\Integer) {
185
  throw new \InvalidArgumentException('A phpseclib3\Math\BigInteger or phpseclib3\Math\Common\FiniteField\Integer object was expected.');
186
  }
187
  $element = $element->toBytes(true);
188
- $result.= pack('Na*', strlen($element), $element);
189
  break;
190
  case 'L':
191
  if (!is_array($element)) {
192
  throw new \InvalidArgumentException('An array was expected.');
193
  }
194
  $element = implode(',', $element);
195
- $result.= pack('Na*', strlen($element), $element);
196
  break;
197
  default:
198
  throw new \InvalidArgumentException('$format contains an invalid character');
@@ -214,10 +241,10 @@ abstract class Strings
214
  {
215
  $parts = preg_split('#(\d+)#', $format, -1, PREG_SPLIT_DELIM_CAPTURE);
216
  $format = '';
217
- for ($i = 1; $i < count($parts); $i+=2) {
218
- $format.= substr($parts[$i - 1], 0, -1) . str_repeat(substr($parts[$i - 1], -1), $parts[$i]);
219
  }
220
- $format.= $parts[$i - 1];
221
 
222
  return $format;
223
  }
@@ -266,7 +293,7 @@ abstract class Strings
266
  foreach ($parts as $part) {
267
  $xor = $part[0] == '1' ? PHP_INT_MIN : 0;
268
  $part[0] = '0';
269
- $str.= pack(
270
  PHP_INT_SIZE == 4 ? 'N' : 'J',
271
  $xor ^ eval('return 0b' . $part . ';')
272
  );
@@ -281,7 +308,7 @@ abstract class Strings
281
  * @param string $x
282
  * @return string
283
  */
284
- public static function bin2bits($x)
285
  {
286
  /*
287
  // the pure-PHP approach is slower than the GMP approach BUT
@@ -301,16 +328,16 @@ abstract class Strings
301
  if (PHP_INT_SIZE == 4) {
302
  $digits = unpack('N*', $x);
303
  foreach ($digits as $digit) {
304
- $bits.= sprintf('%032b', $digit);
305
  }
306
  } else {
307
  $digits = unpack('J*', $x);
308
  foreach ($digits as $digit) {
309
- $bits.= sprintf('%064b', $digit);
310
  }
311
  }
312
 
313
- return ltrim($bits, '0');
314
  }
315
 
316
  /**
@@ -323,14 +350,21 @@ abstract class Strings
323
  public static function switchEndianness($x)
324
  {
325
  $r = '';
326
- // from http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits
327
  for ($i = strlen($x) - 1; $i >= 0; $i--) {
328
  $b = ord($x[$i]);
329
- $p1 = ($b * 0x0802) & 0x22110;
330
- $p2 = ($b * 0x8020) & 0x88440;
331
- $r.= chr(
332
- (($p1 | $p2) * 0x10101) >> 16
333
- );
 
 
 
 
 
 
 
 
334
  }
335
  return $r;
336
  }
@@ -344,7 +378,14 @@ abstract class Strings
344
  */
345
  public static function increment_str(&$var)
346
  {
347
- for ($i = 4; $i <= strlen($var); $i+= 4) {
 
 
 
 
 
 
 
348
  $temp = substr($var, -$i, 4);
349
  switch ($temp) {
350
  case "\xFF\xFF\xFF\xFF":
@@ -376,9 +417,9 @@ abstract class Strings
376
  /**
377
  * Find whether the type of a variable is string (or could be converted to one)
378
  *
379
- * @param string|object $var
380
- * @return boolean
381
- * @access public
382
  */
383
  public static function is_stringable($var)
384
  {
70
  * C = byte
71
  * b = boolean (true/false)
72
  * N = uint32
73
+ * Q = uint64
74
  * s = string
75
  * i = mpint
76
  * L = name-list
101
  throw new \LengthException('At least four byte needs to be present for successful N / i / s / L decodes');
102
  }
103
  break;
104
+ case 'Q':
105
+ if (strlen($data) < 8) {
106
+ throw new \LengthException('At least eight byte needs to be present for successful N / i / s / L decodes');
107
+ }
108
+ break;
109
+
110
  default:
111
  throw new \InvalidArgumentException('$format contains an invalid character');
112
  }
121
  list(, $temp) = unpack('N', self::shift($data, 4));
122
  $result[] = $temp;
123
  continue 2;
124
+ case 'Q':
125
+ // pack() added support for Q in PHP 5.6.3 and PHP 5.6 is phpseclib 3's minimum version
126
+ // so in theory we could support this BUT, "64-bit format codes are not available for
127
+ // 32-bit versions" and phpseclib works on 32-bit installs. on 32-bit installs
128
+ // 64-bit floats can be used to get larger numbers then 32-bit signed ints would allow
129
+ // for. sure, you're not gonna get the full precision of 64-bit numbers but just because
130
+ // you need > 32-bit precision doesn't mean you need the full 64-bit precision
131
+ extract(unpack('Nupper/Nlower', self::shift($data, 8)));
132
+ $temp = $upper ? 4294967296 * $upper : 0;
133
+ $temp += $lower < 0 ? ($lower & 0x7FFFFFFFF) + 0x80000000 : $lower;
134
+ // $temp = hexdec(bin2hex(self::shift($data, 8)));
135
+ $result[] = $temp;
136
+ continue 2;
137
  }
138
  list(, $length) = unpack('N', self::shift($data, 4));
139
  if (strlen($data) < $length) {
158
  /**
159
  * Create SSH2-style string
160
  *
161
+ * @param string $format
162
+ * @param string|int|float|array|bool ...$elements
163
  * @access public
164
+ * @return string
165
  */
166
+ public static function packSSH2($format, ...$elements)
167
  {
168
+ $format = self::formatPack($format);
 
169
  if (strlen($format) != count($elements)) {
170
  throw new \InvalidArgumentException('There must be as many arguments as there are characters in the $format string');
171
  }
177
  if (!is_int($element)) {
178
  throw new \InvalidArgumentException('Bytes must be represented as an integer between 0 and 255, inclusive.');
179
  }
180
+ $result .= pack('C', $element);
181
  break;
182
  case 'b':
183
  if (!is_bool($element)) {
184
  throw new \InvalidArgumentException('A boolean parameter was expected.');
185
  }
186
+ $result .= $element ? "\1" : "\0";
187
+ break;
188
+ case 'Q':
189
+ if (!is_int($element) && !is_float($element)) {
190
+ throw new \InvalidArgumentException('An integer was expected.');
191
+ }
192
+ // 4294967296 == 1 << 32
193
+ $result .= pack('NN', $element / 4294967296, $element);
194
  break;
195
  case 'N':
196
  if (is_float($element)) {
199
  if (!is_int($element)) {
200
  throw new \InvalidArgumentException('An integer was expected.');
201
  }
202
+ $result .= pack('N', $element);
203
  break;
204
  case 's':
205
  if (!self::is_stringable($element)) {
206
  throw new \InvalidArgumentException('A string was expected.');
207
  }
208
+ $result .= pack('Na*', strlen($element), $element);
209
  break;
210
  case 'i':
211
  if (!$element instanceof BigInteger && !$element instanceof FiniteField\Integer) {
212
  throw new \InvalidArgumentException('A phpseclib3\Math\BigInteger or phpseclib3\Math\Common\FiniteField\Integer object was expected.');
213
  }
214
  $element = $element->toBytes(true);
215
+ $result .= pack('Na*', strlen($element), $element);
216
  break;
217
  case 'L':
218
  if (!is_array($element)) {
219
  throw new \InvalidArgumentException('An array was expected.');
220
  }
221
  $element = implode(',', $element);
222
+ $result .= pack('Na*', strlen($element), $element);
223
  break;
224
  default:
225
  throw new \InvalidArgumentException('$format contains an invalid character');
241
  {
242
  $parts = preg_split('#(\d+)#', $format, -1, PREG_SPLIT_DELIM_CAPTURE);
243
  $format = '';
244
+ for ($i = 1; $i < count($parts); $i += 2) {
245
+ $format .= substr($parts[$i - 1], 0, -1) . str_repeat(substr($parts[$i - 1], -1), $parts[$i]);
246
  }
247
+ $format .= $parts[$i - 1];
248
 
249
  return $format;
250
  }
293
  foreach ($parts as $part) {
294
  $xor = $part[0] == '1' ? PHP_INT_MIN : 0;
295
  $part[0] = '0';
296
+ $str .= pack(
297
  PHP_INT_SIZE == 4 ? 'N' : 'J',
298
  $xor ^ eval('return 0b' . $part . ';')
299
  );
308
  * @param string $x
309
  * @return string
310
  */
311
+ public static function bin2bits($x, $trim = true)
312
  {
313
  /*
314
  // the pure-PHP approach is slower than the GMP approach BUT
328
  if (PHP_INT_SIZE == 4) {
329
  $digits = unpack('N*', $x);
330
  foreach ($digits as $digit) {
331
+ $bits .= sprintf('%032b', $digit);
332
  }
333
  } else {
334
  $digits = unpack('J*', $x);
335
  foreach ($digits as $digit) {
336
+ $bits .= sprintf('%064b', $digit);
337
  }
338
  }
339
 
340
+ return $trim ? ltrim($bits, '0') : $bits;
341
  }
342
 
343
  /**
350
  public static function switchEndianness($x)
351
  {
352
  $r = '';
 
353
  for ($i = strlen($x) - 1; $i >= 0; $i--) {
354
  $b = ord($x[$i]);
355
+ if (PHP_INT_SIZE === 8) {
356
+ // 3 operations
357
+ // from http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith64BitsDiv
358
+ $r .= chr((($b * 0x0202020202) & 0x010884422010) % 1023);
359
+ } else {
360
+ // 7 operations
361
+ // from http://graphics.stanford.edu/~seander/bithacks.html#ReverseByteWith32Bits
362
+ $p1 = ($b * 0x0802) & 0x22110;
363
+ $p2 = ($b * 0x8020) & 0x88440;
364
+ $r .= chr(
365
+ (($p1 | $p2) * 0x10101) >> 16
366
+ );
367
+ }
368
  }
369
  return $r;
370
  }
378
  */
379
  public static function increment_str(&$var)
380
  {
381
+ if (function_exists('sodium_increment')) {
382
+ $var = strrev($var);
383
+ sodium_increment($var);
384
+ $var = strrev($var);
385
+ return $var;
386
+ }
387
+
388
+ for ($i = 4; $i <= strlen($var); $i += 4) {
389
  $temp = substr($var, -$i, 4);
390
  switch ($temp) {
391
  case "\xFF\xFF\xFF\xFF":
417
  /**
418
  * Find whether the type of a variable is string (or could be converted to one)
419
  *
420
+ * @param mixed $var
421
+ * @return bool
422
+ * @psalm-assert-if-true string|\Stringable $var
423
  */
424
  public static function is_stringable($var)
425
  {
vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php CHANGED
@@ -422,14 +422,14 @@ class Blowfish extends BlockCipher
422
  $l = $in[1];
423
  $r = $in[2];
424
 
425
- for ($i = 0; $i < 16; $i+= 2) {
426
- $l^= $p[$i];
427
- $r^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^
428
  $sb_2[$l >> 8 & 0xff]) +
429
  $sb_3[$l & 0xff]);
430
 
431
- $r^= $p[$i + 1];
432
- $l^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^
433
  $sb_2[$r >> 8 & 0xff]) +
434
  $sb_3[$r & 0xff]);
435
  }
@@ -455,14 +455,14 @@ class Blowfish extends BlockCipher
455
  $l = $in[1];
456
  $r = $in[2];
457
 
458
- for ($i = 17; $i > 2; $i-= 2) {
459
- $l^= $p[$i];
460
- $r^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^
461
  $sb_2[$l >> 8 & 0xff]) +
462
  $sb_3[$l & 0xff]);
463
 
464
- $r^= $p[$i - 1];
465
- $l^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^
466
  $sb_2[$r >> 8 & 0xff]) +
467
  $sb_3[$r & 0xff]);
468
  }
@@ -496,8 +496,8 @@ class Blowfish extends BlockCipher
496
  $l = $in[1];
497
  $r = $in[2];
498
  ';
499
- for ($i = 0; $i < 16; $i+= 2) {
500
- $encrypt_block.= '
501
  $l^= ' . $p[$i] . ';
502
  $r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^
503
  $sb_2[$l >> 8 & 0xff]) +
@@ -509,7 +509,7 @@ class Blowfish extends BlockCipher
509
  $sb_3[$r & 0xff]') . ';
510
  ';
511
  }
512
- $encrypt_block.= '
513
  $in = pack("N*",
514
  $r ^ ' . $p[17] . ',
515
  $l ^ ' . $p[16] . '
@@ -522,8 +522,8 @@ class Blowfish extends BlockCipher
522
  $r = $in[2];
523
  ';
524
 
525
- for ($i = 17; $i > 2; $i-= 2) {
526
- $decrypt_block.= '
527
  $l^= ' . $p[$i] . ';
528
  $r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^
529
  $sb_2[$l >> 8 & 0xff]) +
@@ -536,7 +536,7 @@ class Blowfish extends BlockCipher
536
  ';
537
  }
538
 
539
- $decrypt_block.= '
540
  $in = pack("N*",
541
  $r ^ ' . $p[0] . ',
542
  $l ^ ' . $p[1] . '
422
  $l = $in[1];
423
  $r = $in[2];
424
 
425
+ for ($i = 0; $i < 16; $i += 2) {
426
+ $l ^= $p[$i];
427
+ $r ^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^
428
  $sb_2[$l >> 8 & 0xff]) +
429
  $sb_3[$l & 0xff]);
430
 
431
+ $r ^= $p[$i + 1];
432
+ $l ^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^
433
  $sb_2[$r >> 8 & 0xff]) +
434
  $sb_3[$r & 0xff]);
435
  }
455
  $l = $in[1];
456
  $r = $in[2];
457
 
458
+ for ($i = 17; $i > 2; $i -= 2) {
459
+ $l ^= $p[$i];
460
+ $r ^= self::safe_intval((self::safe_intval($sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]) ^
461
  $sb_2[$l >> 8 & 0xff]) +
462
  $sb_3[$l & 0xff]);
463
 
464
+ $r ^= $p[$i - 1];
465
+ $l ^= self::safe_intval((self::safe_intval($sb_0[$r >> 24 & 0xff] + $sb_1[$r >> 16 & 0xff]) ^
466
  $sb_2[$r >> 8 & 0xff]) +
467
  $sb_3[$r & 0xff]);
468
  }
496
  $l = $in[1];
497
  $r = $in[2];
498
  ';
499
+ for ($i = 0; $i < 16; $i += 2) {
500
+ $encrypt_block .= '
501
  $l^= ' . $p[$i] . ';
502
  $r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^
503
  $sb_2[$l >> 8 & 0xff]) +
509
  $sb_3[$r & 0xff]') . ';
510
  ';
511
  }
512
+ $encrypt_block .= '
513
  $in = pack("N*",
514
  $r ^ ' . $p[17] . ',
515
  $l ^ ' . $p[16] . '
522
  $r = $in[2];
523
  ';
524
 
525
+ for ($i = 17; $i > 2; $i -= 2) {
526
+ $decrypt_block .= '
527
  $l^= ' . $p[$i] . ';
528
  $r^= ' . sprintf($safeint, '(' . sprintf($safeint, '$sb_0[$l >> 24 & 0xff] + $sb_1[$l >> 16 & 0xff]') . ' ^
529
  $sb_2[$l >> 8 & 0xff]) +
536
  ';
537
  }
538
 
539
+ $decrypt_block .= '
540
  $in = pack("N*",
541
  $r ^ ' . $p[0] . ',
542
  $l ^ ' . $p[1] . '
vendor/phpseclib/phpseclib/phpseclib/Crypt/ChaCha20.php CHANGED
@@ -15,8 +15,8 @@
15
 
16
  namespace phpseclib3\Crypt;
17
 
18
- use phpseclib3\Exception\InsufficientSetupException;
19
  use phpseclib3\Exception\BadDecryptionException;
 
20
 
21
  /**
22
  * Pure-PHP implementation of ChaCha20.
@@ -258,7 +258,7 @@ class ChaCha20 extends Salsa20
258
  $key = $this->key;
259
  if (strlen($key) == 16) {
260
  $constant = 'expand 16-byte k';
261
- $key.= $key;
262
  } else {
263
  $constant = 'expand 32-byte k';
264
  }
@@ -280,10 +280,15 @@ class ChaCha20 extends Salsa20
280
  */
281
  protected static function quarterRound(&$a, &$b, &$c, &$d)
282
  {
 
 
 
 
283
  $a+= $b; $d = self::leftRotate($d ^ $a, 16);
284
  $c+= $d; $b = self::leftRotate($b ^ $c, 12);
285
  $a+= $b; $d = self::leftRotate($d ^ $a, 8);
286
  $c+= $d; $b = self::leftRotate($b ^ $c, 7);
 
287
  }
288
 
289
  /**
@@ -309,15 +314,15 @@ class ChaCha20 extends Salsa20
309
  protected static function doubleRound(&$x0, &$x1, &$x2, &$x3, &$x4, &$x5, &$x6, &$x7, &$x8, &$x9, &$x10, &$x11, &$x12, &$x13, &$x14, &$x15)
310
  {
311
  // columnRound
312
- static::quarterRound($x0, $x4, $x8, $x12);
313
- static::quarterRound($x1, $x5, $x9, $x13);
314
- static::quarterRound($x2, $x6, $x10, $x14);
315
- static::quarterRound($x3, $x7, $x11, $x15);
316
  // rowRound
317
  static::quarterRound($x0, $x5, $x10, $x15);
318
  static::quarterRound($x1, $x6, $x11, $x12);
319
- static::quarterRound($x2, $x7, $x8, $x13);
320
- static::quarterRound($x3, $x4, $x9, $x14);
321
  }
322
 
323
  /**
@@ -355,6 +360,7 @@ class ChaCha20 extends Salsa20
355
  $z14 = $x14;
356
  $z15 = $x15;
357
 
 
358
  // columnRound
359
  $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
360
  $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
@@ -774,23 +780,24 @@ class ChaCha20 extends Salsa20
774
  $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
775
  $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
776
  $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
777
-
778
- $x0+= $z0;
779
- $x1+= $z1;
780
- $x2+= $z2;
781
- $x3+= $z3;
782
- $x4+= $z4;
783
- $x5+= $z5;
784
- $x6+= $z6;
785
- $x7+= $z7;
786
- $x8+= $z8;
787
- $x9+= $z9;
788
- $x10+= $z10;
789
- $x11+= $z11;
790
- $x12+= $z12;
791
- $x13+= $z13;
792
- $x14+= $z14;
793
- $x15+= $z15;
 
794
 
795
  return pack('V*', $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15);
796
  }
15
 
16
  namespace phpseclib3\Crypt;
17
 
 
18
  use phpseclib3\Exception\BadDecryptionException;
19
+ use phpseclib3\Exception\InsufficientSetupException;
20
 
21
  /**
22
  * Pure-PHP implementation of ChaCha20.
258
  $key = $this->key;
259
  if (strlen($key) == 16) {
260
  $constant = 'expand 16-byte k';
261
+ $key .= $key;
262
  } else {
263
  $constant = 'expand 32-byte k';
264
  }
280
  */
281
  protected static function quarterRound(&$a, &$b, &$c, &$d)
282
  {
283
+ // in https://datatracker.ietf.org/doc/html/rfc7539#section-2.1 the addition,
284
+ // xor'ing and rotation are all on the same line so i'm keeping it on the same
285
+ // line here as well
286
+ // @codingStandardsIgnoreStart
287
  $a+= $b; $d = self::leftRotate($d ^ $a, 16);
288
  $c+= $d; $b = self::leftRotate($b ^ $c, 12);
289
  $a+= $b; $d = self::leftRotate($d ^ $a, 8);
290
  $c+= $d; $b = self::leftRotate($b ^ $c, 7);
291
+ // @codingStandardsIgnoreEnd
292
  }
293
 
294
  /**
314
  protected static function doubleRound(&$x0, &$x1, &$x2, &$x3, &$x4, &$x5, &$x6, &$x7, &$x8, &$x9, &$x10, &$x11, &$x12, &$x13, &$x14, &$x15)
315
  {
316
  // columnRound
317
+ static::quarterRound($x0, $x4, $x8, $x12);
318
+ static::quarterRound($x1, $x5, $x9, $x13);
319
+ static::quarterRound($x2, $x6, $x10, $x14);
320
+ static::quarterRound($x3, $x7, $x11, $x15);
321
  // rowRound
322
  static::quarterRound($x0, $x5, $x10, $x15);
323
  static::quarterRound($x1, $x6, $x11, $x12);
324
+ static::quarterRound($x2, $x7, $x8, $x13);
325
+ static::quarterRound($x3, $x4, $x9, $x14);
326
  }
327
 
328
  /**
360
  $z14 = $x14;
361
  $z15 = $x15;
362
 
363
+ // @codingStandardsIgnoreStart
364
  // columnRound
365
  $x0+= $x4; $x12 = self::leftRotate($x12 ^ $x0, 16);
366
  $x8+= $x12; $x4 = self::leftRotate($x4 ^ $x8, 12);
780
  $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 12);
781
  $x3+= $x4; $x14 = self::leftRotate($x14 ^ $x3, 8);
782
  $x9+= $x14; $x4 = self::leftRotate($x4 ^ $x9, 7);
783
+ // @codingStandardsIgnoreEnd
784
+
785
+ $x0 += $z0;
786
+ $x1 += $z1;
787
+ $x2 += $z2;
788
+ $x3 += $z3;
789
+ $x4 += $z4;
790
+ $x5 += $z5;
791
+ $x6 += $z6;
792
+ $x7 += $z7;
793
+ $x8 += $z8;
794
+ $x9 += $z9;
795
+ $x10 += $z10;
796
+ $x11 += $z11;
797
+ $x12 += $z12;
798
+ $x13 += $z13;
799
+ $x14 += $z14;
800
+ $x15 += $z15;
801
 
802
  return pack('V*', $x0, $x1, $x2, $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10, $x11, $x12, $x13, $x14, $x15);
803
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/AsymmetricKey.php CHANGED
@@ -15,13 +15,12 @@
15
 
16
  namespace phpseclib3\Crypt\Common;
17
 
18
- use phpseclib3\Exception\UnsupportedFormatException;
19
- use phpseclib3\Exception\NoKeyLoadedException;
20
- use phpseclib3\Math\BigInteger;
21
  use phpseclib3\Crypt\Hash;
22
  use phpseclib3\Crypt\RSA;
23
- use phpseclib3\Crypt\DSA;
24
- use phpseclib3\Crypt\ECDSA;
 
25
 
26
  /**
27
  * Base Class for all asymmetric cipher classes
@@ -123,6 +122,12 @@ abstract class AsymmetricKey
123
  */
124
  private $comment;
125
 
 
 
 
 
 
 
126
  /**
127
  * The constructor
128
  */
@@ -140,7 +145,7 @@ abstract class AsymmetricKey
140
  protected static function initialize_static_variables()
141
  {
142
  if (!isset(self::$zero)) {
143
- self::$zero= new BigInteger(0);
144
  self::$one = new BigInteger(1);
145
  }
146
 
@@ -198,7 +203,7 @@ abstract class AsymmetricKey
198
  * @param string|array $key
199
  * @param string $password optional
200
  */
201
- public function loadPrivateKey($key, $password = '')
202
  {
203
  $key = self::load($key, $password);
204
  if (!$key instanceof PrivateKey) {
@@ -214,7 +219,7 @@ abstract class AsymmetricKey
214
  * @access public
215
  * @param string|array $key
216
  */
217
- public function loadPublicKey($key)
218
  {
219
  $key = self::load($key);
220
  if (!$key instanceof PublicKey) {
@@ -230,7 +235,7 @@ abstract class AsymmetricKey
230
  * @access public
231
  * @param string|array $key
232
  */
233
- public function loadParameters($key)
234
  {
235
  $key = self::load($key);
236
  if (!$key instanceof PrivateKey && !$key instanceof PublicKey) {
@@ -245,7 +250,7 @@ abstract class AsymmetricKey
245
  * @param string $type
246
  * @param string $key
247
  * @param string $password optional
248
- * @return AsymmetricKey
249
  */
250
  public static function loadFormat($type, $key, $password = false)
251
  {
@@ -280,7 +285,7 @@ abstract class AsymmetricKey
280
  * @param string $key
281
  * @param string $password optional
282
  */
283
- public function loadPrivateKeyFormat($type, $key, $password = false)
284
  {
285
  $key = self::loadFormat($type, $key, $password);
286
  if (!$key instanceof PrivateKey) {
@@ -297,7 +302,7 @@ abstract class AsymmetricKey
297
  * @param string $type
298
  * @param string $key
299
  */
300
- public function loadPublicKeyFormat($type, $key)
301
  {
302
  $key = self::loadFormat($type, $key);
303
  if (!$key instanceof PublicKey) {
@@ -314,7 +319,7 @@ abstract class AsymmetricKey
314
  * @param string $type
315
  * @param string|array $key
316
  */
317
- public function loadParametersFormat($type, $key)
318
  {
319
  $key = self::loadFormat($type, $key);
320
  if (!$key instanceof PrivateKey && !$key instanceof PublicKey) {
@@ -332,7 +337,7 @@ abstract class AsymmetricKey
332
  * @param string $method optional
333
  * @return mixed
334
  */
335
- protected static function validatePlugin($format, $type, $method = NULL)
336
  {
337
  $type = strtolower($type);
338
  if (!isset(self::$plugins[static::ALGORITHM][$format][$type])) {
@@ -514,7 +519,7 @@ abstract class AsymmetricKey
514
  */
515
  public function getHash()
516
  {
517
- return clone $this->hash;
518
  }
519
 
520
  /**
@@ -576,7 +581,7 @@ abstract class AsymmetricKey
576
  $rolen = $this->q->getLengthInBytes();
577
  if (strlen($out) < $rolen) {
578
  return str_pad($out, $rolen, "\0", STR_PAD_LEFT);
579
- } else if (strlen($out) > $rolen) {
580
  return substr($out, -$rolen);
581
  } else {
582
  return $out;
15
 
16
  namespace phpseclib3\Crypt\Common;
17
 
18
+ use phpseclib3\Crypt\DSA;
 
 
19
  use phpseclib3\Crypt\Hash;
20
  use phpseclib3\Crypt\RSA;
21
+ use phpseclib3\Exception\NoKeyLoadedException;
22
+ use phpseclib3\Exception\UnsupportedFormatException;
23
+ use phpseclib3\Math\BigInteger;
24
 
25
  /**
26
  * Base Class for all asymmetric cipher classes
122
  */
123
  private $comment;
124
 
125
+ /**
126
+ * @param string $type
127
+ * @return string
128
+ */
129
+ abstract public function toString($type, array $options = []);
130
+
131
  /**
132
  * The constructor
133
  */
145
  protected static function initialize_static_variables()
146
  {
147
  if (!isset(self::$zero)) {
148
+ self::$zero = new BigInteger(0);
149
  self::$one = new BigInteger(1);
150
  }
151
 
203
  * @param string|array $key
204
  * @param string $password optional
205
  */
206
+ public static function loadPrivateKey($key, $password = '')
207
  {
208
  $key = self::load($key, $password);
209
  if (!$key instanceof PrivateKey) {
219
  * @access public
220
  * @param string|array $key
221
  */
222
+ public static function loadPublicKey($key)
223
  {
224
  $key = self::load($key);
225
  if (!$key instanceof PublicKey) {
235
  * @access public
236
  * @param string|array $key
237
  */
238
+ public static function loadParameters($key)
239
  {
240
  $key = self::load($key);
241
  if (!$key instanceof PrivateKey && !$key instanceof PublicKey) {
250
  * @param string $type
251
  * @param string $key
252
  * @param string $password optional
253
+ * @return static
254
  */
255
  public static function loadFormat($type, $key, $password = false)
256
  {
285
  * @param string $key
286
  * @param string $password optional
287
  */
288
+ public static function loadPrivateKeyFormat($type, $key, $password = false)
289
  {
290
  $key = self::loadFormat($type, $key, $password);
291
  if (!$key instanceof PrivateKey) {
302
  * @param string $type
303
  * @param string $key
304
  */
305
+ public static function loadPublicKeyFormat($type, $key)
306
  {
307
  $key = self::loadFormat($type, $key);
308
  if (!$key instanceof PublicKey) {
319
  * @param string $type
320
  * @param string|array $key
321
  */
322
+ public static function loadParametersFormat($type, $key)
323
  {
324
  $key = self::loadFormat($type, $key);
325
  if (!$key instanceof PrivateKey && !$key instanceof PublicKey) {
337
  * @param string $method optional
338
  * @return mixed
339
  */
340
+ protected static function validatePlugin($format, $type, $method = null)
341
  {
342
  $type = strtolower($type);
343
  if (!isset(self::$plugins[static::ALGORITHM][$format][$type])) {
519
  */
520
  public function getHash()
521
  {
522
+ return clone $this->hash;
523
  }
524
 
525
  /**
581
  $rolen = $this->q->getLengthInBytes();
582
  if (strlen($out) < $rolen) {
583
  return str_pad($out, $rolen, "\0", STR_PAD_LEFT);
584
+ } elseif (strlen($out) > $rolen) {
585
  return substr($out, -$rolen);
586
  } else {
587
  return $out;
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/OpenSSH.php CHANGED
@@ -222,13 +222,13 @@ abstract class OpenSSH
222
  */
223
  $paddingLength = (7 * strlen($paddedKey)) % 8;
224
  for ($i = 1; $i <= $paddingLength; $i++) {
225
- $paddedKey.= chr($i);
226
  }
227
  $key = Strings::packSSH2('sssNss', 'none', 'none', '', 1, $publicKey, $paddedKey);
228
  $key = "openssh-key-v1\0$key";
229
 
230
- return "-----BEGIN OPENSSH PRIVATE KEY-----\r\n" .
231
- chunk_split(Base64::encode($key), 70) .
232
- "-----END OPENSSH PRIVATE KEY-----";
233
  }
234
  }
222
  */
223
  $paddingLength = (7 * strlen($paddedKey)) % 8;
224
  for ($i = 1; $i <= $paddingLength; $i++) {
225
+ $paddedKey .= chr($i);
226
  }
227
  $key = Strings::packSSH2('sssNss', 'none', 'none', '', 1, $publicKey, $paddedKey);
228
  $key = "openssh-key-v1\0$key";
229
 
230
+ return "-----BEGIN OPENSSH PRIVATE KEY-----\n" .
231
+ chunk_split(Base64::encode($key), 70, "\n") .
232
+ "-----END OPENSSH PRIVATE KEY-----\n";
233
  }
234
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS.php CHANGED
@@ -77,4 +77,4 @@ abstract class PKCS
77
  {
78
  self::$format = self::MODE_ANY;
79
  }
80
- }
77
  {
78
  self::$format = self::MODE_ANY;
79
  }
80
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS1.php CHANGED
@@ -17,13 +17,13 @@ namespace phpseclib3\Crypt\Common\Formats\Keys;
17
 
18
  use ParagonIE\ConstantTime\Base64;
19
  use ParagonIE\ConstantTime\Hex;
20
- use phpseclib3\Crypt\Random;
21
  use phpseclib3\Crypt\AES;
22
  use phpseclib3\Crypt\DES;
 
23
  use phpseclib3\Crypt\TripleDES;
24
- use phpseclib3\File\ASN1;
25
- use phpseclib3\Common\Functions\Strings;
26
  use phpseclib3\Exception\UnsupportedAlgorithmException;
 
27
 
28
  /**
29
  * PKCS1 Formatted Key Handler
@@ -113,7 +113,7 @@ abstract class PKCS1 extends PKCS
113
  $symkey = '';
114
  $iv = substr($iv, 0, 8);
115
  while (strlen($symkey) < $length) {
116
- $symkey.= md5($symkey . $password . $iv, true);
117
  }
118
  return substr($symkey, 0, $length);
119
  }
@@ -200,7 +200,7 @@ abstract class PKCS1 extends PKCS
200
  $iv = strtoupper(Hex::encode($iv));
201
  return "-----BEGIN $type PRIVATE KEY-----\r\n" .
202
  "Proc-Type: 4,ENCRYPTED\r\n" .
203
- "DEK-Info: " . $encryptionAlgorithm. ",$iv\r\n" .
204
  "\r\n" .
205
  chunk_split(Base64::encode($cipher->encrypt($key)), 64) .
206
  "-----END $type PRIVATE KEY-----";
@@ -220,4 +220,4 @@ abstract class PKCS1 extends PKCS
220
  chunk_split(Base64::encode($key), 64) .
221
  "-----END $type PUBLIC KEY-----";
222
  }
223
- }
17
 
18
  use ParagonIE\ConstantTime\Base64;
19
  use ParagonIE\ConstantTime\Hex;
20
+ use phpseclib3\Common\Functions\Strings;
21
  use phpseclib3\Crypt\AES;
22
  use phpseclib3\Crypt\DES;
23
+ use phpseclib3\Crypt\Random;
24
  use phpseclib3\Crypt\TripleDES;
 
 
25
  use phpseclib3\Exception\UnsupportedAlgorithmException;
26
+ use phpseclib3\File\ASN1;
27
 
28
  /**
29
  * PKCS1 Formatted Key Handler
113
  $symkey = '';
114
  $iv = substr($iv, 0, 8);
115
  while (strlen($symkey) < $length) {
116
+ $symkey .= md5($symkey . $password . $iv, true);
117
  }
118
  return substr($symkey, 0, $length);
119
  }
200
  $iv = strtoupper(Hex::encode($iv));
201
  return "-----BEGIN $type PRIVATE KEY-----\r\n" .
202
  "Proc-Type: 4,ENCRYPTED\r\n" .
203
+ "DEK-Info: " . $encryptionAlgorithm . ",$iv\r\n" .
204
  "\r\n" .
205
  chunk_split(Base64::encode($cipher->encrypt($key)), 64) .
206
  "-----END $type PRIVATE KEY-----";
220
  chunk_split(Base64::encode($key), 64) .
221
  "-----END $type PUBLIC KEY-----";
222
  }
223
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PKCS8.php CHANGED
@@ -28,17 +28,17 @@
28
  namespace phpseclib3\Crypt\Common\Formats\Keys;
29
 
30
  use ParagonIE\ConstantTime\Base64;
 
 
31
  use phpseclib3\Crypt\DES;
 
32
  use phpseclib3\Crypt\RC2;
33
  use phpseclib3\Crypt\RC4;
34
- use phpseclib3\Crypt\AES;
35
  use phpseclib3\Crypt\TripleDES;
36
- use phpseclib3\Crypt\Random;
37
- use phpseclib3\Math\BigInteger;
38
  use phpseclib3\File\ASN1;
39
  use phpseclib3\File\ASN1\Maps;
40
- use phpseclib3\Common\Functions\Strings;
41
- use phpseclib3\Exception\UnsupportedAlgorithmException;
42
 
43
  /**
44
  * PKCS#8 Formatted Key Handler
@@ -268,11 +268,14 @@ abstract class PKCS8 extends PKCS
268
  */
269
  private static function initialize_static_variables()
270
  {
 
 
 
 
271
  if (!static::$childOIDsLoaded) {
272
  ASN1::loadOIDs(is_array(static::OID_NAME) ?
273
  array_combine(static::OID_NAME, static::OID_VALUE) :
274
- [static::OID_NAME => static::OID_VALUE]
275
- );
276
  static::$childOIDsLoaded = true;
277
  }
278
  if (!self::$oidsLoaded) {
@@ -283,8 +286,8 @@ abstract class PKCS8 extends PKCS
283
  'pbeWithMD2AndRC2-CBC' => '1.2.840.113549.1.5.4',
284
  'pbeWithMD5AndDES-CBC' => '1.2.840.113549.1.5.3',
285
  'pbeWithMD5AndRC2-CBC' => '1.2.840.113549.1.5.6',
286
- 'pbeWithSHA1AndDES-CBC'=> '1.2.840.113549.1.5.10',
287
- 'pbeWithSHA1AndRC2-CBC'=> '1.2.840.113549.1.5.11',
288
 
289
  // from PKCS#12:
290
  // https://tools.ietf.org/html/rfc7292
@@ -304,10 +307,10 @@ abstract class PKCS8 extends PKCS
304
  'id-hmacWithSHA1' => '1.2.840.113549.2.7',
305
  'id-hmacWithSHA224' => '1.2.840.113549.2.8',
306
  'id-hmacWithSHA256' => '1.2.840.113549.2.9',
307
- 'id-hmacWithSHA384'=> '1.2.840.113549.2.10',
308
- 'id-hmacWithSHA512'=> '1.2.840.113549.2.11',
309
- 'id-hmacWithSHA512-224'=> '1.2.840.113549.2.12',
310
- 'id-hmacWithSHA512-256'=> '1.2.840.113549.2.13',
311
 
312
  'desCBC' => '1.3.14.3.2.7',
313
  'des-EDE3-CBC' => '1.2.840.113549.3.7',
@@ -315,8 +318,8 @@ abstract class PKCS8 extends PKCS
315
  'rc5-CBC-PAD' => '1.2.840.113549.3.9',
316
 
317
  'aes128-CBC-PAD' => '2.16.840.1.101.3.4.1.2',
318
- 'aes192-CBC-PAD'=> '2.16.840.1.101.3.4.1.22',
319
- 'aes256-CBC-PAD'=> '2.16.840.1.101.3.4.1.42'
320
  ]);
321
  self::$oidsLoaded = true;
322
  }
@@ -519,11 +522,13 @@ abstract class PKCS8 extends PKCS
519
  $key = [
520
  'version' => 'v1',
521
  'privateKeyAlgorithm' => [
522
- 'algorithm' => is_string(static::OID_NAME) ? static::OID_NAME : $oid,
523
- 'parameters' => $params
524
  ],
525
  'privateKey' => $key
526
  ];
 
 
 
527
  if (!empty($attr)) {
528
  $key['attributes'] = $attr;
529
  }
28
  namespace phpseclib3\Crypt\Common\Formats\Keys;
29
 
30
  use ParagonIE\ConstantTime\Base64;
31
+ use phpseclib3\Common\Functions\Strings;
32
+ use phpseclib3\Crypt\AES;
33
  use phpseclib3\Crypt\DES;
34
+ use phpseclib3\Crypt\Random;
35
  use phpseclib3\Crypt\RC2;
36
  use phpseclib3\Crypt\RC4;
 
37
  use phpseclib3\Crypt\TripleDES;
38
+ use phpseclib3\Exception\InsufficientSetupException;
39
+ use phpseclib3\Exception\UnsupportedAlgorithmException;
40
  use phpseclib3\File\ASN1;
41
  use phpseclib3\File\ASN1\Maps;
 
 
42
 
43
  /**
44
  * PKCS#8 Formatted Key Handler
268
  */
269
  private static function initialize_static_variables()
270
  {
271
+ if (!isset(static::$childOIDsLoaded)) {
272
+ throw new InsufficientSetupException('This class should not be called directly');
273
+ }
274
+
275
  if (!static::$childOIDsLoaded) {
276
  ASN1::loadOIDs(is_array(static::OID_NAME) ?
277
  array_combine(static::OID_NAME, static::OID_VALUE) :
278
+ [static::OID_NAME => static::OID_VALUE]);
 
279
  static::$childOIDsLoaded = true;
280
  }
281
  if (!self::$oidsLoaded) {
286
  'pbeWithMD2AndRC2-CBC' => '1.2.840.113549.1.5.4',
287
  'pbeWithMD5AndDES-CBC' => '1.2.840.113549.1.5.3',
288
  'pbeWithMD5AndRC2-CBC' => '1.2.840.113549.1.5.6',
289
+ 'pbeWithSHA1AndDES-CBC' => '1.2.840.113549.1.5.10',
290
+ 'pbeWithSHA1AndRC2-CBC' => '1.2.840.113549.1.5.11',
291
 
292
  // from PKCS#12:
293
  // https://tools.ietf.org/html/rfc7292
307
  'id-hmacWithSHA1' => '1.2.840.113549.2.7',
308
  'id-hmacWithSHA224' => '1.2.840.113549.2.8',
309
  'id-hmacWithSHA256' => '1.2.840.113549.2.9',
310
+ 'id-hmacWithSHA384' => '1.2.840.113549.2.10',
311
+ 'id-hmacWithSHA512' => '1.2.840.113549.2.11',
312
+ 'id-hmacWithSHA512-224' => '1.2.840.113549.2.12',
313
+ 'id-hmacWithSHA512-256' => '1.2.840.113549.2.13',
314
 
315
  'desCBC' => '1.3.14.3.2.7',
316
  'des-EDE3-CBC' => '1.2.840.113549.3.7',
318
  'rc5-CBC-PAD' => '1.2.840.113549.3.9',
319
 
320
  'aes128-CBC-PAD' => '2.16.840.1.101.3.4.1.2',
321
+ 'aes192-CBC-PAD' => '2.16.840.1.101.3.4.1.22',
322
+ 'aes256-CBC-PAD' => '2.16.840.1.101.3.4.1.42'
323
  ]);
324
  self::$oidsLoaded = true;
325
  }
522
  $key = [
523
  'version' => 'v1',
524
  'privateKeyAlgorithm' => [
525
+ 'algorithm' => is_string(static::OID_NAME) ? static::OID_NAME : $oid
 
526
  ],
527
  'privateKey' => $key
528
  ];
529
+ if ($oid != 'id-Ed25519' && $oid != 'id-Ed448') {
530
+ $key['privateKeyAlgorithm']['parameters'] = $params;
531
+ }
532
  if (!empty($attr)) {
533
  $key['attributes'] = $attr;
534
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Formats/Keys/PuTTY.php CHANGED
@@ -3,6 +3,8 @@
3
  /**
4
  * PuTTY Formatted Key Handler
5
  *
 
 
6
  * PHP version 5
7
  *
8
  * @category Crypt
@@ -17,10 +19,10 @@ namespace phpseclib3\Crypt\Common\Formats\Keys;
17
 
18
  use ParagonIE\ConstantTime\Base64;
19
  use ParagonIE\ConstantTime\Hex;
 
20
  use phpseclib3\Crypt\AES;
21
  use phpseclib3\Crypt\Hash;
22
  use phpseclib3\Crypt\Random;
23
- use phpseclib3\Common\Functions\Strings;
24
  use phpseclib3\Exception\UnsupportedAlgorithmException;
25
 
26
  /**
@@ -40,6 +42,14 @@ abstract class PuTTY
40
  */
41
  private static $comment = 'phpseclib-generated-key';
42
 
 
 
 
 
 
 
 
 
43
  /**
44
  * Sets the default comment
45
  *
@@ -52,24 +62,76 @@ abstract class PuTTY
52
  }
53
 
54
  /**
55
- * Generate a symmetric key for PuTTY keys
56
  *
57
  * @access public
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  * @param string $password
59
  * @param int $length
60
  * @return string
61
  */
62
- private static function generateSymmetricKey($password, $length)
63
  {
64
  $symkey = '';
65
  $sequence = 0;
66
  while (strlen($symkey) < $length) {
67
  $temp = pack('Na*', $sequence++, $password);
68
- $symkey.= Hex::decode(sha1($temp));
69
  }
70
  return substr($symkey, 0, $length);
71
  }
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  /**
74
  * Break a public or private key down into its constituent components
75
  *
@@ -108,10 +170,10 @@ abstract class PuTTY
108
  break;
109
  case $in_value:
110
  $in_value = $line[strlen($line) - 1] == '\\';
111
- $values[$current].= $in_value ? substr($line, 0, -1) : $line;
112
  break;
113
  default:
114
- $data.= $line;
115
  }
116
  }
117
 
@@ -119,7 +181,7 @@ abstract class PuTTY
119
  if ($components === false) {
120
  throw new \UnexpectedValueException('Unable to decode public key');
121
  }
122
- $components+= $values;
123
  $components['comment'] = str_replace(['\\\\', '\"'], ['\\', '"'], $values['comment']);
124
 
125
  return $components;
@@ -128,8 +190,14 @@ abstract class PuTTY
128
  $components = [];
129
 
130
  $key = preg_split('#\r\n|\r|\n#', trim($key));
131
- $type = trim(preg_replace('#PuTTY-User-Key-File-2: (.+)#', '$1', $key[0]));
132
- $components['type'] = $type;
 
 
 
 
 
 
133
  if (!in_array($type, static::$types)) {
134
  $error = count(static::$types) == 1 ?
135
  'Only ' . static::$types[0] . ' keys are supported. ' :
@@ -152,30 +220,59 @@ abstract class PuTTY
152
 
153
  $components['public'] = $public;
154
 
155
- $privateLength = trim(preg_replace('#Private-Lines: (\d+)#', '$1', $key[$publicLength + 4]));
156
- $private = Base64::decode(implode('', array_map('trim', array_slice($key, $publicLength + 5, $privateLength))));
 
 
 
 
 
157
 
 
158
  switch ($encryption) {
159
  case 'aes256-cbc':
160
- $symkey = self::generateSymmetricKey($password, 32);
161
  $crypto = new AES('cbc');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
 
164
- $hashkey = 'putty-private-key-file-mac-key';
 
 
 
 
 
 
 
 
 
 
 
165
 
166
  if ($encryption != 'none') {
167
- $hashkey.= $password;
168
  $crypto->setKey($symkey);
169
- $crypto->setIV(str_repeat("\0", $crypto->getBlockLength() >> 3));
170
  $crypto->disablePadding();
171
  $private = $crypto->decrypt($private);
172
  }
173
 
174
- $source.= Strings::packSSH2('s', $private);
175
 
176
- $hash = new Hash('sha1');
177
- $hash->setKey(sha1($hashkey, true));
178
- $hmac = trim(preg_replace('#Private-MAC: (.+)#', '$1', $key[$publicLength + $privateLength + 5]));
179
  $hmac = Hex::decode($hmac);
180
 
181
  if (!hash_equals($hash->hash($source), $hmac)) {
@@ -202,39 +299,70 @@ abstract class PuTTY
202
  {
203
  $encryption = (!empty($password) || is_string($password)) ? 'aes256-cbc' : 'none';
204
  $comment = isset($options['comment']) ? $options['comment'] : self::$comment;
 
205
 
206
- $key = "PuTTY-User-Key-File-2: " . $type . "\r\nEncryption: "; $key.= $encryption;
207
- $key.= "\r\nComment: " . $comment . "\r\n";
 
208
 
209
  $public = Strings::packSSH2('s', $type) . $public;
210
 
211
  $source = Strings::packSSH2('ssss', $type, $encryption, $comment, $public);
212
 
213
  $public = Base64::encode($public);
214
- $key.= "Public-Lines: " . ((strlen($public) + 63) >> 6) . "\r\n";
215
- $key.= chunk_split($public, 64);
216
 
217
  if (empty($password) && !is_string($password)) {
218
- $source.= Strings::packSSH2('s', $private);
219
- $hashkey = 'putty-private-key-file-mac-key';
 
 
 
 
 
 
 
 
220
  } else {
221
- $private.= Random::string(16 - (strlen($private) & 15));
222
- $source.= Strings::packSSH2('s', $private);
223
  $crypto = new AES('cbc');
224
 
225
- $crypto->setKey(self::generateSymmetricKey($password, 32));
226
- $crypto->setIV(str_repeat("\0", $crypto->getBlockLength() >> 3));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  $crypto->disablePadding();
228
  $private = $crypto->encrypt($private);
229
- $hashkey = 'putty-private-key-file-mac-key' . $password;
230
  }
231
 
232
  $private = Base64::encode($private);
233
- $key.= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n";
234
- $key.= chunk_split($private, 64);
235
- $hash = new Hash('sha1');
236
- $hash->setKey(sha1($hashkey, true));
237
- $key.= 'Private-MAC: ' . Hex::encode($hash->hash($source)) . "\r\n";
238
 
239
  return $key;
240
  }
3
  /**
4
  * PuTTY Formatted Key Handler
5
  *
6
+ * See PuTTY's SSHPUBK.C and https://tartarus.org/~simon/putty-snapshots/htmldoc/AppendixC.html
7
+ *
8
  * PHP version 5
9
  *
10
  * @category Crypt
19
 
20
  use ParagonIE\ConstantTime\Base64;
21
  use ParagonIE\ConstantTime\Hex;
22
+ use phpseclib3\Common\Functions\Strings;
23
  use phpseclib3\Crypt\AES;
24
  use phpseclib3\Crypt\Hash;
25
  use phpseclib3\Crypt\Random;
 
26
  use phpseclib3\Exception\UnsupportedAlgorithmException;
27
 
28
  /**
42
  */
43
  private static $comment = 'phpseclib-generated-key';
44
 
45
+ /**
46
+ * Default version
47
+ *
48
+ * @var int
49
+ * @access private
50
+ */
51
+ private static $version = 2;
52
+
53
  /**
54
  * Sets the default comment
55
  *
62
  }
63
 
64
  /**
65
+ * Sets the default version
66
  *
67
  * @access public
68
+ * @param int $version
69
+ */
70
+ public static function setVersion($version)
71
+ {
72
+ if ($version != 2 && $version != 3) {
73
+ throw new \RuntimeException('Only supported versions are 2 and 3');
74
+ }
75
+ self::$version = $version;
76
+ }
77
+
78
+ /**
79
+ * Generate a symmetric key for PuTTY v2 keys
80
+ *
81
+ * @access private
82
  * @param string $password
83
  * @param int $length
84
  * @return string
85
  */
86
+ private static function generateV2Key($password, $length)
87
  {
88
  $symkey = '';
89
  $sequence = 0;
90
  while (strlen($symkey) < $length) {
91
  $temp = pack('Na*', $sequence++, $password);
92
+ $symkey .= Hex::decode(sha1($temp));
93
  }
94
  return substr($symkey, 0, $length);
95
  }
96
 
97
+ /**
98
+ * Generate a symmetric key for PuTTY v3 keys
99
+ *
100
+ * @access private
101
+ * @param string $password
102
+ * @param string $flavour
103
+ * @param int $memory
104
+ * @param int $passes
105
+ * @param string $salt
106
+ * @return array
107
+ */
108
+ private static function generateV3Key($password, $flavour, $memory, $passes, $salt)
109
+ {
110
+ if (!function_exists('sodium_crypto_pwhash')) {
111
+ throw new \RuntimeException('sodium_crypto_pwhash needs to exist for Argon2 password hasing');
112
+ }
113
+
114
+ switch ($flavour) {
115
+ case 'Argon2i':
116
+ $flavour = SODIUM_CRYPTO_PWHASH_ALG_ARGON2I13;
117
+ break;
118
+ case 'Argon2id':
119
+ $flavour = SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13;
120
+ break;
121
+ default:
122
+ throw new UnsupportedAlgorithmException('Only Argon2i and Argon2id are supported');
123
+ }
124
+
125
+ $length = 80; // keylen + ivlen + mac_keylen
126
+ $temp = sodium_crypto_pwhash($length, $password, $salt, $passes, $memory << 10, $flavour);
127
+
128
+ $symkey = substr($temp, 0, 32);
129
+ $symiv = substr($temp, 32, 16);
130
+ $hashkey = substr($temp, -32);
131
+
132
+ return compact('symkey', 'symiv', 'hashkey');
133
+ }
134
+
135
  /**
136
  * Break a public or private key down into its constituent components
137
  *
170
  break;
171
  case $in_value:
172
  $in_value = $line[strlen($line) - 1] == '\\';
173
+ $values[$current] .= $in_value ? substr($line, 0, -1) : $line;
174
  break;
175
  default:
176
+ $data .= $line;
177
  }
178
  }
179
 
181
  if ($components === false) {
182
  throw new \UnexpectedValueException('Unable to decode public key');
183
  }
184
+ $components += $values;
185
  $components['comment'] = str_replace(['\\\\', '\"'], ['\\', '"'], $values['comment']);
186
 
187
  return $components;
190
  $components = [];
191
 
192
  $key = preg_split('#\r\n|\r|\n#', trim($key));
193
+ if (Strings::shift($key[0], strlen('PuTTY-User-Key-File-')) != 'PuTTY-User-Key-File-') {
194
+ return false;
195
+ }
196
+ $version = (int) Strings::shift($key[0], 3); // should be either "2: " or "3: 0" prior to int casting
197
+ if ($version != 2 && $version != 3) {
198
+ throw new \RuntimeException('Only v2 and v3 PuTTY private keys are supported');
199
+ }
200
+ $components['type'] = $type = rtrim($key[0]);
201
  if (!in_array($type, static::$types)) {
202
  $error = count(static::$types) == 1 ?
203
  'Only ' . static::$types[0] . ' keys are supported. ' :
220
 
221
  $components['public'] = $public;
222
 
223
+ switch ($version) {
224
+ case 3:
225
+ $hashkey = '';
226
+ break;
227
+ case 2:
228
+ $hashkey = 'putty-private-key-file-mac-key';
229
+ }
230
 
231
+ $offset = $publicLength + 4;
232
  switch ($encryption) {
233
  case 'aes256-cbc':
 
234
  $crypto = new AES('cbc');
235
+ switch ($version) {
236
+ case 3:
237
+ $flavour = trim(preg_replace('#Key-Derivation: (.*)#', '$1', $key[$offset++]));
238
+ $memory = trim(preg_replace('#Argon2-Memory: (\d+)#', '$1', $key[$offset++]));
239
+ $passes = trim(preg_replace('#Argon2-Passes: (\d+)#', '$1', $key[$offset++]));
240
+ $parallelism = trim(preg_replace('#Argon2-Parallelism: (\d+)#', '$1', $key[$offset++]));
241
+ $salt = Hex::decode(trim(preg_replace('#Argon2-Salt: ([0-9a-f]+)#', '$1', $key[$offset++])));
242
+
243
+ extract(self::generateV3Key($password, $flavour, $memory, $passes, $salt));
244
+
245
+ break;
246
+ case 2:
247
+ $symkey = self::generateV2Key($password, 32);
248
+ $symiv = str_repeat("\0", $crypto->getBlockLength() >> 3);
249
+ $hashkey .= $password;
250
+ }
251
  }
252
 
253
+ switch ($version) {
254
+ case 3:
255
+ $hash = new Hash('sha256');
256
+ $hash->setKey($hashkey);
257
+ break;
258
+ case 2:
259
+ $hash = new Hash('sha1');
260
+ $hash->setKey(sha1($hashkey, true));
261
+ }
262
+
263
+ $privateLength = trim(preg_replace('#Private-Lines: (\d+)#', '$1', $key[$offset++]));
264
+ $private = Base64::decode(implode('', array_map('trim', array_slice($key, $offset, $privateLength))));
265
 
266
  if ($encryption != 'none') {
 
267
  $crypto->setKey($symkey);
268
+ $crypto->setIV($symiv);
269
  $crypto->disablePadding();
270
  $private = $crypto->decrypt($private);
271
  }
272
 
273
+ $source .= Strings::packSSH2('s', $private);
274
 
275
+ $hmac = trim(preg_replace('#Private-MAC: (.+)#', '$1', $key[$offset + $privateLength]));
 
 
276
  $hmac = Hex::decode($hmac);
277
 
278
  if (!hash_equals($hash->hash($source), $hmac)) {
299
  {
300
  $encryption = (!empty($password) || is_string($password)) ? 'aes256-cbc' : 'none';
301
  $comment = isset($options['comment']) ? $options['comment'] : self::$comment;
302
+ $version = isset($options['version']) ? $options['version'] : self::$version;
303
 
304
+ $key = "PuTTY-User-Key-File-$version: $type\r\n";
305
+ $key .= "Encryption: $encryption\r\n";
306
+ $key .= "Comment: $comment\r\n";
307
 
308
  $public = Strings::packSSH2('s', $type) . $public;
309
 
310
  $source = Strings::packSSH2('ssss', $type, $encryption, $comment, $public);
311
 
312
  $public = Base64::encode($public);
313
+ $key .= "Public-Lines: " . ((strlen($public) + 63) >> 6) . "\r\n";
314
+ $key .= chunk_split($public, 64);
315
 
316
  if (empty($password) && !is_string($password)) {
317
+ $source .= Strings::packSSH2('s', $private);
318
+ switch ($version) {
319
+ case 3:
320
+ $hash = new Hash('sha256');
321
+ $hash->setKey('');
322
+ break;
323
+ case 2:
324
+ $hash = new Hash('sha1');
325
+ $hash->setKey(sha1('putty-private-key-file-mac-key', true));
326
+ }
327
  } else {
328
+ $private .= Random::string(16 - (strlen($private) & 15));
329
+ $source .= Strings::packSSH2('s', $private);
330
  $crypto = new AES('cbc');
331
 
332
+ switch ($version) {
333
+ case 3:
334
+ $salt = Random::string(16);
335
+ $key .= "Key-Derivation: Argon2id\r\n";
336
+ $key .= "Argon2-Memory: 8192\r\n";
337
+ $key .= "Argon2-Passes: 13\r\n";
338
+ $key .= "Argon2-Parallelism: 1\r\n";
339
+ $key .= "Argon2-Salt: " . Hex::encode($salt) . "\r\n";
340
+ extract(self::generateV3Key($password, 'Argon2id', 8192, 13, $salt));
341
+
342
+ $hash = new Hash('sha256');
343
+ $hash->setKey($hashkey);
344
+
345
+ break;
346
+ case 2:
347
+ $symkey = self::generateV2Key($password, 32);
348
+ $symiv = str_repeat("\0", $crypto->getBlockLength() >> 3);
349
+ $hashkey = 'putty-private-key-file-mac-key' . $password;
350
+
351
+ $hash = new Hash('sha1');
352
+ $hash->setKey(sha1($hashkey, true));
353
+ }
354
+
355
+ $crypto->setKey($symkey);
356
+ $crypto->setIV($symiv);
357
  $crypto->disablePadding();
358
  $private = $crypto->encrypt($private);
359
+ $mac = $hash->hash($source);
360
  }
361
 
362
  $private = Base64::encode($private);
363
+ $key .= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n";
364
+ $key .= chunk_split($private, 64);
365
+ $key .= 'Private-MAC: ' . Hex::encode($hash->hash($source)) . "\r\n";
 
 
366
 
367
  return $key;
368
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/PrivateKey.php CHANGED
@@ -26,5 +26,10 @@ interface PrivateKey
26
  //public function decrypt($ciphertext);
27
  public function getPublicKey();
28
  public function toString($type, array $options = []);
29
- public function withPassword($string = false);
 
 
 
 
 
30
  }
26
  //public function decrypt($ciphertext);
27
  public function getPublicKey();
28
  public function toString($type, array $options = []);
29
+
30
+ /**
31
+ * @param string|false $password
32
+ * @return mixed
33
+ */
34
+ public function withPassword($password = false);
35
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/SymmetricKey.php CHANGED
@@ -36,16 +36,16 @@
36
 
37
  namespace phpseclib3\Crypt\Common;
38
 
39
- use phpseclib3\Crypt\Hash;
40
  use phpseclib3\Common\Functions\Strings;
41
- use phpseclib3\Math\BigInteger;
42
- use phpseclib3\Math\BinaryField;
43
- use phpseclib3\Math\PrimeField;
44
  use phpseclib3\Exception\BadDecryptionException;
45
  use phpseclib3\Exception\BadModeException;
46
  use phpseclib3\Exception\InconsistentSetupException;
47
  use phpseclib3\Exception\InsufficientSetupException;
48
  use phpseclib3\Exception\UnsupportedAlgorithmException;
 
 
 
49
 
50
  /**
51
  * Base Class for all \phpseclib3\Crypt\* cipher classes
@@ -101,7 +101,15 @@ abstract class SymmetricKey
101
  * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
102
  * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
103
  */
104
- const MODE_CFB8 = 38;
 
 
 
 
 
 
 
 
105
  /**
106
  * Encrypt / decrypt using the Output Feedback mode.
107
  *
@@ -142,6 +150,7 @@ abstract class SymmetricKey
142
  'cfb' => self::MODE_CFB,
143
  'cfb8' => self::MODE_CFB8,
144
  'ofb' => self::MODE_OFB,
 
145
  'gcm' => self::MODE_GCM,
146
  'stream' => self::MODE_STREAM
147
  ];
@@ -642,6 +651,8 @@ abstract class SymmetricKey
642
  *
643
  * - ofb
644
  *
 
 
645
  * - gcm
646
  *
647
  * @param string $mode
@@ -669,6 +680,7 @@ abstract class SymmetricKey
669
  case self::MODE_CFB:
670
  case self::MODE_CFB8:
671
  case self::MODE_OFB:
 
672
  case self::MODE_STREAM:
673
  $this->paddable = false;
674
  break;
@@ -875,7 +887,7 @@ abstract class SymmetricKey
875
 
876
  if (is_string($this->key) && strlen($this->key) != $this->explicit_key_length) {
877
  $this->key = false;
878
- throw new InconsistentSetupException('Key has already been set and is not ' .$this->explicit_key_length . ' bytes long');
879
  }
880
  }
881
 
@@ -968,7 +980,7 @@ abstract class SymmetricKey
968
 
969
  -- https://tools.ietf.org/html/rfc7292#appendix-B.1
970
  */
971
- $password = "\0". chunk_split($password, 1, "\0") . "\0";
972
 
973
  /*
974
  This standard specifies 3 different values for the ID byte mentioned
@@ -991,7 +1003,7 @@ abstract class SymmetricKey
991
  $s = '';
992
  if (strlen($salt)) {
993
  while (strlen($s) < $blockLength) {
994
- $s.= $salt;
995
  }
996
  }
997
  $s = substr($s, 0, $blockLength);
@@ -999,7 +1011,7 @@ abstract class SymmetricKey
999
  $p = '';
1000
  if (strlen($password)) {
1001
  while (strlen($p) < $blockLength) {
1002
- $p.= $password;
1003
  }
1004
  }
1005
  $p = substr($p, 0, $blockLength);
@@ -1035,9 +1047,9 @@ abstract class SymmetricKey
1035
  $f = $u = $hashObj->hash($salt . pack('N', $i++));
1036
  for ($j = 2; $j <= $count; ++$j) {
1037
  $u = $hashObj->hash($u);
1038
- $f^= $u;
1039
  }
1040
- $key.= $f;
1041
  }
1042
  $key = substr($key, 0, $dkLen);
1043
  break;
@@ -1088,21 +1100,21 @@ abstract class SymmetricKey
1088
  }
1089
  $b = '';
1090
  while (strlen($b) < $blockLength) {
1091
- $b.= $ai;
1092
  }
1093
  $b = substr($b, 0, $blockLength);
1094
  $b = new BigInteger($b, 256);
1095
  $newi = '';
1096
- for ($k = 0; $k < strlen($i); $k+= $blockLength) {
1097
  $temp = substr($i, $k, $blockLength);
1098
  $temp = new BigInteger($temp, 256);
1099
  $temp->setPrecision($blockLength << 3);
1100
  $temp = $temp->add($b);
1101
  $temp = $temp->add($one);
1102
- $newi.= $temp->toBytes(false);
1103
  }
1104
  $i = $newi;
1105
- $a.= $ai;
1106
  }
1107
 
1108
  return substr($a, 0, $n);
@@ -1197,11 +1209,11 @@ abstract class SymmetricKey
1197
  $max = $this->block_size - $pos;
1198
  if ($len >= $max) {
1199
  $i = $max;
1200
- $len-= $max;
1201
  $pos = 0;
1202
  } else {
1203
  $i = $len;
1204
- $pos+= $len;
1205
  $len = 0;
1206
  }
1207
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
@@ -1213,13 +1225,13 @@ abstract class SymmetricKey
1213
  $overflow = $len % $this->block_size;
1214
 
1215
  if ($overflow) {
1216
- $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
1217
  $iv = Strings::pop($ciphertext, $this->block_size);
1218
 
1219
  $size = $len - $overflow;
1220
  $block = $iv ^ substr($plaintext, -$overflow);
1221
  $iv = substr_replace($iv, $block, 0, $overflow);
1222
- $ciphertext.= $block;
1223
  $pos = $overflow;
1224
  } elseif ($len) {
1225
  $ciphertext = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
@@ -1237,13 +1249,29 @@ abstract class SymmetricKey
1237
  }
1238
  }
1239
  return $ciphertext;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1240
  case self::MODE_OFB:
1241
  return $this->openssl_ofb_process($plaintext, $this->encryptIV, $this->enbuffer);
1242
  }
1243
  }
1244
 
1245
  if ($this->engine === self::ENGINE_MCRYPT) {
1246
- set_error_handler(function() {});
 
1247
  if ($this->enchanged) {
1248
  mcrypt_generic_init($this->enmcrypt, $this->key, $this->getIV($this->encryptIV));
1249
  $this->enchanged = false;
@@ -1264,11 +1292,11 @@ abstract class SymmetricKey
1264
  $max = $block_size - $pos;
1265
  if ($len >= $max) {
1266
  $i = $max;
1267
- $len-= $max;
1268
  $pos = 0;
1269
  } else {
1270
  $i = $len;
1271
- $pos+= $len;
1272
  $len = 0;
1273
  }
1274
  $ciphertext = substr($iv, $orig_pos) ^ $plaintext;
@@ -1281,15 +1309,15 @@ abstract class SymmetricKey
1281
  mcrypt_generic_init($this->enmcrypt, $this->key, $iv);
1282
  $this->enbuffer['enmcrypt_init'] = false;
1283
  }
1284
- $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size));
1285
  $iv = substr($ciphertext, -$block_size);
1286
- $len%= $block_size;
1287
  } else {
1288
  while ($len >= $block_size) {
1289
  $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size);
1290
- $ciphertext.= $iv;
1291
- $len-= $block_size;
1292
- $i+= $block_size;
1293
  }
1294
  }
1295
  }
@@ -1298,7 +1326,7 @@ abstract class SymmetricKey
1298
  $iv = mcrypt_generic($this->ecb, $iv);
1299
  $block = $iv ^ substr($plaintext, -$len);
1300
  $iv = substr_replace($iv, $block, 0, $len);
1301
- $ciphertext.= $block;
1302
  $pos = $len;
1303
  }
1304
 
@@ -1328,17 +1356,17 @@ abstract class SymmetricKey
1328
  $ciphertext = '';
1329
  switch ($this->mode) {
1330
  case self::MODE_ECB:
1331
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1332
- $ciphertext.= $this->encryptBlock(substr($plaintext, $i, $block_size));
1333
  }
1334
  break;
1335
  case self::MODE_CBC:
1336
  $xor = $this->encryptIV;
1337
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1338
  $block = substr($plaintext, $i, $block_size);
1339
  $block = $this->encryptBlock($block ^ $xor);
1340
  $xor = $block;
1341
- $ciphertext.= $block;
1342
  }
1343
  if ($this->continuousBuffer) {
1344
  $this->encryptIV = $xor;
@@ -1347,21 +1375,21 @@ abstract class SymmetricKey
1347
  case self::MODE_CTR:
1348
  $xor = $this->encryptIV;
1349
  if (strlen($buffer['ciphertext'])) {
1350
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1351
  $block = substr($plaintext, $i, $block_size);
1352
  if (strlen($block) > strlen($buffer['ciphertext'])) {
1353
- $buffer['ciphertext'].= $this->encryptBlock($xor);
 
1354
  }
1355
- Strings::increment_str($xor);
1356
  $key = Strings::shift($buffer['ciphertext'], $block_size);
1357
- $ciphertext.= $block ^ $key;
1358
  }
1359
  } else {
1360
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1361
  $block = substr($plaintext, $i, $block_size);
1362
  $key = $this->encryptBlock($xor);
1363
  Strings::increment_str($xor);
1364
- $ciphertext.= $block ^ $key;
1365
  }
1366
  }
1367
  if ($this->continuousBuffer) {
@@ -1388,11 +1416,11 @@ abstract class SymmetricKey
1388
  $max = $block_size - $pos;
1389
  if ($len >= $max) {
1390
  $i = $max;
1391
- $len-= $max;
1392
  $pos = 0;
1393
  } else {
1394
  $i = $len;
1395
- $pos+= $len;
1396
  $len = 0;
1397
  }
1398
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
@@ -1401,15 +1429,15 @@ abstract class SymmetricKey
1401
  }
1402
  while ($len >= $block_size) {
1403
  $iv = $this->encryptBlock($iv) ^ substr($plaintext, $i, $block_size);
1404
- $ciphertext.= $iv;
1405
- $len-= $block_size;
1406
- $i+= $block_size;
1407
  }
1408
  if ($len) {
1409
  $iv = $this->encryptBlock($iv);
1410
  $block = $iv ^ substr($plaintext, $i);
1411
  $iv = substr_replace($iv, $block, 0, $len);
1412
- $ciphertext.= $block;
1413
  $pos = $len;
1414
  }
1415
  break;
@@ -1431,22 +1459,37 @@ abstract class SymmetricKey
1431
  }
1432
  }
1433
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1434
  case self::MODE_OFB:
1435
  $xor = $this->encryptIV;
1436
  if (strlen($buffer['xor'])) {
1437
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1438
  $block = substr($plaintext, $i, $block_size);
1439
  if (strlen($block) > strlen($buffer['xor'])) {
1440
  $xor = $this->encryptBlock($xor);
1441
- $buffer['xor'].= $xor;
1442
  }
1443
  $key = Strings::shift($buffer['xor'], $block_size);
1444
- $ciphertext.= $block ^ $key;
1445
  }
1446
  } else {
1447
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1448
  $xor = $this->encryptBlock($xor);
1449
- $ciphertext.= substr($plaintext, $i, $block_size) ^ $xor;
1450
  }
1451
  $key = $xor;
1452
  }
@@ -1558,11 +1601,11 @@ abstract class SymmetricKey
1558
  $max = $this->block_size - $pos;
1559
  if ($len >= $max) {
1560
  $i = $max;
1561
- $len-= $max;
1562
  $pos = 0;
1563
  } else {
1564
  $i = $len;
1565
- $pos+= $len;
1566
  $len = 0;
1567
  }
1568
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $this->blocksize
@@ -1572,16 +1615,16 @@ abstract class SymmetricKey
1572
  }
1573
  $overflow = $len % $this->block_size;
1574
  if ($overflow) {
1575
- $plaintext.= openssl_decrypt(substr($ciphertext, 0, -$overflow), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
1576
  if ($len - $overflow) {
1577
  $iv = substr($ciphertext, -$overflow - $this->block_size, -$overflow);
1578
  }
1579
  $iv = openssl_encrypt(str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
1580
- $plaintext.= $iv ^ substr($ciphertext, -$overflow);
1581
  $iv = substr_replace($iv, substr($ciphertext, -$overflow), 0, $overflow);
1582
  $pos = $overflow;
1583
  } elseif ($len) {
1584
- $plaintext.= openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
1585
  $iv = substr($ciphertext, -$this->block_size);
1586
  }
1587
  break;
@@ -1595,6 +1638,21 @@ abstract class SymmetricKey
1595
  }
1596
  }
1597
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1598
  case self::MODE_OFB:
1599
  $plaintext = $this->openssl_ofb_process($ciphertext, $this->decryptIV, $this->debuffer);
1600
  }
@@ -1603,7 +1661,8 @@ abstract class SymmetricKey
1603
  }
1604
 
1605
  if ($this->engine === self::ENGINE_MCRYPT) {
1606
- set_error_handler(function() {});
 
1607
  $block_size = $this->block_size;
1608
  if ($this->dechanged) {
1609
  mcrypt_generic_init($this->demcrypt, $this->key, $this->getIV($this->decryptIV));
@@ -1621,11 +1680,11 @@ abstract class SymmetricKey
1621
  $max = $block_size - $pos;
1622
  if ($len >= $max) {
1623
  $i = $max;
1624
- $len-= $max;
1625
  $pos = 0;
1626
  } else {
1627
  $i = $len;
1628
- $pos+= $len;
1629
  $len = 0;
1630
  }
1631
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
@@ -1634,13 +1693,13 @@ abstract class SymmetricKey
1634
  }
1635
  if ($len >= $block_size) {
1636
  $cb = substr($ciphertext, $i, $len - $len % $block_size);
1637
- $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb;
1638
  $iv = substr($cb, -$block_size);
1639
- $len%= $block_size;
1640
  }
1641
  if ($len) {
1642
  $iv = mcrypt_generic($this->ecb, $iv);
1643
- $plaintext.= $iv ^ substr($ciphertext, -$len);
1644
  $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len);
1645
  $pos = $len;
1646
  }
@@ -1672,15 +1731,15 @@ abstract class SymmetricKey
1672
  $plaintext = '';
1673
  switch ($this->mode) {
1674
  case self::MODE_ECB:
1675
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1676
- $plaintext.= $this->decryptBlock(substr($ciphertext, $i, $block_size));
1677
  }
1678
  break;
1679
  case self::MODE_CBC:
1680
  $xor = $this->decryptIV;
1681
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1682
  $block = substr($ciphertext, $i, $block_size);
1683
- $plaintext.= $this->decryptBlock($block) ^ $xor;
1684
  $xor = $block;
1685
  }
1686
  if ($this->continuousBuffer) {
@@ -1690,21 +1749,21 @@ abstract class SymmetricKey
1690
  case self::MODE_CTR:
1691
  $xor = $this->decryptIV;
1692
  if (strlen($buffer['ciphertext'])) {
1693
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1694
  $block = substr($ciphertext, $i, $block_size);
1695
  if (strlen($block) > strlen($buffer['ciphertext'])) {
1696
- $buffer['ciphertext'].= $this->encryptBlock($xor);
 
1697
  }
1698
- Strings::increment_str($xor);
1699
  $key = Strings::shift($buffer['ciphertext'], $block_size);
1700
- $plaintext.= $block ^ $key;
1701
  }
1702
  } else {
1703
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1704
  $block = substr($ciphertext, $i, $block_size);
1705
  $key = $this->encryptBlock($xor);
1706
  Strings::increment_str($xor);
1707
- $plaintext.= $block ^ $key;
1708
  }
1709
  }
1710
  if ($this->continuousBuffer) {
@@ -1729,11 +1788,11 @@ abstract class SymmetricKey
1729
  $max = $block_size - $pos;
1730
  if ($len >= $max) {
1731
  $i = $max;
1732
- $len-= $max;
1733
  $pos = 0;
1734
  } else {
1735
  $i = $len;
1736
- $pos+= $len;
1737
  $len = 0;
1738
  }
1739
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
@@ -1743,14 +1802,14 @@ abstract class SymmetricKey
1743
  while ($len >= $block_size) {
1744
  $iv = $this->encryptBlock($iv);
1745
  $cb = substr($ciphertext, $i, $block_size);
1746
- $plaintext.= $iv ^ $cb;
1747
  $iv = $cb;
1748
- $len-= $block_size;
1749
- $i+= $block_size;
1750
  }
1751
  if ($len) {
1752
  $iv = $this->encryptBlock($iv);
1753
- $plaintext.= $iv ^ substr($ciphertext, $i);
1754
  $iv = substr_replace($iv, substr($ciphertext, $i), 0, $len);
1755
  $pos = $len;
1756
  }
@@ -1773,22 +1832,37 @@ abstract class SymmetricKey
1773
  }
1774
  }
1775
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1776
  case self::MODE_OFB:
1777
  $xor = $this->decryptIV;
1778
  if (strlen($buffer['xor'])) {
1779
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1780
  $block = substr($ciphertext, $i, $block_size);
1781
  if (strlen($block) > strlen($buffer['xor'])) {
1782
  $xor = $this->encryptBlock($xor);
1783
- $buffer['xor'].= $xor;
1784
  }
1785
  $key = Strings::shift($buffer['xor'], $block_size);
1786
- $plaintext.= $block ^ $key;
1787
  }
1788
  } else {
1789
- for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
1790
  $xor = $this->encryptBlock($xor);
1791
- $plaintext.= substr($ciphertext, $i, $block_size) ^ $xor;
1792
  }
1793
  $key = $xor;
1794
  }
@@ -1912,21 +1986,21 @@ abstract class SymmetricKey
1912
  if ($this->openssl_emulate_ctr) {
1913
  $xor = $encryptIV;
1914
  if (strlen($buffer['ciphertext'])) {
1915
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1916
  $block = substr($plaintext, $i, $block_size);
1917
  if (strlen($block) > strlen($buffer['ciphertext'])) {
1918
- $buffer['ciphertext'].= openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
1919
  }
1920
  Strings::increment_str($xor);
1921
  $otp = Strings::shift($buffer['ciphertext'], $block_size);
1922
- $ciphertext.= $block ^ $otp;
1923
  }
1924
  } else {
1925
- for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
1926
  $block = substr($plaintext, $i, $block_size);
1927
  $otp = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
1928
  Strings::increment_str($xor);
1929
- $ciphertext.= $block ^ $otp;
1930
  }
1931
  }
1932
  if ($this->continuousBuffer) {
@@ -1953,13 +2027,13 @@ abstract class SymmetricKey
1953
  $plaintext2 = Strings::pop($plaintext, $overflow); // ie. trim $plaintext to a multiple of $block_size and put rest of $plaintext in $plaintext2
1954
  $encrypted = openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV);
1955
  $temp = Strings::pop($encrypted, $block_size);
1956
- $ciphertext.= $encrypted . ($plaintext2 ^ $temp);
1957
  if ($this->continuousBuffer) {
1958
  $buffer['ciphertext'] = substr($temp, $overflow);
1959
  $encryptIV = $temp;
1960
  }
1961
  } elseif (!strlen($buffer['ciphertext'])) {
1962
- $ciphertext.= openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV);
1963
  $temp = Strings::pop($ciphertext, $block_size);
1964
  if ($this->continuousBuffer) {
1965
  $encryptIV = $temp;
@@ -2008,12 +2082,12 @@ abstract class SymmetricKey
2008
 
2009
  if (strlen($plaintext)) {
2010
  if ($overflow) {
2011
- $ciphertext.= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV);
2012
  $xor = Strings::pop($ciphertext, $block_size);
2013
  if ($this->continuousBuffer) {
2014
  $encryptIV = $xor;
2015
  }
2016
- $ciphertext.= Strings::shift($xor, $overflow) ^ substr($plaintext, -$overflow);
2017
  if ($this->continuousBuffer) {
2018
  $buffer['xor'] = $xor;
2019
  }
@@ -2198,7 +2272,8 @@ abstract class SymmetricKey
2198
  }
2199
  return false;
2200
  case self::ENGINE_MCRYPT:
2201
- set_error_handler(function() {});
 
2202
  $result = $this->cipher_name_mcrypt &&
2203
  extension_loaded('mcrypt') &&
2204
  in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms());
@@ -2316,7 +2391,8 @@ abstract class SymmetricKey
2316
  }
2317
 
2318
  if ($this->engine != self::ENGINE_MCRYPT && $this->enmcrypt) {
2319
- set_error_handler(function() {});
 
2320
  // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed,
2321
  // (re)open them with the module named in $this->cipher_name_mcrypt
2322
  mcrypt_module_close($this->enmcrypt);
@@ -2436,7 +2512,8 @@ abstract class SymmetricKey
2436
  case self::ENGINE_MCRYPT:
2437
  $this->enchanged = $this->dechanged = true;
2438
 
2439
- set_error_handler(function() {});
 
2440
 
2441
  if (!isset($this->enmcrypt)) {
2442
  static $mcrypt_modes = [
@@ -2446,6 +2523,7 @@ abstract class SymmetricKey
2446
  self::MODE_CFB => 'ncfb',
2447
  self::MODE_CFB8 => MCRYPT_MODE_CFB,
2448
  self::MODE_OFB => MCRYPT_MODE_NOFB,
 
2449
  self::MODE_STREAM => MCRYPT_MODE_STREAM,
2450
  ];
2451
 
@@ -2458,7 +2536,6 @@ abstract class SymmetricKey
2458
  if ($this->mode == self::MODE_CFB) {
2459
  $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
2460
  }
2461
-
2462
  } // else should mcrypt_generic_deinit be called?
2463
 
2464
  if ($this->mode == self::MODE_CFB) {
@@ -2733,9 +2810,9 @@ abstract class SymmetricKey
2733
  $_ciphertext = "";
2734
  $_plaintext_len = strlen($_text);
2735
 
2736
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2737
- $in = substr($_text, $_i, '.$block_size.');
2738
- '.$encrypt_block.'
2739
  $_ciphertext.= $in;
2740
  }
2741
 
@@ -2744,12 +2821,12 @@ abstract class SymmetricKey
2744
 
2745
  $decrypt = $init_decrypt . '
2746
  $_plaintext = "";
2747
- $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0));
2748
  $_ciphertext_len = strlen($_text);
2749
 
2750
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
2751
- $in = substr($_text, $_i, '.$block_size.');
2752
- '.$decrypt_block.'
2753
  $_plaintext.= $in;
2754
  }
2755
 
@@ -2763,22 +2840,22 @@ abstract class SymmetricKey
2763
  $_xor = $this->encryptIV;
2764
  $_buffer = &$this->enbuffer;
2765
  if (strlen($_buffer["ciphertext"])) {
2766
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2767
- $_block = substr($_text, $_i, '.$block_size.');
2768
  if (strlen($_block) > strlen($_buffer["ciphertext"])) {
2769
  $in = $_xor;
2770
- '.$encrypt_block.'
2771
  \phpseclib3\Common\Functions\Strings::increment_str($_xor);
2772
  $_buffer["ciphertext"].= $in;
2773
  }
2774
- $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["ciphertext"], '.$block_size.');
2775
  $_ciphertext.= $_block ^ $_key;
2776
  }
2777
  } else {
2778
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2779
- $_block = substr($_text, $_i, '.$block_size.');
2780
  $in = $_xor;
2781
- '.$encrypt_block.'
2782
  \phpseclib3\Common\Functions\Strings::increment_str($_xor);
2783
  $_key = $in;
2784
  $_ciphertext.= $_block ^ $_key;
@@ -2786,7 +2863,7 @@ abstract class SymmetricKey
2786
  }
2787
  if ($this->continuousBuffer) {
2788
  $this->encryptIV = $_xor;
2789
- if ($_start = $_plaintext_len % '.$block_size.') {
2790
  $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"];
2791
  }
2792
  }
@@ -2801,22 +2878,22 @@ abstract class SymmetricKey
2801
  $_buffer = &$this->debuffer;
2802
 
2803
  if (strlen($_buffer["ciphertext"])) {
2804
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
2805
- $_block = substr($_text, $_i, '.$block_size.');
2806
  if (strlen($_block) > strlen($_buffer["ciphertext"])) {
2807
  $in = $_xor;
2808
- '.$encrypt_block.'
2809
  \phpseclib3\Common\Functions\Strings::increment_str($_xor);
2810
  $_buffer["ciphertext"].= $in;
2811
  }
2812
- $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["ciphertext"], '.$block_size.');
2813
  $_plaintext.= $_block ^ $_key;
2814
  }
2815
  } else {
2816
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
2817
- $_block = substr($_text, $_i, '.$block_size.');
2818
  $in = $_xor;
2819
- '.$encrypt_block.'
2820
  \phpseclib3\Common\Functions\Strings::increment_str($_xor);
2821
  $_key = $in;
2822
  $_plaintext.= $_block ^ $_key;
@@ -2824,7 +2901,7 @@ abstract class SymmetricKey
2824
  }
2825
  if ($this->continuousBuffer) {
2826
  $this->decryptIV = $_xor;
2827
- if ($_start = $_ciphertext_len % '.$block_size.') {
2828
  $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"];
2829
  }
2830
  }
@@ -2848,7 +2925,7 @@ abstract class SymmetricKey
2848
  $_i = 0;
2849
  if ($_pos) {
2850
  $_orig_pos = $_pos;
2851
- $_max = '.$block_size.' - $_pos;
2852
  if ($_len >= $_max) {
2853
  $_i = $_max;
2854
  $_len-= $_max;
@@ -2861,17 +2938,17 @@ abstract class SymmetricKey
2861
  $_ciphertext = substr($_iv, $_orig_pos) ^ $_text;
2862
  $_iv = substr_replace($_iv, $_ciphertext, $_orig_pos, $_i);
2863
  }
2864
- while ($_len >= '.$block_size.') {
2865
  $in = $_iv;
2866
- '.$encrypt_block.';
2867
- $_iv = $in ^ substr($_text, $_i, '.$block_size.');
2868
  $_ciphertext.= $_iv;
2869
- $_len-= '.$block_size.';
2870
- $_i+= '.$block_size.';
2871
  }
2872
  if ($_len) {
2873
  $in = $_iv;
2874
- '.$encrypt_block.'
2875
  $_iv = $in;
2876
  $_block = $_iv ^ substr($_text, $_i);
2877
  $_iv = substr_replace($_iv, $_block, 0, $_len);
@@ -2896,7 +2973,7 @@ abstract class SymmetricKey
2896
  $_i = 0;
2897
  if ($_pos) {
2898
  $_orig_pos = $_pos;
2899
- $_max = '.$block_size.' - $_pos;
2900
  if ($_len >= $_max) {
2901
  $_i = $_max;
2902
  $_len-= $_max;
@@ -2909,19 +2986,19 @@ abstract class SymmetricKey
2909
  $_plaintext = substr($_iv, $_orig_pos) ^ $_text;
2910
  $_iv = substr_replace($_iv, substr($_text, 0, $_i), $_orig_pos, $_i);
2911
  }
2912
- while ($_len >= '.$block_size.') {
2913
  $in = $_iv;
2914
- '.$encrypt_block.'
2915
  $_iv = $in;
2916
- $cb = substr($_text, $_i, '.$block_size.');
2917
  $_plaintext.= $_iv ^ $cb;
2918
  $_iv = $cb;
2919
- $_len-= '.$block_size.';
2920
- $_i+= '.$block_size.';
2921
  }
2922
  if ($_len) {
2923
  $in = $_iv;
2924
- '.$encrypt_block.'
2925
  $_iv = $in;
2926
  $_plaintext.= $_iv ^ substr($_text, $_i);
2927
  $_iv = substr_replace($_iv, substr($_text, $_i), 0, $_len);
@@ -2939,16 +3016,16 @@ abstract class SymmetricKey
2939
 
2940
  for ($_i = 0; $_i < $_len; ++$_i) {
2941
  $in = $_iv;
2942
- '.$encrypt_block.'
2943
  $_ciphertext .= ($_c = $_text[$_i] ^ $in);
2944
  $_iv = substr($_iv, 1) . $_c;
2945
  }
2946
 
2947
  if ($this->continuousBuffer) {
2948
- if ($_len >= '.$block_size.') {
2949
- $this->encryptIV = substr($_ciphertext, -'.$block_size.');
2950
  } else {
2951
- $this->encryptIV = substr($this->encryptIV, $_len - '.$block_size.') . substr($_ciphertext, -$_len);
2952
  }
2953
  }
2954
 
@@ -2961,19 +3038,57 @@ abstract class SymmetricKey
2961
 
2962
  for ($_i = 0; $_i < $_len; ++$_i) {
2963
  $in = $_iv;
2964
- '.$encrypt_block.'
2965
  $_plaintext .= $_text[$_i] ^ $in;
2966
  $_iv = substr($_iv, 1) . $_text[$_i];
2967
  }
2968
 
2969
  if ($this->continuousBuffer) {
2970
- if ($_len >= '.$block_size.') {
2971
- $this->decryptIV = substr($_text, -'.$block_size.');
2972
  } else {
2973
- $this->decryptIV = substr($this->decryptIV, $_len - '.$block_size.') . substr($_text, -$_len);
2974
  }
2975
  }
2976
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2977
  return $_plaintext;
2978
  ';
2979
  break;
@@ -2985,29 +3100,29 @@ abstract class SymmetricKey
2985
  $_buffer = &$this->enbuffer;
2986
 
2987
  if (strlen($_buffer["xor"])) {
2988
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
2989
- $_block = substr($_text, $_i, '.$block_size.');
2990
  if (strlen($_block) > strlen($_buffer["xor"])) {
2991
  $in = $_xor;
2992
- '.$encrypt_block.'
2993
  $_xor = $in;
2994
  $_buffer["xor"].= $_xor;
2995
  }
2996
- $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["xor"], '.$block_size.');
2997
  $_ciphertext.= $_block ^ $_key;
2998
  }
2999
  } else {
3000
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
3001
  $in = $_xor;
3002
- '.$encrypt_block.'
3003
  $_xor = $in;
3004
- $_ciphertext.= substr($_text, $_i, '.$block_size.') ^ $_xor;
3005
  }
3006
  $_key = $_xor;
3007
  }
3008
  if ($this->continuousBuffer) {
3009
  $this->encryptIV = $_xor;
3010
- if ($_start = $_plaintext_len % '.$block_size.') {
3011
  $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"];
3012
  }
3013
  }
@@ -3021,29 +3136,29 @@ abstract class SymmetricKey
3021
  $_buffer = &$this->debuffer;
3022
 
3023
  if (strlen($_buffer["xor"])) {
3024
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
3025
- $_block = substr($_text, $_i, '.$block_size.');
3026
  if (strlen($_block) > strlen($_buffer["xor"])) {
3027
  $in = $_xor;
3028
- '.$encrypt_block.'
3029
  $_xor = $in;
3030
  $_buffer["xor"].= $_xor;
3031
  }
3032
- $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["xor"], '.$block_size.');
3033
  $_plaintext.= $_block ^ $_key;
3034
  }
3035
  } else {
3036
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
3037
  $in = $_xor;
3038
- '.$encrypt_block.'
3039
  $_xor = $in;
3040
- $_plaintext.= substr($_text, $_i, '.$block_size.') ^ $_xor;
3041
  }
3042
  $_key = $_xor;
3043
  }
3044
  if ($this->continuousBuffer) {
3045
  $this->decryptIV = $_xor;
3046
- if ($_start = $_ciphertext_len % '.$block_size.') {
3047
  $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"];
3048
  }
3049
  }
@@ -3053,12 +3168,12 @@ abstract class SymmetricKey
3053
  case self::MODE_STREAM:
3054
  $encrypt = $init_encrypt . '
3055
  $_ciphertext = "";
3056
- '.$encrypt_block.'
3057
  return $_ciphertext;
3058
  ';
3059
  $decrypt = $init_decrypt . '
3060
  $_plaintext = "";
3061
- '.$decrypt_block.'
3062
  return $_plaintext;
3063
  ';
3064
  break;
@@ -3070,9 +3185,9 @@ abstract class SymmetricKey
3070
 
3071
  $in = $this->encryptIV;
3072
 
3073
- for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
3074
- $in = substr($_text, $_i, '.$block_size.') ^ $in;
3075
- '.$encrypt_block.'
3076
  $_ciphertext.= $in;
3077
  }
3078
 
@@ -3085,14 +3200,14 @@ abstract class SymmetricKey
3085
 
3086
  $decrypt = $init_decrypt . '
3087
  $_plaintext = "";
3088
- $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0));
3089
  $_ciphertext_len = strlen($_text);
3090
 
3091
  $_iv = $this->decryptIV;
3092
 
3093
- for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
3094
- $in = $_block = substr($_text, $_i, '.$block_size.');
3095
- '.$decrypt_block.'
3096
  $_plaintext.= $in ^ $_iv;
3097
  $_iv = $_block;
3098
  }
@@ -3270,7 +3385,7 @@ abstract class SymmetricKey
3270
  $s = $this->poly1305Key; // strlen($this->poly1305Key) == 32
3271
  $r = Strings::shift($s, 16);
3272
  $r = strrev($r);
3273
- $r&= "\x0f\xff\xff\xfc\x0f\xff\xff\xfc\x0f\xff\xff\xfc\x0f\xff\xff\xff";
3274
  $s = strrev($s);
3275
 
3276
  $r = self::$poly1305Field->newInteger(new BigInteger($r, 256));
@@ -3288,4 +3403,17 @@ abstract class SymmetricKey
3288
  $mask = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
3289
  return strrev($r->toBytes()) & $mask;
3290
  }
3291
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  namespace phpseclib3\Crypt\Common;
38
 
 
39
  use phpseclib3\Common\Functions\Strings;
40
+ use phpseclib3\Crypt\Hash;
 
 
41
  use phpseclib3\Exception\BadDecryptionException;
42
  use phpseclib3\Exception\BadModeException;
43
  use phpseclib3\Exception\InconsistentSetupException;
44
  use phpseclib3\Exception\InsufficientSetupException;
45
  use phpseclib3\Exception\UnsupportedAlgorithmException;
46
+ use phpseclib3\Math\BigInteger;
47
+ use phpseclib3\Math\BinaryField;
48
+ use phpseclib3\Math\PrimeField;
49
 
50
  /**
51
  * Base Class for all \phpseclib3\Crypt\* cipher classes
101
  * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
102
  * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
103
  */
104
+ const MODE_CFB8 = 7;
105
+ /**
106
+ * Encrypt / decrypt using the Output Feedback mode (8bit)
107
+ *
108
+ * @access public
109
+ * @see \phpseclib3\Crypt\Common\SymmetricKey::encrypt()
110
+ * @see \phpseclib3\Crypt\Common\SymmetricKey::decrypt()
111
+ */
112
+ const MODE_OFB8 = 8;
113
  /**
114
  * Encrypt / decrypt using the Output Feedback mode.
115
  *
150
  'cfb' => self::MODE_CFB,
151
  'cfb8' => self::MODE_CFB8,
152
  'ofb' => self::MODE_OFB,
153
+ 'ofb8' => self::MODE_OFB8,
154
  'gcm' => self::MODE_GCM,
155
  'stream' => self::MODE_STREAM
156
  ];
651
  *
652
  * - ofb
653
  *
654
+ * - ofb8
655
+ *
656
  * - gcm
657
  *
658
  * @param string $mode
680
  case self::MODE_CFB:
681
  case self::MODE_CFB8:
682
  case self::MODE_OFB:
683
+ case self::MODE_OFB8:
684
  case self::MODE_STREAM:
685
  $this->paddable = false;
686
  break;
887
 
888
  if (is_string($this->key) && strlen($this->key) != $this->explicit_key_length) {
889
  $this->key = false;
890
+ throw new InconsistentSetupException('Key has already been set and is not ' . $this->explicit_key_length . ' bytes long');
891
  }
892
  }
893
 
980
 
981
  -- https://tools.ietf.org/html/rfc7292#appendix-B.1
982
  */
983
+ $password = "\0" . chunk_split($password, 1, "\0") . "\0";
984
 
985
  /*
986
  This standard specifies 3 different values for the ID byte mentioned
1003
  $s = '';
1004
  if (strlen($salt)) {
1005
  while (strlen($s) < $blockLength) {
1006
+ $s .= $salt;
1007
  }
1008
  }
1009
  $s = substr($s, 0, $blockLength);
1011
  $p = '';
1012
  if (strlen($password)) {
1013
  while (strlen($p) < $blockLength) {
1014
+ $p .= $password;
1015
  }
1016
  }
1017
  $p = substr($p, 0, $blockLength);
1047
  $f = $u = $hashObj->hash($salt . pack('N', $i++));
1048
  for ($j = 2; $j <= $count; ++$j) {
1049
  $u = $hashObj->hash($u);
1050
+ $f ^= $u;
1051
  }
1052
+ $key .= $f;
1053
  }
1054
  $key = substr($key, 0, $dkLen);
1055
  break;
1100
  }
1101
  $b = '';
1102
  while (strlen($b) < $blockLength) {
1103
+ $b .= $ai;
1104
  }
1105
  $b = substr($b, 0, $blockLength);
1106
  $b = new BigInteger($b, 256);
1107
  $newi = '';
1108
+ for ($k = 0; $k < strlen($i); $k += $blockLength) {
1109
  $temp = substr($i, $k, $blockLength);
1110
  $temp = new BigInteger($temp, 256);
1111
  $temp->setPrecision($blockLength << 3);
1112
  $temp = $temp->add($b);
1113
  $temp = $temp->add($one);
1114
+ $newi .= $temp->toBytes(false);
1115
  }
1116
  $i = $newi;
1117
+ $a .= $ai;
1118
  }
1119
 
1120
  return substr($a, 0, $n);
1209
  $max = $this->block_size - $pos;
1210
  if ($len >= $max) {
1211
  $i = $max;
1212
+ $len -= $max;
1213
  $pos = 0;
1214
  } else {
1215
  $i = $len;
1216
+ $pos += $len;
1217
  $len = 0;
1218
  }
1219
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
1225
  $overflow = $len % $this->block_size;
1226
 
1227
  if ($overflow) {
1228
+ $ciphertext .= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
1229
  $iv = Strings::pop($ciphertext, $this->block_size);
1230
 
1231
  $size = $len - $overflow;
1232
  $block = $iv ^ substr($plaintext, -$overflow);
1233
  $iv = substr_replace($iv, $block, 0, $overflow);
1234
+ $ciphertext .= $block;
1235
  $pos = $overflow;
1236
  } elseif ($len) {
1237
  $ciphertext = openssl_encrypt($plaintext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
1249
  }
1250
  }
1251
  return $ciphertext;
1252
+ case self::MODE_OFB8:
1253
+ $ciphertext = '';
1254
+ $len = strlen($plaintext);
1255
+ $iv = $this->encryptIV;
1256
+
1257
+ for ($i = 0; $i < $len; ++$i) {
1258
+ $xor = openssl_encrypt($iv, $this->cipher_name_openssl_ecb, $this->key, $this->openssl_options, $this->decryptIV);
1259
+ $ciphertext .= $plaintext[$i] ^ $xor;
1260
+ $iv = substr($iv, 1) . $xor[0];
1261
+ }
1262
+
1263
+ if ($this->continuousBuffer) {
1264
+ $this->encryptIV = $iv;
1265
+ }
1266
+ break;
1267
  case self::MODE_OFB:
1268
  return $this->openssl_ofb_process($plaintext, $this->encryptIV, $this->enbuffer);
1269
  }
1270
  }
1271
 
1272
  if ($this->engine === self::ENGINE_MCRYPT) {
1273
+ set_error_handler(function () {
1274
+ });
1275
  if ($this->enchanged) {
1276
  mcrypt_generic_init($this->enmcrypt, $this->key, $this->getIV($this->encryptIV));
1277
  $this->enchanged = false;
1292
  $max = $block_size - $pos;
1293
  if ($len >= $max) {
1294
  $i = $max;
1295
+ $len -= $max;
1296
  $pos = 0;
1297
  } else {
1298
  $i = $len;
1299
+ $pos += $len;
1300
  $len = 0;
1301
  }
1302
  $ciphertext = substr($iv, $orig_pos) ^ $plaintext;
1309
  mcrypt_generic_init($this->enmcrypt, $this->key, $iv);
1310
  $this->enbuffer['enmcrypt_init'] = false;
1311
  }
1312
+ $ciphertext .= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size));
1313
  $iv = substr($ciphertext, -$block_size);
1314
+ $len %= $block_size;
1315
  } else {
1316
  while ($len >= $block_size) {
1317
  $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size);
1318
+ $ciphertext .= $iv;
1319
+ $len -= $block_size;
1320
+ $i += $block_size;
1321
  }
1322
  }
1323
  }
1326
  $iv = mcrypt_generic($this->ecb, $iv);
1327
  $block = $iv ^ substr($plaintext, -$len);
1328
  $iv = substr_replace($iv, $block, 0, $len);
1329
+ $ciphertext .= $block;
1330
  $pos = $len;
1331
  }
1332
 
1356
  $ciphertext = '';
1357
  switch ($this->mode) {
1358
  case self::MODE_ECB:
1359
+ for ($i = 0; $i < strlen($plaintext); $i += $block_size) {
1360
+ $ciphertext .= $this->encryptBlock(substr($plaintext, $i, $block_size));
1361
  }
1362
  break;
1363
  case self::MODE_CBC:
1364
  $xor = $this->encryptIV;
1365
+ for ($i = 0; $i < strlen($plaintext); $i += $block_size) {
1366
  $block = substr($plaintext, $i, $block_size);
1367
  $block = $this->encryptBlock($block ^ $xor);
1368
  $xor = $block;
1369
+ $ciphertext .= $block;
1370
  }
1371
  if ($this->continuousBuffer) {
1372
  $this->encryptIV = $xor;
1375
  case self::MODE_CTR:
1376
  $xor = $this->encryptIV;
1377
  if (strlen($buffer['ciphertext'])) {
1378
+ for ($i = 0; $i < strlen($plaintext); $i += $block_size) {
1379
  $block = substr($plaintext, $i, $block_size);
1380
  if (strlen($block) > strlen($buffer['ciphertext'])) {
1381
+ $buffer['ciphertext'] .= $this->encryptBlock($xor);
1382
+ Strings::increment_str($xor);
1383
  }
 
1384
  $key = Strings::shift($buffer['ciphertext'], $block_size);
1385
+ $ciphertext .= $block ^ $key;
1386
  }
1387
  } else {
1388
+ for ($i = 0; $i < strlen($plaintext); $i += $block_size) {
1389
  $block = substr($plaintext, $i, $block_size);
1390
  $key = $this->encryptBlock($xor);
1391
  Strings::increment_str($xor);
1392
+ $ciphertext .= $block ^ $key;
1393
  }
1394
  }
1395
  if ($this->continuousBuffer) {
1416
  $max = $block_size - $pos;
1417
  if ($len >= $max) {
1418
  $i = $max;
1419
+ $len -= $max;
1420
  $pos = 0;
1421
  } else {
1422
  $i = $len;
1423
+ $pos += $len;
1424
  $len = 0;
1425
  }
1426
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
1429
  }
1430
  while ($len >= $block_size) {
1431
  $iv = $this->encryptBlock($iv) ^ substr($plaintext, $i, $block_size);
1432
+ $ciphertext .= $iv;
1433
+ $len -= $block_size;
1434
+ $i += $block_size;
1435
  }
1436
  if ($len) {
1437
  $iv = $this->encryptBlock($iv);
1438
  $block = $iv ^ substr($plaintext, $i);
1439
  $iv = substr_replace($iv, $block, 0, $len);
1440
+ $ciphertext .= $block;
1441
  $pos = $len;
1442
  }
1443
  break;
1459
  }
1460
  }
1461
  break;
1462
+ case self::MODE_OFB8:
1463
+ $ciphertext = '';
1464
+ $len = strlen($plaintext);
1465
+ $iv = $this->encryptIV;
1466
+
1467
+ for ($i = 0; $i < $len; ++$i) {
1468
+ $xor = $this->encryptBlock($iv);
1469
+ $ciphertext .= $plaintext[$i] ^ $xor;
1470
+ $iv = substr($iv, 1) . $xor[0];
1471
+ }
1472
+
1473
+ if ($this->continuousBuffer) {
1474
+ $this->encryptIV = $iv;
1475
+ }
1476
+ break;
1477
  case self::MODE_OFB:
1478
  $xor = $this->encryptIV;
1479
  if (strlen($buffer['xor'])) {
1480
+ for ($i = 0; $i < strlen($plaintext); $i += $block_size) {
1481
  $block = substr($plaintext, $i, $block_size);
1482
  if (strlen($block) > strlen($buffer['xor'])) {
1483
  $xor = $this->encryptBlock($xor);
1484
+ $buffer['xor'] .= $xor;
1485
  }
1486
  $key = Strings::shift($buffer['xor'], $block_size);
1487
+ $ciphertext .= $block ^ $key;
1488
  }
1489
  } else {
1490
+ for ($i = 0; $i < strlen($plaintext); $i += $block_size) {
1491
  $xor = $this->encryptBlock($xor);
1492
+ $ciphertext .= substr($plaintext, $i, $block_size) ^ $xor;
1493
  }
1494
  $key = $xor;
1495
  }
1601
  $max = $this->block_size - $pos;
1602
  if ($len >= $max) {
1603
  $i = $max;
1604
+ $len -= $max;
1605
  $pos = 0;
1606
  } else {
1607
  $i = $len;
1608
+ $pos += $len;
1609
  $len = 0;
1610
  }
1611
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $this->blocksize
1615
  }
1616
  $overflow = $len % $this->block_size;
1617
  if ($overflow) {
1618
+ $plaintext .= openssl_decrypt(substr($ciphertext, 0, -$overflow), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
1619
  if ($len - $overflow) {
1620
  $iv = substr($ciphertext, -$overflow - $this->block_size, -$overflow);
1621
  }
1622
  $iv = openssl_encrypt(str_repeat("\0", $this->block_size), $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
1623
+ $plaintext .= $iv ^ substr($ciphertext, -$overflow);
1624
  $iv = substr_replace($iv, substr($ciphertext, -$overflow), 0, $overflow);
1625
  $pos = $overflow;
1626
  } elseif ($len) {
1627
+ $plaintext .= openssl_decrypt($ciphertext, $this->cipher_name_openssl, $this->key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
1628
  $iv = substr($ciphertext, -$this->block_size);
1629
  }
1630
  break;
1638
  }
1639
  }
1640
  break;
1641
+ case self::MODE_OFB8:
1642
+ $plaintext = '';
1643
+ $len = strlen($ciphertext);
1644
+ $iv = $this->decryptIV;
1645
+
1646
+ for ($i = 0; $i < $len; ++$i) {
1647
+ $xor = openssl_encrypt($iv, $this->cipher_name_openssl_ecb, $this->key, $this->openssl_options, $this->decryptIV);
1648
+ $plaintext .= $ciphertext[$i] ^ $xor;
1649
+ $iv = substr($iv, 1) . $xor[0];
1650
+ }
1651
+
1652
+ if ($this->continuousBuffer) {
1653
+ $this->decryptIV = $iv;
1654
+ }
1655
+ break;
1656
  case self::MODE_OFB:
1657
  $plaintext = $this->openssl_ofb_process($ciphertext, $this->decryptIV, $this->debuffer);
1658
  }
1661
  }
1662
 
1663
  if ($this->engine === self::ENGINE_MCRYPT) {
1664
+ set_error_handler(function () {
1665
+ });
1666
  $block_size = $this->block_size;
1667
  if ($this->dechanged) {
1668
  mcrypt_generic_init($this->demcrypt, $this->key, $this->getIV($this->decryptIV));
1680
  $max = $block_size - $pos;
1681
  if ($len >= $max) {
1682
  $i = $max;
1683
+ $len -= $max;
1684
  $pos = 0;
1685
  } else {
1686
  $i = $len;
1687
+ $pos += $len;
1688
  $len = 0;
1689
  }
1690
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
1693
  }
1694
  if ($len >= $block_size) {
1695
  $cb = substr($ciphertext, $i, $len - $len % $block_size);
1696
+ $plaintext .= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb;
1697
  $iv = substr($cb, -$block_size);
1698
+ $len %= $block_size;
1699
  }
1700
  if ($len) {
1701
  $iv = mcrypt_generic($this->ecb, $iv);
1702
+ $plaintext .= $iv ^ substr($ciphertext, -$len);
1703
  $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len);
1704
  $pos = $len;
1705
  }
1731
  $plaintext = '';
1732
  switch ($this->mode) {
1733
  case self::MODE_ECB:
1734
+ for ($i = 0; $i < strlen($ciphertext); $i += $block_size) {
1735
+ $plaintext .= $this->decryptBlock(substr($ciphertext, $i, $block_size));
1736
  }
1737
  break;
1738
  case self::MODE_CBC:
1739
  $xor = $this->decryptIV;
1740
+ for ($i = 0; $i < strlen($ciphertext); $i += $block_size) {
1741
  $block = substr($ciphertext, $i, $block_size);
1742
+ $plaintext .= $this->decryptBlock($block) ^ $xor;
1743
  $xor = $block;
1744
  }
1745
  if ($this->continuousBuffer) {
1749
  case self::MODE_CTR:
1750
  $xor = $this->decryptIV;
1751
  if (strlen($buffer['ciphertext'])) {
1752
+ for ($i = 0; $i < strlen($ciphertext); $i += $block_size) {
1753
  $block = substr($ciphertext, $i, $block_size);
1754
  if (strlen($block) > strlen($buffer['ciphertext'])) {
1755
+ $buffer['ciphertext'] .= $this->encryptBlock($xor);
1756
+ Strings::increment_str($xor);
1757
  }
 
1758
  $key = Strings::shift($buffer['ciphertext'], $block_size);
1759
+ $plaintext .= $block ^ $key;
1760
  }
1761
  } else {
1762
+ for ($i = 0; $i < strlen($ciphertext); $i += $block_size) {
1763
  $block = substr($ciphertext, $i, $block_size);
1764
  $key = $this->encryptBlock($xor);
1765
  Strings::increment_str($xor);
1766
+ $plaintext .= $block ^ $key;
1767
  }
1768
  }
1769
  if ($this->continuousBuffer) {
1788
  $max = $block_size - $pos;
1789
  if ($len >= $max) {
1790
  $i = $max;
1791
+ $len -= $max;
1792
  $pos = 0;
1793
  } else {
1794
  $i = $len;
1795
+ $pos += $len;
1796
  $len = 0;
1797
  }
1798
  // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
1802
  while ($len >= $block_size) {
1803
  $iv = $this->encryptBlock($iv);
1804
  $cb = substr($ciphertext, $i, $block_size);
1805
+ $plaintext .= $iv ^ $cb;
1806
  $iv = $cb;
1807
+ $len -= $block_size;
1808
+ $i += $block_size;
1809
  }
1810
  if ($len) {
1811
  $iv = $this->encryptBlock($iv);
1812
+ $plaintext .= $iv ^ substr($ciphertext, $i);
1813
  $iv = substr_replace($iv, substr($ciphertext, $i), 0, $len);
1814
  $pos = $len;
1815
  }
1832
  }
1833
  }
1834
  break;
1835
+ case self::MODE_OFB8:
1836
+ $plaintext = '';
1837
+ $len = strlen($ciphertext);
1838
+ $iv = $this->decryptIV;
1839
+
1840
+ for ($i = 0; $i < $len; ++$i) {
1841
+ $xor = $this->encryptBlock($iv);
1842
+ $plaintext .= $ciphertext[$i] ^ $xor;
1843
+ $iv = substr($iv, 1) . $xor[0];
1844
+ }
1845
+
1846
+ if ($this->continuousBuffer) {
1847
+ $this->decryptIV = $iv;
1848
+ }
1849
+ break;
1850
  case self::MODE_OFB:
1851
  $xor = $this->decryptIV;
1852
  if (strlen($buffer['xor'])) {
1853
+ for ($i = 0; $i < strlen($ciphertext); $i += $block_size) {
1854
  $block = substr($ciphertext, $i, $block_size);
1855
  if (strlen($block) > strlen($buffer['xor'])) {
1856
  $xor = $this->encryptBlock($xor);
1857
+ $buffer['xor'] .= $xor;
1858
  }
1859
  $key = Strings::shift($buffer['xor'], $block_size);
1860
+ $plaintext .= $block ^ $key;
1861
  }
1862
  } else {
1863
+ for ($i = 0; $i < strlen($ciphertext); $i += $block_size) {
1864
  $xor = $this->encryptBlock($xor);
1865
+ $plaintext .= substr($ciphertext, $i, $block_size) ^ $xor;
1866
  }
1867
  $key = $xor;
1868
  }
1986
  if ($this->openssl_emulate_ctr) {
1987
  $xor = $encryptIV;
1988
  if (strlen($buffer['ciphertext'])) {
1989
+ for ($i = 0; $i < strlen($plaintext); $i += $block_size) {
1990
  $block = substr($plaintext, $i, $block_size);
1991
  if (strlen($block) > strlen($buffer['ciphertext'])) {
1992
+ $buffer['ciphertext'] .= openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
1993
  }
1994
  Strings::increment_str($xor);
1995
  $otp = Strings::shift($buffer['ciphertext'], $block_size);
1996
+ $ciphertext .= $block ^ $otp;
1997
  }
1998
  } else {
1999
+ for ($i = 0; $i < strlen($plaintext); $i += $block_size) {
2000
  $block = substr($plaintext, $i, $block_size);
2001
  $otp = openssl_encrypt($xor, $this->cipher_name_openssl_ecb, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
2002
  Strings::increment_str($xor);
2003
+ $ciphertext .= $block ^ $otp;
2004
  }
2005
  }
2006
  if ($this->continuousBuffer) {
2027
  $plaintext2 = Strings::pop($plaintext, $overflow); // ie. trim $plaintext to a multiple of $block_size and put rest of $plaintext in $plaintext2
2028
  $encrypted = openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV);
2029
  $temp = Strings::pop($encrypted, $block_size);
2030
+ $ciphertext .= $encrypted . ($plaintext2 ^ $temp);
2031
  if ($this->continuousBuffer) {
2032
  $buffer['ciphertext'] = substr($temp, $overflow);
2033
  $encryptIV = $temp;
2034
  }
2035
  } elseif (!strlen($buffer['ciphertext'])) {
2036
+ $ciphertext .= openssl_encrypt($plaintext . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV);
2037
  $temp = Strings::pop($ciphertext, $block_size);
2038
  if ($this->continuousBuffer) {
2039
  $encryptIV = $temp;
2082
 
2083
  if (strlen($plaintext)) {
2084
  if ($overflow) {
2085
+ $ciphertext .= openssl_encrypt(substr($plaintext, 0, -$overflow) . str_repeat("\0", $block_size), $this->cipher_name_openssl, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $encryptIV);
2086
  $xor = Strings::pop($ciphertext, $block_size);
2087
  if ($this->continuousBuffer) {
2088
  $encryptIV = $xor;
2089
  }
2090
+ $ciphertext .= Strings::shift($xor, $overflow) ^ substr($plaintext, -$overflow);
2091
  if ($this->continuousBuffer) {
2092
  $buffer['xor'] = $xor;
2093
  }
2272
  }
2273
  return false;
2274
  case self::ENGINE_MCRYPT:
2275
+ set_error_handler(function () {
2276
+ });
2277
  $result = $this->cipher_name_mcrypt &&
2278
  extension_loaded('mcrypt') &&
2279
  in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms());
2391
  }
2392
 
2393
  if ($this->engine != self::ENGINE_MCRYPT && $this->enmcrypt) {
2394
+ set_error_handler(function () {
2395
+ });
2396
  // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed,
2397
  // (re)open them with the module named in $this->cipher_name_mcrypt
2398
  mcrypt_module_close($this->enmcrypt);
2512
  case self::ENGINE_MCRYPT:
2513
  $this->enchanged = $this->dechanged = true;
2514
 
2515
+ set_error_handler(function () {
2516
+ });
2517
 
2518
  if (!isset($this->enmcrypt)) {
2519
  static $mcrypt_modes = [
2523
  self::MODE_CFB => 'ncfb',
2524
  self::MODE_CFB8 => MCRYPT_MODE_CFB,
2525
  self::MODE_OFB => MCRYPT_MODE_NOFB,
2526
+ self::MODE_OFB8 => MCRYPT_MODE_OFB,
2527
  self::MODE_STREAM => MCRYPT_MODE_STREAM,
2528
  ];
2529
 
2536
  if ($this->mode == self::MODE_CFB) {
2537
  $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
2538
  }
 
2539
  } // else should mcrypt_generic_deinit be called?
2540
 
2541
  if ($this->mode == self::MODE_CFB) {
2810
  $_ciphertext = "";
2811
  $_plaintext_len = strlen($_text);
2812
 
2813
+ for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') {
2814
+ $in = substr($_text, $_i, ' . $block_size . ');
2815
+ ' . $encrypt_block . '
2816
  $_ciphertext.= $in;
2817
  }
2818
 
2821
 
2822
  $decrypt = $init_decrypt . '
2823
  $_plaintext = "";
2824
+ $_text = str_pad($_text, strlen($_text) + (' . $block_size . ' - strlen($_text) % ' . $block_size . ') % ' . $block_size . ', chr(0));
2825
  $_ciphertext_len = strlen($_text);
2826
 
2827
+ for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') {
2828
+ $in = substr($_text, $_i, ' . $block_size . ');
2829
+ ' . $decrypt_block . '
2830
  $_plaintext.= $in;
2831
  }
2832
 
2840
  $_xor = $this->encryptIV;
2841
  $_buffer = &$this->enbuffer;
2842
  if (strlen($_buffer["ciphertext"])) {
2843
+ for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') {
2844
+ $_block = substr($_text, $_i, ' . $block_size . ');
2845
  if (strlen($_block) > strlen($_buffer["ciphertext"])) {
2846
  $in = $_xor;
2847
+ ' . $encrypt_block . '
2848
  \phpseclib3\Common\Functions\Strings::increment_str($_xor);
2849
  $_buffer["ciphertext"].= $in;
2850
  }
2851
+ $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["ciphertext"], ' . $block_size . ');
2852
  $_ciphertext.= $_block ^ $_key;
2853
  }
2854
  } else {
2855
+ for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') {
2856
+ $_block = substr($_text, $_i, ' . $block_size . ');
2857
  $in = $_xor;
2858
+ ' . $encrypt_block . '
2859
  \phpseclib3\Common\Functions\Strings::increment_str($_xor);
2860
  $_key = $in;
2861
  $_ciphertext.= $_block ^ $_key;
2863
  }
2864
  if ($this->continuousBuffer) {
2865
  $this->encryptIV = $_xor;
2866
+ if ($_start = $_plaintext_len % ' . $block_size . ') {
2867
  $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"];
2868
  }
2869
  }
2878
  $_buffer = &$this->debuffer;
2879
 
2880
  if (strlen($_buffer["ciphertext"])) {
2881
+ for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') {
2882
+ $_block = substr($_text, $_i, ' . $block_size . ');
2883
  if (strlen($_block) > strlen($_buffer["ciphertext"])) {
2884
  $in = $_xor;
2885
+ ' . $encrypt_block . '
2886
  \phpseclib3\Common\Functions\Strings::increment_str($_xor);
2887
  $_buffer["ciphertext"].= $in;
2888
  }
2889
+ $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["ciphertext"], ' . $block_size . ');
2890
  $_plaintext.= $_block ^ $_key;
2891
  }
2892
  } else {
2893
+ for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') {
2894
+ $_block = substr($_text, $_i, ' . $block_size . ');
2895
  $in = $_xor;
2896
+ ' . $encrypt_block . '
2897
  \phpseclib3\Common\Functions\Strings::increment_str($_xor);
2898
  $_key = $in;
2899
  $_plaintext.= $_block ^ $_key;
2901
  }
2902
  if ($this->continuousBuffer) {
2903
  $this->decryptIV = $_xor;
2904
+ if ($_start = $_ciphertext_len % ' . $block_size . ') {
2905
  $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"];
2906
  }
2907
  }
2925
  $_i = 0;
2926
  if ($_pos) {
2927
  $_orig_pos = $_pos;
2928
+ $_max = ' . $block_size . ' - $_pos;
2929
  if ($_len >= $_max) {
2930
  $_i = $_max;
2931
  $_len-= $_max;
2938
  $_ciphertext = substr($_iv, $_orig_pos) ^ $_text;
2939
  $_iv = substr_replace($_iv, $_ciphertext, $_orig_pos, $_i);
2940
  }
2941
+ while ($_len >= ' . $block_size . ') {
2942
  $in = $_iv;
2943
+ ' . $encrypt_block . ';
2944
+ $_iv = $in ^ substr($_text, $_i, ' . $block_size . ');
2945
  $_ciphertext.= $_iv;
2946
+ $_len-= ' . $block_size . ';
2947
+ $_i+= ' . $block_size . ';
2948
  }
2949
  if ($_len) {
2950
  $in = $_iv;
2951
+ ' . $encrypt_block . '
2952
  $_iv = $in;
2953
  $_block = $_iv ^ substr($_text, $_i);
2954
  $_iv = substr_replace($_iv, $_block, 0, $_len);
2973
  $_i = 0;
2974
  if ($_pos) {
2975
  $_orig_pos = $_pos;
2976
+ $_max = ' . $block_size . ' - $_pos;
2977
  if ($_len >= $_max) {
2978
  $_i = $_max;
2979
  $_len-= $_max;
2986
  $_plaintext = substr($_iv, $_orig_pos) ^ $_text;
2987
  $_iv = substr_replace($_iv, substr($_text, 0, $_i), $_orig_pos, $_i);
2988
  }
2989
+ while ($_len >= ' . $block_size . ') {
2990
  $in = $_iv;
2991
+ ' . $encrypt_block . '
2992
  $_iv = $in;
2993
+ $cb = substr($_text, $_i, ' . $block_size . ');
2994
  $_plaintext.= $_iv ^ $cb;
2995
  $_iv = $cb;
2996
+ $_len-= ' . $block_size . ';
2997
+ $_i+= ' . $block_size . ';
2998
  }
2999
  if ($_len) {
3000
  $in = $_iv;
3001
+ ' . $encrypt_block . '
3002
  $_iv = $in;
3003
  $_plaintext.= $_iv ^ substr($_text, $_i);
3004
  $_iv = substr_replace($_iv, substr($_text, $_i), 0, $_len);
3016
 
3017
  for ($_i = 0; $_i < $_len; ++$_i) {
3018
  $in = $_iv;
3019
+ ' . $encrypt_block . '
3020
  $_ciphertext .= ($_c = $_text[$_i] ^ $in);
3021
  $_iv = substr($_iv, 1) . $_c;
3022
  }
3023
 
3024
  if ($this->continuousBuffer) {
3025
+ if ($_len >= ' . $block_size . ') {
3026
+ $this->encryptIV = substr($_ciphertext, -' . $block_size . ');
3027
  } else {
3028
+ $this->encryptIV = substr($this->encryptIV, $_len - ' . $block_size . ') . substr($_ciphertext, -$_len);
3029
  }
3030
  }
3031
 
3038
 
3039
  for ($_i = 0; $_i < $_len; ++$_i) {
3040
  $in = $_iv;
3041
+ ' . $encrypt_block . '
3042
  $_plaintext .= $_text[$_i] ^ $in;
3043
  $_iv = substr($_iv, 1) . $_text[$_i];
3044
  }
3045
 
3046
  if ($this->continuousBuffer) {
3047
+ if ($_len >= ' . $block_size . ') {
3048
+ $this->decryptIV = substr($_text, -' . $block_size . ');
3049
  } else {
3050
+ $this->decryptIV = substr($this->decryptIV, $_len - ' . $block_size . ') . substr($_text, -$_len);
3051
  }
3052
  }
3053
 
3054
+ return $_plaintext;
3055
+ ';
3056
+ break;
3057
+ case self::MODE_OFB8:
3058
+ $encrypt = $init_encrypt . '
3059
+ $_ciphertext = "";
3060
+ $_len = strlen($_text);
3061
+ $_iv = $this->encryptIV;
3062
+
3063
+ for ($_i = 0; $_i < $_len; ++$_i) {
3064
+ $in = $_iv;
3065
+ ' . $encrypt_block . '
3066
+ $_ciphertext.= $_text[$_i] ^ $in;
3067
+ $_iv = substr($_iv, 1) . $in[0];
3068
+ }
3069
+
3070
+ if ($this->continuousBuffer) {
3071
+ $this->encryptIV = $_iv;
3072
+ }
3073
+
3074
+ return $_ciphertext;
3075
+ ';
3076
+ $decrypt = $init_encrypt . '
3077
+ $_plaintext = "";
3078
+ $_len = strlen($_text);
3079
+ $_iv = $this->decryptIV;
3080
+
3081
+ for ($_i = 0; $_i < $_len; ++$_i) {
3082
+ $in = $_iv;
3083
+ ' . $encrypt_block . '
3084
+ $_plaintext.= $_text[$_i] ^ $in;
3085
+ $_iv = substr($_iv, 1) . $in[0];
3086
+ }
3087
+
3088
+ if ($this->continuousBuffer) {
3089
+ $this->decryptIV = $_iv;
3090
+ }
3091
+
3092
  return $_plaintext;
3093
  ';
3094
  break;
3100
  $_buffer = &$this->enbuffer;
3101
 
3102
  if (strlen($_buffer["xor"])) {
3103
+ for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') {
3104
+ $_block = substr($_text, $_i, ' . $block_size . ');
3105
  if (strlen($_block) > strlen($_buffer["xor"])) {
3106
  $in = $_xor;
3107
+ ' . $encrypt_block . '
3108
  $_xor = $in;
3109
  $_buffer["xor"].= $_xor;
3110
  }
3111
+ $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["xor"], ' . $block_size . ');
3112
  $_ciphertext.= $_block ^ $_key;
3113
  }
3114
  } else {
3115
+ for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') {
3116
  $in = $_xor;
3117
+ ' . $encrypt_block . '
3118
  $_xor = $in;
3119
+ $_ciphertext.= substr($_text, $_i, ' . $block_size . ') ^ $_xor;
3120
  }
3121
  $_key = $_xor;
3122
  }
3123
  if ($this->continuousBuffer) {
3124
  $this->encryptIV = $_xor;
3125
+ if ($_start = $_plaintext_len % ' . $block_size . ') {
3126
  $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"];
3127
  }
3128
  }
3136
  $_buffer = &$this->debuffer;
3137
 
3138
  if (strlen($_buffer["xor"])) {
3139
+ for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') {
3140
+ $_block = substr($_text, $_i, ' . $block_size . ');
3141
  if (strlen($_block) > strlen($_buffer["xor"])) {
3142
  $in = $_xor;
3143
+ ' . $encrypt_block . '
3144
  $_xor = $in;
3145
  $_buffer["xor"].= $_xor;
3146
  }
3147
+ $_key = \phpseclib3\Common\Functions\Strings::shift($_buffer["xor"], ' . $block_size . ');
3148
  $_plaintext.= $_block ^ $_key;
3149
  }
3150
  } else {
3151
+ for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') {
3152
  $in = $_xor;
3153
+ ' . $encrypt_block . '
3154
  $_xor = $in;
3155
+ $_plaintext.= substr($_text, $_i, ' . $block_size . ') ^ $_xor;
3156
  }
3157
  $_key = $_xor;
3158
  }
3159
  if ($this->continuousBuffer) {
3160
  $this->decryptIV = $_xor;
3161
+ if ($_start = $_ciphertext_len % ' . $block_size . ') {
3162
  $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"];
3163
  }
3164
  }
3168
  case self::MODE_STREAM:
3169
  $encrypt = $init_encrypt . '
3170
  $_ciphertext = "";
3171
+ ' . $encrypt_block . '
3172
  return $_ciphertext;
3173
  ';
3174
  $decrypt = $init_decrypt . '
3175
  $_plaintext = "";
3176
+ ' . $decrypt_block . '
3177
  return $_plaintext;
3178
  ';
3179
  break;
3185
 
3186
  $in = $this->encryptIV;
3187
 
3188
+ for ($_i = 0; $_i < $_plaintext_len; $_i+= ' . $block_size . ') {
3189
+ $in = substr($_text, $_i, ' . $block_size . ') ^ $in;
3190
+ ' . $encrypt_block . '
3191
  $_ciphertext.= $in;
3192
  }
3193
 
3200
 
3201
  $decrypt = $init_decrypt . '
3202
  $_plaintext = "";
3203
+ $_text = str_pad($_text, strlen($_text) + (' . $block_size . ' - strlen($_text) % ' . $block_size . ') % ' . $block_size . ', chr(0));
3204
  $_ciphertext_len = strlen($_text);
3205
 
3206
  $_iv = $this->decryptIV;
3207
 
3208
+ for ($_i = 0; $_i < $_ciphertext_len; $_i+= ' . $block_size . ') {
3209
+ $in = $_block = substr($_text, $_i, ' . $block_size . ');
3210
+ ' . $decrypt_block . '
3211
  $_plaintext.= $in ^ $_iv;
3212
  $_iv = $_block;
3213
  }
3385
  $s = $this->poly1305Key; // strlen($this->poly1305Key) == 32
3386
  $r = Strings::shift($s, 16);
3387
  $r = strrev($r);
3388
+ $r &= "\x0f\xff\xff\xfc\x0f\xff\xff\xfc\x0f\xff\xff\xfc\x0f\xff\xff\xff";
3389
  $s = strrev($s);
3390
 
3391
  $r = self::$poly1305Field->newInteger(new BigInteger($r, 256));
3403
  $mask = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
3404
  return strrev($r->toBytes()) & $mask;
3405
  }
3406
+
3407
+ /**
3408
+ * Return the mode
3409
+ *
3410
+ * You can do $obj instanceof AES or whatever to get the cipher but you can't do that to get the mode
3411
+ *
3412
+ * @access public
3413
+ * @return string
3414
+ */
3415
+ public function getMode()
3416
+ {
3417
+ return array_flip(self::MODE_MAP)[$this->mode];
3418
+ }
3419
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Traits/Fingerprint.php CHANGED
@@ -59,4 +59,4 @@ trait Fingerprint
59
  return false;
60
  }
61
  }
62
- }
59
  return false;
60
  }
61
  }
62
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Common/Traits/PasswordProtected.php CHANGED
@@ -40,7 +40,7 @@ trait PasswordProtected
40
  * @see self::createKey()
41
  * @see self::load()
42
  * @access public
43
- * @param string|boolean $password
44
  */
45
  public function withPassword($password = false)
46
  {
@@ -48,4 +48,4 @@ trait PasswordProtected
48
  $new->password = $password;
49
  return $new;
50
  }
51
- }
40
  * @see self::createKey()
41
  * @see self::load()
42
  * @access public
43
+ * @param string|bool $password
44
  */
45
  public function withPassword($password = false)
46
  {
48
  $new->password = $password;
49
  return $new;
50
  }
51
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php CHANGED
@@ -87,7 +87,7 @@ class DES extends BlockCipher
87
  * @var int
88
  * @access private
89
  */
90
- protected $key_length = 8;
91
 
92
  /**
93
  * The mcrypt specific name of the cipher
@@ -1248,7 +1248,7 @@ class DES extends BlockCipher
1248
  self::ENCRYPT => [],
1249
  self::DECRYPT => array_fill(0, 32, 0)
1250
  ];
1251
- for ($i = 0, $ki = 31; $i < 16; ++$i, $ki-= 2) {
1252
  $c <<= $shifts[$i];
1253
  $c = ($c | ($c >> 28)) & 0x0FFFFFFF;
1254
  $d <<= $shifts[$i];
@@ -1367,7 +1367,7 @@ class DES extends BlockCipher
1367
  // start of "the Feistel (F) function" - see the following URL:
1368
  // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png
1369
  // Merge key schedule.
1370
- $crypt_block[$c].= '
1371
  $b1 = ((' . $r . ' >> 3) & 0x1FFFFFFF) ^ (' . $r . ' << 29) ^ ' . $k[$c][++$ki] . ';
1372
  $b2 = ((' . $r . ' >> 31) & 0x00000001) ^ (' . $r . ' << 1) ^ ' . $k[$c][++$ki] . ';' .
1373
  /* S-box indexing. */
@@ -1385,7 +1385,7 @@ class DES extends BlockCipher
1385
  }
1386
 
1387
  // Perform the inverse IP permutation.
1388
- $crypt_block[$c].= '$in =
1389
  ($shuffleinvip[($l >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") |
1390
  ($shuffleinvip[($r >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") |
1391
  ($shuffleinvip[($l >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") |
87
  * @var int
88
  * @access private
89
  */
90
+ protected $key_length = 8;
91
 
92
  /**
93
  * The mcrypt specific name of the cipher
1248
  self::ENCRYPT => [],
1249
  self::DECRYPT => array_fill(0, 32, 0)
1250
  ];
1251
+ for ($i = 0, $ki = 31; $i < 16; ++$i, $ki -= 2) {
1252
  $c <<= $shifts[$i];
1253
  $c = ($c | ($c >> 28)) & 0x0FFFFFFF;
1254
  $d <<= $shifts[$i];
1367
  // start of "the Feistel (F) function" - see the following URL:
1368
  // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png
1369
  // Merge key schedule.
1370
+ $crypt_block[$c] .= '
1371
  $b1 = ((' . $r . ' >> 3) & 0x1FFFFFFF) ^ (' . $r . ' << 29) ^ ' . $k[$c][++$ki] . ';
1372
  $b2 = ((' . $r . ' >> 31) & 0x00000001) ^ (' . $r . ' << 1) ^ ' . $k[$c][++$ki] . ';' .
1373
  /* S-box indexing. */
1385
  }
1386
 
1387
  // Perform the inverse IP permutation.
1388
+ $crypt_block[$c] .= '$in =
1389
  ($shuffleinvip[($l >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") |
1390
  ($shuffleinvip[($r >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") |
1391
  ($shuffleinvip[($l >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") |
vendor/phpseclib/phpseclib/phpseclib/Crypt/DH.php CHANGED
@@ -26,12 +26,12 @@
26
 
27
  namespace phpseclib3\Crypt;
28
 
29
- use phpseclib3\Exception\NoKeyLoadedException;
30
- use phpseclib3\Exception\UnsupportedOperationException;
31
  use phpseclib3\Crypt\Common\AsymmetricKey;
 
32
  use phpseclib3\Crypt\DH\PrivateKey;
33
  use phpseclib3\Crypt\DH\PublicKey;
34
- use phpseclib3\Crypt\DH\Parameters;
 
35
  use phpseclib3\Math\BigInteger;
36
 
37
  /**
@@ -78,11 +78,11 @@ abstract class DH extends AsymmetricKey
78
  * - a string (eg. diffie-hellman-group14-sha1)
79
  *
80
  * @access public
81
- * @return \phpseclib3\Crypt\DH|bool
82
  */
83
  public static function createParameters(...$args)
84
  {
85
- $params = new Parameters;
86
  if (count($args) == 2 && $args[0] instanceof BigInteger && $args[1] instanceof BigInteger) {
87
  //if (!$args[0]->isPrime()) {
88
  // throw new \InvalidArgumentException('The first parameter should be a prime number');
@@ -252,7 +252,7 @@ abstract class DH extends AsymmetricKey
252
  $max = $params->prime->subtract($one);
253
  }
254
 
255
- $key = new PrivateKey;
256
  $key->prime = $params->prime;
257
  $key->base = $params->base;
258
  $key->privateKey = BigInteger::randomRange($one, $max);
@@ -279,6 +279,7 @@ abstract class DH extends AsymmetricKey
279
  return $public->publicKey->powMod($private->privateKey, $private->prime)->toBytes(true);
280
  case is_string($public):
281
  $public = new BigInteger($public, -256);
 
282
  case $public instanceof BigInteger:
283
  return $public->powMod($private->privateKey, $private->prime)->toBytes(true);
284
  default:
@@ -290,6 +291,7 @@ abstract class DH extends AsymmetricKey
290
  switch (true) {
291
  case $public instanceof EC\PublicKey:
292
  $public = $public->getEncodedCoordinates();
 
293
  case is_string($public):
294
  $point = $private->multiply($public);
295
  switch ($private->getCurve()) {
@@ -324,7 +326,8 @@ abstract class DH extends AsymmetricKey
324
  {
325
  try {
326
  return EC::load($key, $password);
327
- } catch (NoKeyLoadedException $e) {}
 
328
 
329
  return parent::load($key, $password);
330
  }
@@ -339,11 +342,11 @@ abstract class DH extends AsymmetricKey
339
  protected static function onLoad($components)
340
  {
341
  if (!isset($components['privateKey']) && !isset($components['publicKey'])) {
342
- $new = new Parameters;
343
  } else {
344
  $new = isset($components['privateKey']) ?
345
- new PrivateKey :
346
- new PublicKey;
347
  }
348
 
349
  $new->prime = $components['prime'];
@@ -397,4 +400,4 @@ abstract class DH extends AsymmetricKey
397
  $key = $type::saveParameters($this->prime, $this->base);
398
  return self::load($key, 'PKCS1');
399
  }
400
- }
26
 
27
  namespace phpseclib3\Crypt;
28
 
 
 
29
  use phpseclib3\Crypt\Common\AsymmetricKey;
30
+ use phpseclib3\Crypt\DH\Parameters;
31
  use phpseclib3\Crypt\DH\PrivateKey;
32
  use phpseclib3\Crypt\DH\PublicKey;
33
+ use phpseclib3\Exception\NoKeyLoadedException;
34
+ use phpseclib3\Exception\UnsupportedOperationException;
35
  use phpseclib3\Math\BigInteger;
36
 
37
  /**
78
  * - a string (eg. diffie-hellman-group14-sha1)
79
  *
80
  * @access public
81
+ * @return Parameters
82
  */
83
  public static function createParameters(...$args)
84
  {
85
+ $params = new Parameters();
86
  if (count($args) == 2 && $args[0] instanceof BigInteger && $args[1] instanceof BigInteger) {
87
  //if (!$args[0]->isPrime()) {
88
  // throw new \InvalidArgumentException('The first parameter should be a prime number');
252
  $max = $params->prime->subtract($one);
253
  }
254
 
255
+ $key = new PrivateKey();
256
  $key->prime = $params->prime;
257
  $key->base = $params->base;
258
  $key->privateKey = BigInteger::randomRange($one, $max);
279
  return $public->publicKey->powMod($private->privateKey, $private->prime)->toBytes(true);
280
  case is_string($public):
281
  $public = new BigInteger($public, -256);
282
+ // fall-through
283
  case $public instanceof BigInteger:
284
  return $public->powMod($private->privateKey, $private->prime)->toBytes(true);
285
  default:
291
  switch (true) {
292
  case $public instanceof EC\PublicKey:
293
  $public = $public->getEncodedCoordinates();
294
+ // fall-through
295
  case is_string($public):
296
  $point = $private->multiply($public);
297
  switch ($private->getCurve()) {
326
  {
327
  try {
328
  return EC::load($key, $password);
329
+ } catch (NoKeyLoadedException $e) {
330
+ }
331
 
332
  return parent::load($key, $password);
333
  }
342
  protected static function onLoad($components)
343
  {
344
  if (!isset($components['privateKey']) && !isset($components['publicKey'])) {
345
+ $new = new Parameters();
346
  } else {
347
  $new = isset($components['privateKey']) ?
348
+ new PrivateKey() :
349
+ new PublicKey();
350
  }
351
 
352
  $new->prime = $components['prime'];
400
  $key = $type::saveParameters($this->prime, $this->base);
401
  return self::load($key, 'PKCS1');
402
  }
403
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/DH/Formats/Keys/PKCS1.php CHANGED
@@ -23,10 +23,10 @@
23
 
24
  namespace phpseclib3\Crypt\DH\Formats\Keys;
25
 
26
- use phpseclib3\Math\BigInteger;
27
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
28
  use phpseclib3\File\ASN1;
29
  use phpseclib3\File\ASN1\Maps;
 
30
 
31
  /**
32
  * "PKCS1" Formatted DH Key Handler
23
 
24
  namespace phpseclib3\Crypt\DH\Formats\Keys;
25
 
 
26
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
27
  use phpseclib3\File\ASN1;
28
  use phpseclib3\File\ASN1\Maps;
29
+ use phpseclib3\Math\BigInteger;
30
 
31
  /**
32
  * "PKCS1" Formatted DH Key Handler
vendor/phpseclib/phpseclib/phpseclib/Crypt/DH/Formats/Keys/PKCS8.php CHANGED
@@ -21,11 +21,11 @@
21
 
22
  namespace phpseclib3\Crypt\DH\Formats\Keys;
23
 
24
- use phpseclib3\Math\BigInteger;
25
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
26
  use phpseclib3\File\ASN1;
27
  use phpseclib3\File\ASN1\Maps;
28
- use phpseclib3\Common\Functions\Strings;
29
 
30
  /**
31
  * PKCS#8 Formatted DH Key Handler
@@ -130,7 +130,7 @@ abstract class PKCS8 extends Progenitor
130
  $params = ASN1::encodeDER($params, Maps\DHParameter::MAP);
131
  $params = new ASN1\Element($params);
132
  $key = ASN1::encodeDER($privateKey, ['type' => ASN1::TYPE_INTEGER]);
133
- return self::wrapPrivateKey($key, [], $params, $password, $options);
134
  }
135
 
136
  /**
@@ -154,4 +154,4 @@ abstract class PKCS8 extends Progenitor
154
  $key = ASN1::encodeDER($publicKey, ['type' => ASN1::TYPE_INTEGER]);
155
  return self::wrapPublicKey($key, $params);
156
  }
157
- }
21
 
22
  namespace phpseclib3\Crypt\DH\Formats\Keys;
23
 
24
+ use phpseclib3\Common\Functions\Strings;
25
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
26
  use phpseclib3\File\ASN1;
27
  use phpseclib3\File\ASN1\Maps;
28
+ use phpseclib3\Math\BigInteger;
29
 
30
  /**
31
  * PKCS#8 Formatted DH Key Handler
130
  $params = ASN1::encodeDER($params, Maps\DHParameter::MAP);
131
  $params = new ASN1\Element($params);
132
  $key = ASN1::encodeDER($privateKey, ['type' => ASN1::TYPE_INTEGER]);
133
+ return self::wrapPrivateKey($key, [], $params, $password, null, '', $options);
134
  }
135
 
136
  /**
154
  $key = ASN1::encodeDER($publicKey, ['type' => ASN1::TYPE_INTEGER]);
155
  return self::wrapPublicKey($key, $params);
156
  }
157
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/DH/PrivateKey.php CHANGED
@@ -13,8 +13,8 @@
13
 
14
  namespace phpseclib3\Crypt\DH;
15
 
16
- use phpseclib3\Crypt\DH;
17
  use phpseclib3\Crypt\Common;
 
18
 
19
  /**
20
  * DH Private Key
13
 
14
  namespace phpseclib3\Crypt\DH;
15
 
 
16
  use phpseclib3\Crypt\Common;
17
+ use phpseclib3\Crypt\DH;
18
 
19
  /**
20
  * DH Private Key
vendor/phpseclib/phpseclib/phpseclib/Crypt/DH/PublicKey.php CHANGED
@@ -13,8 +13,8 @@
13
 
14
  namespace phpseclib3\Crypt\DH;
15
 
16
- use phpseclib3\Crypt\DH;
17
  use phpseclib3\Crypt\Common;
 
18
 
19
  /**
20
  * DH Public Key
13
 
14
  namespace phpseclib3\Crypt\DH;
15
 
 
16
  use phpseclib3\Crypt\Common;
17
+ use phpseclib3\Crypt\DH;
18
 
19
  /**
20
  * DH Public Key
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA.php CHANGED
@@ -32,11 +32,11 @@
32
  namespace phpseclib3\Crypt;
33
 
34
  use phpseclib3\Crypt\Common\AsymmetricKey;
 
35
  use phpseclib3\Crypt\DSA\PrivateKey;
36
  use phpseclib3\Crypt\DSA\PublicKey;
37
- use phpseclib3\Crypt\DSA\Parameters;
38
- use phpseclib3\Math\BigInteger;
39
  use phpseclib3\Exception\InsufficientSetupException;
 
40
 
41
  /**
42
  * Pure-PHP FIPS 186-4 compliant implementation of DSA.
@@ -129,7 +129,7 @@ abstract class DSA extends AsymmetricKey
129
  SSH DSA implementations only support keys with an N of 160.
130
  puttygen let's you set the size of L (but not the size of N) and uses 2048 as the
131
  default L value. that's not really compliant with any of the FIPS standards, however,
132
- for the purposes of maintaining compatibility with puttygen, we'll support it
133
  */
134
  //case ($L >= 512 || $L <= 1024) && (($L & 0x3F) == 0) && $N == 160:
135
  // FIPS 186-3 changed this as follows:
@@ -169,7 +169,7 @@ abstract class DSA extends AsymmetricKey
169
  $h = $h->add(self::$one);
170
  }
171
 
172
- $dsa = new Parameters;
173
  $dsa->p = $p;
174
  $dsa->q = $q;
175
  $dsa->g = $g;
@@ -199,15 +199,15 @@ abstract class DSA extends AsymmetricKey
199
 
200
  if (count($args) == 2 && is_int($args[0]) && is_int($args[1])) {
201
  $params = self::createParameters($args[0], $args[1]);
202
- } else if (count($args) == 1 && $args[0] instanceof Parameters) {
203
  $params = $args[0];
204
- } else if (!count($args)) {
205
  $params = self::createParameters();
206
  } else {
207
  throw new InsufficientSetupException('Valid parameters are either two integers (L and N), a single DSA object or no parameters at all.');
208
  }
209
 
210
- $private = new PrivateKey;
211
  $private->p = $params->p;
212
  $private->q = $params->q;
213
  $private->g = $params->g;
@@ -237,12 +237,12 @@ abstract class DSA extends AsymmetricKey
237
  }
238
 
239
  if (!isset($components['x']) && !isset($components['y'])) {
240
- $new = new Parameters;
241
- } else if (isset($components['x'])) {
242
- $new = new PrivateKey;
243
  $new->x = $components['x'];
244
  } else {
245
- $new = new PublicKey;
246
  }
247
 
248
  $new->p = $components['p'];
@@ -292,6 +292,9 @@ abstract class DSA extends AsymmetricKey
292
  */
293
  public function getEngine()
294
  {
 
 
 
295
  return self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods()) ?
296
  'OpenSSL' : 'PHP';
297
  }
@@ -339,6 +342,6 @@ abstract class DSA extends AsymmetricKey
339
  */
340
  public function getSignatureFormat()
341
  {
342
- return $this->shortFormat;
343
  }
344
- }
32
  namespace phpseclib3\Crypt;
33
 
34
  use phpseclib3\Crypt\Common\AsymmetricKey;
35
+ use phpseclib3\Crypt\DSA\Parameters;
36
  use phpseclib3\Crypt\DSA\PrivateKey;
37
  use phpseclib3\Crypt\DSA\PublicKey;
 
 
38
  use phpseclib3\Exception\InsufficientSetupException;
39
+ use phpseclib3\Math\BigInteger;
40
 
41
  /**
42
  * Pure-PHP FIPS 186-4 compliant implementation of DSA.
129
  SSH DSA implementations only support keys with an N of 160.
130
  puttygen let's you set the size of L (but not the size of N) and uses 2048 as the
131
  default L value. that's not really compliant with any of the FIPS standards, however,
132
+ for the purposes of maintaining compatibility with puttygen, we'll support it
133
  */
134
  //case ($L >= 512 || $L <= 1024) && (($L & 0x3F) == 0) && $N == 160:
135
  // FIPS 186-3 changed this as follows:
169
  $h = $h->add(self::$one);
170
  }
171
 
172
+ $dsa = new Parameters();
173
  $dsa->p = $p;
174
  $dsa->q = $q;
175
  $dsa->g = $g;
199
 
200
  if (count($args) == 2 && is_int($args[0]) && is_int($args[1])) {
201
  $params = self::createParameters($args[0], $args[1]);
202
+ } elseif (count($args) == 1 && $args[0] instanceof Parameters) {
203
  $params = $args[0];
204
+ } elseif (!count($args)) {
205
  $params = self::createParameters();
206
  } else {
207
  throw new InsufficientSetupException('Valid parameters are either two integers (L and N), a single DSA object or no parameters at all.');
208
  }
209
 
210
+ $private = new PrivateKey();
211
  $private->p = $params->p;
212
  $private->q = $params->q;
213
  $private->g = $params->g;
237
  }
238
 
239
  if (!isset($components['x']) && !isset($components['y'])) {
240
+ $new = new Parameters();
241
+ } elseif (isset($components['x'])) {
242
+ $new = new PrivateKey();
243
  $new->x = $components['x'];
244
  } else {
245
+ $new = new PublicKey();
246
  }
247
 
248
  $new->p = $components['p'];
292
  */
293
  public function getEngine()
294
  {
295
+ if (!isset(self::$engines['PHP'])) {
296
+ self::useBestEngine();
297
+ }
298
  return self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods()) ?
299
  'OpenSSL' : 'PHP';
300
  }
342
  */
343
  public function getSignatureFormat()
344
  {
345
+ return $this->shortFormat;
346
  }
347
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/OpenSSH.php CHANGED
@@ -17,10 +17,9 @@
17
 
18
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
19
 
20
- use ParagonIE\ConstantTime\Base64;
21
- use phpseclib3\Math\BigInteger;
22
  use phpseclib3\Common\Functions\Strings;
23
  use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor;
 
24
 
25
  /**
26
  * OpenSSH Formatted DSA Key Handler
17
 
18
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
19
 
 
 
20
  use phpseclib3\Common\Functions\Strings;
21
  use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor;
22
+ use phpseclib3\Math\BigInteger;
23
 
24
  /**
25
  * OpenSSH Formatted DSA Key Handler
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PKCS1.php CHANGED
@@ -29,11 +29,11 @@
29
 
30
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
31
 
32
- use phpseclib3\Math\BigInteger;
33
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
34
  use phpseclib3\File\ASN1;
35
  use phpseclib3\File\ASN1\Maps;
36
- use ParagonIE\ConstantTime\Base64;
37
 
38
  /**
39
  * PKCS#1 Formatted DSA Key Handler
29
 
30
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
31
 
32
+ use ParagonIE\ConstantTime\Base64;
33
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
34
  use phpseclib3\File\ASN1;
35
  use phpseclib3\File\ASN1\Maps;
36
+ use phpseclib3\Math\BigInteger;
37
 
38
  /**
39
  * PKCS#1 Formatted DSA Key Handler
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PKCS8.php CHANGED
@@ -25,11 +25,11 @@
25
 
26
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
27
 
28
- use phpseclib3\Math\BigInteger;
29
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
30
  use phpseclib3\File\ASN1;
31
  use phpseclib3\File\ASN1\Maps;
32
- use phpseclib3\Common\Functions\Strings;
33
 
34
  /**
35
  * PKCS#8 Formatted DSA Key Handler
@@ -141,7 +141,7 @@ abstract class PKCS8 extends Progenitor
141
  $params = ASN1::encodeDER($params, Maps\DSAParams::MAP);
142
  $params = new ASN1\Element($params);
143
  $key = ASN1::encodeDER($x, Maps\DSAPublicKey::MAP);
144
- return self::wrapPrivateKey($key, [], $params, $password, $options);
145
  }
146
 
147
  /**
25
 
26
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
27
 
28
+ use phpseclib3\Common\Functions\Strings;
29
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
30
  use phpseclib3\File\ASN1;
31
  use phpseclib3\File\ASN1\Maps;
32
+ use phpseclib3\Math\BigInteger;
33
 
34
  /**
35
  * PKCS#8 Formatted DSA Key Handler
141
  $params = ASN1::encodeDER($params, Maps\DSAParams::MAP);
142
  $params = new ASN1\Element($params);
143
  $key = ASN1::encodeDER($x, Maps\DSAPublicKey::MAP);
144
+ return self::wrapPrivateKey($key, [], $params, $password, null, '', $options);
145
  }
146
 
147
  /**
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/PuTTY.php CHANGED
@@ -20,9 +20,9 @@
20
 
21
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
22
 
23
- use phpseclib3\Math\BigInteger;
24
  use phpseclib3\Common\Functions\Strings;
25
  use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor;
 
26
 
27
  /**
28
  * PuTTY Formatted DSA Key Handler
20
 
21
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
22
 
 
23
  use phpseclib3\Common\Functions\Strings;
24
  use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor;
25
+ use phpseclib3\Math\BigInteger;
26
 
27
  /**
28
  * PuTTY Formatted DSA Key Handler
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Keys/XML.php CHANGED
@@ -22,8 +22,9 @@
22
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
23
 
24
  use ParagonIE\ConstantTime\Base64;
25
- use phpseclib3\Math\BigInteger;
26
  use phpseclib3\Common\Functions\Strings;
 
 
27
 
28
  /**
29
  * XML Formatted DSA Key Handler
@@ -48,6 +49,10 @@ abstract class XML
48
  throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
49
  }
50
 
 
 
 
 
51
  $use_errors = libxml_use_internal_errors(true);
52
 
53
  $dom = new \DOMDocument();
@@ -55,6 +60,7 @@ abstract class XML
55
  $key = '<xml>' . $key . '</xml>';
56
  }
57
  if (!$dom->loadXML($key)) {
 
58
  throw new \UnexpectedValueException('Key does not appear to contain XML');
59
  }
60
  $xpath = new \DOMXPath($dom);
22
  namespace phpseclib3\Crypt\DSA\Formats\Keys;
23
 
24
  use ParagonIE\ConstantTime\Base64;
 
25
  use phpseclib3\Common\Functions\Strings;
26
+ use phpseclib3\Exception\BadConfigurationException;
27
+ use phpseclib3\Math\BigInteger;
28
 
29
  /**
30
  * XML Formatted DSA Key Handler
49
  throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
50
  }
51
 
52
+ if (!class_exists('DOMDocument')) {
53
+ throw new BadConfigurationException('The dom extension is not setup correctly on this system');
54
+ }
55
+
56
  $use_errors = libxml_use_internal_errors(true);
57
 
58
  $dom = new \DOMDocument();
60
  $key = '<xml>' . $key . '</xml>';
61
  }
62
  if (!$dom->loadXML($key)) {
63
+ libxml_use_internal_errors($use_errors);
64
  throw new \UnexpectedValueException('Key does not appear to contain XML');
65
  }
66
  $xpath = new \DOMXPath($dom);
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/ASN1.php CHANGED
@@ -18,9 +18,9 @@
18
 
19
  namespace phpseclib3\Crypt\DSA\Formats\Signature;
20
 
21
- use phpseclib3\Math\BigInteger;
22
  use phpseclib3\File\ASN1 as Encoder;
23
  use phpseclib3\File\ASN1\Maps;
 
24
 
25
  /**
26
  * ASN1 Signature Handler
18
 
19
  namespace phpseclib3\Crypt\DSA\Formats\Signature;
20
 
 
21
  use phpseclib3\File\ASN1 as Encoder;
22
  use phpseclib3\File\ASN1\Maps;
23
+ use phpseclib3\Math\BigInteger;
24
 
25
  /**
26
  * ASN1 Signature Handler
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/Formats/Signature/SSH2.php CHANGED
@@ -17,8 +17,8 @@
17
 
18
  namespace phpseclib3\Crypt\DSA\Formats\Signature;
19
 
20
- use phpseclib3\Math\BigInteger;
21
  use phpseclib3\Common\Functions\Strings;
 
22
 
23
  /**
24
  * SSH2 Signature Handler
@@ -70,7 +70,9 @@ abstract class SSH2
70
  if ($r->getLength() > 160 || $s->getLength() > 160) {
71
  return false;
72
  }
73
- return Strings::packSSH2('ss', 'ssh-dss',
 
 
74
  str_pad($r->toBytes(), 20, "\0", STR_PAD_LEFT) .
75
  str_pad($s->toBytes(), 20, "\0", STR_PAD_LEFT)
76
  );
17
 
18
  namespace phpseclib3\Crypt\DSA\Formats\Signature;
19
 
 
20
  use phpseclib3\Common\Functions\Strings;
21
+ use phpseclib3\Math\BigInteger;
22
 
23
  /**
24
  * SSH2 Signature Handler
70
  if ($r->getLength() > 160 || $s->getLength() > 160) {
71
  return false;
72
  }
73
+ return Strings::packSSH2(
74
+ 'ss',
75
+ 'ssh-dss',
76
  str_pad($r->toBytes(), 20, "\0", STR_PAD_LEFT) .
77
  str_pad($s->toBytes(), 20, "\0", STR_PAD_LEFT)
78
  );
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PrivateKey.php CHANGED
@@ -13,10 +13,10 @@
13
 
14
  namespace phpseclib3\Crypt\DSA;
15
 
 
16
  use phpseclib3\Crypt\DSA;
17
  use phpseclib3\Crypt\DSA\Formats\Signature\ASN1 as ASN1Signature;
18
  use phpseclib3\Math\BigInteger;
19
- use phpseclib3\Crypt\Common;
20
 
21
  /**
22
  * DSA Private Key
13
 
14
  namespace phpseclib3\Crypt\DSA;
15
 
16
+ use phpseclib3\Crypt\Common;
17
  use phpseclib3\Crypt\DSA;
18
  use phpseclib3\Crypt\DSA\Formats\Signature\ASN1 as ASN1Signature;
19
  use phpseclib3\Math\BigInteger;
 
20
 
21
  /**
22
  * DSA Private Key
vendor/phpseclib/phpseclib/phpseclib/Crypt/DSA/PublicKey.php CHANGED
@@ -13,9 +13,9 @@
13
 
14
  namespace phpseclib3\Crypt\DSA;
15
 
 
16
  use phpseclib3\Crypt\DSA;
17
  use phpseclib3\Crypt\DSA\Formats\Signature\ASN1 as ASN1Signature;
18
- use phpseclib3\Crypt\Common;
19
 
20
  /**
21
  * DSA Public Key
13
 
14
  namespace phpseclib3\Crypt\DSA;
15
 
16
+ use phpseclib3\Crypt\Common;
17
  use phpseclib3\Crypt\DSA;
18
  use phpseclib3\Crypt\DSA\Formats\Signature\ASN1 as ASN1Signature;
 
19
 
20
  /**
21
  * DSA Public Key
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC.php CHANGED
@@ -32,21 +32,21 @@
32
  namespace phpseclib3\Crypt;
33
 
34
  use phpseclib3\Crypt\Common\AsymmetricKey;
35
- use phpseclib3\Crypt\EC\PrivateKey;
36
- use phpseclib3\Crypt\EC\PublicKey;
37
- use phpseclib3\Crypt\EC\Parameters;
38
- use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
39
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
 
40
  use phpseclib3\Crypt\EC\Curves\Curve25519;
41
  use phpseclib3\Crypt\EC\Curves\Ed25519;
42
  use phpseclib3\Crypt\EC\Curves\Ed448;
43
  use phpseclib3\Crypt\EC\Formats\Keys\PKCS1;
44
- use phpseclib3\File\ASN1\Maps\ECParameters;
45
- use phpseclib3\File\ASN1;
46
- use phpseclib3\Math\BigInteger;
47
- use phpseclib3\Exception\UnsupportedCurveException;
48
  use phpseclib3\Exception\UnsupportedAlgorithmException;
 
49
  use phpseclib3\Exception\UnsupportedOperationException;
 
 
 
50
 
51
  /**
52
  * Pure-PHP implementation of EC.
@@ -158,7 +158,7 @@ abstract class EC extends AsymmetricKey
158
  return $privatekey;
159
  }
160
 
161
- $privatekey = new PrivateKey;
162
 
163
  $curveName = $curve;
164
  if (preg_match('#(?:^curve|^ed)\d+$#', $curveName)) {
@@ -217,14 +217,14 @@ abstract class EC extends AsymmetricKey
217
  }
218
 
219
  if (!isset($components['dA']) && !isset($components['QA'])) {
220
- $new = new Parameters;
221
  $new->curve = $components['curve'];
222
  return $new;
223
  }
224
 
225
  $new = isset($components['dA']) ?
226
- new PrivateKey :
227
- new PublicKey;
228
  $new->curve = $components['curve'];
229
  $new->QA = $components['QA'];
230
 
@@ -323,6 +323,9 @@ abstract class EC extends AsymmetricKey
323
  */
324
  public function getEngine()
325
  {
 
 
 
326
  if ($this->curve instanceof TwistedEdwardsCurve) {
327
  return $this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context) ?
328
  'libsodium' : 'PHP';
@@ -396,7 +399,7 @@ abstract class EC extends AsymmetricKey
396
  */
397
  public function getSignatureFormat()
398
  {
399
- return $this->shortFormat;
400
  }
401
 
402
  /**
@@ -437,7 +440,7 @@ abstract class EC extends AsymmetricKey
437
  */
438
  public function getContext()
439
  {
440
- return $this->context;
441
  }
442
 
443
  /**
@@ -474,4 +477,4 @@ abstract class EC extends AsymmetricKey
474
 
475
  return parent::__toString();
476
  }
477
- }
32
  namespace phpseclib3\Crypt;
33
 
34
  use phpseclib3\Crypt\Common\AsymmetricKey;
 
 
 
 
35
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
36
+ use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
37
  use phpseclib3\Crypt\EC\Curves\Curve25519;
38
  use phpseclib3\Crypt\EC\Curves\Ed25519;
39
  use phpseclib3\Crypt\EC\Curves\Ed448;
40
  use phpseclib3\Crypt\EC\Formats\Keys\PKCS1;
41
+ use phpseclib3\Crypt\EC\Parameters;
42
+ use phpseclib3\Crypt\EC\PrivateKey;
43
+ use phpseclib3\Crypt\EC\PublicKey;
 
44
  use phpseclib3\Exception\UnsupportedAlgorithmException;
45
+ use phpseclib3\Exception\UnsupportedCurveException;
46
  use phpseclib3\Exception\UnsupportedOperationException;
47
+ use phpseclib3\File\ASN1;
48
+ use phpseclib3\File\ASN1\Maps\ECParameters;
49
+ use phpseclib3\Math\BigInteger;
50
 
51
  /**
52
  * Pure-PHP implementation of EC.
158
  return $privatekey;
159
  }
160
 
161
+ $privatekey = new PrivateKey();
162
 
163
  $curveName = $curve;
164
  if (preg_match('#(?:^curve|^ed)\d+$#', $curveName)) {
217
  }
218
 
219
  if (!isset($components['dA']) && !isset($components['QA'])) {
220
+ $new = new Parameters();
221
  $new->curve = $components['curve'];
222
  return $new;
223
  }
224
 
225
  $new = isset($components['dA']) ?
226
+ new PrivateKey() :
227
+ new PublicKey();
228
  $new->curve = $components['curve'];
229
  $new->QA = $components['QA'];
230
 
323
  */
324
  public function getEngine()
325
  {
326
+ if (!isset(self::$engines['PHP'])) {
327
+ self::useBestEngine();
328
+ }
329
  if ($this->curve instanceof TwistedEdwardsCurve) {
330
  return $this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context) ?
331
  'libsodium' : 'PHP';
399
  */
400
  public function getSignatureFormat()
401
  {
402
+ return $this->shortFormat;
403
  }
404
 
405
  /**
440
  */
441
  public function getContext()
442
  {
443
+ return $this->context;
444
  }
445
 
446
  /**
477
 
478
  return parent::__toString();
479
  }
480
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Base.php CHANGED
@@ -15,7 +15,6 @@
15
 
16
  namespace phpseclib3\Crypt\EC\BaseCurves;
17
 
18
- use phpseclib3\Math\Common\FiniteField;
19
  use phpseclib3\Math\BigInteger;
20
 
21
  /**
@@ -66,7 +65,7 @@ abstract class Base
66
  }
67
 
68
  /**
69
- * Converts a BigInteger to a FiniteField integer
70
  *
71
  * @return object
72
  */
@@ -105,7 +104,7 @@ abstract class Base
105
  *
106
  * @return array
107
  */
108
- public function multiplyPoint(array $p, FiniteField\Integer $d)
109
  {
110
  $alreadyInternal = isset($p[2]);
111
  $r = $alreadyInternal ?
@@ -125,7 +124,7 @@ abstract class Base
125
  /**
126
  * Creates a random scalar multiplier
127
  *
128
- * @return FiniteField
129
  */
130
  public function createRandomMultiplier()
131
  {
@@ -134,8 +133,25 @@ abstract class Base
134
  $one = new BigInteger(1);
135
  }
136
 
137
- $dA = BigInteger::randomRange($one, $this->order->subtract($one));
138
- return $this->factory->newInteger($dA);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
 
141
  /**
@@ -217,4 +233,4 @@ abstract class Base
217
  $r = $this->addPoint($p1, $p2);
218
  return $this->convertToAffine($r);
219
  }
220
- }
15
 
16
  namespace phpseclib3\Crypt\EC\BaseCurves;
17
 
 
18
  use phpseclib3\Math\BigInteger;
19
 
20
  /**
65
  }
66
 
67
  /**
68
+ * Converts a BigInteger to a \phpseclib3\Math\FiniteField\Integer integer
69
  *
70
  * @return object
71
  */
104
  *
105
  * @return array
106
  */
107
+ public function multiplyPoint(array $p, BigInteger $d)
108
  {
109
  $alreadyInternal = isset($p[2]);
110
  $r = $alreadyInternal ?
124
  /**
125
  * Creates a random scalar multiplier
126
  *
127
+ * @return BigInteger
128
  */
129
  public function createRandomMultiplier()
130
  {
133
  $one = new BigInteger(1);
134
  }
135
 
136
+ return BigInteger::randomRange($one, $this->order->subtract($one));
137
+ }
138
+
139
+ /**
140
+ * Performs range check
141
+ */
142
+ public function rangeCheck(BigInteger $x)
143
+ {
144
+ static $zero;
145
+ if (!isset($zero)) {
146
+ $zero = new BigInteger();
147
+ }
148
+
149
+ if (!isset($this->order)) {
150
+ throw new \RuntimeException('setOrder needs to be called before this method');
151
+ }
152
+ if ($x->compare($this->order) > 0 || $x->compare($zero) <= 0) {
153
+ throw new \RangeException('x must be between 1 and the order of the curve');
154
+ }
155
  }
156
 
157
  /**
233
  $r = $this->addPoint($p1, $p2);
234
  return $this->convertToAffine($r);
235
  }
236
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Binary.php CHANGED
@@ -23,9 +23,8 @@
23
 
24
  namespace phpseclib3\Crypt\EC\BaseCurves;
25
 
26
- use phpseclib3\Common\Functions\Strings;
27
- use phpseclib3\Math\BinaryField;
28
  use phpseclib3\Math\BigInteger;
 
29
  use phpseclib3\Math\BinaryField\Integer as BinaryInteger;
30
 
31
  /**
@@ -278,7 +277,7 @@ class Binary extends Base
278
  *
279
  * Not supported because it is covered by patents.
280
  * Quoting https://www.openssl.org/docs/man1.1.0/apps/ecparam.html ,
281
- *
282
  * "Due to patent issues the compressed option is disabled by default for binary curves
283
  * and can be enabled by defining the preprocessor macro OPENSSL_EC_BIN_PT_COMP at
284
  * compile time."
@@ -370,9 +369,9 @@ class Binary extends Base
370
  if (isset($p[2])) {
371
  return $p;
372
  }
373
-
374
  $p[2] = clone $this->one;
375
  $p['fresh'] = true;
376
  return $p;
377
  }
378
- }
23
 
24
  namespace phpseclib3\Crypt\EC\BaseCurves;
25
 
 
 
26
  use phpseclib3\Math\BigInteger;
27
+ use phpseclib3\Math\BinaryField;
28
  use phpseclib3\Math\BinaryField\Integer as BinaryInteger;
29
 
30
  /**
277
  *
278
  * Not supported because it is covered by patents.
279
  * Quoting https://www.openssl.org/docs/man1.1.0/apps/ecparam.html ,
280
+ *
281
  * "Due to patent issues the compressed option is disabled by default for binary curves
282
  * and can be enabled by defining the preprocessor macro OPENSSL_EC_BIN_PT_COMP at
283
  * compile time."
369
  if (isset($p[2])) {
370
  return $p;
371
  }
372
+
373
  $p[2] = clone $this->one;
374
  $p['fresh'] = true;
375
  return $p;
376
  }
377
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/KoblitzPrime.php CHANGED
@@ -30,10 +30,8 @@
30
 
31
  namespace phpseclib3\Crypt\EC\BaseCurves;
32
 
33
- use phpseclib3\Common\Functions\Strings;
34
- use phpseclib3\Math\PrimeField;
35
  use phpseclib3\Math\BigInteger;
36
- use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
37
 
38
  /**
39
  * Curves over y^2 = x^3 + b
@@ -141,7 +139,7 @@ class KoblitzPrime extends Prime
141
  ];
142
 
143
  if (isset($p['naf'])) {
144
- $beta['naf'] = array_map(function($p) {
145
  return [
146
  $p[0]->multiply($this->beta),
147
  $p[1],
@@ -204,7 +202,8 @@ class KoblitzPrime extends Prime
204
  $f = $e->multiply($e);
205
  $x3 = $f->subtract($this->two->multiply($d));
206
  $y3 = $e->multiply($d->subtract($x3))->subtract(
207
- $this->eight->multiply($c));
 
208
  $z3 = $this->two->multiply($y1)->multiply($z1);
209
  return [$x3, $y3, $z3];
210
  }
@@ -322,4 +321,4 @@ class KoblitzPrime extends Prime
322
  ['a' => $a2, 'b' => $b2]
323
  ];
324
  }
325
- }
30
 
31
  namespace phpseclib3\Crypt\EC\BaseCurves;
32
 
 
 
33
  use phpseclib3\Math\BigInteger;
34
+ use phpseclib3\Math\PrimeField;
35
 
36
  /**
37
  * Curves over y^2 = x^3 + b
139
  ];
140
 
141
  if (isset($p['naf'])) {
142
+ $beta['naf'] = array_map(function ($p) {
143
  return [
144
  $p[0]->multiply($this->beta),
145
  $p[1],
202
  $f = $e->multiply($e);
203
  $x3 = $f->subtract($this->two->multiply($d));
204
  $y3 = $e->multiply($d->subtract($x3))->subtract(
205
+ $this->eight->multiply($c)
206
+ );
207
  $z3 = $this->two->multiply($y1)->multiply($z1);
208
  return [$x3, $y3, $z3];
209
  }
321
  ['a' => $a2, 'b' => $b2]
322
  ];
323
  }
324
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Montgomery.php CHANGED
@@ -26,11 +26,9 @@
26
 
27
  namespace phpseclib3\Crypt\EC\BaseCurves;
28
 
29
- use phpseclib3\Math\Common\FiniteField\Integer;
30
- use phpseclib3\Common\Functions\Strings;
31
- use phpseclib3\Math\PrimeField;
32
- use phpseclib3\Math\BigInteger;
33
  use phpseclib3\Crypt\EC\Curves\Curve25519;
 
 
34
  use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
35
 
36
  /**
@@ -222,7 +220,7 @@ class Montgomery extends Base
222
  *
223
  * @return array
224
  */
225
- public function multiplyPoint(array $p, Integer $d)
226
  {
227
  $p1 = [$this->one, $this->zero];
228
  $alreadyInternal = isset($x[1]);
@@ -282,4 +280,4 @@ class Montgomery extends Base
282
  list($x, $z) = $p;
283
  return [$x->divide($z)];
284
  }
285
- }
26
 
27
  namespace phpseclib3\Crypt\EC\BaseCurves;
28
 
 
 
 
 
29
  use phpseclib3\Crypt\EC\Curves\Curve25519;
30
+ use phpseclib3\Math\BigInteger;
31
+ use phpseclib3\Math\PrimeField;
32
  use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
33
 
34
  /**
220
  *
221
  * @return array
222
  */
223
+ public function multiplyPoint(array $p, BigInteger $d)
224
  {
225
  $p1 = [$this->one, $this->zero];
226
  $alreadyInternal = isset($x[1]);
280
  list($x, $z) = $p;
281
  return [$x->divide($z)];
282
  }
283
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/Prime.php CHANGED
@@ -23,10 +23,10 @@
23
 
24
  namespace phpseclib3\Crypt\EC\BaseCurves;
25
 
26
- use phpseclib3\Math\Common\FiniteField\Integer;
27
  use phpseclib3\Common\Functions\Strings;
28
- use phpseclib3\Math\PrimeField;
29
  use phpseclib3\Math\BigInteger;
 
 
30
  use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
31
 
32
  /**
@@ -207,8 +207,10 @@ class Prime extends Base
207
  $v = $u1->multiply($h2);
208
  $x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
209
  $y3 = $r->multiply(
210
- $v->subtract($x3))->subtract(
211
- $s1->multiply($h3));
 
 
212
  return [$x3, $y3, $h];
213
  }
214
 
@@ -242,8 +244,10 @@ class Prime extends Base
242
  $v = $u1->multiply($h2);
243
  $x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
244
  $y3 = $r->multiply(
245
- $v->subtract($x3))->subtract(
246
- $s1->multiply($h3));
 
 
247
  $z3 = $h->multiply($z1);
248
  return [$x3, $y3, $z3];
249
  }
@@ -279,8 +283,10 @@ class Prime extends Base
279
  $v = $u1->multiply($h2);
280
  $x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
281
  $y3 = $r->multiply(
282
- $v->subtract($x3))->subtract(
283
- $s1->multiply($h3));
 
 
284
  $z3 = $h->multiply($z1)->multiply($z2);
285
  return [$x3, $y3, $z3];
286
  }
@@ -370,7 +376,8 @@ class Prime extends Base
370
  $m = $m1->add($m2);
371
  $x1 = $m->multiply($m)->subtract($this->two->multiply($s));
372
  $y1 = $m->multiply($s->subtract($x1))->subtract(
373
- $this->eight->multiply($y2->multiply($y2)));
 
374
  $z1 = $this->two->multiply($y)->multiply($z);
375
  return [$x1, $y1, $z1];
376
  }
@@ -390,7 +397,8 @@ class Prime extends Base
390
  $m = $m1->add($this->a);
391
  $x1 = $m->multiply($m)->subtract($this->two->multiply($s));
392
  $y1 = $m->multiply($s->subtract($x1))->subtract(
393
- $this->eight->multiply($y2->multiply($y2)));
 
394
  $z1 = $this->two->multiply($y);
395
  return [$x1, $y1, $z1];
396
  }
@@ -439,8 +447,12 @@ class Prime extends Base
439
  $x = new BigInteger($m, 256);
440
  $xp = $this->convertInteger($x);
441
  switch ($y) {
442
- case 2: $ypn = false; break;
443
- case 3: $ypn = true; break;
 
 
 
 
444
  default:
445
  throw new \RuntimeException('Coordinate not in recognized format');
446
  }
@@ -529,7 +541,7 @@ class Prime extends Base
529
  // comb all window NAFs
530
 
531
  $max = 0;
532
- for ($i = $length - 1; $i >= 1; $i-= 2) {
533
  $a = $i - 1;
534
  $b = $i;
535
  if ($wndWidth[$a] != 1 || $wndWidth[$b] != 1) {
@@ -687,12 +699,12 @@ class Prime extends Base
687
  while ($k1->compare(new BigInteger(-$d1)) > 0 || $k2->compare(new BigInteger(-$d2)) > 0) {
688
  // first phase
689
  $m14 = $k1->testBit(0) + 2 * $k1->testBit(1);
690
- $m14+= $d1;
691
- $m14&= 3;
692
 
693
  $m24 = $k2->testBit(0) + 2 * $k2->testBit(1);
694
- $m24+= $d2;
695
- $m24&= 3;
696
 
697
  if ($m14 == 3) {
698
  $m14 = -1;
@@ -704,8 +716,8 @@ class Prime extends Base
704
  $u1 = 0;
705
  if ($m14 & 1) { // if $m14 is odd
706
  $m8 = $k1->testBit(0) + 2 * $k1->testBit(1) + 4 * $k1->testBit(2);
707
- $m8+= $d1;
708
- $m8&= 7;
709
  $u1 = ($m8 == 3 || $m8 == 5) && $m24 == 2 ? -$m14 : $m14;
710
  }
711
  $jsf[0][] = $u1;
@@ -713,8 +725,8 @@ class Prime extends Base
713
  $u2 = 0;
714
  if ($m24 & 1) { // if $m24 is odd
715
  $m8 = $k2->testBit(0) + 2 * $k2->testBit(1) + 4 * $k2->testBit(2);
716
- $m8+= $d2;
717
- $m8&= 7;
718
  $u2 = ($m8 == 3 || $m8 == 5) && $m14 == 2 ? -$m24 : $m24;
719
  }
720
  $jsf[1][] = $u2;
@@ -771,4 +783,4 @@ class Prime extends Base
771
  $p['fresh'] = true;
772
  return $p;
773
  }
774
- }
23
 
24
  namespace phpseclib3\Crypt\EC\BaseCurves;
25
 
 
26
  use phpseclib3\Common\Functions\Strings;
 
27
  use phpseclib3\Math\BigInteger;
28
+ use phpseclib3\Math\Common\FiniteField\Integer;
29
+ use phpseclib3\Math\PrimeField;
30
  use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
31
 
32
  /**
207
  $v = $u1->multiply($h2);
208
  $x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
209
  $y3 = $r->multiply(
210
+ $v->subtract($x3)
211
+ )->subtract(
212
+ $s1->multiply($h3)
213
+ );
214
  return [$x3, $y3, $h];
215
  }
216
 
244
  $v = $u1->multiply($h2);
245
  $x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
246
  $y3 = $r->multiply(
247
+ $v->subtract($x3)
248
+ )->subtract(
249
+ $s1->multiply($h3)
250
+ );
251
  $z3 = $h->multiply($z1);
252
  return [$x3, $y3, $z3];
253
  }
283
  $v = $u1->multiply($h2);
284
  $x3 = $r->multiply($r)->subtract($h3)->subtract($v->multiply($this->two));
285
  $y3 = $r->multiply(
286
+ $v->subtract($x3)
287
+ )->subtract(
288
+ $s1->multiply($h3)
289
+ );
290
  $z3 = $h->multiply($z1)->multiply($z2);
291
  return [$x3, $y3, $z3];
292
  }
376
  $m = $m1->add($m2);
377
  $x1 = $m->multiply($m)->subtract($this->two->multiply($s));
378
  $y1 = $m->multiply($s->subtract($x1))->subtract(
379
+ $this->eight->multiply($y2->multiply($y2))
380
+ );
381
  $z1 = $this->two->multiply($y)->multiply($z);
382
  return [$x1, $y1, $z1];
383
  }
397
  $m = $m1->add($this->a);
398
  $x1 = $m->multiply($m)->subtract($this->two->multiply($s));
399
  $y1 = $m->multiply($s->subtract($x1))->subtract(
400
+ $this->eight->multiply($y2->multiply($y2))
401
+ );
402
  $z1 = $this->two->multiply($y);
403
  return [$x1, $y1, $z1];
404
  }
447
  $x = new BigInteger($m, 256);
448
  $xp = $this->convertInteger($x);
449
  switch ($y) {
450
+ case 2:
451
+ $ypn = false;
452
+ break;
453
+ case 3:
454
+ $ypn = true;
455
+ break;
456
  default:
457
  throw new \RuntimeException('Coordinate not in recognized format');
458
  }
541
  // comb all window NAFs
542
 
543
  $max = 0;
544
+ for ($i = $length - 1; $i >= 1; $i -= 2) {
545
  $a = $i - 1;
546
  $b = $i;
547
  if ($wndWidth[$a] != 1 || $wndWidth[$b] != 1) {
699
  while ($k1->compare(new BigInteger(-$d1)) > 0 || $k2->compare(new BigInteger(-$d2)) > 0) {
700
  // first phase
701
  $m14 = $k1->testBit(0) + 2 * $k1->testBit(1);
702
+ $m14 += $d1;
703
+ $m14 &= 3;
704
 
705
  $m24 = $k2->testBit(0) + 2 * $k2->testBit(1);
706
+ $m24 += $d2;
707
+ $m24 &= 3;
708
 
709
  if ($m14 == 3) {
710
  $m14 = -1;
716
  $u1 = 0;
717
  if ($m14 & 1) { // if $m14 is odd
718
  $m8 = $k1->testBit(0) + 2 * $k1->testBit(1) + 4 * $k1->testBit(2);
719
+ $m8 += $d1;
720
+ $m8 &= 7;
721
  $u1 = ($m8 == 3 || $m8 == 5) && $m24 == 2 ? -$m14 : $m14;
722
  }
723
  $jsf[0][] = $u1;
725
  $u2 = 0;
726
  if ($m24 & 1) { // if $m24 is odd
727
  $m8 = $k2->testBit(0) + 2 * $k2->testBit(1) + 4 * $k2->testBit(2);
728
+ $m8 += $d2;
729
+ $m8 &= 7;
730
  $u2 = ($m8 == 3 || $m8 == 5) && $m14 == 2 ? -$m24 : $m24;
731
  }
732
  $jsf[1][] = $u2;
783
  $p['fresh'] = true;
784
  return $p;
785
  }
786
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/BaseCurves/TwistedEdwards.php CHANGED
@@ -28,8 +28,8 @@
28
 
29
  namespace phpseclib3\Crypt\EC\BaseCurves;
30
 
31
- use phpseclib3\Math\PrimeField;
32
  use phpseclib3\Math\BigInteger;
 
33
  use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
34
 
35
  /**
@@ -216,4 +216,4 @@ class TwistedEdwards extends Base
216
 
217
  return $lhs->equals($rhs);
218
  }
219
- }
28
 
29
  namespace phpseclib3\Crypt\EC\BaseCurves;
30
 
 
31
  use phpseclib3\Math\BigInteger;
32
+ use phpseclib3\Math\PrimeField;
33
  use phpseclib3\Math\PrimeField\Integer as PrimeInteger;
34
 
35
  /**
216
 
217
  return $lhs->equals($rhs);
218
  }
219
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Curve25519.php CHANGED
@@ -15,7 +15,6 @@
15
 
16
  namespace phpseclib3\Crypt\EC\Curves;
17
 
18
- use phpseclib3\Math\Common\FiniteField\Integer;
19
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery;
20
  use phpseclib3\Math\BigInteger;
21
 
@@ -48,17 +47,37 @@ class Curve25519 extends Montgomery
48
  *
49
  * @return array
50
  */
51
- public function multiplyPoint(array $p, Integer $d)
52
  {
53
  //$r = strrev(sodium_crypto_scalarmult($d->toBytes(), strrev($p[0]->toBytes())));
54
  //return [$this->factory->newInteger(new BigInteger($r, 256))];
55
 
56
  $d = $d->toBytes();
57
- $d&= "\xF8" . str_repeat("\xFF", 30) . "\x7F";
58
  $d = strrev($d);
59
- $d|= "\x40";
60
- $d = $this->factory->newInteger(new BigInteger($d, -256));
61
 
62
  return parent::multiplyPoint($p, $d);
63
  }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  namespace phpseclib3\Crypt\EC\Curves;
17
 
 
18
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery;
19
  use phpseclib3\Math\BigInteger;
20
 
47
  *
48
  * @return array
49
  */
50
+ public function multiplyPoint(array $p, BigInteger $d)
51
  {
52
  //$r = strrev(sodium_crypto_scalarmult($d->toBytes(), strrev($p[0]->toBytes())));
53
  //return [$this->factory->newInteger(new BigInteger($r, 256))];
54
 
55
  $d = $d->toBytes();
56
+ $d &= "\xF8" . str_repeat("\xFF", 30) . "\x7F";
57
  $d = strrev($d);
58
+ $d |= "\x40";
59
+ $d = new BigInteger($d, -256);
60
 
61
  return parent::multiplyPoint($p, $d);
62
  }
63
+
64
+ /**
65
+ * Creates a random scalar multiplier
66
+ *
67
+ * @return BigInteger
68
+ */
69
+ public function createRandomMultiplier()
70
+ {
71
+ return BigInteger::random(256);
72
+ }
73
+
74
+ /**
75
+ * Performs range check
76
+ */
77
+ public function rangeCheck(BigInteger $x)
78
+ {
79
+ if ($x->getLength() > 256 || $x->isNegative()) {
80
+ throw new \RangeException('x must be a positive integer less than 256 bytes in length');
81
+ }
82
+ }
83
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Curve448.php CHANGED
@@ -15,7 +15,6 @@
15
 
16
  namespace phpseclib3\Crypt\EC\Curves;
17
 
18
- use phpseclib3\Math\Common\FiniteField\Integer;
19
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery;
20
  use phpseclib3\Math\BigInteger;
21
 
@@ -26,13 +25,17 @@ class Curve448 extends Montgomery
26
  // 2^448 - 2^224 - 1
27
  $this->setModulo(new BigInteger(
28
  'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
29
- 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16));
 
 
30
  $this->a24 = $this->factory->newInteger(new BigInteger('39081'));
31
  $this->p = [$this->factory->newInteger(new BigInteger(5))];
32
  // 2^446 - 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d
33
  $this->setOrder(new BigInteger(
34
  '3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
35
- '7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', 16));
 
 
36
 
37
  /*
38
  $this->setCoefficients(
@@ -55,7 +58,7 @@ class Curve448 extends Montgomery
55
  *
56
  * @return array
57
  */
58
- public function multiplyPoint(array $p, Integer $d)
59
  {
60
  //$r = strrev(sodium_crypto_scalarmult($d->toBytes(), strrev($p[0]->toBytes())));
61
  //return [$this->factory->newInteger(new BigInteger($r, 256))];
@@ -63,9 +66,29 @@ class Curve448 extends Montgomery
63
  $d = $d->toBytes();
64
  $d[0] = $d[0] & "\xFC";
65
  $d = strrev($d);
66
- $d|= "\x80";
67
- $d = $this->factory->newInteger(new BigInteger($d, 256));
68
 
69
  return parent::multiplyPoint($p, $d);
70
  }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  namespace phpseclib3\Crypt\EC\Curves;
17
 
 
18
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery;
19
  use phpseclib3\Math\BigInteger;
20
 
25
  // 2^448 - 2^224 - 1
26
  $this->setModulo(new BigInteger(
27
  'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
28
+ 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
29
+ 16
30
+ ));
31
  $this->a24 = $this->factory->newInteger(new BigInteger('39081'));
32
  $this->p = [$this->factory->newInteger(new BigInteger(5))];
33
  // 2^446 - 0x8335dc163bb124b65129c96fde933d8d723a70aadc873d6d54a7bb0d
34
  $this->setOrder(new BigInteger(
35
  '3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
36
+ '7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3',
37
+ 16
38
+ ));
39
 
40
  /*
41
  $this->setCoefficients(
58
  *
59
  * @return array
60
  */
61
+ public function multiplyPoint(array $p, BigInteger $d)
62
  {
63
  //$r = strrev(sodium_crypto_scalarmult($d->toBytes(), strrev($p[0]->toBytes())));
64
  //return [$this->factory->newInteger(new BigInteger($r, 256))];
66
  $d = $d->toBytes();
67
  $d[0] = $d[0] & "\xFC";
68
  $d = strrev($d);
69
+ $d |= "\x80";
70
+ $d = new BigInteger($d, 256);
71
 
72
  return parent::multiplyPoint($p, $d);
73
  }
74
+
75
+ /**
76
+ * Creates a random scalar multiplier
77
+ *
78
+ * @return BigInteger
79
+ */
80
+ public function createRandomMultiplier()
81
+ {
82
+ return BigInteger::random(446);
83
+ }
84
+
85
+ /**
86
+ * Performs range check
87
+ */
88
+ public function rangeCheck(BigInteger $x)
89
+ {
90
+ if ($x->getLength() > 448 || $x->isNegative()) {
91
+ throw new \RangeException('x must be a positive integer less than 446 bytes in length');
92
+ }
93
+ }
94
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Ed25519.php CHANGED
@@ -15,9 +15,9 @@
15
  namespace phpseclib3\Crypt\EC\Curves;
16
 
17
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards;
18
- use phpseclib3\Math\BigInteger;
19
  use phpseclib3\Crypt\Hash;
20
  use phpseclib3\Crypt\Random;
 
21
 
22
  class Ed25519 extends TwistedEdwards
23
  {
@@ -180,7 +180,6 @@ class Ed25519 extends TwistedEdwards
180
  // 3. Interpret the buffer as the little-endian integer, forming a
181
  // secret scalar s.
182
  $dA = new BigInteger($h, 256);
183
- $dA = $this->factory->newInteger($dA);
184
 
185
  $dA->secret = $str;
186
  return $dA;
15
  namespace phpseclib3\Crypt\EC\Curves;
16
 
17
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards;
 
18
  use phpseclib3\Crypt\Hash;
19
  use phpseclib3\Crypt\Random;
20
+ use phpseclib3\Math\BigInteger;
21
 
22
  class Ed25519 extends TwistedEdwards
23
  {
180
  // 3. Interpret the buffer as the little-endian integer, forming a
181
  // secret scalar s.
182
  $dA = new BigInteger($h, 256);
 
183
 
184
  $dA->secret = $str;
185
  return $dA;
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/Ed448.php CHANGED
@@ -15,9 +15,9 @@
15
  namespace phpseclib3\Crypt\EC\Curves;
16
 
17
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards;
18
- use phpseclib3\Math\BigInteger;
19
  use phpseclib3\Crypt\Hash;
20
  use phpseclib3\Crypt\Random;
 
21
 
22
  class Ed448 extends TwistedEdwards
23
  {
@@ -29,11 +29,13 @@ class Ed448 extends TwistedEdwards
29
  // 2^448 - 2^224 - 1
30
  $this->setModulo(new BigInteger(
31
  'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
32
- 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16));
 
 
33
  $this->setCoefficients(
34
  new BigInteger(1),
35
  // -39081
36
- new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
37
  'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6756', 16)
38
  );
39
  $this->setBasePoint(
@@ -44,7 +46,9 @@ class Ed448 extends TwistedEdwards
44
  );
45
  $this->setOrder(new BigInteger(
46
  '3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
47
- '7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3', 16));
 
 
48
  }
49
 
50
  /**
@@ -118,7 +122,6 @@ class Ed448 extends TwistedEdwards
118
  // 3. Interpret the buffer as the little-endian integer, forming a
119
  // secret scalar s.
120
  $dA = new BigInteger($h, 256);
121
- $dA = $this->factory->newInteger($dA);
122
 
123
  $dA->secret = $str;
124
  return $dA;
@@ -264,4 +267,4 @@ class Ed448 extends TwistedEdwards
264
 
265
  return [$x3, $y3, $z3];
266
  }
267
- }
15
  namespace phpseclib3\Crypt\EC\Curves;
16
 
17
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards;
 
18
  use phpseclib3\Crypt\Hash;
19
  use phpseclib3\Crypt\Random;
20
+ use phpseclib3\Math\BigInteger;
21
 
22
  class Ed448 extends TwistedEdwards
23
  {
29
  // 2^448 - 2^224 - 1
30
  $this->setModulo(new BigInteger(
31
  'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
32
+ 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF',
33
+ 16
34
+ ));
35
  $this->setCoefficients(
36
  new BigInteger(1),
37
  // -39081
38
+ new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE' .
39
  'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6756', 16)
40
  );
41
  $this->setBasePoint(
46
  );
47
  $this->setOrder(new BigInteger(
48
  '3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
49
+ '7CCA23E9C44EDB49AED63690216CC2728DC58F552378C292AB5844F3',
50
+ 16
51
+ ));
52
  }
53
 
54
  /**
122
  // 3. Interpret the buffer as the little-endian integer, forming a
123
  // secret scalar s.
124
  $dA = new BigInteger($h, 256);
 
125
 
126
  $dA->secret = $str;
127
  return $dA;
267
 
268
  return [$x3, $y3, $z3];
269
  }
270
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP160r1.php CHANGED
@@ -33,4 +33,4 @@ class brainpoolP160r1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('E95E4A5F737059DC60DF5991D45029409E60FC09', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('E95E4A5F737059DC60DF5991D45029409E60FC09', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP160t1.php CHANGED
@@ -46,4 +46,4 @@ class brainpoolP160t1 extends Prime
46
  );
47
  $this->setOrder(new BigInteger('E95E4A5F737059DC60DF5991D45029409E60FC09', 16));
48
  }
49
- }
46
  );
47
  $this->setOrder(new BigInteger('E95E4A5F737059DC60DF5991D45029409E60FC09', 16));
48
  }
49
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP192r1.php CHANGED
@@ -33,4 +33,4 @@ class brainpoolP192r1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP192t1.php CHANGED
@@ -33,4 +33,4 @@ class brainpoolP192t1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('C302F41D932A36CDA7A3462F9E9E916B5BE8F1029AC4ACC1', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP224r1.php CHANGED
@@ -33,4 +33,4 @@ class brainpoolP224r1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP224t1.php CHANGED
@@ -33,4 +33,4 @@ class brainpoolP224t1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('D7C134AA264366862A18302575D0FB98D116BC4B6DDEBCA3A5A7939F', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP256r1.php CHANGED
@@ -33,4 +33,4 @@ class brainpoolP256r1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP320r1.php CHANGED
@@ -39,4 +39,4 @@ class brainpoolP320r1 extends Prime
39
  $this->setOrder(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D4' .
40
  '82EC7EE8658E98691555B44C59311', 16));
41
  }
42
- }
39
  $this->setOrder(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D4' .
40
  '82EC7EE8658E98691555B44C59311', 16));
41
  }
42
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP320t1.php CHANGED
@@ -39,4 +39,4 @@ class brainpoolP320t1 extends Prime
39
  $this->setOrder(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D4' .
40
  '82EC7EE8658E98691555B44C59311', 16));
41
  }
42
- }
39
  $this->setOrder(new BigInteger('D35E472036BC4FB7E13C785ED201E065F98FCFA5B68F12A32D4' .
40
  '82EC7EE8658E98691555B44C59311', 16));
41
  }
42
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP384r1.php CHANGED
@@ -24,25 +24,37 @@ class brainpoolP384r1 extends Prime
24
  {
25
  $this->setModulo(new BigInteger(
26
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' .
27
- '1874700133107EC53', 16));
 
 
28
  $this->setCoefficients(
29
  new BigInteger(
30
  '7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503' .
31
- 'AD4EB04A8C7DD22CE2826', 16),
 
 
32
  new BigInteger(
33
  '4A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DB' .
34
- 'C9943AB78696FA504C11', 16)
 
 
35
  );
36
  $this->setBasePoint(
37
  new BigInteger(
38
  '1D1C64F068CF45FFA2A63A81B7C13F6B8847A3E77EF14FE3DB7FCAFE0CBD10E8E826E03436D' .
39
- '646AAEF87B2E247D4AF1E', 16),
 
 
40
  new BigInteger(
41
  '8ABE1D7520F9C2A45CB1EB8E95CFD55262B70B29FEEC5864E19C054FF99129280E464621779' .
42
- '1811142820341263C5315', 16)
 
 
43
  );
44
  $this->setOrder(new BigInteger(
45
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' .
46
- '03B883202E9046565', 16));
 
 
47
  }
48
- }
24
  {
25
  $this->setModulo(new BigInteger(
26
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' .
27
+ '1874700133107EC53',
28
+ 16
29
+ ));
30
  $this->setCoefficients(
31
  new BigInteger(
32
  '7BC382C63D8C150C3C72080ACE05AFA0C2BEA28E4FB22787139165EFBA91F90F8AA5814A503' .
33
+ 'AD4EB04A8C7DD22CE2826',
34
+ 16
35
+ ),
36
  new BigInteger(
37
  '4A8C7DD22CE28268B39B55416F0447C2FB77DE107DCD2A62E880EA53EEB62D57CB4390295DB' .
38
+ 'C9943AB78696FA504C11',
39
+ 16
40
+ )
41
  );
42
  $this->setBasePoint(
43
  new BigInteger(
44
  '1D1C64F068CF45FFA2A63A81B7C13F6B8847A3E77EF14FE3DB7FCAFE0CBD10E8E826E03436D' .
45
+ '646AAEF87B2E247D4AF1E',
46
+ 16
47
+ ),
48
  new BigInteger(
49
  '8ABE1D7520F9C2A45CB1EB8E95CFD55262B70B29FEEC5864E19C054FF99129280E464621779' .
50
+ '1811142820341263C5315',
51
+ 16
52
+ )
53
  );
54
  $this->setOrder(new BigInteger(
55
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' .
56
+ '03B883202E9046565',
57
+ 16
58
+ ));
59
  }
60
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP384t1.php CHANGED
@@ -24,25 +24,37 @@ class brainpoolP384t1 extends Prime
24
  {
25
  $this->setModulo(new BigInteger(
26
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' .
27
- '1874700133107EC53', 16));
 
 
28
  $this->setCoefficients(
29
  new BigInteger(
30
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901' .
31
- 'D1A71874700133107EC50', 16), // eg. -3
 
 
32
  new BigInteger(
33
  '7F519EADA7BDA81BD826DBA647910F8C4B9346ED8CCDC64E4B1ABD11756DCE1D2074AA263B8' .
34
- '8805CED70355A33B471EE', 16)
 
 
35
  );
36
  $this->setBasePoint(
37
  new BigInteger(
38
  '18DE98B02DB9A306F2AFCD7235F72A819B80AB12EBD653172476FECD462AABFFC4FF191B946' .
39
- 'A5F54D8D0AA2F418808CC', 16),
 
 
40
  new BigInteger(
41
  '25AB056962D30651A114AFD2755AD336747F93475B7A1FCA3B88F2B6A208CCFE469408584DC' .
42
- '2B2912675BF5B9E582928', 16)
 
 
43
  );
44
  $this->setOrder(new BigInteger(
45
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' .
46
- '03B883202E9046565', 16));
 
 
47
  }
48
- }
24
  {
25
  $this->setModulo(new BigInteger(
26
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901D1A7' .
27
+ '1874700133107EC53',
28
+ 16
29
+ ));
30
  $this->setCoefficients(
31
  new BigInteger(
32
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B412B1DA197FB71123ACD3A729901' .
33
+ 'D1A71874700133107EC50',
34
+ 16
35
+ ), // eg. -3
36
  new BigInteger(
37
  '7F519EADA7BDA81BD826DBA647910F8C4B9346ED8CCDC64E4B1ABD11756DCE1D2074AA263B8' .
38
+ '8805CED70355A33B471EE',
39
+ 16
40
+ )
41
  );
42
  $this->setBasePoint(
43
  new BigInteger(
44
  '18DE98B02DB9A306F2AFCD7235F72A819B80AB12EBD653172476FECD462AABFFC4FF191B946' .
45
+ 'A5F54D8D0AA2F418808CC',
46
+ 16
47
+ ),
48
  new BigInteger(
49
  '25AB056962D30651A114AFD2755AD336747F93475B7A1FCA3B88F2B6A208CCFE469408584DC' .
50
+ '2B2912675BF5B9E582928',
51
+ 16
52
+ )
53
  );
54
  $this->setOrder(new BigInteger(
55
  '8CB91E82A3386D280F5D6F7E50E641DF152F7109ED5456B31F166E6CAC0425A7CF3AB6AF6B7FC31' .
56
+ '03B883202E9046565',
57
+ 16
58
+ ));
59
  }
60
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP512r1.php CHANGED
@@ -24,25 +24,37 @@ class brainpoolP512r1 extends Prime
24
  {
25
  $this->setModulo(new BigInteger(
26
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
27
- '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', 16));
 
 
28
  $this->setCoefficients(
29
  new BigInteger(
30
  '7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA82' .
31
- '53AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA', 16),
 
 
32
  new BigInteger(
33
  '3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C' .
34
- '1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723', 16)
 
 
35
  );
36
  $this->setBasePoint(
37
  new BigInteger(
38
  '81AEE4BDD82ED9645A21322E9C4C6A9385ED9F70B5D916C1B43B62EEF4D0098EFF3B1F78E2D' .
39
- '0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F822', 16),
 
 
40
  new BigInteger(
41
  '7DDE385D566332ECC0EABFA9CF7822FDF209F70024A57B1AA000C55B881F8111B2DCDE494A5' .
42
- 'F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892', 16)
 
 
43
  );
44
  $this->setOrder(new BigInteger(
45
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' .
46
- '92619418661197FAC10471DB1D381085DDADDB58796829CA90069', 16));
 
 
47
  }
48
- }
24
  {
25
  $this->setModulo(new BigInteger(
26
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
27
+ '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3',
28
+ 16
29
+ ));
30
  $this->setCoefficients(
31
  new BigInteger(
32
  '7830A3318B603B89E2327145AC234CC594CBDD8D3DF91610A83441CAEA9863BC2DED5D5AA82' .
33
+ '53AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C1AC4D77FC94CA',
34
+ 16
35
+ ),
36
  new BigInteger(
37
  '3DF91610A83441CAEA9863BC2DED5D5AA8253AA10A2EF1C98B9AC8B57F1117A72BF2C7B9E7C' .
38
+ '1AC4D77FC94CADC083E67984050B75EBAE5DD2809BD638016F723',
39
+ 16
40
+ )
41
  );
42
  $this->setBasePoint(
43
  new BigInteger(
44
  '81AEE4BDD82ED9645A21322E9C4C6A9385ED9F70B5D916C1B43B62EEF4D0098EFF3B1F78E2D' .
45
+ '0D48D50D1687B93B97D5F7C6D5047406A5E688B352209BCB9F822',
46
+ 16
47
+ ),
48
  new BigInteger(
49
  '7DDE385D566332ECC0EABFA9CF7822FDF209F70024A57B1AA000C55B881F8111B2DCDE494A5' .
50
+ 'F485E5BCA4BD88A2763AED1CA2B2FA8F0540678CD1E0F3AD80892',
51
+ 16
52
+ )
53
  );
54
  $this->setOrder(new BigInteger(
55
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' .
56
+ '92619418661197FAC10471DB1D381085DDADDB58796829CA90069',
57
+ 16
58
+ ));
59
  }
60
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/brainpoolP512t1.php CHANGED
@@ -24,25 +24,37 @@ class brainpoolP512t1 extends Prime
24
  {
25
  $this->setModulo(new BigInteger(
26
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
27
- '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3', 16));
 
 
28
  $this->setCoefficients(
29
  new BigInteger(
30
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
31
- '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0', 16), // eg. -3
 
 
32
  new BigInteger(
33
  '7CBBBCF9441CFAB76E1890E46884EAE321F70C0BCB4981527897504BEC3E36A62BCDFA23049' .
34
- '76540F6450085F2DAE145C22553B465763689180EA2571867423E', 16)
 
 
35
  );
36
  $this->setBasePoint(
37
  new BigInteger(
38
  '640ECE5C12788717B9C1BA06CBC2A6FEBA85842458C56DDE9DB1758D39C0313D82BA51735CD' .
39
- 'B3EA499AA77A7D6943A64F7A3F25FE26F06B51BAA2696FA9035DA', 16),
 
 
40
  new BigInteger(
41
  '5B534BD595F5AF0FA2C892376C84ACE1BB4E3019B71634C01131159CAE03CEE9D9932184BEE' .
42
- 'F216BD71DF2DADF86A627306ECFF96DBB8BACE198B61E00F8B332', 16)
 
 
43
  );
44
  $this->setOrder(new BigInteger(
45
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' .
46
- '92619418661197FAC10471DB1D381085DDADDB58796829CA90069', 16));
 
 
47
  }
48
- }
24
  {
25
  $this->setModulo(new BigInteger(
26
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
27
+ '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F3',
28
+ 16
29
+ ));
30
  $this->setCoefficients(
31
  new BigInteger(
32
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA703308717D4D9B009BC' .
33
+ '66842AECDA12AE6A380E62881FF2F2D82C68528AA6056583A48F0',
34
+ 16
35
+ ), // eg. -3
36
  new BigInteger(
37
  '7CBBBCF9441CFAB76E1890E46884EAE321F70C0BCB4981527897504BEC3E36A62BCDFA23049' .
38
+ '76540F6450085F2DAE145C22553B465763689180EA2571867423E',
39
+ 16
40
+ )
41
  );
42
  $this->setBasePoint(
43
  new BigInteger(
44
  '640ECE5C12788717B9C1BA06CBC2A6FEBA85842458C56DDE9DB1758D39C0313D82BA51735CD' .
45
+ 'B3EA499AA77A7D6943A64F7A3F25FE26F06B51BAA2696FA9035DA',
46
+ 16
47
+ ),
48
  new BigInteger(
49
  '5B534BD595F5AF0FA2C892376C84ACE1BB4E3019B71634C01131159CAE03CEE9D9932184BEE' .
50
+ 'F216BD71DF2DADF86A627306ECFF96DBB8BACE198B61E00F8B332',
51
+ 16
52
+ )
53
  );
54
  $this->setOrder(new BigInteger(
55
  'AADD9DB8DBE9C48B3FD4E6AE33C9FC07CB308DB3B3C9D20ED6639CCA70330870553E5C414CA' .
56
+ '92619418661197FAC10471DB1D381085DDADDB58796829CA90069',
57
+ 16
58
+ ));
59
  }
60
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistb233.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistb233 extends sect233r1
19
  {
20
- }
17
 
18
  final class nistb233 extends sect233r1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistb409.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistb409 extends sect409r1
19
  {
20
- }
17
 
18
  final class nistb409 extends sect409r1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk163.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistk163 extends sect163k1
19
  {
20
- }
17
 
18
  final class nistk163 extends sect163k1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk233.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistk233 extends sect233k1
19
  {
20
- }
17
 
18
  final class nistk233 extends sect233k1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk283.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistk283 extends sect283k1
19
  {
20
- }
17
 
18
  final class nistk283 extends sect283k1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistk409.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistk409 extends sect409k1
19
  {
20
- }
17
 
18
  final class nistk409 extends sect409k1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp192.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistp192 extends secp192r1
19
  {
20
- }
17
 
18
  final class nistp192 extends secp192r1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp224.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistp224 extends secp224r1
19
  {
20
- }
17
 
18
  final class nistp224 extends secp224r1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp256.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistp256 extends secp256r1
19
  {
20
- }
17
 
18
  final class nistp256 extends secp256r1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp384.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistp384 extends secp384r1
19
  {
20
- }
17
 
18
  final class nistp384 extends secp384r1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistp521.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistp521 extends secp521r1
19
  {
20
- }
17
 
18
  final class nistp521 extends secp521r1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/nistt571.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class nistt571 extends sect571k1
19
  {
20
- }
17
 
18
  final class nistt571 extends sect571k1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v1.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class prime192v1 extends secp192r1
19
  {
20
- }
17
 
18
  final class prime192v1 extends secp192r1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v2.php CHANGED
@@ -33,4 +33,4 @@ class prime192v2 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFE5FB1A724DC80418648D8DD31', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFE5FB1A724DC80418648D8DD31', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime192v3.php CHANGED
@@ -33,4 +33,4 @@ class prime192v3 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFF7A62D031C83F4294F640EC13', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFF7A62D031C83F4294F640EC13', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v1.php CHANGED
@@ -33,4 +33,4 @@ class prime239v1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF9E5E9A9F5D9071FBD1522688909D0B', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF9E5E9A9F5D9071FBD1522688909D0B', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v2.php CHANGED
@@ -33,4 +33,4 @@ class prime239v2 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFF800000CFA7E8594377D414C03821BC582063', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFF800000CFA7E8594377D414C03821BC582063', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime239v3.php CHANGED
@@ -33,4 +33,4 @@ class prime239v3 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF975DEB41B3A6057C3C432146526551', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('7FFFFFFFFFFFFFFFFFFFFFFF7FFFFF975DEB41B3A6057C3C432146526551', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/prime256v1.php CHANGED
@@ -17,4 +17,4 @@ namespace phpseclib3\Crypt\EC\Curves;
17
 
18
  final class prime256v1 extends secp256r1
19
  {
20
- }
17
 
18
  final class prime256v1 extends secp256r1
19
  {
20
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp112r1.php CHANGED
@@ -33,4 +33,4 @@ class secp112r1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('DB7C2ABF62E35E7628DFAC6561C5', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('DB7C2ABF62E35E7628DFAC6561C5', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp112r2.php CHANGED
@@ -34,4 +34,4 @@ class secp112r2 extends Prime
34
  );
35
  $this->setOrder(new BigInteger('36DF0AAFD8B8D7597CA10520D04B', 16));
36
  }
37
- }
34
  );
35
  $this->setOrder(new BigInteger('36DF0AAFD8B8D7597CA10520D04B', 16));
36
  }
37
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp128r1.php CHANGED
@@ -33,4 +33,4 @@ class secp128r1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('FFFFFFFE0000000075A30D1B9038A115', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('FFFFFFFE0000000075A30D1B9038A115', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp128r2.php CHANGED
@@ -34,4 +34,4 @@ class secp128r2 extends Prime
34
  );
35
  $this->setOrder(new BigInteger('3FFFFFFF7FFFFFFFBE0024720613B5A3', 16));
36
  }
37
- }
34
  );
35
  $this->setOrder(new BigInteger('3FFFFFFF7FFFFFFFBE0024720613B5A3', 16));
36
  }
37
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160k1.php CHANGED
@@ -45,4 +45,4 @@ class secp160k1 extends KoblitzPrime
45
  ];
46
  $this->beta = $this->factory->newInteger(new BigInteger('645B7345A143464942CC46D7CF4D5D1E1E6CBB68', -16));
47
  }
48
- }
45
  ];
46
  $this->beta = $this->factory->newInteger(new BigInteger('645B7345A143464942CC46D7CF4D5D1E1E6CBB68', -16));
47
  }
48
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160r1.php CHANGED
@@ -33,4 +33,4 @@ class secp160r1 extends Prime
33
  );
34
  $this->setOrder(new BigInteger('0100000000000000000001F4C8F927AED3CA752257', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('0100000000000000000001F4C8F927AED3CA752257', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp160r2.php CHANGED
@@ -34,4 +34,4 @@ class secp160r2 extends Prime
34
  );
35
  $this->setOrder(new BigInteger('0100000000000000000000351EE786A818F3A1A16B', 16));
36
  }
37
- }
34
  );
35
  $this->setOrder(new BigInteger('0100000000000000000000351EE786A818F3A1A16B', 16));
36
  }
37
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp192k1.php CHANGED
@@ -44,4 +44,4 @@ class secp192k1 extends KoblitzPrime
44
  ];
45
  $this->beta = $this->factory->newInteger(new BigInteger('447A96E6C647963E2F7809FEAAB46947F34B0AA3CA0BBA74', -16));
46
  }
47
- }
44
  ];
45
  $this->beta = $this->factory->newInteger(new BigInteger('447A96E6C647963E2F7809FEAAB46947F34B0AA3CA0BBA74', -16));
46
  }
47
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp192r1.php CHANGED
@@ -36,7 +36,7 @@ class secp192r1 extends Prime
36
  now, if PHP supported unsigned integers things might be different. no bit-shifting
37
  would be required for the PHP engine and it'd be a lot faster. but as is, BigInteger
38
  uses base-2**31 or base-2**26 depending on whether or not the system is has a 32-bit
39
- or a 64-bit OS.
40
  */
41
  /*
42
  $m_length = $this->getLengthInBytes();
@@ -77,4 +77,4 @@ class secp192r1 extends Prime
77
  );
78
  $this->setOrder(new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831', 16));
79
  }
80
- }
36
  now, if PHP supported unsigned integers things might be different. no bit-shifting
37
  would be required for the PHP engine and it'd be a lot faster. but as is, BigInteger
38
  uses base-2**31 or base-2**26 depending on whether or not the system is has a 32-bit
39
+ or a 64-bit OS.
40
  */
41
  /*
42
  $m_length = $this->getLengthInBytes();
77
  );
78
  $this->setOrder(new BigInteger('FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831', 16));
79
  }
80
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp224k1.php CHANGED
@@ -44,4 +44,4 @@ class secp224k1 extends KoblitzPrime
44
  ];
45
  $this->beta = $this->factory->newInteger(new BigInteger('01F178FFA4B17C89E6F73AECE2AAD57AF4C0A748B63C830947B27E04', -16));
46
  }
47
- }
44
  ];
45
  $this->beta = $this->factory->newInteger(new BigInteger('01F178FFA4B17C89E6F73AECE2AAD57AF4C0A748B63C830947B27E04', -16));
46
  }
47
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp256k1.php CHANGED
@@ -48,4 +48,4 @@ class secp256k1 extends KoblitzPrime
48
  ];
49
  $this->beta = $this->factory->newInteger(new BigInteger('7AE96A2B657C07106E64479EAC3434E99CF0497512F58995C1396C28719501EE', -16));
50
  }
51
- }
48
  ];
49
  $this->beta = $this->factory->newInteger(new BigInteger('7AE96A2B657C07106E64479EAC3434E99CF0497512F58995C1396C28719501EE', -16));
50
  }
51
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp384r1.php CHANGED
@@ -51,4 +51,4 @@ class secp384r1 extends Prime
51
  16
52
  ));
53
  }
54
- }
51
  16
52
  ));
53
  }
54
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/secp521r1.php CHANGED
@@ -45,4 +45,4 @@ class secp521r1 extends Prime
45
  'FFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E9138' .
46
  '6409', 16));
47
  }
48
- }
45
  'FFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E9138' .
46
  '6409', 16));
47
  }
48
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect113r1.php CHANGED
@@ -33,4 +33,4 @@ class sect113r1 extends Binary
33
  );
34
  $this->setOrder(new BigInteger('0100000000000000D9CCEC8A39E56F', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('0100000000000000D9CCEC8A39E56F', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect113r2.php CHANGED
@@ -33,4 +33,4 @@ class sect113r2 extends Binary
33
  );
34
  $this->setOrder(new BigInteger('010000000000000108789B2496AF93', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('010000000000000108789B2496AF93', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect131r1.php CHANGED
@@ -33,4 +33,4 @@ class sect131r1 extends Binary
33
  );
34
  $this->setOrder(new BigInteger('0400000000000000023123953A9464B54D', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('0400000000000000023123953A9464B54D', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect131r2.php CHANGED
@@ -33,4 +33,4 @@ class sect131r2 extends Binary
33
  );
34
  $this->setOrder(new BigInteger('0400000000000000016954A233049BA98F', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('0400000000000000016954A233049BA98F', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163k1.php CHANGED
@@ -33,4 +33,4 @@ class sect163k1 extends Binary
33
  );
34
  $this->setOrder(new BigInteger('04000000000000000000020108A2E0CC0D99F8A5EF', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('04000000000000000000020108A2E0CC0D99F8A5EF', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect163r1.php CHANGED
@@ -33,4 +33,4 @@ class sect163r1 extends Binary
33
  );
34
  $this->setOrder(new BigInteger('03FFFFFFFFFFFFFFFFFFFF48AAB689C29CA710279B', 16));
35
  }
36
- }
33
  );
34
  $this->setOrder(new BigInteger('03FFFFFFFFFFFFFFFFFFFF48AAB689C29CA710279B', 16));
35
  }
36
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect409k1.php CHANGED
@@ -33,7 +33,8 @@ class sect409k1 extends Binary
33
  );
34
  $this->setOrder(new BigInteger(
35
  '7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F' .
36
- '83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF', 16
 
37
  ));
38
  }
39
  }
33
  );
34
  $this->setOrder(new BigInteger(
35
  '7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE5F' .
36
+ '83B2D4EA20400EC4557D5ED3E3E7CA5B4B5C83B8E01E5FCF',
37
+ 16
38
  ));
39
  }
40
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect409r1.php CHANGED
@@ -33,7 +33,8 @@ class sect409r1 extends Binary
33
  );
34
  $this->setOrder(new BigInteger(
35
  '010000000000000000000000000000000000000000000000000001E2' .
36
- 'AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173', 16
 
37
  ));
38
  }
39
  }
33
  );
34
  $this->setOrder(new BigInteger(
35
  '010000000000000000000000000000000000000000000000000001E2' .
36
+ 'AAD6A612F33307BE5FA47C3C9E052F838164CD37D9A21173',
37
+ 16
38
  ));
39
  }
40
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect571k1.php CHANGED
@@ -37,7 +37,8 @@ class sect571k1 extends Binary
37
  );
38
  $this->setOrder(new BigInteger(
39
  '020000000000000000000000000000000000000000000000000000000000000000000000' .
40
- '131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001', 16
 
41
  ));
42
  }
43
  }
37
  );
38
  $this->setOrder(new BigInteger(
39
  '020000000000000000000000000000000000000000000000000000000000000000000000' .
40
+ '131850E1F19A63E4B391A8DB917F4138B630D84BE5D639381E91DEB45CFE778F637C1001',
41
+ 16
42
  ));
43
  }
44
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Curves/sect571r1.php CHANGED
@@ -37,7 +37,8 @@ class sect571r1 extends Binary
37
  );
38
  $this->setOrder(new BigInteger(
39
  '03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
40
- 'E661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47', 16
 
41
  ));
42
  }
43
  }
37
  );
38
  $this->setOrder(new BigInteger(
39
  '03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' .
40
+ 'E661CE18FF55987308059B186823851EC7DD9CA1161DE93D5174D66E8382E9BB2FE84E47',
41
+ 16
42
  ));
43
  }
44
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/Common.php CHANGED
@@ -16,16 +16,15 @@
16
  namespace phpseclib3\Crypt\EC\Formats\Keys;
17
 
18
  use ParagonIE\ConstantTime\Hex;
 
19
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
20
- use phpseclib3\Crypt\EC\BaseCurves\Prime as PrimeCurve;
21
  use phpseclib3\Crypt\EC\BaseCurves\Binary as BinaryCurve;
 
22
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
23
- use phpseclib3\Common\Functions\Strings;
24
- use phpseclib3\Math\BigInteger;
25
- use phpseclib3\Math\PrimeField;
26
  use phpseclib3\File\ASN1;
27
  use phpseclib3\File\ASN1\Maps;
28
- use phpseclib3\Exception\UnsupportedCurveException;
29
 
30
  /**
31
  * Generic EC Key Parsing Helper functions
@@ -98,8 +97,8 @@ trait Common
98
  'sect163k1' => '1.3.132.0.1',
99
  'sect163r2' => '1.3.132.0.15',
100
  'secp224r1' => '1.3.132.0.33',
101
- 'sect233k1'=> '1.3.132.0.26',
102
- 'sect233r1'=> '1.3.132.0.27',
103
  'secp256r1' => '1.2.840.10045.3.1.7', // aka prime256v1
104
  'sect283k1' => '1.3.132.0.16',
105
  'sect283r1' => '1.3.132.0.17',
16
  namespace phpseclib3\Crypt\EC\Formats\Keys;
17
 
18
  use ParagonIE\ConstantTime\Hex;
19
+ use phpseclib3\Common\Functions\Strings;
20
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
 
21
  use phpseclib3\Crypt\EC\BaseCurves\Binary as BinaryCurve;
22
+ use phpseclib3\Crypt\EC\BaseCurves\Prime as PrimeCurve;
23
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
24
+ use phpseclib3\Exception\UnsupportedCurveException;
 
 
25
  use phpseclib3\File\ASN1;
26
  use phpseclib3\File\ASN1\Maps;
27
+ use phpseclib3\Math\BigInteger;
28
 
29
  /**
30
  * Generic EC Key Parsing Helper functions
97
  'sect163k1' => '1.3.132.0.1',
98
  'sect163r2' => '1.3.132.0.15',
99
  'secp224r1' => '1.3.132.0.33',
100
+ 'sect233k1' => '1.3.132.0.26',
101
+ 'sect233r1' => '1.3.132.0.27',
102
  'secp256r1' => '1.2.840.10045.3.1.7', // aka prime256v1
103
  'sect283k1' => '1.3.132.0.16',
104
  'sect283r1' => '1.3.132.0.17',
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPrivate.php CHANGED
@@ -22,12 +22,11 @@
22
 
23
  namespace phpseclib3\Crypt\EC\Formats\Keys;
24
 
 
25
  use phpseclib3\Crypt\EC\Curves\Curve25519;
26
  use phpseclib3\Crypt\EC\Curves\Curve448;
27
- use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
28
- use phpseclib3\Math\Common\FiniteField\Integer;
29
- use phpseclib3\Math\BigInteger;
30
  use phpseclib3\Exception\UnsupportedFormatException;
 
31
 
32
  /**
33
  * Montgomery Curve Private Key Handler
@@ -57,17 +56,18 @@ abstract class MontgomeryPrivate
57
  {
58
  switch (strlen($key)) {
59
  case 32:
60
- $curve = new Curve25519;
61
  break;
62
  case 56:
63
- $curve = new Curve448;
64
  break;
65
  default:
66
  throw new \LengthException('The only supported lengths are 32 and 56');
67
  }
68
 
69
  $components = ['curve' => $curve];
70
- $components['dA'] = $components['curve']->convertInteger(new BigInteger($key, 256));
 
71
  // note that EC::getEncodedCoordinates does some additional "magic" (it does strrev on the result)
72
  $components['QA'] = $components['curve']->multiplyPoint($components['curve']->getBasePoint(), $components['dA']);
73
 
@@ -91,13 +91,13 @@ abstract class MontgomeryPrivate
91
  * Convert a private key to the appropriate format.
92
  *
93
  * @access public
94
- * @param \phpseclib3\Math\Common\FiniteField\Integer $privateKey
95
  * @param \phpseclib3\Crypt\EC\BaseCurves\Montgomery $curve
96
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
97
  * @param string $password optional
98
  * @return string
99
  */
100
- public static function savePrivateKey(Integer $privateKey, MontgomeryCurve $curve, array $publicKey, $password = '')
101
  {
102
  if (!empty($password) && is_string($password)) {
103
  throw new UnsupportedFormatException('MontgomeryPrivate private keys do not support encryption');
22
 
23
  namespace phpseclib3\Crypt\EC\Formats\Keys;
24
 
25
+ use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
26
  use phpseclib3\Crypt\EC\Curves\Curve25519;
27
  use phpseclib3\Crypt\EC\Curves\Curve448;
 
 
 
28
  use phpseclib3\Exception\UnsupportedFormatException;
29
+ use phpseclib3\Math\BigInteger;
30
 
31
  /**
32
  * Montgomery Curve Private Key Handler
56
  {
57
  switch (strlen($key)) {
58
  case 32:
59
+ $curve = new Curve25519();
60
  break;
61
  case 56:
62
+ $curve = new Curve448();
63
  break;
64
  default:
65
  throw new \LengthException('The only supported lengths are 32 and 56');
66
  }
67
 
68
  $components = ['curve' => $curve];
69
+ $components['dA'] = new BigInteger($key, 256);
70
+ $curve->rangeCheck($components['dA']);
71
  // note that EC::getEncodedCoordinates does some additional "magic" (it does strrev on the result)
72
  $components['QA'] = $components['curve']->multiplyPoint($components['curve']->getBasePoint(), $components['dA']);
73
 
91
  * Convert a private key to the appropriate format.
92
  *
93
  * @access public
94
+ * @param \phpseclib3\Math\BigInteger $privateKey
95
  * @param \phpseclib3\Crypt\EC\BaseCurves\Montgomery $curve
96
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
97
  * @param string $password optional
98
  * @return string
99
  */
100
+ public static function savePrivateKey(BigInteger $privateKey, MontgomeryCurve $curve, array $publicKey, $password = '')
101
  {
102
  if (!empty($password) && is_string($password)) {
103
  throw new UnsupportedFormatException('MontgomeryPrivate private keys do not support encryption');
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/MontgomeryPublic.php CHANGED
@@ -15,10 +15,9 @@
15
 
16
  namespace phpseclib3\Crypt\EC\Formats\Keys;
17
 
 
18
  use phpseclib3\Crypt\EC\Curves\Curve25519;
19
  use phpseclib3\Crypt\EC\Curves\Curve448;
20
- use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
21
- use phpseclib3\Math\Common\FiniteField\Integer;
22
  use phpseclib3\Math\BigInteger;
23
 
24
  /**
@@ -49,10 +48,10 @@ abstract class MontgomeryPublic
49
  {
50
  switch (strlen($key)) {
51
  case 32:
52
- $curve = new Curve25519;
53
  break;
54
  case 56:
55
- $curve = new Curve448;
56
  break;
57
  default:
58
  throw new \LengthException('The only supported lengths are 32 and 56');
15
 
16
  namespace phpseclib3\Crypt\EC\Formats\Keys;
17
 
18
+ use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
19
  use phpseclib3\Crypt\EC\Curves\Curve25519;
20
  use phpseclib3\Crypt\EC\Curves\Curve448;
 
 
21
  use phpseclib3\Math\BigInteger;
22
 
23
  /**
48
  {
49
  switch (strlen($key)) {
50
  case 32:
51
+ $curve = new Curve25519();
52
  break;
53
  case 56:
54
+ $curve = new Curve448();
55
  break;
56
  default:
57
  throw new \LengthException('The only supported lengths are 32 and 56');
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/OpenSSH.php CHANGED
@@ -17,14 +17,12 @@
17
 
18
  namespace phpseclib3\Crypt\EC\Formats\Keys;
19
 
20
- use ParagonIE\ConstantTime\Base64;
21
- use phpseclib3\Math\BigInteger;
22
  use phpseclib3\Common\Functions\Strings;
23
  use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor;
24
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
25
- use phpseclib3\Exception\UnsupportedCurveException;
26
  use phpseclib3\Crypt\EC\Curves\Ed25519;
27
- use phpseclib3\Math\Common\FiniteField\Integer;
 
28
 
29
  /**
30
  * OpenSSH Formatted EC Key Handler
@@ -67,7 +65,7 @@ abstract class OpenSSH extends Progenitor
67
  if ($type != $parsed['type']) {
68
  throw new \RuntimeException("The public and private keys are not of the same type ($type vs $parsed[type])");
69
  }
70
- if ($type == 'ssh-ed25519' ) {
71
  list(, $key, $comment) = Strings::unpackSSH2('sss', $paddedKey);
72
  $key = libsodium::load($key);
73
  $key['comment'] = $comment;
@@ -75,9 +73,10 @@ abstract class OpenSSH extends Progenitor
75
  }
76
  list($curveName, $publicKey, $privateKey, $comment) = Strings::unpackSSH2('ssis', $paddedKey);
77
  $curve = self::loadCurveByParam(['namedCurve' => $curveName]);
 
78
  return [
79
  'curve' => $curve,
80
- 'dA' => $curve->convertInteger($privateKey),
81
  'QA' => self::extractPoint("\0$publicKey", $curve),
82
  'comment' => $comment
83
  ];
@@ -118,7 +117,7 @@ abstract class OpenSSH extends Progenitor
118
  $name = $reflect->getShortName();
119
 
120
  $oid = self::$curveOIDs[$name];
121
- $aliases = array_filter(self::$curveOIDs, function($v) use ($oid) {
122
  return $v == $oid;
123
  });
124
  $aliases = array_keys($aliases);
@@ -179,14 +178,14 @@ abstract class OpenSSH extends Progenitor
179
  * Convert a private key to the appropriate format.
180
  *
181
  * @access public
182
- * @param \phpseclib3\Math\Common\FiniteField\Integer $privateKey
183
  * @param \phpseclib3\Crypt\EC\Curves\Ed25519 $curve
184
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
185
  * @param string $password optional
186
  * @param array $options optional
187
  * @return string
188
  */
189
- public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = [])
190
  {
191
  if ($curve instanceof Ed25519) {
192
  if (!isset($privateKey->secret)) {
17
 
18
  namespace phpseclib3\Crypt\EC\Formats\Keys;
19
 
 
 
20
  use phpseclib3\Common\Functions\Strings;
21
  use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor;
22
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
 
23
  use phpseclib3\Crypt\EC\Curves\Ed25519;
24
+ use phpseclib3\Exception\UnsupportedCurveException;
25
+ use phpseclib3\Math\BigInteger;
26
 
27
  /**
28
  * OpenSSH Formatted EC Key Handler
65
  if ($type != $parsed['type']) {
66
  throw new \RuntimeException("The public and private keys are not of the same type ($type vs $parsed[type])");
67
  }
68
+ if ($type == 'ssh-ed25519') {
69
  list(, $key, $comment) = Strings::unpackSSH2('sss', $paddedKey);
70
  $key = libsodium::load($key);
71
  $key['comment'] = $comment;
73
  }
74
  list($curveName, $publicKey, $privateKey, $comment) = Strings::unpackSSH2('ssis', $paddedKey);
75
  $curve = self::loadCurveByParam(['namedCurve' => $curveName]);
76
+ $curve->rangeCheck($privateKey);
77
  return [
78
  'curve' => $curve,
79
+ 'dA' => $privateKey,
80
  'QA' => self::extractPoint("\0$publicKey", $curve),
81
  'comment' => $comment
82
  ];
117
  $name = $reflect->getShortName();
118
 
119
  $oid = self::$curveOIDs[$name];
120
+ $aliases = array_filter(self::$curveOIDs, function ($v) use ($oid) {
121
  return $v == $oid;
122
  });
123
  $aliases = array_keys($aliases);
178
  * Convert a private key to the appropriate format.
179
  *
180
  * @access public
181
+ * @param \phpseclib3\Math\BigInteger $privateKey
182
  * @param \phpseclib3\Crypt\EC\Curves\Ed25519 $curve
183
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
184
  * @param string $password optional
185
  * @param array $options optional
186
  * @return string
187
  */
188
+ public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = [])
189
  {
190
  if ($curve instanceof Ed25519) {
191
  if (!isset($privateKey->secret)) {
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PKCS1.php CHANGED
@@ -27,17 +27,16 @@
27
 
28
  namespace phpseclib3\Crypt\EC\Formats\Keys;
29
 
30
- use phpseclib3\Math\Common\FiniteField\Integer;
 
31
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
32
- use phpseclib3\File\ASN1;
33
- use phpseclib3\File\ASN1\Maps;
34
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
35
- use phpseclib3\Math\BigInteger;
36
- use ParagonIE\ConstantTime\Base64;
37
- use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
38
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
 
39
  use phpseclib3\Exception\UnsupportedCurveException;
40
- use phpseclib3\Common\Functions\Strings;
 
 
41
 
42
  /**
43
  * "PKCS1" (RFC5915) Formatted EC Key Handler
@@ -107,8 +106,8 @@ abstract class PKCS1 extends Progenitor
107
  $components['curve'] = $ecParams;
108
  }
109
 
110
- $temp = new BigInteger($ecPrivate['privateKey'], 256);
111
- $components['dA'] = $components['curve']->convertInteger($temp);
112
  $components['QA'] = isset($ecPrivate['publicKey']) ?
113
  self::extractPoint($ecPrivate['publicKey'], $components['curve']) :
114
  $components['curve']->multiplyPoint($components['curve']->getBasePoint(), $components['dA']);
@@ -138,8 +137,7 @@ abstract class PKCS1 extends Progenitor
138
 
139
  $components = [];
140
  $components['curve'] = self::loadCurveByParam($key['parameters']);
141
- $temp = new BigInteger($key['privateKey'], 256);
142
- $components['dA'] = $components['curve']->convertInteger($temp);
143
  $components['QA'] = isset($ecPrivate['publicKey']) ?
144
  self::extractPoint($ecPrivate['publicKey'], $components['curve']) :
145
  $components['curve']->multiplyPoint($components['curve']->getBasePoint(), $components['dA']);
@@ -172,14 +170,14 @@ abstract class PKCS1 extends Progenitor
172
  * Convert a private key to the appropriate format.
173
  *
174
  * @access public
175
- * @param \phpseclib3\Math\Common\FiniteField\Integer $privateKey
176
  * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve
177
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
178
  * @param string $password optional
179
  * @param array $options optional
180
  * @return string
181
  */
182
- public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = [])
183
  {
184
  self::initialize_static_variables();
185
 
27
 
28
  namespace phpseclib3\Crypt\EC\Formats\Keys;
29
 
30
+ use ParagonIE\ConstantTime\Base64;
31
+ use phpseclib3\Common\Functions\Strings;
32
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
 
 
33
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
 
 
 
34
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
35
+ use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
36
  use phpseclib3\Exception\UnsupportedCurveException;
37
+ use phpseclib3\File\ASN1;
38
+ use phpseclib3\File\ASN1\Maps;
39
+ use phpseclib3\Math\BigInteger;
40
 
41
  /**
42
  * "PKCS1" (RFC5915) Formatted EC Key Handler
106
  $components['curve'] = $ecParams;
107
  }
108
 
109
+ $components['dA'] = new BigInteger($ecPrivate['privateKey'], 256);
110
+ $components['curve']->rangeCheck($components['dA']);
111
  $components['QA'] = isset($ecPrivate['publicKey']) ?
112
  self::extractPoint($ecPrivate['publicKey'], $components['curve']) :
113
  $components['curve']->multiplyPoint($components['curve']->getBasePoint(), $components['dA']);
137
 
138
  $components = [];
139
  $components['curve'] = self::loadCurveByParam($key['parameters']);
140
+ $components['dA'] = new BigInteger($key['privateKey'], 256);
 
141
  $components['QA'] = isset($ecPrivate['publicKey']) ?
142
  self::extractPoint($ecPrivate['publicKey'], $components['curve']) :
143
  $components['curve']->multiplyPoint($components['curve']->getBasePoint(), $components['dA']);
170
  * Convert a private key to the appropriate format.
171
  *
172
  * @access public
173
+ * @param \phpseclib3\Math\BigInteger $privateKey
174
  * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve
175
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
176
  * @param string $password optional
177
  * @param array $options optional
178
  * @return string
179
  */
180
+ public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = [])
181
  {
182
  self::initialize_static_variables();
183
 
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PKCS8.php CHANGED
@@ -25,18 +25,17 @@
25
 
26
  namespace phpseclib3\Crypt\EC\Formats\Keys;
27
 
28
- use phpseclib3\Math\BigInteger;
29
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
30
- use phpseclib3\File\ASN1;
31
- use phpseclib3\File\ASN1\Maps;
32
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
33
- use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
34
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
35
- use phpseclib3\Math\Common\FiniteField\Integer;
36
  use phpseclib3\Crypt\EC\Curves\Ed25519;
37
  use phpseclib3\Crypt\EC\Curves\Ed448;
38
  use phpseclib3\Exception\UnsupportedCurveException;
39
- use phpseclib3\Common\Functions\Strings;
 
 
40
 
41
  /**
42
  * PKCS#8 Formatted EC Key Handler
@@ -126,10 +125,11 @@ abstract class PKCS8 extends Progenitor
126
  throw new \RuntimeException('The PKCS8 parameter field does not match the private key parameter field');
127
  }
128
 
129
- $temp = new BigInteger($key['privateKey'], 256);
130
- $components['dA'] = $components['curve']->convertInteger($temp);
131
-
132
- $components['QA'] = self::extractPoint($key['publicKey'], $components['curve']);
 
133
 
134
  return $components;
135
  }
@@ -205,14 +205,14 @@ abstract class PKCS8 extends Progenitor
205
  * Convert a private key to the appropriate format.
206
  *
207
  * @access public
208
- * @param \phpseclib3\Math\Common\FiniteField\Integer $privateKey
209
  * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve
210
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
211
  * @param string $password optional
212
  * @param array $options optional
213
  * @return string
214
  */
215
- public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = [])
216
  {
217
  self::initialize_static_variables();
218
 
@@ -226,8 +226,7 @@ abstract class PKCS8 extends Progenitor
226
  [],
227
  null,
228
  $password,
229
- $curve instanceof Ed25519 ? 'id-Ed25519' : 'id-Ed448',
230
- "\0" . $curve->encodePoint($publicKey)
231
  );
232
  }
233
 
25
 
26
  namespace phpseclib3\Crypt\EC\Formats\Keys;
27
 
28
+ use phpseclib3\Common\Functions\Strings;
29
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
 
 
30
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
 
31
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
32
+ use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
33
  use phpseclib3\Crypt\EC\Curves\Ed25519;
34
  use phpseclib3\Crypt\EC\Curves\Ed448;
35
  use phpseclib3\Exception\UnsupportedCurveException;
36
+ use phpseclib3\File\ASN1;
37
+ use phpseclib3\File\ASN1\Maps;
38
+ use phpseclib3\Math\BigInteger;
39
 
40
  /**
41
  * PKCS#8 Formatted EC Key Handler
125
  throw new \RuntimeException('The PKCS8 parameter field does not match the private key parameter field');
126
  }
127
 
128
+ $components['dA'] = new BigInteger($key['privateKey'], 256);
129
+ $components['curve']->rangeCheck($components['dA']);
130
+ $components['QA'] = isset($key['publicKey']) ?
131
+ self::extractPoint($key['publicKey'], $components['curve']) :
132
+ $components['curve']->multiplyPoint($components['curve']->getBasePoint(), $components['dA']);
133
 
134
  return $components;
135
  }
205
  * Convert a private key to the appropriate format.
206
  *
207
  * @access public
208
+ * @param \phpseclib3\Math\BigInteger $privateKey
209
  * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve
210
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
211
  * @param string $password optional
212
  * @param array $options optional
213
  * @return string
214
  */
215
+ public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = [])
216
  {
217
  self::initialize_static_variables();
218
 
226
  [],
227
  null,
228
  $password,
229
+ $curve instanceof Ed25519 ? 'id-Ed25519' : 'id-Ed448'
 
230
  );
231
  }
232
 
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/PuTTY.php CHANGED
@@ -16,12 +16,11 @@
16
  namespace phpseclib3\Crypt\EC\Formats\Keys;
17
 
18
  use ParagonIE\ConstantTime\Base64;
19
- use phpseclib3\Math\BigInteger;
20
  use phpseclib3\Common\Functions\Strings;
21
  use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor;
22
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
23
- use phpseclib3\Math\Common\FiniteField\Integer;
24
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
 
25
 
26
  /**
27
  * PuTTY Formatted EC Key Handler
@@ -81,8 +80,8 @@ abstract class PuTTY extends Progenitor
81
  }
82
  $components['dA'] = $components['curve']->extractSecret($private);
83
  } else {
84
- list($temp) = Strings::unpackSSH2('i', $private);
85
- $components['dA'] = $components['curve']->convertInteger($temp);
86
  }
87
 
88
  return $components;
@@ -92,14 +91,14 @@ abstract class PuTTY extends Progenitor
92
  * Convert a private key to the appropriate format.
93
  *
94
  * @access public
95
- * @param \phpseclib3\Math\Common\FiniteField\Integer $privateKey
96
  * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve
97
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
98
  * @param string $password optional
99
  * @param array $options optional
100
  * @return string
101
  */
102
- public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = false, array $options = [])
103
  {
104
  self::initialize_static_variables();
105
 
@@ -114,7 +113,7 @@ abstract class PuTTY extends Progenitor
114
  if (!$curve instanceof TwistedEdwardsCurve) {
115
  $private = $privateKey->toBytes();
116
  if (!(strlen($privateKey->toBits()) & 7)) {
117
- $private ="\0$private";
118
  }
119
  }
120
 
16
  namespace phpseclib3\Crypt\EC\Formats\Keys;
17
 
18
  use ParagonIE\ConstantTime\Base64;
 
19
  use phpseclib3\Common\Functions\Strings;
20
  use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor;
21
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
 
22
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
23
+ use phpseclib3\Math\BigInteger;
24
 
25
  /**
26
  * PuTTY Formatted EC Key Handler
80
  }
81
  $components['dA'] = $components['curve']->extractSecret($private);
82
  } else {
83
+ list($components['dA']) = Strings::unpackSSH2('i', $private);
84
+ $components['curve']->rangeCheck($components['dA']);
85
  }
86
 
87
  return $components;
91
  * Convert a private key to the appropriate format.
92
  *
93
  * @access public
94
+ * @param \phpseclib3\Math\BigInteger $privateKey
95
  * @param \phpseclib3\Crypt\EC\BaseCurves\Base $curve
96
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
97
  * @param string $password optional
98
  * @param array $options optional
99
  * @return string
100
  */
101
+ public static function savePrivateKey(BigInteger $privateKey, BaseCurve $curve, array $publicKey, $password = false, array $options = [])
102
  {
103
  self::initialize_static_variables();
104
 
113
  if (!$curve instanceof TwistedEdwardsCurve) {
114
  $private = $privateKey->toBytes();
115
  if (!(strlen($privateKey->toBits()) & 7)) {
116
+ $private = "\0$private";
117
  }
118
  }
119
 
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/XML.php CHANGED
@@ -21,13 +21,14 @@
21
  namespace phpseclib3\Crypt\EC\Formats\Keys;
22
 
23
  use ParagonIE\ConstantTime\Base64;
24
- use phpseclib3\Math\BigInteger;
25
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
 
26
  use phpseclib3\Crypt\EC\BaseCurves\Prime as PrimeCurve;
27
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
28
- use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
29
- use phpseclib3\Common\Functions\Strings;
30
  use phpseclib3\Exception\UnsupportedCurveException;
 
31
 
32
  /**
33
  * XML Formatted EC Key Handler
@@ -70,6 +71,10 @@ abstract class XML
70
  throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
71
  }
72
 
 
 
 
 
73
  $use_errors = libxml_use_internal_errors(true);
74
 
75
  $temp = self::isolateNamespace($key, 'http://www.w3.org/2009/xmldsig11#');
@@ -120,7 +125,7 @@ abstract class XML
120
  $query = '/';
121
  $names = explode('/', $name);
122
  foreach ($names as $name) {
123
- $query.= "/*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='$name']";
124
  }
125
  $result = $xpath->query($query);
126
  if (!isset($error)) {
@@ -152,7 +157,9 @@ abstract class XML
152
  }
153
  $node = $nodes->item(0);
154
  $ns_name = $node->lookupPrefix($ns);
155
- $node->removeAttributeNS($ns, $ns_name);
 
 
156
  return $dom->saveXML($node);
157
  }
158
 
@@ -428,7 +435,7 @@ abstract class XML
428
  $temp = $result['specifiedCurve'];
429
  switch ($temp['fieldID']['fieldType']) {
430
  case 'prime-field':
431
- $xml.= '<' . $pre . 'PrimeFieldParamsType>' . "\r\n" .
432
  '<' . $pre . 'P>' . $temp['fieldID']['parameters'] . '</' . $pre . 'P>' . "\r\n" .
433
  '</' . $pre . 'PrimeFieldParamsType>' . "\r\n";
434
  $a = $curve->getA();
@@ -438,7 +445,7 @@ abstract class XML
438
  default:
439
  throw new UnsupportedCurveException('Field Type of ' . $temp['fieldID']['fieldType'] . ' is not supported');
440
  }
441
- $xml.= '</' . $pre . 'FieldParams>' . "\r\n" .
442
  '<' . $pre . 'CurveParamsType>' . "\r\n" .
443
  '<' . $pre . 'A>' . $a . '</' . $pre . 'A>' . "\r\n" .
444
  '<' . $pre . 'B>' . $b . '</' . $pre . 'B>' . "\r\n" .
@@ -463,14 +470,14 @@ abstract class XML
463
  $temp = $result['specifiedCurve'];
464
  switch ($temp['fieldID']['fieldType']) {
465
  case 'prime-field':
466
- $xml.= '<' . $pre . 'Prime>' . "\r\n" .
467
  '<' . $pre . 'P>' . Base64::encode($temp['fieldID']['parameters']->toBytes()) . '</' . $pre . 'P>' . "\r\n" .
468
  '</' . $pre . 'Prime>' . "\r\n" ;
469
  break;
470
  default:
471
  throw new UnsupportedCurveException('Field Type of ' . $temp['fieldID']['fieldType'] . ' is not supported');
472
  }
473
- $xml.= '</' . $pre . 'FieldID>' . "\r\n" .
474
  '<' . $pre . 'Curve>' . "\r\n" .
475
  '<' . $pre . 'A>' . Base64::encode($temp['curve']['a']) . '</' . $pre . 'A>' . "\r\n" .
476
  '<' . $pre . 'B>' . Base64::encode($temp['curve']['b']) . '</' . $pre . 'B>' . "\r\n" .
21
  namespace phpseclib3\Crypt\EC\Formats\Keys;
22
 
23
  use ParagonIE\ConstantTime\Base64;
24
+ use phpseclib3\Common\Functions\Strings;
25
  use phpseclib3\Crypt\EC\BaseCurves\Base as BaseCurve;
26
+ use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
27
  use phpseclib3\Crypt\EC\BaseCurves\Prime as PrimeCurve;
28
  use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
29
+ use phpseclib3\Exception\BadConfigurationException;
 
30
  use phpseclib3\Exception\UnsupportedCurveException;
31
+ use phpseclib3\Math\BigInteger;
32
 
33
  /**
34
  * XML Formatted EC Key Handler
71
  throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
72
  }
73
 
74
+ if (!class_exists('DOMDocument')) {
75
+ throw new BadConfigurationException('The dom extension is not setup correctly on this system');
76
+ }
77
+
78
  $use_errors = libxml_use_internal_errors(true);
79
 
80
  $temp = self::isolateNamespace($key, 'http://www.w3.org/2009/xmldsig11#');
125
  $query = '/';
126
  $names = explode('/', $name);
127
  foreach ($names as $name) {
128
+ $query .= "/*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='$name']";
129
  }
130
  $result = $xpath->query($query);
131
  if (!isset($error)) {
157
  }
158
  $node = $nodes->item(0);
159
  $ns_name = $node->lookupPrefix($ns);
160
+ if ($ns_name) {
161
+ $node->removeAttributeNS($ns, $ns_name);
162
+ }
163
  return $dom->saveXML($node);
164
  }
165
 
435
  $temp = $result['specifiedCurve'];
436
  switch ($temp['fieldID']['fieldType']) {
437
  case 'prime-field':
438
+ $xml .= '<' . $pre . 'PrimeFieldParamsType>' . "\r\n" .
439
  '<' . $pre . 'P>' . $temp['fieldID']['parameters'] . '</' . $pre . 'P>' . "\r\n" .
440
  '</' . $pre . 'PrimeFieldParamsType>' . "\r\n";
441
  $a = $curve->getA();
445
  default:
446
  throw new UnsupportedCurveException('Field Type of ' . $temp['fieldID']['fieldType'] . ' is not supported');
447
  }
448
+ $xml .= '</' . $pre . 'FieldParams>' . "\r\n" .
449
  '<' . $pre . 'CurveParamsType>' . "\r\n" .
450
  '<' . $pre . 'A>' . $a . '</' . $pre . 'A>' . "\r\n" .
451
  '<' . $pre . 'B>' . $b . '</' . $pre . 'B>' . "\r\n" .
470
  $temp = $result['specifiedCurve'];
471
  switch ($temp['fieldID']['fieldType']) {
472
  case 'prime-field':
473
+ $xml .= '<' . $pre . 'Prime>' . "\r\n" .
474
  '<' . $pre . 'P>' . Base64::encode($temp['fieldID']['parameters']->toBytes()) . '</' . $pre . 'P>' . "\r\n" .
475
  '</' . $pre . 'Prime>' . "\r\n" ;
476
  break;
477
  default:
478
  throw new UnsupportedCurveException('Field Type of ' . $temp['fieldID']['fieldType'] . ' is not supported');
479
  }
480
+ $xml .= '</' . $pre . 'FieldID>' . "\r\n" .
481
  '<' . $pre . 'Curve>' . "\r\n" .
482
  '<' . $pre . 'A>' . Base64::encode($temp['curve']['a']) . '</' . $pre . 'A>' . "\r\n" .
483
  '<' . $pre . 'B>' . Base64::encode($temp['curve']['b']) . '</' . $pre . 'B>' . "\r\n" .
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Keys/libsodium.php CHANGED
@@ -20,8 +20,8 @@
20
  namespace phpseclib3\Crypt\EC\Formats\Keys;
21
 
22
  use phpseclib3\Crypt\EC\Curves\Ed25519;
23
- use phpseclib3\Math\Common\FiniteField\Integer;
24
  use phpseclib3\Exception\UnsupportedFormatException;
 
25
 
26
  /**
27
  * libsodium Key Handler
@@ -78,7 +78,6 @@ abstract class libsodium
78
  $components['QA'] = isset($public) ?
79
  self::extractPoint($public, $curve) :
80
  $curve->multiplyPoint($curve->getBasePoint(), $components['dA']);
81
-
82
 
83
  return $components;
84
  }
@@ -100,13 +99,13 @@ abstract class libsodium
100
  * Convert a private key to the appropriate format.
101
  *
102
  * @access public
103
- * @param \phpseclib3\Math\Common\FiniteField\Integer $privateKey
104
  * @param \phpseclib3\Crypt\EC\Curves\Ed25519 $curve
105
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
106
  * @param string $password optional
107
  * @return string
108
  */
109
- public static function savePrivateKey(Integer $privateKey, Ed25519 $curve, array $publicKey, $password = '')
110
  {
111
  if (!isset($privateKey->secret)) {
112
  throw new \RuntimeException('Private Key does not have a secret set');
20
  namespace phpseclib3\Crypt\EC\Formats\Keys;
21
 
22
  use phpseclib3\Crypt\EC\Curves\Ed25519;
 
23
  use phpseclib3\Exception\UnsupportedFormatException;
24
+ use phpseclib3\Math\BigInteger;
25
 
26
  /**
27
  * libsodium Key Handler
78
  $components['QA'] = isset($public) ?
79
  self::extractPoint($public, $curve) :
80
  $curve->multiplyPoint($curve->getBasePoint(), $components['dA']);
 
81
 
82
  return $components;
83
  }
99
  * Convert a private key to the appropriate format.
100
  *
101
  * @access public
102
+ * @param \phpseclib3\Math\BigInteger $privateKey
103
  * @param \phpseclib3\Crypt\EC\Curves\Ed25519 $curve
104
  * @param \phpseclib3\Math\Common\FiniteField\Integer[] $publicKey
105
  * @param string $password optional
106
  * @return string
107
  */
108
+ public static function savePrivateKey(BigInteger $privateKey, Ed25519 $curve, array $publicKey, $password = '')
109
  {
110
  if (!isset($privateKey->secret)) {
111
  throw new \RuntimeException('Private Key does not have a secret set');
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/ASN1.php CHANGED
@@ -18,9 +18,9 @@
18
 
19
  namespace phpseclib3\Crypt\EC\Formats\Signature;
20
 
21
- use phpseclib3\Math\BigInteger;
22
  use phpseclib3\File\ASN1 as Encoder;
23
  use phpseclib3\File\ASN1\Maps\EcdsaSigValue;
 
24
 
25
  /**
26
  * ASN1 Signature Handler
18
 
19
  namespace phpseclib3\Crypt\EC\Formats\Signature;
20
 
 
21
  use phpseclib3\File\ASN1 as Encoder;
22
  use phpseclib3\File\ASN1\Maps\EcdsaSigValue;
23
+ use phpseclib3\Math\BigInteger;
24
 
25
  /**
26
  * ASN1 Signature Handler
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/Formats/Signature/SSH2.php CHANGED
@@ -17,8 +17,8 @@
17
 
18
  namespace phpseclib3\Crypt\EC\Formats\Signature;
19
 
20
- use phpseclib3\Math\BigInteger;
21
  use phpseclib3\Common\Functions\Strings;
 
22
 
23
  /**
24
  * SSH2 Signature Handler
17
 
18
  namespace phpseclib3\Crypt\EC\Formats\Signature;
19
 
 
20
  use phpseclib3\Common\Functions\Strings;
21
+ use phpseclib3\Math\BigInteger;
22
 
23
  /**
24
  * SSH2 Signature Handler
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PrivateKey.php CHANGED
@@ -13,18 +13,18 @@
13
 
14
  namespace phpseclib3\Crypt\EC;
15
 
 
 
16
  use phpseclib3\Crypt\EC;
17
- use phpseclib3\Crypt\EC\Formats\Signature\ASN1 as ASN1Signature;
18
- use phpseclib3\Math\BigInteger;
19
- use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
20
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
21
- use phpseclib3\Crypt\Hash;
22
- use phpseclib3\Crypt\EC\Curves\Ed25519;
23
  use phpseclib3\Crypt\EC\Curves\Curve25519;
 
24
  use phpseclib3\Crypt\EC\Formats\Keys\PKCS1;
25
- use phpseclib3\Crypt\Common;
 
26
  use phpseclib3\Exception\UnsupportedOperationException;
27
- use phpseclib3\Common\Functions\Strings;
28
 
29
  /**
30
  * EC Private Key
@@ -95,8 +95,7 @@ class PrivateKey extends EC implements Common\PrivateKey
95
  throw new UnsupportedOperationException('Montgomery Curves cannot be used to create signatures');
96
  }
97
 
98
- $dA = $this->dA->toBigInteger();
99
-
100
  $order = $this->curve->getOrder();
101
 
102
  $shortFormat = $this->shortFormat;
@@ -107,7 +106,7 @@ class PrivateKey extends EC implements Common\PrivateKey
107
 
108
  if ($this->curve instanceof TwistedEdwardsCurve) {
109
  if ($this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context)) {
110
- $result = sodium_crypto_sign_detached($message, $this->toString('libsodium'));
111
  return $shortFormat == 'SSH2' ? Strings::packSSH2('ss', 'ssh-' . strtolower($this->getCurve()), $result) : $result;
112
  }
113
 
@@ -132,7 +131,7 @@ class PrivateKey extends EC implements Common\PrivateKey
132
  $r = strrev($r);
133
  $r = new BigInteger($r, 256);
134
  list(, $r) = $r->divide($order);
135
- $R = $curve->multiplyPoint($curve->getBasePoint(), $curve->convertInteger($r));
136
  $R = $curve->encodePoint($R);
137
  $k = $hash->hash($dom . $R . $A . $message);
138
  $k = strrev($k);
@@ -172,7 +171,7 @@ class PrivateKey extends EC implements Common\PrivateKey
172
 
173
  while (true) {
174
  $k = BigInteger::randomRange(self::$one, $order->subtract(self::$one));
175
- list($x, $y) = $this->curve->multiplyPoint($this->curve->getBasePoint(), $this->curve->convertInteger($k));
176
  $x = $x->toBigInteger();
177
  list(, $r) = $x->divide($order);
178
  if ($r->equals(self::$zero)) {
@@ -199,7 +198,7 @@ class PrivateKey extends EC implements Common\PrivateKey
199
 
200
  $h1 = $this->hash->hash($message);
201
  $k = $this->computek($h1);
202
- list($x, $y) = $this->curve->multiplyPoint($this->curve->getBasePoint(), $this->curve->convertInteger($k));
203
  $x = $x->toBigInteger();
204
  list(, $r) = $x->divide($this->q);
205
  $kinv = $k->modInverse($this->q);
13
 
14
  namespace phpseclib3\Crypt\EC;
15
 
16
+ use phpseclib3\Common\Functions\Strings;
17
+ use phpseclib3\Crypt\Common;
18
  use phpseclib3\Crypt\EC;
 
 
 
19
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
20
+ use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
 
21
  use phpseclib3\Crypt\EC\Curves\Curve25519;
22
+ use phpseclib3\Crypt\EC\Curves\Ed25519;
23
  use phpseclib3\Crypt\EC\Formats\Keys\PKCS1;
24
+ use phpseclib3\Crypt\EC\Formats\Signature\ASN1 as ASN1Signature;
25
+ use phpseclib3\Crypt\Hash;
26
  use phpseclib3\Exception\UnsupportedOperationException;
27
+ use phpseclib3\Math\BigInteger;
28
 
29
  /**
30
  * EC Private Key
95
  throw new UnsupportedOperationException('Montgomery Curves cannot be used to create signatures');
96
  }
97
 
98
+ $dA = $this->dA;
 
99
  $order = $this->curve->getOrder();
100
 
101
  $shortFormat = $this->shortFormat;
106
 
107
  if ($this->curve instanceof TwistedEdwardsCurve) {
108
  if ($this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context)) {
109
+ $result = sodium_crypto_sign_detached($message, $this->withPassword()->toString('libsodium'));
110
  return $shortFormat == 'SSH2' ? Strings::packSSH2('ss', 'ssh-' . strtolower($this->getCurve()), $result) : $result;
111
  }
112
 
131
  $r = strrev($r);
132
  $r = new BigInteger($r, 256);
133
  list(, $r) = $r->divide($order);
134
+ $R = $curve->multiplyPoint($curve->getBasePoint(), $r);
135
  $R = $curve->encodePoint($R);
136
  $k = $hash->hash($dom . $R . $A . $message);
137
  $k = strrev($k);
171
 
172
  while (true) {
173
  $k = BigInteger::randomRange(self::$one, $order->subtract(self::$one));
174
+ list($x, $y) = $this->curve->multiplyPoint($this->curve->getBasePoint(), $k);
175
  $x = $x->toBigInteger();
176
  list(, $r) = $x->divide($order);
177
  if ($r->equals(self::$zero)) {
198
 
199
  $h1 = $this->hash->hash($message);
200
  $k = $this->computek($h1);
201
+ list($x, $y) = $this->curve->multiplyPoint($this->curve->getBasePoint(), $k);
202
  $x = $x->toBigInteger();
203
  list(, $r) = $x->divide($this->q);
204
  $kinv = $k->modInverse($this->q);
vendor/phpseclib/phpseclib/phpseclib/Crypt/EC/PublicKey.php CHANGED
@@ -13,17 +13,17 @@
13
 
14
  namespace phpseclib3\Crypt\EC;
15
 
 
 
16
  use phpseclib3\Crypt\EC;
17
- use phpseclib3\Crypt\Hash;
18
- use phpseclib3\Math\BigInteger;
19
- use phpseclib3\Crypt\EC\Formats\Signature\ASN1 as ASN1Signature;
20
- use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
21
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
 
22
  use phpseclib3\Crypt\EC\Curves\Ed25519;
23
  use phpseclib3\Crypt\EC\Formats\Keys\PKCS1;
24
- use phpseclib3\Crypt\Common;
 
25
  use phpseclib3\Exception\UnsupportedOperationException;
26
- use phpseclib3\Common\Functions\Strings;
27
 
28
  /**
29
  * EC Public Key
@@ -108,8 +108,8 @@ class PublicKey extends EC implements Common\PublicKey
108
 
109
  $qa = $curve->convertToInternal($this->QA);
110
 
111
- $lhs = $curve->multiplyPoint($curve->getBasePoint(), $curve->convertInteger($S));
112
- $rhs = $curve->multiplyPoint($qa, $curve->convertInteger($k));
113
  $rhs = $curve->addPoint($rhs, $R);
114
  $rhs = $curve->convertToAffine($rhs);
115
 
13
 
14
  namespace phpseclib3\Crypt\EC;
15
 
16
+ use phpseclib3\Common\Functions\Strings;
17
+ use phpseclib3\Crypt\Common;
18
  use phpseclib3\Crypt\EC;
 
 
 
 
19
  use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
20
+ use phpseclib3\Crypt\EC\BaseCurves\TwistedEdwards as TwistedEdwardsCurve;
21
  use phpseclib3\Crypt\EC\Curves\Ed25519;
22
  use phpseclib3\Crypt\EC\Formats\Keys\PKCS1;
23
+ use phpseclib3\Crypt\EC\Formats\Signature\ASN1 as ASN1Signature;
24
+ use phpseclib3\Crypt\Hash;
25
  use phpseclib3\Exception\UnsupportedOperationException;
26
+ use phpseclib3\Math\BigInteger;
27
 
28
  /**
29
  * EC Public Key
108
 
109
  $qa = $curve->convertToInternal($this->QA);
110
 
111
+ $lhs = $curve->multiplyPoint($curve->getBasePoint(), $S);
112
+ $rhs = $curve->multiplyPoint($qa, $k);
113
  $rhs = $curve->addPoint($rhs, $R);
114
  $rhs = $curve->convertToAffine($rhs);
115
 
vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php CHANGED
@@ -33,11 +33,10 @@
33
 
34
  namespace phpseclib3\Crypt;
35
 
36
- use phpseclib3\Math\BigInteger;
37
- use phpseclib3\Exception\UnsupportedAlgorithmException;
38
- use phpseclib3\Exception\InsufficientSetupException;
39
  use phpseclib3\Common\Functions\Strings;
40
- use phpseclib3\Crypt\AES;
 
 
41
  use phpseclib3\Math\PrimeField;
42
 
43
  /**
@@ -53,7 +52,7 @@ class Hash
53
  *
54
  * @access private
55
  */
56
- //const PADDING_KECCAK = 1;
57
 
58
  /**
59
  * Padding Types
@@ -339,6 +338,9 @@ class Hash
339
  case 'sha3-224':
340
  $this->length = 28;
341
  break;
 
 
 
342
  case 'sha256':
343
  case 'sha512/256':
344
  case 'sha3-256':
@@ -384,6 +386,7 @@ class Hash
384
  break;
385
  case 'sha3-256':
386
  case 'shake256':
 
387
  $this->blockSize = 1088; // 1600 - 2*256
388
  break;
389
  case 'sha3-384':
@@ -399,10 +402,10 @@ class Hash
399
  $this->blockSize = 1024;
400
  }
401
 
402
- if (in_array(substr($hash, 0, 5), ['sha3-', 'shake'])) {
403
  // PHP 7.1.0 introduced support for "SHA3 fixed mode algorithms":
404
  // http://php.net/ChangeLog-7.php#7.1.0
405
- if (version_compare(PHP_VERSION, '7.1.0') < 0 || substr($hash, 0,5) == 'shake') {
406
  //preg_match('#(\d+)$#', $hash, $matches);
407
  //$this->parameters['capacity'] = 2 * $matches[1]; // 1600 - $this->blockSize
408
  //$this->parameters['rate'] = 1600 - $this->parameters['capacity']; // == $this->blockSize
@@ -544,15 +547,15 @@ class Hash
544
  //
545
  $y = '';
546
  for ($i = 0; $i < $iters; $i++) {
547
- $L1Key_i = substr($L1Key, $i * 16, 1024);
548
- $L2Key_i = substr($L2Key, $i * 24, 24);
549
  $L3Key1_i = substr($L3Key1, $i * 64, 64);
550
  $L3Key2_i = substr($L3Key2, $i * 4, 4);
551
 
552
  $a = self::L1Hash($L1Key_i, $m);
553
  $b = strlen($m) <= 1024 ? "\0\0\0\0\0\0\0\0$a" : self::L2Hash($L2Key_i, $a);
554
  $c = self::L3Hash($L3Key1_i, $L3Key2_i, $b);
555
- $y.= $c;
556
  }
557
 
558
  return $y;
@@ -584,7 +587,7 @@ class Hash
584
  $y = '';
585
  for ($i = 0; $i < count($m) - 1; $i++) {
586
  $m[$i] = pack('N*', ...unpack('V*', $m[$i])); // ENDIAN-SWAP
587
- $y.= static::nh($k, $m[$i], $length);
588
  }
589
 
590
  //
@@ -597,7 +600,7 @@ class Hash
597
  $m[$i] = str_pad($m[$i], $pad, "\0"); // zeropad
598
  $m[$i] = pack('N*', ...unpack('V*', $m[$i])); // ENDIAN-SWAP
599
 
600
- $y.= static::nh($k, $m[$i], new BigInteger($length * 8));
601
 
602
  return $y;
603
  }
@@ -611,7 +614,7 @@ class Hash
611
  */
612
  private static function nh($k, $m, $length)
613
  {
614
- $toUInt32 = function($x) {
615
  $x = new BigInteger($x, 256);
616
  $x->setPrecision(32);
617
  return $x;
@@ -633,7 +636,7 @@ class Hash
633
  // Perform NH hash on the chunks, pairing words for multiplication
634
  // which are 4 apart to accommodate vector-parallelism.
635
  //
636
- $y = new BigInteger;
637
  $y->setPrecision(64);
638
  $i = 0;
639
  while ($i < $t) {
@@ -657,7 +660,7 @@ class Hash
657
  $temp = $temp->multiply($m[$i + 7]->add($k[$i + 7]));
658
  $y = $y->add($temp);
659
 
660
- $i+= 8;
661
  }
662
 
663
  return $y->add($length)->toBytes();
@@ -700,7 +703,7 @@ class Hash
700
  $m_2 = substr($m, 0x20000) . "\x80";
701
  $length = strlen($m_2);
702
  $pad = 16 - ($length % 16);
703
- $pad%= 16;
704
  $m_2 = str_pad($m_2, $length + $pad, "\0"); // zeropad
705
  $y = self::poly(64, self::$maxwordrange64, $k64, $m_1);
706
  $y = str_pad($y, 16, "\0", STR_PAD_LEFT);
@@ -861,7 +864,7 @@ class Hash
861
  $temp .= $text;
862
  $temp = substr($algo($temp, ...array_values($this->parameters)), 0, $this->length);
863
  $output = $this->opad ^ $key;
864
- $output.= $temp;
865
  $output = $algo($output, ...array_values($this->parameters));
866
 
867
  return substr($output, 0, $this->length);
@@ -931,10 +934,10 @@ class Hash
931
  private static function sha3_pad($padLength, $padType)
932
  {
933
  switch ($padType) {
934
- //case self::PADDING_KECCAK:
935
- // $temp = chr(0x06) . str_repeat("\0", $padLength - 1);
936
- // $temp[$padLength - 1] = $temp[$padLength - 1] | chr(0x80);
937
- // return $temp
938
  case self::PADDING_SHAKE:
939
  $temp = chr(0x1F) . str_repeat("\0", $padLength - 1);
940
  $temp[$padLength - 1] = $temp[$padLength - 1] | chr(0x80);
@@ -979,7 +982,7 @@ class Hash
979
  $padLength = $block_size - (strlen($p) % $block_size);
980
  $num_ints = $block_size >> 2;
981
 
982
- $p.= static::sha3_pad($padLength, $padType);
983
 
984
  $n = strlen($p) / $r; // number of blocks
985
 
@@ -996,9 +999,9 @@ class Hash
996
  foreach ($p as $pi) {
997
  $pi = unpack('V*', $pi);
998
  $x = $y = 0;
999
- for ($i = 1; $i <= $num_ints; $i+=2) {
1000
- $s[$x][$y][0]^= $pi[$i + 1];
1001
- $s[$x][$y][1]^= $pi[$i];
1002
  if (++$y == 5) {
1003
  $y = 0;
1004
  $x++;
@@ -1010,7 +1013,7 @@ class Hash
1010
  $z = '';
1011
  $i = $j = 0;
1012
  while (strlen($z) < $d) {
1013
- $z.= pack('V2', $s[$i][$j][1], $s[$i][$j++][0]);
1014
  if ($j == 5) {
1015
  $j = 0;
1016
  $i++;
@@ -1090,8 +1093,8 @@ class Hash
1090
  ];
1091
  for ($i = 0; $i < 5; $i++) {
1092
  for ($j = 0; $j < 5; $j++) {
1093
- $s[$i][$j][0]^= $temp[$j][0];
1094
- $s[$i][$j][1]^= $temp[$j][1];
1095
  }
1096
  }
1097
 
@@ -1129,8 +1132,8 @@ class Hash
1129
  }
1130
 
1131
  // iota step
1132
- $s[0][0][0]^= $roundConstants[$round][0];
1133
- $s[0][0][1]^= $roundConstants[$round][1];
1134
  }
1135
  }
1136
 
@@ -1146,7 +1149,7 @@ class Hash
1146
  if ($shift < 32) {
1147
  list($hi, $lo) = $x;
1148
  } else {
1149
- $shift-= 32;
1150
  list($lo, $hi) = $x;
1151
  }
1152
 
@@ -1172,7 +1175,7 @@ class Hash
1172
  $padLength = $block_size - (strlen($p) % $block_size);
1173
  $num_ints = $block_size >> 2;
1174
 
1175
- $p.= static::sha3_pad($padLength, $padType);
1176
 
1177
  $n = strlen($p) / $r; // number of blocks
1178
 
@@ -1190,7 +1193,7 @@ class Hash
1190
  $pi = unpack('P*', $pi);
1191
  $x = $y = 0;
1192
  foreach ($pi as $subpi) {
1193
- $s[$x][$y++]^= $subpi;
1194
  if ($y == 5) {
1195
  $y = 0;
1196
  $x++;
@@ -1202,7 +1205,7 @@ class Hash
1202
  $z = '';
1203
  $i = $j = 0;
1204
  while (strlen($z) < $d) {
1205
- $z.= pack('P', $s[$i][$j++]);
1206
  if ($j == 5) {
1207
  $j = 0;
1208
  $i++;
@@ -1274,7 +1277,7 @@ class Hash
1274
  ];
1275
  for ($i = 0; $i < 5; $i++) {
1276
  for ($j = 0; $j < 5; $j++) {
1277
- $s[$i][$j]^= $temp[$j];
1278
  }
1279
  }
1280
 
@@ -1299,7 +1302,7 @@ class Hash
1299
  }
1300
 
1301
  // iota step
1302
- $s[0][0]^= $roundConstants[$round];
1303
  }
1304
  }
1305
 
@@ -1361,10 +1364,10 @@ class Hash
1361
  // Pre-processing
1362
  $length = strlen($m);
1363
  // to round to nearest 112 mod 128, we'll add 128 - (length + (128 - 112)) % 128
1364
- $m.= str_repeat(chr(0), 128 - (($length + 16) & 0x7F));
1365
  $m[$length] = chr(0x80);
1366
  // we don't support hashing strings 512MB long
1367
- $m.= pack('N4', 0, 0, 0, $length << 3);
1368
 
1369
  // Process the message in successive 1024-bit chunks
1370
  $chunks = str_split($m, 128);
33
 
34
  namespace phpseclib3\Crypt;
35
 
 
 
 
36
  use phpseclib3\Common\Functions\Strings;
37
+ use phpseclib3\Exception\InsufficientSetupException;
38
+ use phpseclib3\Exception\UnsupportedAlgorithmException;
39
+ use phpseclib3\Math\BigInteger;
40
  use phpseclib3\Math\PrimeField;
41
 
42
  /**
52
  *
53
  * @access private
54
  */
55
+ const PADDING_KECCAK = 1;
56
 
57
  /**
58
  * Padding Types
338
  case 'sha3-224':
339
  $this->length = 28;
340
  break;
341
+ case 'keccak256':
342
+ $this->paddingType = self::PADDING_KECCAK;
343
+ // fall-through
344
  case 'sha256':
345
  case 'sha512/256':
346
  case 'sha3-256':
386
  break;
387
  case 'sha3-256':
388
  case 'shake256':
389
+ case 'keccak256':
390
  $this->blockSize = 1088; // 1600 - 2*256
391
  break;
392
  case 'sha3-384':
402
  $this->blockSize = 1024;
403
  }
404
 
405
+ if (in_array(substr($hash, 0, 5), ['sha3-', 'shake', 'kecca'])) {
406
  // PHP 7.1.0 introduced support for "SHA3 fixed mode algorithms":
407
  // http://php.net/ChangeLog-7.php#7.1.0
408
+ if (version_compare(PHP_VERSION, '7.1.0') < 0 || substr($hash, 0, 5) != 'sha3-') {
409
  //preg_match('#(\d+)$#', $hash, $matches);
410
  //$this->parameters['capacity'] = 2 * $matches[1]; // 1600 - $this->blockSize
411
  //$this->parameters['rate'] = 1600 - $this->parameters['capacity']; // == $this->blockSize
547
  //
548
  $y = '';
549
  for ($i = 0; $i < $iters; $i++) {
550
+ $L1Key_i = substr($L1Key, $i * 16, 1024);
551
+ $L2Key_i = substr($L2Key, $i * 24, 24);
552
  $L3Key1_i = substr($L3Key1, $i * 64, 64);
553
  $L3Key2_i = substr($L3Key2, $i * 4, 4);
554
 
555
  $a = self::L1Hash($L1Key_i, $m);
556
  $b = strlen($m) <= 1024 ? "\0\0\0\0\0\0\0\0$a" : self::L2Hash($L2Key_i, $a);
557
  $c = self::L3Hash($L3Key1_i, $L3Key2_i, $b);
558
+ $y .= $c;
559
  }
560
 
561
  return $y;
587
  $y = '';
588
  for ($i = 0; $i < count($m) - 1; $i++) {
589
  $m[$i] = pack('N*', ...unpack('V*', $m[$i])); // ENDIAN-SWAP
590
+ $y .= static::nh($k, $m[$i], $length);
591
  }
592
 
593
  //
600
  $m[$i] = str_pad($m[$i], $pad, "\0"); // zeropad
601
  $m[$i] = pack('N*', ...unpack('V*', $m[$i])); // ENDIAN-SWAP
602
 
603
+ $y .= static::nh($k, $m[$i], new BigInteger($length * 8));
604
 
605
  return $y;
606
  }
614
  */
615
  private static function nh($k, $m, $length)
616
  {
617
+ $toUInt32 = function ($x) {
618
  $x = new BigInteger($x, 256);
619
  $x->setPrecision(32);
620
  return $x;
636
  // Perform NH hash on the chunks, pairing words for multiplication
637
  // which are 4 apart to accommodate vector-parallelism.
638
  //
639
+ $y = new BigInteger();
640
  $y->setPrecision(64);
641
  $i = 0;
642
  while ($i < $t) {
660
  $temp = $temp->multiply($m[$i + 7]->add($k[$i + 7]));
661
  $y = $y->add($temp);
662
 
663
+ $i += 8;
664
  }
665
 
666
  return $y->add($length)->toBytes();
703
  $m_2 = substr($m, 0x20000) . "\x80";
704
  $length = strlen($m_2);
705
  $pad = 16 - ($length % 16);
706
+ $pad %= 16;
707
  $m_2 = str_pad($m_2, $length + $pad, "\0"); // zeropad
708
  $y = self::poly(64, self::$maxwordrange64, $k64, $m_1);
709
  $y = str_pad($y, 16, "\0", STR_PAD_LEFT);
864
  $temp .= $text;
865
  $temp = substr($algo($temp, ...array_values($this->parameters)), 0, $this->length);
866
  $output = $this->opad ^ $key;
867
+ $output .= $temp;
868
  $output = $algo($output, ...array_values($this->parameters));
869
 
870
  return substr($output, 0, $this->length);
934
  private static function sha3_pad($padLength, $padType)
935
  {
936
  switch ($padType) {
937
+ case self::PADDING_KECCAK:
938
+ $temp = chr(0x01) . str_repeat("\0", $padLength - 1);
939
+ $temp[$padLength - 1] = $temp[$padLength - 1] | chr(0x80);
940
+ return $temp;
941
  case self::PADDING_SHAKE:
942
  $temp = chr(0x1F) . str_repeat("\0", $padLength - 1);
943
  $temp[$padLength - 1] = $temp[$padLength - 1] | chr(0x80);
982
  $padLength = $block_size - (strlen($p) % $block_size);
983
  $num_ints = $block_size >> 2;
984
 
985
+ $p .= static::sha3_pad($padLength, $padType);
986
 
987
  $n = strlen($p) / $r; // number of blocks
988
 
999
  foreach ($p as $pi) {
1000
  $pi = unpack('V*', $pi);
1001
  $x = $y = 0;
1002
+ for ($i = 1; $i <= $num_ints; $i += 2) {
1003
+ $s[$x][$y][0] ^= $pi[$i + 1];
1004
+ $s[$x][$y][1] ^= $pi[$i];
1005
  if (++$y == 5) {
1006
  $y = 0;
1007
  $x++;
1013
  $z = '';
1014
  $i = $j = 0;
1015
  while (strlen($z) < $d) {
1016
+ $z .= pack('V2', $s[$i][$j][1], $s[$i][$j++][0]);
1017
  if ($j == 5) {
1018
  $j = 0;
1019
  $i++;
1093
  ];
1094
  for ($i = 0; $i < 5; $i++) {
1095
  for ($j = 0; $j < 5; $j++) {
1096
+ $s[$i][$j][0] ^= $temp[$j][0];
1097
+ $s[$i][$j][1] ^= $temp[$j][1];
1098
  }
1099
  }
1100
 
1132
  }
1133
 
1134
  // iota step
1135
+ $s[0][0][0] ^= $roundConstants[$round][0];
1136
+ $s[0][0][1] ^= $roundConstants[$round][1];
1137
  }
1138
  }
1139
 
1149
  if ($shift < 32) {
1150
  list($hi, $lo) = $x;
1151
  } else {
1152
+ $shift -= 32;
1153
  list($lo, $hi) = $x;
1154
  }
1155
 
1175
  $padLength = $block_size - (strlen($p) % $block_size);
1176
  $num_ints = $block_size >> 2;
1177
 
1178
+ $p .= static::sha3_pad($padLength, $padType);
1179
 
1180
  $n = strlen($p) / $r; // number of blocks
1181
 
1193
  $pi = unpack('P*', $pi);
1194
  $x = $y = 0;
1195
  foreach ($pi as $subpi) {
1196
+ $s[$x][$y++] ^= $subpi;
1197
  if ($y == 5) {
1198
  $y = 0;
1199
  $x++;
1205
  $z = '';
1206
  $i = $j = 0;
1207
  while (strlen($z) < $d) {
1208
+ $z .= pack('P', $s[$i][$j++]);
1209
  if ($j == 5) {
1210
  $j = 0;
1211
  $i++;
1277
  ];
1278
  for ($i = 0; $i < 5; $i++) {
1279
  for ($j = 0; $j < 5; $j++) {
1280
+ $s[$i][$j] ^= $temp[$j];
1281
  }
1282
  }
1283
 
1302
  }
1303
 
1304
  // iota step
1305
+ $s[0][0] ^= $roundConstants[$round];
1306
  }
1307
  }
1308
 
1364
  // Pre-processing
1365
  $length = strlen($m);
1366
  // to round to nearest 112 mod 128, we'll add 128 - (length + (128 - 112)) % 128
1367
+ $m .= str_repeat(chr(0), 128 - (($length + 16) & 0x7F));
1368
  $m[$length] = chr(0x80);
1369
  // we don't support hashing strings 512MB long
1370
+ $m .= pack('N4', 0, 0, 0, $length << 3);
1371
 
1372
  // Process the message in successive 1024-bit chunks
1373
  $chunks = str_split($m, 128);
vendor/phpseclib/phpseclib/phpseclib/Crypt/PublicKeyLoader.php CHANGED
@@ -16,8 +16,8 @@
16
  namespace phpseclib3\Crypt;
17
 
18
  use phpseclib3\Crypt\Common\AsymmetricKey;
19
- use phpseclib3\Crypt\Common\PublicKey;
20
  use phpseclib3\Crypt\Common\PrivateKey;
 
21
  use phpseclib3\Exception\NoKeyLoadedException;
22
  use phpseclib3\File\X509;
23
 
@@ -42,15 +42,18 @@ abstract class PublicKeyLoader
42
  {
43
  try {
44
  return EC::load($key, $password);
45
- } catch (NoKeyLoadedException $e) {}
 
46
 
47
  try {
48
  return RSA::load($key, $password);
49
- } catch (NoKeyLoadedException $e) {}
 
50
 
51
  try {
52
  return DSA::load($key, $password);
53
- } catch (NoKeyLoadedException $e) {}
 
54
 
55
  try {
56
  $x509 = new X509();
@@ -59,7 +62,8 @@ abstract class PublicKeyLoader
59
  if ($key) {
60
  return $key;
61
  }
62
- } catch (\Exception $e) {}
 
63
 
64
  throw new NoKeyLoadedException('Unable to read key');
65
  }
@@ -72,7 +76,7 @@ abstract class PublicKeyLoader
72
  * @param string|array $key
73
  * @param string $password optional
74
  */
75
- public function loadPrivateKey($key, $password = false)
76
  {
77
  $key = self::load($key, $password);
78
  if (!$key instanceof PrivateKey) {
@@ -88,7 +92,7 @@ abstract class PublicKeyLoader
88
  * @access public
89
  * @param string|array $key
90
  */
91
- public function loadPublicKey($key)
92
  {
93
  $key = self::load($key);
94
  if (!$key instanceof PublicKey) {
@@ -104,7 +108,7 @@ abstract class PublicKeyLoader
104
  * @access public
105
  * @param string|array $key
106
  */
107
- public function loadParameters($key)
108
  {
109
  $key = self::load($key);
110
  if (!$key instanceof PrivateKey && !$key instanceof PublicKey) {
16
  namespace phpseclib3\Crypt;
17
 
18
  use phpseclib3\Crypt\Common\AsymmetricKey;
 
19
  use phpseclib3\Crypt\Common\PrivateKey;
20
+ use phpseclib3\Crypt\Common\PublicKey;
21
  use phpseclib3\Exception\NoKeyLoadedException;
22
  use phpseclib3\File\X509;
23
 
42
  {
43
  try {
44
  return EC::load($key, $password);
45
+ } catch (NoKeyLoadedException $e) {
46
+ }
47
 
48
  try {
49
  return RSA::load($key, $password);
50
+ } catch (NoKeyLoadedException $e) {
51
+ }
52
 
53
  try {
54
  return DSA::load($key, $password);
55
+ } catch (NoKeyLoadedException $e) {
56
+ }
57
 
58
  try {
59
  $x509 = new X509();
62
  if ($key) {
63
  return $key;
64
  }
65
+ } catch (\Exception $e) {
66
+ }
67
 
68
  throw new NoKeyLoadedException('Unable to read key');
69
  }
76
  * @param string|array $key
77
  * @param string $password optional
78
  */
79
+ public static function loadPrivateKey($key, $password = false)
80
  {
81
  $key = self::load($key, $password);
82
  if (!$key instanceof PrivateKey) {
92
  * @access public
93
  * @param string|array $key
94
  */
95
+ public static function loadPublicKey($key)
96
  {
97
  $key = self::load($key);
98
  if (!$key instanceof PublicKey) {
108
  * @access public
109
  * @param string|array $key
110
  */
111
+ public static function loadParameters($key)
112
  {
113
  $key = self::load($key);
114
  if (!$key instanceof PrivateKey && !$key instanceof PublicKey) {
vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php CHANGED
@@ -615,7 +615,7 @@ class RC2 extends BlockCipher
615
  $r3 += $keys[$r2 & 0x3F];';
616
  $limit = $actions[$limit];
617
  }
618
- }
619
 
620
  $encrypt_block .= '$in = pack("v4", $r0, $r1, $r2, $r3);';
621
 
615
  $r3 += $keys[$r2 & 0x3F];';
616
  $limit = $actions[$limit];
617
  }
618
+ }
619
 
620
  $encrypt_block .= '$in = pack("v4", $r0, $r1, $r2, $r3);';
621
 
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php CHANGED
@@ -56,12 +56,12 @@
56
  namespace phpseclib3\Crypt;
57
 
58
  use phpseclib3\Crypt\Common\AsymmetricKey;
 
59
  use phpseclib3\Crypt\RSA\PrivateKey;
60
  use phpseclib3\Crypt\RSA\PublicKey;
61
- use phpseclib3\Math\BigInteger;
62
- use phpseclib3\Exception\UnsupportedAlgorithmException;
63
  use phpseclib3\Exception\InconsistentSetupException;
64
- use phpseclib3\Crypt\RSA\Formats\Keys\PSS;
 
65
 
66
  /**
67
  * Pure-PHP PKCS#1 compliant implementation of RSA.
@@ -425,12 +425,11 @@ abstract class RSA extends AsymmetricKey
425
  // coefficient INTEGER, -- (inverse of q) mod p
426
  // otherPrimeInfos OtherPrimeInfos OPTIONAL
427
  // }
428
- $privatekey = new PrivateKey;
429
  $privatekey->modulus = $n;
430
  $privatekey->k = $bits >> 3;
431
  $privatekey->publicExponent = $e;
432
  $privatekey->exponent = $d;
433
- $privatekey->privateExponent = $e;
434
  $privatekey->primes = $primes;
435
  $privatekey->exponents = $exponents;
436
  $privatekey->coefficients = $coefficients;
@@ -457,8 +456,8 @@ abstract class RSA extends AsymmetricKey
457
  protected static function onLoad($components)
458
  {
459
  $key = $components['isPublicKey'] ?
460
- new PublicKey :
461
- new PrivateKey;
462
 
463
  $key->modulus = $components['modulus'];
464
  $key->publicExponent = $components['publicExponent'];
@@ -604,7 +603,7 @@ abstract class RSA extends AsymmetricKey
604
  case 'sha512/256':
605
  $t = "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x06\x05\x00\x04\x20";
606
  }
607
- $t.= $h;
608
  $tLen = strlen($t);
609
 
610
  if ($emLen < $tLen + 11) {
@@ -664,7 +663,7 @@ abstract class RSA extends AsymmetricKey
664
  default:
665
  throw new UnsupportedAlgorithmException('md2 and md5 require NULLs');
666
  }
667
- $t.= $h;
668
  $tLen = strlen($t);
669
 
670
  if ($emLen < $tLen + 11) {
@@ -696,7 +695,7 @@ abstract class RSA extends AsymmetricKey
696
  $count = ceil($maskLen / $this->mgfHLen);
697
  for ($i = 0; $i < $count; $i++) {
698
  $c = pack('N', $i);
699
- $t.= $this->mgfHash->hash($mgfSeed . $c);
700
  }
701
 
702
  return substr($t, 0, $maskLen);
@@ -794,7 +793,7 @@ abstract class RSA extends AsymmetricKey
794
  */
795
  public function getMGFHash()
796
  {
797
- return clone $this->mgfHash;
798
  }
799
 
800
  /**
@@ -824,7 +823,7 @@ abstract class RSA extends AsymmetricKey
824
  */
825
  public function getSaltLength()
826
  {
827
- return $this->sLen !== null ? $this->sLen : $this->hLen;
828
  }
829
 
830
  /**
@@ -856,7 +855,7 @@ abstract class RSA extends AsymmetricKey
856
  */
857
  public function getLabel()
858
  {
859
- return $this->label;
860
  }
861
 
862
  /**
@@ -918,7 +917,7 @@ abstract class RSA extends AsymmetricKey
918
  */
919
  public function getPadding()
920
  {
921
- return $this->signaturePadding | $this->encryptionPadding;
922
  }
923
 
924
  /**
@@ -936,6 +935,9 @@ abstract class RSA extends AsymmetricKey
936
  */
937
  public function getEngine()
938
  {
 
 
 
939
  return self::$engines['OpenSSL'] && self::$defaultExponent == 65537 ?
940
  'OpenSSL' :
941
  'PHP';
@@ -960,4 +962,4 @@ abstract class RSA extends AsymmetricKey
960
  {
961
  static::$enableBlinding = false;
962
  }
963
- }
56
  namespace phpseclib3\Crypt;
57
 
58
  use phpseclib3\Crypt\Common\AsymmetricKey;
59
+ use phpseclib3\Crypt\RSA\Formats\Keys\PSS;
60
  use phpseclib3\Crypt\RSA\PrivateKey;
61
  use phpseclib3\Crypt\RSA\PublicKey;
 
 
62
  use phpseclib3\Exception\InconsistentSetupException;
63
+ use phpseclib3\Exception\UnsupportedAlgorithmException;
64
+ use phpseclib3\Math\BigInteger;
65
 
66
  /**
67
  * Pure-PHP PKCS#1 compliant implementation of RSA.
425
  // coefficient INTEGER, -- (inverse of q) mod p
426
  // otherPrimeInfos OtherPrimeInfos OPTIONAL
427
  // }
428
+ $privatekey = new PrivateKey();
429
  $privatekey->modulus = $n;
430
  $privatekey->k = $bits >> 3;
431
  $privatekey->publicExponent = $e;
432
  $privatekey->exponent = $d;
 
433
  $privatekey->primes = $primes;
434
  $privatekey->exponents = $exponents;
435
  $privatekey->coefficients = $coefficients;
456
  protected static function onLoad($components)
457
  {
458
  $key = $components['isPublicKey'] ?
459
+ new PublicKey() :
460
+ new PrivateKey();
461
 
462
  $key->modulus = $components['modulus'];
463
  $key->publicExponent = $components['publicExponent'];
603
  case 'sha512/256':
604
  $t = "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x06\x05\x00\x04\x20";
605
  }
606
+ $t .= $h;
607
  $tLen = strlen($t);
608
 
609
  if ($emLen < $tLen + 11) {
663
  default:
664
  throw new UnsupportedAlgorithmException('md2 and md5 require NULLs');
665
  }
666
+ $t .= $h;
667
  $tLen = strlen($t);
668
 
669
  if ($emLen < $tLen + 11) {
695
  $count = ceil($maskLen / $this->mgfHLen);
696
  for ($i = 0; $i < $count; $i++) {
697
  $c = pack('N', $i);
698
+ $t .= $this->mgfHash->hash($mgfSeed . $c);
699
  }
700
 
701
  return substr($t, 0, $maskLen);
793
  */
794
  public function getMGFHash()
795
  {
796
+ return clone $this->mgfHash;
797
  }
798
 
799
  /**
823
  */
824
  public function getSaltLength()
825
  {
826
+ return $this->sLen !== null ? $this->sLen : $this->hLen;
827
  }
828
 
829
  /**
855
  */
856
  public function getLabel()
857
  {
858
+ return $this->label;
859
  }
860
 
861
  /**
917
  */
918
  public function getPadding()
919
  {
920
+ return $this->signaturePadding | $this->encryptionPadding;
921
  }
922
 
923
  /**
935
  */
936
  public function getEngine()
937
  {
938
+ if (!isset(self::$engines['PHP'])) {
939
+ self::useBestEngine();
940
+ }
941
  return self::$engines['OpenSSL'] && self::$defaultExponent == 65537 ?
942
  'OpenSSL' :
943
  'PHP';
962
  {
963
  static::$enableBlinding = false;
964
  }
965
+ }
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/MSBLOB.php CHANGED
@@ -20,9 +20,9 @@
20
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
21
 
22
  use ParagonIE\ConstantTime\Base64;
23
- use phpseclib3\Math\BigInteger;
24
  use phpseclib3\Common\Functions\Strings;
25
  use phpseclib3\Exception\UnsupportedFormatException;
 
26
 
27
  /**
28
  * Microsoft BLOB Formatted RSA Key Handler
@@ -143,6 +143,7 @@ abstract class MSBLOB
143
  switch ($magic) {
144
  case self::RSA2:
145
  $components['isPublicKey'] = false;
 
146
  case self::RSA1:
147
  break;
148
  default:
@@ -209,14 +210,14 @@ abstract class MSBLOB
209
  $n = strrev($n->toBytes());
210
  $e = str_pad(strrev($e->toBytes()), 4, "\0");
211
  $key = pack('aavV', chr(self::PRIVATEKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX);
212
- $key.= pack('VVa*', self::RSA2, 8 * strlen($n), $e);
213
- $key.= $n;
214
- $key.= strrev($primes[1]->toBytes());
215
- $key.= strrev($primes[2]->toBytes());
216
- $key.= strrev($exponents[1]->toBytes());
217
- $key.= strrev($exponents[2]->toBytes());
218
- $key.= strrev($coefficients[2]->toBytes());
219
- $key.= strrev($d->toBytes());
220
 
221
  return Base64::encode($key);
222
  }
@@ -234,8 +235,8 @@ abstract class MSBLOB
234
  $n = strrev($n->toBytes());
235
  $e = str_pad(strrev($e->toBytes()), 4, "\0");
236
  $key = pack('aavV', chr(self::PUBLICKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX);
237
- $key.= pack('VVa*', self::RSA1, 8 * strlen($n), $e);
238
- $key.= $n;
239
 
240
  return Base64::encode($key);
241
  }
20
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
21
 
22
  use ParagonIE\ConstantTime\Base64;
 
23
  use phpseclib3\Common\Functions\Strings;
24
  use phpseclib3\Exception\UnsupportedFormatException;
25
+ use phpseclib3\Math\BigInteger;
26
 
27
  /**
28
  * Microsoft BLOB Formatted RSA Key Handler
143
  switch ($magic) {
144
  case self::RSA2:
145
  $components['isPublicKey'] = false;
146
+ // fall-through
147
  case self::RSA1:
148
  break;
149
  default:
210
  $n = strrev($n->toBytes());
211
  $e = str_pad(strrev($e->toBytes()), 4, "\0");
212
  $key = pack('aavV', chr(self::PRIVATEKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX);
213
+ $key .= pack('VVa*', self::RSA2, 8 * strlen($n), $e);
214
+ $key .= $n;
215
+ $key .= strrev($primes[1]->toBytes());
216
+ $key .= strrev($primes[2]->toBytes());
217
+ $key .= strrev($exponents[1]->toBytes());
218
+ $key .= strrev($exponents[2]->toBytes());
219
+ $key .= strrev($coefficients[2]->toBytes());
220
+ $key .= strrev($d->toBytes());
221
 
222
  return Base64::encode($key);
223
  }
235
  $n = strrev($n->toBytes());
236
  $e = str_pad(strrev($e->toBytes()), 4, "\0");
237
  $key = pack('aavV', chr(self::PUBLICKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX);
238
+ $key .= pack('VVa*', self::RSA1, 8 * strlen($n), $e);
239
+ $key .= $n;
240
 
241
  return Base64::encode($key);
242
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/OpenSSH.php CHANGED
@@ -17,10 +17,9 @@
17
 
18
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
19
 
20
- use ParagonIE\ConstantTime\Base64;
21
- use phpseclib3\Math\BigInteger;
22
  use phpseclib3\Common\Functions\Strings;
23
  use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor;
 
24
 
25
  /**
26
  * OpenSSH Formatted RSA Key Handler
17
 
18
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
19
 
 
 
20
  use phpseclib3\Common\Functions\Strings;
21
  use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH as Progenitor;
22
+ use phpseclib3\Math\BigInteger;
23
 
24
  /**
25
  * OpenSSH Formatted RSA Key Handler
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS1.php CHANGED
@@ -24,11 +24,11 @@
24
 
25
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
26
 
27
- use phpseclib3\Math\BigInteger;
28
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
29
  use phpseclib3\File\ASN1;
30
  use phpseclib3\File\ASN1\Maps;
31
- use phpseclib3\Common\Functions\Strings;
32
 
33
  /**
34
  * PKCS#1 Formatted RSA Key Handler
@@ -70,7 +70,7 @@ abstract class PKCS1 extends Progenitor
70
 
71
  $key = ASN1::asn1map($decoded[0], Maps\RSAPrivateKey::MAP);
72
  if (is_array($key)) {
73
- $components+= [
74
  'modulus' => $key['modulus'],
75
  'publicExponent' => $key['publicExponent'],
76
  'privateExponent' => $key['privateExponent'],
24
 
25
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
26
 
27
+ use phpseclib3\Common\Functions\Strings;
28
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS1 as Progenitor;
29
  use phpseclib3\File\ASN1;
30
  use phpseclib3\File\ASN1\Maps;
31
+ use phpseclib3\Math\BigInteger;
32
 
33
  /**
34
  * PKCS#1 Formatted RSA Key Handler
70
 
71
  $key = ASN1::asn1map($decoded[0], Maps\RSAPrivateKey::MAP);
72
  if (is_array($key)) {
73
+ $components += [
74
  'modulus' => $key['modulus'],
75
  'publicExponent' => $key['publicExponent'],
76
  'privateExponent' => $key['privateExponent'],
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PKCS8.php CHANGED
@@ -27,10 +27,10 @@
27
 
28
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
29
 
30
- use phpseclib3\Math\BigInteger;
31
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
32
  use phpseclib3\File\ASN1;
33
- use phpseclib3\Common\Functions\Strings;
34
 
35
  /**
36
  * PKCS#8 Formatted RSA Key Handler
@@ -128,7 +128,7 @@ abstract class PKCS8 extends Progenitor
128
  {
129
  $key = PKCS1::savePrivateKey($n, $e, $d, $primes, $exponents, $coefficients);
130
  $key = ASN1::extractBER($key);
131
- return self::wrapPrivateKey($key, [], null, $password, $options);
132
  }
133
 
134
  /**
27
 
28
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
29
 
30
+ use phpseclib3\Common\Functions\Strings;
31
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
32
  use phpseclib3\File\ASN1;
33
+ use phpseclib3\Math\BigInteger;
34
 
35
  /**
36
  * PKCS#8 Formatted RSA Key Handler
128
  {
129
  $key = PKCS1::savePrivateKey($n, $e, $d, $primes, $exponents, $coefficients);
130
  $key = ASN1::extractBER($key);
131
+ return self::wrapPrivateKey($key, [], null, $password, null, '', $options);
132
  }
133
 
134
  /**
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PSS.php CHANGED
@@ -25,11 +25,11 @@
25
 
26
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
27
 
28
- use phpseclib3\Math\BigInteger;
29
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
30
  use phpseclib3\File\ASN1;
31
  use phpseclib3\File\ASN1\Maps;
32
- use phpseclib3\Common\Functions\Strings;
33
 
34
  /**
35
  * PKCS#8 Formatted RSA-PSS Key Handler
@@ -181,7 +181,7 @@ abstract class PSS extends Progenitor
181
  $key = PKCS1::savePrivateKey($n, $e, $d, $primes, $exponents, $coefficients);
182
  $key = ASN1::extractBER($key);
183
  $params = self::savePSSParams($options);
184
- return self::wrapPrivateKey($key, [], $params, $password, $options);
185
  }
186
 
187
  /**
25
 
26
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
27
 
28
+ use phpseclib3\Common\Functions\Strings;
29
  use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
30
  use phpseclib3\File\ASN1;
31
  use phpseclib3\File\ASN1\Maps;
32
+ use phpseclib3\Math\BigInteger;
33
 
34
  /**
35
  * PKCS#8 Formatted RSA-PSS Key Handler
181
  $key = PKCS1::savePrivateKey($n, $e, $d, $primes, $exponents, $coefficients);
182
  $key = ASN1::extractBER($key);
183
  $params = self::savePSSParams($options);
184
+ return self::wrapPrivateKey($key, [], $params, $password, null, '', $options);
185
  }
186
 
187
  /**
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/PuTTY.php CHANGED
@@ -15,9 +15,9 @@
15
 
16
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
17
 
18
- use phpseclib3\Math\BigInteger;
19
  use phpseclib3\Common\Functions\Strings;
20
  use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor;
 
21
 
22
  /**
23
  * PuTTY Formatted RSA Key Handler
15
 
16
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
17
 
 
18
  use phpseclib3\Common\Functions\Strings;
19
  use phpseclib3\Crypt\Common\Formats\Keys\PuTTY as Progenitor;
20
+ use phpseclib3\Math\BigInteger;
21
 
22
  /**
23
  * PuTTY Formatted RSA Key Handler
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/Raw.php CHANGED
@@ -49,48 +49,131 @@ abstract class Raw
49
  if (!is_array($key)) {
50
  throw new \UnexpectedValueException('Key should be a array - not a ' . gettype($key));
51
  }
52
- if (isset($key['isPublicKey']) && isset($key['modulus'])) {
53
- if (isset($key['privateExponent']) || isset($key['publicExponent'])) {
54
- if (!isset($key['primes'])) {
55
- return $key;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
- if (isset($key['exponents']) && isset($key['coefficients']) && isset($key['publicExponent']) && isset($key['privateExponent'])) {
58
- return $key;
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
  }
61
  }
62
- $components = ['isPublicKey' => true];
63
- switch (true) {
64
- case isset($key['e']):
65
- $components['publicExponent'] = $key['e'];
66
- break;
67
- case isset($key['exponent']):
68
- $components['publicExponent'] = $key['exponent'];
69
- break;
70
- case isset($key['publicExponent']):
71
- $components['publicExponent'] = $key['publicExponent'];
72
- break;
73
- case isset($key[0]):
74
- $components['publicExponent'] = $key[0];
75
  }
76
- switch (true) {
77
- case isset($key['n']):
78
- $components['modulus'] = $key['n'];
79
- break;
80
- case isset($key['modulo']):
81
- $components['modulus'] = $key['modulo'];
82
- break;
83
- case isset($key['modulus']):
84
- $components['modulus'] = $key['modulus'];
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  break;
86
- case isset($key[1]):
87
- $components['modulus'] = $key[1];
88
  }
89
- if (isset($components['modulus']) && isset($components['publicExponent'])) {
90
- return $components;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  }
92
 
93
- throw new \UnexpectedValueException('Modulus / exponent not present');
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
 
96
  /**
49
  if (!is_array($key)) {
50
  throw new \UnexpectedValueException('Key should be a array - not a ' . gettype($key));
51
  }
52
+
53
+ $key = array_change_key_case($key, CASE_LOWER);
54
+
55
+ $components = ['isPublicKey' => false];
56
+
57
+ foreach (['e', 'exponent', 'publicexponent', 0, 'privateexponent', 'd'] as $index) {
58
+ if (isset($key[$index])) {
59
+ $components['publicExponent'] = $key[$index];
60
+ break;
61
+ }
62
+ }
63
+
64
+ foreach (['n', 'modulo', 'modulus', 1] as $index) {
65
+ if (isset($key[$index])) {
66
+ $components['modulus'] = $key[$index];
67
+ break;
68
+ }
69
+ }
70
+
71
+ if (!isset($components['publicExponent']) || !isset($components['modulus'])) {
72
+ throw new \UnexpectedValueException('Modulus / exponent not present');
73
+ }
74
+
75
+ if (isset($key['primes'])) {
76
+ $components['primes'] = $key['primes'];
77
+ } elseif (isset($key['p']) && isset($key['q'])) {
78
+ $indices = [
79
+ ['p', 'q'],
80
+ ['prime1', 'prime2']
81
+ ];
82
+ foreach ($indices as $index) {
83
+ list($i0, $i1) = $index;
84
+ if (isset($key[$i0]) && isset($key[$i1])) {
85
+ $components['primes'] = [1 => $key[$i0], $key[$i1]];
86
  }
87
+ }
88
+ }
89
+
90
+ if (isset($key['exponents'])) {
91
+ $components['exponents'] = $key['exponents'];
92
+ } else {
93
+ $indices = [
94
+ ['dp', 'dq'],
95
+ ['exponent1', 'exponent2']
96
+ ];
97
+ foreach ($indices as $index) {
98
+ list($i0, $i1) = $index;
99
+ if (isset($key[$i0]) && isset($key[$i1])) {
100
+ $components['exponents'] = [1 => $key[$i0], $key[$i1]];
101
  }
102
  }
103
  }
104
+
105
+ if (isset($key['coefficients'])) {
106
+ $components['coefficients'] = $key['coefficients'];
107
+ } else {
108
+ foreach (['inverseq', 'q\'', 'coefficient'] as $index) {
109
+ if (isset($key[$index])) {
110
+ $components['coefficients'] = [2 => $key[$index]];
111
+ }
112
+ }
 
 
 
 
113
  }
114
+
115
+ if (!isset($components['primes'])) {
116
+ $components['isPublicKey'] = true;
117
+ return $components;
118
+ }
119
+
120
+ if (!isset($components['exponents'])) {
121
+ $one = new BigInteger(1);
122
+ $temp = $components['primes'][1]->subtract($one);
123
+ $exponents = [1 => $components['publicExponent']->modInverse($temp)];
124
+ $temp = $components['primes'][2]->subtract($one);
125
+ $exponents[] = $components['publicExponent']->modInverse($temp);
126
+ $components['exponents'] = $exponents;
127
+ }
128
+
129
+ if (!isset($components['coefficients'])) {
130
+ $components['coefficients'] = [2 => $components['primes'][2]->modInverse($components['primes'][1])];
131
+ }
132
+
133
+ foreach (['privateexponent', 'd'] as $index) {
134
+ if (isset($key[$index])) {
135
+ $components['privateExponent'] = $key[$index];
136
  break;
137
+ }
 
138
  }
139
+
140
+ return $components;
141
+ }
142
+
143
+ /**
144
+ * Convert a private key to the appropriate format.
145
+ *
146
+ * @access public
147
+ * @param \phpseclib3\Math\BigInteger $n
148
+ * @param \phpseclib3\Math\BigInteger $e
149
+ * @param \phpseclib3\Math\BigInteger $d
150
+ * @param array $primes
151
+ * @param array $exponents
152
+ * @param array $coefficients
153
+ * @param string $password optional
154
+ * @param array $options optional
155
+ * @return array
156
+ */
157
+ public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = [])
158
+ {
159
+ if (!empty($password) && is_string($password)) {
160
+ throw new UnsupportedFormatException('Raw private keys do not support encryption');
161
  }
162
 
163
+ return [
164
+ 'e' => clone $e,
165
+ 'n' => clone $n,
166
+ 'd' => clone $d,
167
+ 'primes' => array_map(function ($var) {
168
+ return clone $var;
169
+ }, $primes),
170
+ 'exponents' => array_map(function ($var) {
171
+ return clone $var;
172
+ }, $exponents),
173
+ 'coefficients' => array_map(function ($var) {
174
+ return clone $var;
175
+ }, $coefficients)
176
+ ];
177
  }
178
 
179
  /**
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/Formats/Keys/XML.php CHANGED
@@ -23,9 +23,10 @@
23
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
24
 
25
  use ParagonIE\ConstantTime\Base64;
26
- use phpseclib3\Math\BigInteger;
27
  use phpseclib3\Common\Functions\Strings;
 
28
  use phpseclib3\Exception\UnsupportedFormatException;
 
29
 
30
  /**
31
  * XML Formatted RSA Key Handler
@@ -50,6 +51,10 @@ abstract class XML
50
  throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
51
  }
52
 
 
 
 
 
53
  $components = [
54
  'isPublicKey' => false,
55
  'primes' => [],
@@ -64,6 +69,7 @@ abstract class XML
64
  $key = '<xml>' . $key . '</xml>';
65
  }
66
  if (!$dom->loadXML($key)) {
 
67
  throw new \UnexpectedValueException('Key does not appear to contain XML');
68
  }
69
  $xpath = new \DOMXPath($dom);
23
  namespace phpseclib3\Crypt\RSA\Formats\Keys;
24
 
25
  use ParagonIE\ConstantTime\Base64;
 
26
  use phpseclib3\Common\Functions\Strings;
27
+ use phpseclib3\Exception\BadConfigurationException;
28
  use phpseclib3\Exception\UnsupportedFormatException;
29
+ use phpseclib3\Math\BigInteger;
30
 
31
  /**
32
  * XML Formatted RSA Key Handler
51
  throw new \UnexpectedValueException('Key should be a string - not a ' . gettype($key));
52
  }
53
 
54
+ if (!class_exists('DOMDocument')) {
55
+ throw new BadConfigurationException('The dom extension is not setup correctly on this system');
56
+ }
57
+
58
  $components = [
59
  'isPublicKey' => false,
60
  'primes' => [],
69
  $key = '<xml>' . $key . '</xml>';
70
  }
71
  if (!$dom->loadXML($key)) {
72
+ libxml_use_internal_errors($use_errors);
73
  throw new \UnexpectedValueException('Key does not appear to contain XML');
74
  }
75
  $xpath = new \DOMXPath($dom);
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/PrivateKey.php CHANGED
@@ -13,16 +13,12 @@
13
 
14
  namespace phpseclib3\Crypt\RSA;
15
 
16
- use phpseclib3\Crypt\RSA;
17
- use phpseclib3\Math\BigInteger;
18
- use phpseclib3\File\ASN1;
19
- use phpseclib3\Common\Functions\Strings;
20
- use phpseclib3\Crypt\Hash;
21
- use phpseclib3\Exceptions\NoKeyLoadedException;
22
- use phpseclib3\Exception\UnsupportedFormatException;
23
- use phpseclib3\Crypt\Random;
24
  use phpseclib3\Crypt\Common;
 
 
25
  use phpseclib3\Crypt\RSA\Formats\Keys\PSS;
 
 
26
 
27
  /**
28
  * Raw RSA Key Handler
@@ -232,7 +228,7 @@ class PrivateKey extends RSA implements Common\PrivateKey
232
  $h = $this->hash->hash($m2);
233
  $ps = str_repeat(chr(0), $emLen - $sLen - $this->hLen - 2);
234
  $db = $ps . chr(1) . $salt;
235
- $dbMask = $this->mgf1($h, $emLen - $this->hLen - 1);
236
  $maskedDB = $db ^ $dbMask;
237
  $maskedDB[0] = ~chr(0xFF << ($emBits & 7)) & $maskedDB[0];
238
  $em = $maskedDB . $h . chr(0xBC);
@@ -412,9 +408,9 @@ class PrivateKey extends RSA implements Common\PrivateKey
412
  $patternMatch = 0;
413
  $offset = 0;
414
  for ($i = 0; $i < strlen($m); $i++) {
415
- $patternMatch|= $leadingZeros & ($m[$i] === "\1");
416
- $leadingZeros&= $m[$i] === "\0";
417
- $offset+= $patternMatch ? 0 : 1;
418
  }
419
 
420
  // we do | instead of || to avoid https://en.wikipedia.org/wiki/Short-circuit_evaluation
@@ -509,7 +505,7 @@ class PrivateKey extends RSA implements Common\PrivateKey
509
 
510
  if ($type == PSS::class) {
511
  if ($this->signaturePadding == self::SIGNATURE_PSS) {
512
- $options+= [
513
  'hash' => $this->hash->getHash(),
514
  'MGFHash' => $this->mgfHash->getHash(),
515
  'saltLength' => $this->getSaltLength()
13
 
14
  namespace phpseclib3\Crypt\RSA;
15
 
 
 
 
 
 
 
 
 
16
  use phpseclib3\Crypt\Common;
17
+ use phpseclib3\Crypt\Random;
18
+ use phpseclib3\Crypt\RSA;
19
  use phpseclib3\Crypt\RSA\Formats\Keys\PSS;
20
+ use phpseclib3\Exception\UnsupportedFormatException;
21
+ use phpseclib3\Math\BigInteger;
22
 
23
  /**
24
  * Raw RSA Key Handler
228
  $h = $this->hash->hash($m2);
229
  $ps = str_repeat(chr(0), $emLen - $sLen - $this->hLen - 2);
230
  $db = $ps . chr(1) . $salt;
231
+ $dbMask = $this->mgf1($h, $emLen - $this->hLen - 1); // ie. stlren($db)
232
  $maskedDB = $db ^ $dbMask;
233
  $maskedDB[0] = ~chr(0xFF << ($emBits & 7)) & $maskedDB[0];
234
  $em = $maskedDB . $h . chr(0xBC);
408
  $patternMatch = 0;
409
  $offset = 0;
410
  for ($i = 0; $i < strlen($m); $i++) {
411
+ $patternMatch |= $leadingZeros & ($m[$i] === "\1");
412
+ $leadingZeros &= $m[$i] === "\0";
413
+ $offset += $patternMatch ? 0 : 1;
414
  }
415
 
416
  // we do | instead of || to avoid https://en.wikipedia.org/wiki/Short-circuit_evaluation
505
 
506
  if ($type == PSS::class) {
507
  if ($this->signaturePadding == self::SIGNATURE_PSS) {
508
+ $options += [
509
  'hash' => $this->hash->getHash(),
510
  'MGFHash' => $this->mgfHash->getHash(),
511
  'saltLength' => $this->getSaltLength()
vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA/PublicKey.php CHANGED
@@ -13,18 +13,17 @@
13
 
14
  namespace phpseclib3\Crypt\RSA;
15
 
16
- use phpseclib3\Crypt\RSA;
17
- use phpseclib3\Math\BigInteger;
18
- use phpseclib3\File\ASN1;
19
  use phpseclib3\Common\Functions\Strings;
 
20
  use phpseclib3\Crypt\Hash;
21
- use phpseclib3\Exception\NoKeyLoadedException;
22
- use phpseclib3\Exception\UnsupportedFormatException;
23
- use phpseclib3\Exception\UnsupportedAlgorithmException;
24
  use phpseclib3\Crypt\Random;
25
- use phpseclib3\Crypt\Common;
26
- use phpseclib3\File\ASN1\Maps\DigestInfo;
27
  use phpseclib3\Crypt\RSA\Formats\Keys\PSS;
 
 
 
 
 
28
 
29
  /**
30
  * Raw RSA Key Handler
@@ -350,7 +349,7 @@ class PublicKey extends RSA implements Common\PublicKey
350
  while (strlen($ps) != $psLen) {
351
  $temp = Random::string($psLen - strlen($ps));
352
  $temp = str_replace("\x00", '', $temp);
353
- $ps.= $temp;
354
  }
355
  $type = 2;
356
  $em = chr(0) . chr($type) . $ps . chr(0) . $m;
@@ -493,7 +492,7 @@ class PublicKey extends RSA implements Common\PublicKey
493
 
494
  if ($type == PSS::class) {
495
  if ($this->signaturePadding == self::SIGNATURE_PSS) {
496
- $options+= [
497
  'hash' => $this->hash->getHash(),
498
  'MGFHash' => $this->mgfHash->getHash(),
499
  'saltLength' => $this->getSaltLength()
@@ -513,7 +512,7 @@ class PublicKey extends RSA implements Common\PublicKey
513
  */
514
  public function asPrivateKey()
515
  {
516
- $new = new PrivateKey;
517
  $new->exponent = $this->exponent;
518
  $new->modulus = $this->modulus;
519
  $new->k = $this->k;
13
 
14
  namespace phpseclib3\Crypt\RSA;
15
 
 
 
 
16
  use phpseclib3\Common\Functions\Strings;
17
+ use phpseclib3\Crypt\Common;
18
  use phpseclib3\Crypt\Hash;
 
 
 
19
  use phpseclib3\Crypt\Random;
20
+ use phpseclib3\Crypt\RSA;
 
21
  use phpseclib3\Crypt\RSA\Formats\Keys\PSS;
22
+ use phpseclib3\Exception\UnsupportedAlgorithmException;
23
+ use phpseclib3\Exception\UnsupportedFormatException;
24
+ use phpseclib3\File\ASN1;
25
+ use phpseclib3\File\ASN1\Maps\DigestInfo;
26
+ use phpseclib3\Math\BigInteger;
27
 
28
  /**
29
  * Raw RSA Key Handler
349
  while (strlen($ps) != $psLen) {
350
  $temp = Random::string($psLen - strlen($ps));
351
  $temp = str_replace("\x00", '', $temp);
352
+ $ps .= $temp;
353
  }
354
  $type = 2;
355
  $em = chr(0) . chr($type) . $ps . chr(0) . $m;
492
 
493
  if ($type == PSS::class) {
494
  if ($this->signaturePadding == self::SIGNATURE_PSS) {
495
+ $options += [
496
  'hash' => $this->hash->getHash(),
497
  'MGFHash' => $this->mgfHash->getHash(),
498
  'saltLength' => $this->getSaltLength()
512
  */
513
  public function asPrivateKey()
514
  {
515
+ $new = new PrivateKey();
516
  $new->exponent = $this->exponent;
517
  $new->modulus = $this->modulus;
518
  $new->k = $this->k;
vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php CHANGED
@@ -51,7 +51,7 @@ abstract class Random
51
  }
52
 
53
  try {
54
- return \random_bytes($length);
55
  } catch (\Exception $e) {
56
  // random_compat will throw an Exception, which in PHP 5 does not implement Throwable
57
  } catch (\Throwable $e) {
@@ -184,7 +184,7 @@ abstract class Random
184
  $i = $crypto->encrypt(microtime()); // strlen(microtime()) == 21
185
  $r = $crypto->encrypt($i ^ $v); // strlen($v) == 20
186
  $v = $crypto->encrypt($r ^ $i); // strlen($r) == 20
187
- $result.= $r;
188
  }
189
 
190
  return substr($result, 0, $length);
51
  }
52
 
53
  try {
54
+ return random_bytes($length);
55
  } catch (\Exception $e) {
56
  // random_compat will throw an Exception, which in PHP 5 does not implement Throwable
57
  } catch (\Throwable $e) {
184
  $i = $crypto->encrypt(microtime()); // strlen(microtime()) == 21
185
  $r = $crypto->encrypt($i ^ $v); // strlen($v) == 20
186
  $v = $crypto->encrypt($r ^ $i); // strlen($r) == 20
187
+ $result .= $r;
188
  }
189
 
190
  return substr($result, 0, $length);
vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php CHANGED
@@ -54,13 +54,12 @@
54
 
55
  namespace phpseclib3\Crypt;
56
 
57
- use phpseclib3\Crypt\Common\BlockCipher;
58
-
59
  use phpseclib3\Common\Functions\Strings;
 
 
60
  use phpseclib3\Exception\BadModeException;
61
- use phpseclib3\Exception\InsufficientSetupException;
62
  use phpseclib3\Exception\InconsistentSetupException;
63
- use phpseclib3\Exception\BadDecryptionException;
64
 
65
  /**
66
  * Pure-PHP implementation of Rijndael.
@@ -854,7 +853,7 @@ class Rijndael extends BlockCipher
854
  $c = $this->c;
855
 
856
  // Generating encrypt code:
857
- $init_encrypt.= '
858
  static $tables;
859
  if (empty($tables)) {
860
  $tables = &$this->getTables();
@@ -871,47 +870,47 @@ class Rijndael extends BlockCipher
871
  $wc = $Nb - 1;
872
 
873
  // Preround: addRoundKey
874
- $encrypt_block = '$in = unpack("N*", $in);'."\n";
875
  for ($i = 0; $i < $Nb; ++$i) {
876
- $encrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$w[++$wc].";\n";
877
  }
878
 
879
  // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey
880
  for ($round = 1; $round < $Nr; ++$round) {
881
  list($s, $e) = [$e, $s];
882
  for ($i = 0; $i < $Nb; ++$i) {
883
- $encrypt_block.=
884
- '$'.$e.$i.' =
885
- $t0[($'.$s.$i .' >> 24) & 0xff] ^
886
- $t1[($'.$s.(($i + $c[1]) % $Nb).' >> 16) & 0xff] ^
887
- $t2[($'.$s.(($i + $c[2]) % $Nb).' >> 8) & 0xff] ^
888
- $t3[ $'.$s.(($i + $c[3]) % $Nb).' & 0xff] ^
889
- '.$w[++$wc].";\n";
890
  }
891
  }
892
 
893
  // Finalround: subWord + shiftRows + addRoundKey
894
  for ($i = 0; $i < $Nb; ++$i) {
895
- $encrypt_block.=
896
- '$'.$e.$i.' =
897
- $sbox[ $'.$e.$i.' & 0xff] |
898
- ($sbox[($'.$e.$i.' >> 8) & 0xff] << 8) |
899
- ($sbox[($'.$e.$i.' >> 16) & 0xff] << 16) |
900
- ($sbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n";
901
  }
902
- $encrypt_block .= '$in = pack("N*"'."\n";
903
  for ($i = 0; $i < $Nb; ++$i) {
904
- $encrypt_block.= ',
905
- ($'.$e.$i .' & '.((int)0xFF000000).') ^
906
- ($'.$e.(($i + $c[1]) % $Nb).' & 0x00FF0000 ) ^
907
- ($'.$e.(($i + $c[2]) % $Nb).' & 0x0000FF00 ) ^
908
- ($'.$e.(($i + $c[3]) % $Nb).' & 0x000000FF ) ^
909
- '.$w[$i]."\n";
910
  }
911
  $encrypt_block .= ');';
912
 
913
  // Generating decrypt code:
914
- $init_decrypt.= '
915
  static $invtables;
916
  if (empty($invtables)) {
917
  $invtables = &$this->getInvTables();
@@ -928,42 +927,42 @@ class Rijndael extends BlockCipher
928
  $wc = $Nb - 1;
929
 
930
  // Preround: addRoundKey
931
- $decrypt_block = '$in = unpack("N*", $in);'."\n";
932
  for ($i = 0; $i < $Nb; ++$i) {
933
- $decrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$dw[++$wc].';'."\n";
934
  }
935
 
936
  // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey
937
  for ($round = 1; $round < $Nr; ++$round) {
938
  list($s, $e) = [$e, $s];
939
  for ($i = 0; $i < $Nb; ++$i) {
940
- $decrypt_block.=
941
- '$'.$e.$i.' =
942
- $dt0[($'.$s.$i .' >> 24) & 0xff] ^
943
- $dt1[($'.$s.(($Nb + $i - $c[1]) % $Nb).' >> 16) & 0xff] ^
944
- $dt2[($'.$s.(($Nb + $i - $c[2]) % $Nb).' >> 8) & 0xff] ^
945
- $dt3[ $'.$s.(($Nb + $i - $c[3]) % $Nb).' & 0xff] ^
946
- '.$dw[++$wc].";\n";
947
  }
948
  }
949
 
950
  // Finalround: subWord + shiftRows + addRoundKey
951
  for ($i = 0; $i < $Nb; ++$i) {
952
- $decrypt_block.=
953
- '$'.$e.$i.' =
954
- $isbox[ $'.$e.$i.' & 0xff] |
955
- ($isbox[($'.$e.$i.' >> 8) & 0xff] << 8) |
956
- ($isbox[($'.$e.$i.' >> 16) & 0xff] << 16) |
957
- ($isbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n";
958
  }
959
- $decrypt_block .= '$in = pack("N*"'."\n";
960
  for ($i = 0; $i < $Nb; ++$i) {
961
- $decrypt_block.= ',
962
- ($'.$e.$i. ' & '.((int)0xFF000000).') ^
963
- ($'.$e.(($Nb + $i - $c[1]) % $Nb).' & 0x00FF0000 ) ^
964
- ($'.$e.(($Nb + $i - $c[2]) % $Nb).' & 0x0000FF00 ) ^
965
- ($'.$e.(($Nb + $i - $c[3]) % $Nb).' & 0x000000FF ) ^
966
- '.$dw[$i]."\n";
967
  }
968
  $decrypt_block .= ');';
969
 
54
 
55
  namespace phpseclib3\Crypt;
56
 
 
 
57
  use phpseclib3\Common\Functions\Strings;
58
+ use phpseclib3\Crypt\Common\BlockCipher;
59
+ use phpseclib3\Exception\BadDecryptionException;
60
  use phpseclib3\Exception\BadModeException;
 
61
  use phpseclib3\Exception\InconsistentSetupException;
62
+ use phpseclib3\Exception\InsufficientSetupException;
63
 
64
  /**
65
  * Pure-PHP implementation of Rijndael.
853
  $c = $this->c;
854
 
855
  // Generating encrypt code:
856
+ $init_encrypt .= '
857
  static $tables;
858
  if (empty($tables)) {
859
  $tables = &$this->getTables();
870
  $wc = $Nb - 1;
871
 
872
  // Preround: addRoundKey
873
+ $encrypt_block = '$in = unpack("N*", $in);' . "\n";
874
  for ($i = 0; $i < $Nb; ++$i) {
875
+ $encrypt_block .= '$s' . $i . ' = $in[' . ($i + 1) . '] ^ ' . $w[++$wc] . ";\n";
876
  }
877
 
878
  // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey
879
  for ($round = 1; $round < $Nr; ++$round) {
880
  list($s, $e) = [$e, $s];
881
  for ($i = 0; $i < $Nb; ++$i) {
882
+ $encrypt_block .=
883
+ '$' . $e . $i . ' =
884
+ $t0[($' . $s . $i . ' >> 24) & 0xff] ^
885
+ $t1[($' . $s . (($i + $c[1]) % $Nb) . ' >> 16) & 0xff] ^
886
+ $t2[($' . $s . (($i + $c[2]) % $Nb) . ' >> 8) & 0xff] ^
887
+ $t3[ $' . $s . (($i + $c[3]) % $Nb) . ' & 0xff] ^
888
+ ' . $w[++$wc] . ";\n";
889
  }
890
  }
891
 
892
  // Finalround: subWord + shiftRows + addRoundKey
893
  for ($i = 0; $i < $Nb; ++$i) {
894
+ $encrypt_block .=
895
+ '$' . $e . $i . ' =
896
+ $sbox[ $' . $e . $i . ' & 0xff] |
897
+ ($sbox[($' . $e . $i . ' >> 8) & 0xff] << 8) |
898
+ ($sbox[($' . $e . $i . ' >> 16) & 0xff] << 16) |
899
+ ($sbox[($' . $e . $i . ' >> 24) & 0xff] << 24);' . "\n";
900
  }
901
+ $encrypt_block .= '$in = pack("N*"' . "\n";
902
  for ($i = 0; $i < $Nb; ++$i) {
903
+ $encrypt_block .= ',
904
+ ($' . $e . $i . ' & ' . ((int)0xFF000000) . ') ^
905
+ ($' . $e . (($i + $c[1]) % $Nb) . ' & 0x00FF0000 ) ^
906
+ ($' . $e . (($i + $c[2]) % $Nb) . ' & 0x0000FF00 ) ^
907
+ ($' . $e . (($i + $c[3]) % $Nb) . ' & 0x000000FF ) ^
908
+ ' . $w[$i] . "\n";
909
  }
910
  $encrypt_block .= ');';
911
 
912
  // Generating decrypt code:
913
+ $init_decrypt .= '
914
  static $invtables;
915
  if (empty($invtables)) {
916
  $invtables = &$this->getInvTables();
927
  $wc = $Nb - 1;
928
 
929
  // Preround: addRoundKey
930
+ $decrypt_block = '$in = unpack("N*", $in);' . "\n";
931
  for ($i = 0; $i < $Nb; ++$i) {
932
+ $decrypt_block .= '$s' . $i . ' = $in[' . ($i + 1) . '] ^ ' . $dw[++$wc] . ';' . "\n";
933
  }
934
 
935
  // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey
936
  for ($round = 1; $round < $Nr; ++$round) {
937
  list($s, $e) = [$e, $s];
938
  for ($i = 0; $i < $Nb; ++$i) {
939
+ $decrypt_block .=
940
+ '$' . $e . $i . ' =
941
+ $dt0[($' . $s . $i . ' >> 24) & 0xff] ^
942
+ $dt1[($' . $s . (($Nb + $i - $c[1]) % $Nb) . ' >> 16) & 0xff] ^
943
+ $dt2[($' . $s . (($Nb + $i - $c[2]) % $Nb) . ' >> 8) & 0xff] ^
944
+ $dt3[ $' . $s . (($Nb + $i - $c[3]) % $Nb) . ' & 0xff] ^
945
+ ' . $dw[++$wc] . ";\n";
946
  }
947
  }
948
 
949
  // Finalround: subWord + shiftRows + addRoundKey
950
  for ($i = 0; $i < $Nb; ++$i) {
951
+ $decrypt_block .=
952
+ '$' . $e . $i . ' =
953
+ $isbox[ $' . $e . $i . ' & 0xff] |
954
+ ($isbox[($' . $e . $i . ' >> 8) & 0xff] << 8) |
955
+ ($isbox[($' . $e . $i . ' >> 16) & 0xff] << 16) |
956
+ ($isbox[($' . $e . $i . ' >> 24) & 0xff] << 24);' . "\n";
957
  }
958
+ $decrypt_block .= '$in = pack("N*"' . "\n";
959
  for ($i = 0; $i < $Nb; ++$i) {
960
+ $decrypt_block .= ',
961
+ ($' . $e . $i . ' & ' . ((int)0xFF000000) . ') ^
962
+ ($' . $e . (($Nb + $i - $c[1]) % $Nb) . ' & 0x00FF0000 ) ^
963
+ ($' . $e . (($Nb + $i - $c[2]) % $Nb) . ' & 0x0000FF00 ) ^
964
+ ($' . $e . (($Nb + $i - $c[3]) % $Nb) . ' & 0x000000FF ) ^
965
+ ' . $dw[$i] . "\n";
966
  }
967
  $decrypt_block .= ');';
968
 
vendor/phpseclib/phpseclib/phpseclib/Crypt/Salsa20.php CHANGED
@@ -15,10 +15,10 @@
15
 
16
  namespace phpseclib3\Crypt;
17
 
 
18
  use phpseclib3\Crypt\Common\StreamCipher;
19
- use phpseclib3\Exception\InsufficientSetupException;
20
  use phpseclib3\Exception\BadDecryptionException;
21
- use phpseclib3\Common\Functions\Strings;
22
 
23
  /**
24
  * Pure-PHP implementation of Salsa20.
@@ -216,7 +216,7 @@ class Salsa20 extends StreamCipher
216
  $key = $this->key;
217
  if (strlen($key) == 16) {
218
  $constant = 'expand 16-byte k';
219
- $key.= $key;
220
  } else {
221
  $constant = 'expand 32-byte k';
222
  }
@@ -330,7 +330,7 @@ class Salsa20 extends StreamCipher
330
  $i = $this->counter;
331
  $blocks = str_split($text, 64);
332
  foreach ($blocks as &$block) {
333
- $block^= static::salsa20($this->p1 . pack('V', $i++) . $this->p2);
334
  }
335
 
336
  return implode('', $blocks);
@@ -341,7 +341,9 @@ class Salsa20 extends StreamCipher
341
  } else {
342
  $buffer = &$this->debuffer;
343
  }
344
- if (strlen($buffer['ciphertext'])) {
 
 
345
  $ciphertext = $text ^ Strings::shift($buffer['ciphertext'], strlen($text));
346
  $text = substr($text, strlen($ciphertext));
347
  if (!strlen($text)) {
@@ -355,7 +357,7 @@ class Salsa20 extends StreamCipher
355
  if ($this->engine == self::ENGINE_OPENSSL) {
356
  $iv = pack('V', $buffer['counter']) . $this->p2;
357
  // at this point $text should be a multiple of 64
358
- $buffer['counter']+= (strlen($text) >> 6) + 1; // ie. divide by 64
359
  $encrypted = openssl_encrypt(
360
  $text . str_repeat("\0", 64),
361
  $this->cipher_name_openssl,
@@ -368,19 +370,19 @@ class Salsa20 extends StreamCipher
368
  $blocks = str_split($text, 64);
369
  if (strlen($text)) {
370
  foreach ($blocks as &$block) {
371
- $block^= static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2);
372
  }
373
  }
374
  $encrypted = implode('', $blocks);
375
  $temp = static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2);
376
  }
377
- $ciphertext.= $encrypted . ($text2 ^ $temp);
378
  $buffer['ciphertext'] = substr($temp, $overflow);
379
  } elseif (!strlen($buffer['ciphertext'])) {
380
  if ($this->engine == self::ENGINE_OPENSSL) {
381
  $iv = pack('V', $buffer['counter']) . $this->p2;
382
- $buffer['counter']+= (strlen($text) >> 6);
383
- $ciphertext.= openssl_encrypt(
384
  $text,
385
  $this->cipher_name_openssl,
386
  $this->key,
@@ -390,9 +392,9 @@ class Salsa20 extends StreamCipher
390
  } else {
391
  $blocks = str_split($text, 64);
392
  foreach ($blocks as &$block) {
393
- $block^= static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2);
394
  }
395
- $ciphertext.= implode('', $blocks);
396
  }
397
  }
398
 
@@ -410,11 +412,11 @@ class Salsa20 extends StreamCipher
410
  {
411
  $r1 = $x << $n;
412
  if (PHP_INT_SIZE == 8) {
413
- $r1&= 0xFFFFFFFF;
414
  $r2 = ($x & 0xFFFFFFFF) >> (32 - $n);
415
  } else {
416
  $r2 = $x >> (32 - $n);
417
- $r2&= (1 << $n) - 1;
418
  }
419
  return $r1 | $r2;
420
  }
@@ -429,10 +431,10 @@ class Salsa20 extends StreamCipher
429
  */
430
  protected static function quarterRound(&$a, &$b, &$c, &$d)
431
  {
432
- $b^= self::leftRotate($a + $d, 7);
433
- $c^= self::leftRotate($b + $a, 9);
434
- $d^= self::leftRotate($c + $b, 13);
435
- $a^= self::leftRotate($d + $c, 18);
436
  }
437
 
438
  /**
@@ -458,14 +460,14 @@ class Salsa20 extends StreamCipher
458
  protected static function doubleRound(&$x0, &$x1, &$x2, &$x3, &$x4, &$x5, &$x6, &$x7, &$x8, &$x9, &$x10, &$x11, &$x12, &$x13, &$x14, &$x15)
459
  {
460
  // columnRound
461
- static::quarterRound( $x0, $x4, $x8, $x12);
462
- static::quarterRound( $x5, $x9, $x13, $x1);
463
- static::quarterRound($x10, $x14, $x2, $x6);
464
- static::quarterRound($x15, $x3, $x7, $x11);
465
  // rowRound
466
- static::quarterRound( $x0, $x1, $x2, $x3);
467
- static::quarterRound( $x5, $x6, $x7, $x4);
468
- static::quarterRound($x10, $x11, $x8, $x9);
469
  static::quarterRound($x15, $x12, $x13, $x14);
470
  }
471
 
@@ -478,11 +480,11 @@ class Salsa20 extends StreamCipher
478
  {
479
  $z = $x = unpack('V*', $x);
480
  for ($i = 0; $i < 10; $i++) {
481
- static::doubleRound(...$z);
482
  }
483
 
484
  for ($i = 1; $i <= 16; $i++) {
485
- $x[$i]+= $z[$i];
486
  }
487
 
488
  return pack('V*', ...$x);
15
 
16
  namespace phpseclib3\Crypt;
17
 
18
+ use phpseclib3\Common\Functions\Strings;
19
  use phpseclib3\Crypt\Common\StreamCipher;
 
20
  use phpseclib3\Exception\BadDecryptionException;
21
+ use phpseclib3\Exception\InsufficientSetupException;
22
 
23
  /**
24
  * Pure-PHP implementation of Salsa20.
216
  $key = $this->key;
217
  if (strlen($key) == 16) {
218
  $constant = 'expand 16-byte k';
219
+ $key .= $key;
220
  } else {
221
  $constant = 'expand 32-byte k';
222
  }
330
  $i = $this->counter;
331
  $blocks = str_split($text, 64);
332
  foreach ($blocks as &$block) {
333
+ $block ^= static::salsa20($this->p1 . pack('V', $i++) . $this->p2);
334
  }
335
 
336
  return implode('', $blocks);
341
  } else {
342
  $buffer = &$this->debuffer;
343
  }
344
+ if (!strlen($buffer['ciphertext'])) {
345
+ $ciphertext = '';
346
+ } else {
347
  $ciphertext = $text ^ Strings::shift($buffer['ciphertext'], strlen($text));
348
  $text = substr($text, strlen($ciphertext));
349
  if (!strlen($text)) {
357
  if ($this->engine == self::ENGINE_OPENSSL) {
358
  $iv = pack('V', $buffer['counter']) . $this->p2;
359
  // at this point $text should be a multiple of 64
360
+ $buffer['counter'] += (strlen($text) >> 6) + 1; // ie. divide by 64
361
  $encrypted = openssl_encrypt(
362
  $text . str_repeat("\0", 64),
363
  $this->cipher_name_openssl,
370
  $blocks = str_split($text, 64);
371
  if (strlen($text)) {
372
  foreach ($blocks as &$block) {
373
+ $block ^= static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2);
374
  }
375
  }
376
  $encrypted = implode('', $blocks);
377
  $temp = static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2);
378
  }
379
+ $ciphertext .= $encrypted . ($text2 ^ $temp);
380
  $buffer['ciphertext'] = substr($temp, $overflow);
381
  } elseif (!strlen($buffer['ciphertext'])) {
382
  if ($this->engine == self::ENGINE_OPENSSL) {
383
  $iv = pack('V', $buffer['counter']) . $this->p2;
384
+ $buffer['counter'] += (strlen($text) >> 6);
385
+ $ciphertext .= openssl_encrypt(
386
  $text,
387
  $this->cipher_name_openssl,
388
  $this->key,
392
  } else {
393
  $blocks = str_split($text, 64);
394
  foreach ($blocks as &$block) {
395
+ $block ^= static::salsa20($this->p1 . pack('V', $buffer['counter']++) . $this->p2);
396
  }
397
+ $ciphertext .= implode('', $blocks);
398
  }
399
  }
400
 
412
  {
413
  $r1 = $x << $n;
414
  if (PHP_INT_SIZE == 8) {
415
+ $r1 &= 0xFFFFFFFF;
416
  $r2 = ($x & 0xFFFFFFFF) >> (32 - $n);
417
  } else {
418
  $r2 = $x >> (32 - $n);
419
+ $r2 &= (1 << $n) - 1;
420
  }
421
  return $r1 | $r2;
422
  }
431
  */
432
  protected static function quarterRound(&$a, &$b, &$c, &$d)
433
  {
434
+ $b ^= self::leftRotate($a + $d, 7);
435
+ $c ^= self::leftRotate($b + $a, 9);
436
+ $d ^= self::leftRotate($c + $b, 13);
437
+ $a ^= self::leftRotate($d + $c, 18);
438
  }
439
 
440
  /**
460
  protected static function doubleRound(&$x0, &$x1, &$x2, &$x3, &$x4, &$x5, &$x6, &$x7, &$x8, &$x9, &$x10, &$x11, &$x12, &$x13, &$x14, &$x15)
461
  {
462
  // columnRound
463
+ static::quarterRound($x0, $x4, $x8, $x12);
464
+ static::quarterRound($x5, $x9, $x13, $x1);
465
+ static::quarterRound($x10, $x14, $x2, $x6);
466
+ static::quarterRound($x15, $x3, $x7, $x11);
467
  // rowRound
468
+ static::quarterRound($x0, $x1, $x2, $x3);
469
+ static::quarterRound($x5, $x6, $x7, $x4);
470
+ static::quarterRound($x10, $x11, $x8, $x9);
471
  static::quarterRound($x15, $x12, $x13, $x14);
472
  }
473
 
480
  {
481
  $z = $x = unpack('V*', $x);
482
  for ($i = 0; $i < 10; $i++) {
483
+ static::doubleRound($z[1], $z[2], $z[3], $z[4], $z[5], $z[6], $z[7], $z[8], $z[9], $z[10], $z[11], $z[12], $z[13], $z[14], $z[15], $z[16]);
484
  }
485
 
486
  for ($i = 1; $i <= 16; $i++) {
487
+ $x[$i] += $z[$i];
488
  }
489
 
490
  return pack('V*', ...$x);
vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php CHANGED
@@ -164,6 +164,7 @@ class TripleDES extends DES
164
  break;
165
  case 'cbc3':
166
  $mode = 'cbc';
 
167
  // If not 3CBC, we init as usual
168
  default:
169
  parent::__construct($mode);
@@ -260,7 +261,7 @@ class TripleDES extends DES
260
 
261
  switch (strlen($key)) {
262
  case 16:
263
- $key.= substr($key, 0, 8);
264
  break;
265
  case 24:
266
  break;
@@ -275,8 +276,8 @@ class TripleDES extends DES
275
  $this->setEngine();
276
 
277
  if ($this->mode_3cbc) {
278
- $this->des[0]->setKey(substr($key, 0, 8));
279
- $this->des[1]->setKey(substr($key, 8, 8));
280
  $this->des[2]->setKey(substr($key, 16, 8));
281
  }
282
  }
164
  break;
165
  case 'cbc3':
166
  $mode = 'cbc';
167
+ // fall-through
168
  // If not 3CBC, we init as usual
169
  default:
170
  parent::__construct($mode);
261
 
262
  switch (strlen($key)) {
263
  case 16:
264
+ $key .= substr($key, 0, 8);
265
  break;
266
  case 24:
267
  break;
276
  $this->setEngine();
277
 
278
  if ($this->mode_3cbc) {
279
+ $this->des[0]->setKey(substr($key, 0, 8));
280
+ $this->des[1]->setKey(substr($key, 8, 8));
281
  $this->des[2]->setKey(substr($key, 16, 8));
282
  }
283
  }
vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php CHANGED
@@ -463,7 +463,7 @@ class Twofish extends BlockCipher
463
  case 16:
464
  list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[1], $le_longs[2]);
465
  list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[3], $le_longs[4]);
466
- for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
467
  $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^
468
  $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^
469
  $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^
@@ -489,7 +489,7 @@ class Twofish extends BlockCipher
489
  list($sb, $sa, $s9, $s8) = $this->mdsrem($le_longs[1], $le_longs[2]);
490
  list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[3], $le_longs[4]);
491
  list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[5], $le_longs[6]);
492
- for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
493
  $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
494
  $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
495
  $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^
@@ -516,7 +516,7 @@ class Twofish extends BlockCipher
516
  list($sb, $sa, $s9, $s8) = $this->mdsrem($le_longs[3], $le_longs[4]);
517
  list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[5], $le_longs[6]);
518
  list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[7], $le_longs[8]);
519
- for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) {
520
  $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
521
  $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
522
  $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^
@@ -563,28 +563,28 @@ class Twofish extends BlockCipher
563
 
564
  // Shift the others up.
565
  $B = ($B << 8) | (0xff & ($A >> 24));
566
- $A<<= 8;
567
 
568
  $u = $t << 1;
569
 
570
  // Subtract the modular polynomial on overflow.
571
  if ($t & 0x80) {
572
- $u^= 0x14d;
573
  }
574
 
575
  // Remove t * (a * x^2 + 1).
576
  $B ^= $t ^ ($u << 16);
577
 
578
  // Form u = a*t + t/a = t*(a + 1/a).
579
- $u^= 0x7fffffff & ($t >> 1);
580
 
581
  // Add the modular polynomial on underflow.
582
  if ($t & 0x01) {
583
- $u^= 0xa6 ;
584
  }
585
 
586
  // Remove t * (a + 1/a) * (x^3 + x).
587
- $B^= ($u << 24) | ($u << 8);
588
  }
589
 
590
  return [
@@ -625,7 +625,7 @@ class Twofish extends BlockCipher
625
  $S1[ $R1 & 0xff] ^
626
  $S2[($R1 >> 8) & 0xff] ^
627
  $S3[($R1 >> 16) & 0xff];
628
- $R2^= self::safe_intval($t0 + $t1 + $K[++$ki]);
629
  $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31);
630
  $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ self::safe_intval($t0 + ($t1 << 1) + $K[++$ki]);
631
 
@@ -637,7 +637,7 @@ class Twofish extends BlockCipher
637
  $S1[ $R3 & 0xff] ^
638
  $S2[($R3 >> 8) & 0xff] ^
639
  $S3[($R3 >> 16) & 0xff];
640
- $R0^= self::safe_intval($t0 + $t1 + $K[++$ki]);
641
  $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31);
642
  $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ self::safe_intval($t0 + ($t1 << 1) + $K[++$ki]);
643
  }
@@ -681,7 +681,7 @@ class Twofish extends BlockCipher
681
  $S1[$R1 & 0xff] ^
682
  $S2[$R1 >> 8 & 0xff] ^
683
  $S3[$R1 >> 16 & 0xff];
684
- $R3^= self::safe_intval($t0 + ($t1 << 1) + $K[--$ki]);
685
  $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31;
686
  $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ self::safe_intval($t0 + $t1 + $K[--$ki]);
687
 
@@ -693,7 +693,7 @@ class Twofish extends BlockCipher
693
  $S1[$R3 & 0xff] ^
694
  $S2[$R3 >> 8 & 0xff] ^
695
  $S3[$R3 >> 16 & 0xff];
696
- $R1^= self::safe_intval($t0 + ($t1 << 1) + $K[--$ki]);
697
  $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31;
698
  $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ self::safe_intval($t0 + $t1 + $K[--$ki]);
699
  }
@@ -732,13 +732,13 @@ class Twofish extends BlockCipher
732
  // Generating encrypt code:
733
  $encrypt_block = '
734
  $in = unpack("V4", $in);
735
- $R0 = '.$K[0].' ^ $in[1];
736
- $R1 = '.$K[1].' ^ $in[2];
737
- $R2 = '.$K[2].' ^ $in[3];
738
- $R3 = '.$K[3].' ^ $in[4];
739
  ';
740
  for ($ki = 7, $i = 0; $i < 8; ++$i) {
741
- $encrypt_block.= '
742
  $t0 = $S0[ $R0 & 0xff] ^
743
  $S1[($R0 >> 8) & 0xff] ^
744
  $S2[($R0 >> 16) & 0xff] ^
@@ -764,23 +764,23 @@ class Twofish extends BlockCipher
764
  $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ' . sprintf($safeint, '($t0 + ($t1 << 1) + ' . $K[++$ki] . ')') . ';
765
  ';
766
  }
767
- $encrypt_block.= '
768
- $in = pack("V4", '.$K[4].' ^ $R2,
769
- '.$K[5].' ^ $R3,
770
- '.$K[6].' ^ $R0,
771
- '.$K[7].' ^ $R1);
772
  ';
773
 
774
  // Generating decrypt code:
775
  $decrypt_block = '
776
  $in = unpack("V4", $in);
777
- $R0 = '.$K[4].' ^ $in[1];
778
- $R1 = '.$K[5].' ^ $in[2];
779
- $R2 = '.$K[6].' ^ $in[3];
780
- $R3 = '.$K[7].' ^ $in[4];
781
  ';
782
  for ($ki = 40, $i = 0; $i < 8; ++$i) {
783
- $decrypt_block.= '
784
  $t0 = $S0[$R0 & 0xff] ^
785
  $S1[$R0 >> 8 & 0xff] ^
786
  $S2[$R0 >> 16 & 0xff] ^
@@ -791,7 +791,7 @@ class Twofish extends BlockCipher
791
  $S3[$R1 >> 16 & 0xff];
792
  $R3^= ' . sprintf($safeint, '$t0 + ($t1 << 1) + ' . $K[--$ki]) . ';
793
  $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31;
794
- $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ' . sprintf($safeint, '($t0 + $t1 + '.$K[--$ki] . ')') . ';
795
 
796
  $t0 = $S0[$R2 & 0xff] ^
797
  $S1[$R2 >> 8 & 0xff] ^
@@ -803,14 +803,14 @@ class Twofish extends BlockCipher
803
  $S3[$R3 >> 16 & 0xff];
804
  $R1^= ' . sprintf($safeint, '$t0 + ($t1 << 1) + ' . $K[--$ki]) . ';
805
  $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31;
806
- $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ' . sprintf($safeint, '($t0 + $t1 + '.$K[--$ki] . ')') . ';
807
  ';
808
  }
809
- $decrypt_block.= '
810
- $in = pack("V4", '.$K[0].' ^ $R2,
811
- '.$K[1].' ^ $R3,
812
- '.$K[2].' ^ $R0,
813
- '.$K[3].' ^ $R1);
814
  ';
815
 
816
  $this->inline_crypt = $this->createInlineCryptFunction(
463
  case 16:
464
  list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[1], $le_longs[2]);
465
  list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[3], $le_longs[4]);
466
+ for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) {
467
  $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^
468
  $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^
469
  $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^
489
  list($sb, $sa, $s9, $s8) = $this->mdsrem($le_longs[1], $le_longs[2]);
490
  list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[3], $le_longs[4]);
491
  list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[5], $le_longs[6]);
492
+ for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) {
493
  $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
494
  $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
495
  $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^
516
  list($sb, $sa, $s9, $s8) = $this->mdsrem($le_longs[3], $le_longs[4]);
517
  list($s7, $s6, $s5, $s4) = $this->mdsrem($le_longs[5], $le_longs[6]);
518
  list($s3, $s2, $s1, $s0) = $this->mdsrem($le_longs[7], $le_longs[8]);
519
+ for ($i = 0, $j = 1; $i < 40; $i += 2, $j += 2) {
520
  $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^
521
  $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^
522
  $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^
563
 
564
  // Shift the others up.
565
  $B = ($B << 8) | (0xff & ($A >> 24));
566
+ $A <<= 8;
567
 
568
  $u = $t << 1;
569
 
570
  // Subtract the modular polynomial on overflow.
571
  if ($t & 0x80) {
572
+ $u ^= 0x14d;
573
  }
574
 
575
  // Remove t * (a * x^2 + 1).
576
  $B ^= $t ^ ($u << 16);
577
 
578
  // Form u = a*t + t/a = t*(a + 1/a).
579
+ $u ^= 0x7fffffff & ($t >> 1);
580
 
581
  // Add the modular polynomial on underflow.
582
  if ($t & 0x01) {
583
+ $u ^= 0xa6 ;
584
  }
585
 
586
  // Remove t * (a + 1/a) * (x^3 + x).
587
+ $B ^= ($u << 24) | ($u << 8);
588
  }
589
 
590
  return [
625
  $S1[ $R1 & 0xff] ^
626
  $S2[($R1 >> 8) & 0xff] ^
627
  $S3[($R1 >> 16) & 0xff];
628
+ $R2 ^= self::safe_intval($t0 + $t1 + $K[++$ki]);
629
  $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31);
630
  $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ self::safe_intval($t0 + ($t1 << 1) + $K[++$ki]);
631
 
637
  $S1[ $R3 & 0xff] ^
638
  $S2[($R3 >> 8) & 0xff] ^
639
  $S3[($R3 >> 16) & 0xff];
640
+ $R0 ^= self::safe_intval($t0 + $t1 + $K[++$ki]);
641
  $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31);
642
  $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ self::safe_intval($t0 + ($t1 << 1) + $K[++$ki]);
643
  }
681
  $S1[$R1 & 0xff] ^
682
  $S2[$R1 >> 8 & 0xff] ^
683
  $S3[$R1 >> 16 & 0xff];
684
+ $R3 ^= self::safe_intval($t0 + ($t1 << 1) + $K[--$ki]);
685
  $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31;
686
  $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ self::safe_intval($t0 + $t1 + $K[--$ki]);
687
 
693
  $S1[$R3 & 0xff] ^
694
  $S2[$R3 >> 8 & 0xff] ^
695
  $S3[$R3 >> 16 & 0xff];
696
+ $R1 ^= self::safe_intval($t0 + ($t1 << 1) + $K[--$ki]);
697
  $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31;
698
  $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ self::safe_intval($t0 + $t1 + $K[--$ki]);
699
  }
732
  // Generating encrypt code:
733
  $encrypt_block = '
734
  $in = unpack("V4", $in);
735
+ $R0 = ' . $K[0] . ' ^ $in[1];
736
+ $R1 = ' . $K[1] . ' ^ $in[2];
737
+ $R2 = ' . $K[2] . ' ^ $in[3];
738
+ $R3 = ' . $K[3] . ' ^ $in[4];
739
  ';
740
  for ($ki = 7, $i = 0; $i < 8; ++$i) {
741
+ $encrypt_block .= '
742
  $t0 = $S0[ $R0 & 0xff] ^
743
  $S1[($R0 >> 8) & 0xff] ^
744
  $S2[($R0 >> 16) & 0xff] ^
764
  $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ' . sprintf($safeint, '($t0 + ($t1 << 1) + ' . $K[++$ki] . ')') . ';
765
  ';
766
  }
767
+ $encrypt_block .= '
768
+ $in = pack("V4", ' . $K[4] . ' ^ $R2,
769
+ ' . $K[5] . ' ^ $R3,
770
+ ' . $K[6] . ' ^ $R0,
771
+ ' . $K[7] . ' ^ $R1);
772
  ';
773
 
774
  // Generating decrypt code:
775
  $decrypt_block = '
776
  $in = unpack("V4", $in);
777
+ $R0 = ' . $K[4] . ' ^ $in[1];
778
+ $R1 = ' . $K[5] . ' ^ $in[2];
779
+ $R2 = ' . $K[6] . ' ^ $in[3];
780
+ $R3 = ' . $K[7] . ' ^ $in[4];
781
  ';
782
  for ($ki = 40, $i = 0; $i < 8; ++$i) {
783
+ $decrypt_block .= '
784
  $t0 = $S0[$R0 & 0xff] ^
785
  $S1[$R0 >> 8 & 0xff] ^
786
  $S2[$R0 >> 16 & 0xff] ^
791
  $S3[$R1 >> 16 & 0xff];
792
  $R3^= ' . sprintf($safeint, '$t0 + ($t1 << 1) + ' . $K[--$ki]) . ';
793
  $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31;
794
+ $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ' . sprintf($safeint, '($t0 + $t1 + ' . $K[--$ki] . ')') . ';
795
 
796
  $t0 = $S0[$R2 & 0xff] ^
797
  $S1[$R2 >> 8 & 0xff] ^
803
  $S3[$R3 >> 16 & 0xff];
804
  $R1^= ' . sprintf($safeint, '$t0 + ($t1 << 1) + ' . $K[--$ki]) . ';
805
  $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31;
806
+ $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ' . sprintf($safeint, '($t0 + $t1 + ' . $K[--$ki] . ')') . ';
807
  ';
808
  }
809
+ $decrypt_block .= '
810
+ $in = pack("V4", ' . $K[0] . ' ^ $R2,
811
+ ' . $K[1] . ' ^ $R3,
812
+ ' . $K[2] . ' ^ $R0,
813
+ ' . $K[3] . ' ^ $R1);
814
  ';
815
 
816
  $this->inline_crypt = $this->createInlineCryptFunction(
vendor/phpseclib/phpseclib/phpseclib/File/ANSI.php CHANGED
@@ -128,7 +128,7 @@ class ANSI
128
  /**
129
  * The current screen text
130
  *
131
- * @var array
132
  * @access private
133
  */
134
  private $screen;
@@ -234,7 +234,7 @@ class ANSI
234
  $this->tokenization = [''];
235
  for ($i = 0; $i < strlen($source); $i++) {
236
  if (strlen($this->ansi)) {
237
- $this->ansi.= $source[$i];
238
  $chr = ord($source[$i]);
239
  // http://en.wikipedia.org/wiki/ANSI_escape_code#Sequence_elements
240
  // single character CSI's not currently supported
@@ -268,6 +268,7 @@ class ANSI
268
  array_shift($this->history);
269
  array_shift($this->history_attrs);
270
  }
 
271
  case "\x1B[K": // Clear screen from cursor right
272
  $this->screen[$this->y] = substr($this->screen[$this->y], 0, $this->x);
273
 
@@ -289,21 +290,21 @@ class ANSI
289
  switch (true) {
290
  case preg_match('#\x1B\[(\d+)B#', $this->ansi, $match): // Move cursor down n lines
291
  $this->old_y = $this->y;
292
- $this->y+= $match[1];
293
  break;
294
  case preg_match('#\x1B\[(\d+);(\d+)H#', $this->ansi, $match): // Move cursor to screen location v,h
295
  $this->old_x = $this->x;
296
  $this->old_y = $this->y;
297
  $this->x = $match[2] - 1;
298
- $this->y = $match[1] - 1;
299
  break;
300
  case preg_match('#\x1B\[(\d+)C#', $this->ansi, $match): // Move cursor right n lines
301
  $this->old_x = $this->x;
302
- $this->x+= $match[1];
303
  break;
304
  case preg_match('#\x1B\[(\d+)D#', $this->ansi, $match): // Move cursor left n lines
305
  $this->old_x = $this->x;
306
- $this->x-= $match[1];
307
  if ($this->x < 0) {
308
  $this->x = 0;
309
  }
@@ -376,7 +377,7 @@ class ANSI
376
  continue;
377
  }
378
 
379
- $this->tokenization[count($this->tokenization) - 1].= $source[$i];
380
  switch ($source[$i]) {
381
  case "\r":
382
  $this->x = 0;
@@ -403,7 +404,7 @@ class ANSI
403
  //if (!strlen($this->tokenization[count($this->tokenization) - 1])) {
404
  // array_pop($this->tokenization);
405
  //}
406
- $this->ansi.= "\x1B";
407
  break;
408
  default:
409
  $this->attrs[$this->y][$this->x] = clone $this->attr_cell;
@@ -474,7 +475,7 @@ class ANSI
474
  $close = $open = '';
475
  if ($last_attr->foreground != $cur_attr->foreground) {
476
  if ($cur_attr->foreground != 'white') {
477
- $open.= '<span style="color: ' . $cur_attr->foreground . '">';
478
  }
479
  if ($last_attr->foreground != 'white') {
480
  $close = '</span>' . $close;
@@ -482,7 +483,7 @@ class ANSI
482
  }
483
  if ($last_attr->background != $cur_attr->background) {
484
  if ($cur_attr->background != 'black') {
485
- $open.= '<span style="background: ' . $cur_attr->background . '">';
486
  }
487
  if ($last_attr->background != 'black') {
488
  $close = '</span>' . $close;
@@ -490,29 +491,29 @@ class ANSI
490
  }
491
  if ($last_attr->bold != $cur_attr->bold) {
492
  if ($cur_attr->bold) {
493
- $open.= '<b>';
494
  } else {
495
  $close = '</b>' . $close;
496
  }
497
  }
498
  if ($last_attr->underline != $cur_attr->underline) {
499
  if ($cur_attr->underline) {
500
- $open.= '<u>';
501
  } else {
502
  $close = '</u>' . $close;
503
  }
504
  }
505
  if ($last_attr->blink != $cur_attr->blink) {
506
  if ($cur_attr->blink) {
507
- $open.= '<blink>';
508
  } else {
509
  $close = '</blink>' . $close;
510
  }
511
  }
512
- $output.= $close . $open;
513
  }
514
 
515
- $output.= htmlspecialchars($char);
516
 
517
  return $output;
518
  }
@@ -530,14 +531,14 @@ class ANSI
530
  for ($i = 0; $i <= $this->max_y; $i++) {
531
  for ($j = 0; $j <= $this->max_x; $j++) {
532
  $cur_attr = $this->attrs[$i][$j];
533
- $output.= $this->processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : '');
534
  $last_attr = $this->attrs[$i][$j];
535
  }
536
- $output.= "\r\n";
537
  }
538
  $output = substr($output, 0, -2);
539
  // close any remaining open tags
540
- $output.= $this->processCoordinate($last_attr, $this->base_attr_cell, '');
541
  return rtrim($output);
542
  }
543
 
@@ -565,14 +566,14 @@ class ANSI
565
  for ($i = 0; $i < count($this->history); $i++) {
566
  for ($j = 0; $j <= $this->max_x + 1; $j++) {
567
  $cur_attr = $this->history_attrs[$i][$j];
568
- $scrollback.= $this->processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : '');
569
  $last_attr = $this->history_attrs[$i][$j];
570
  }
571
- $scrollback.= "\r\n";
572
  }
573
  $base_attr_cell = $this->base_attr_cell;
574
  $this->base_attr_cell = $last_attr;
575
- $scrollback.= $this->getScreen();
576
  $this->base_attr_cell = $base_attr_cell;
577
 
578
  return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $scrollback . '</span></pre>';
128
  /**
129
  * The current screen text
130
  *
131
+ * @var list<string>
132
  * @access private
133
  */
134
  private $screen;
234
  $this->tokenization = [''];
235
  for ($i = 0; $i < strlen($source); $i++) {
236
  if (strlen($this->ansi)) {
237
+ $this->ansi .= $source[$i];
238
  $chr = ord($source[$i]);
239
  // http://en.wikipedia.org/wiki/ANSI_escape_code#Sequence_elements
240
  // single character CSI's not currently supported
268
  array_shift($this->history);
269
  array_shift($this->history_attrs);
270
  }
271
+ // fall-through
272
  case "\x1B[K": // Clear screen from cursor right
273
  $this->screen[$this->y] = substr($this->screen[$this->y], 0, $this->x);
274
 
290
  switch (true) {
291
  case preg_match('#\x1B\[(\d+)B#', $this->ansi, $match): // Move cursor down n lines
292
  $this->old_y = $this->y;
293
+ $this->y += (int) $match[1];
294
  break;
295
  case preg_match('#\x1B\[(\d+);(\d+)H#', $this->ansi, $match): // Move cursor to screen location v,h
296
  $this->old_x = $this->x;
297
  $this->old_y = $this->y;
298
  $this->x = $match[2] - 1;
299
+ $this->y = (int) $match[1] - 1;
300
  break;
301
  case preg_match('#\x1B\[(\d+)C#', $this->ansi, $match): // Move cursor right n lines
302
  $this->old_x = $this->x;
303
+ $this->x += $match[1];
304
  break;
305
  case preg_match('#\x1B\[(\d+)D#', $this->ansi, $match): // Move cursor left n lines
306
  $this->old_x = $this->x;
307
+ $this->x -= $match[1];
308
  if ($this->x < 0) {
309
  $this->x = 0;
310
  }
377
  continue;
378
  }
379
 
380
+ $this->tokenization[count($this->tokenization) - 1] .= $source[$i];
381
  switch ($source[$i]) {
382
  case "\r":
383
  $this->x = 0;
404
  //if (!strlen($this->tokenization[count($this->tokenization) - 1])) {
405
  // array_pop($this->tokenization);
406
  //}
407
+ $this->ansi .= "\x1B";
408
  break;
409
  default:
410
  $this->attrs[$this->y][$this->x] = clone $this->attr_cell;
475
  $close = $open = '';
476
  if ($last_attr->foreground != $cur_attr->foreground) {
477
  if ($cur_attr->foreground != 'white') {
478
+ $open .= '<span style="color: ' . $cur_attr->foreground . '">';
479
  }
480
  if ($last_attr->foreground != 'white') {
481
  $close = '</span>' . $close;
483
  }
484
  if ($last_attr->background != $cur_attr->background) {
485
  if ($cur_attr->background != 'black') {
486
+ $open .= '<span style="background: ' . $cur_attr->background . '">';
487
  }
488
  if ($last_attr->background != 'black') {
489
  $close = '</span>' . $close;
491
  }
492
  if ($last_attr->bold != $cur_attr->bold) {
493
  if ($cur_attr->bold) {
494
+ $open .= '<b>';
495
  } else {
496
  $close = '</b>' . $close;
497
  }
498
  }
499
  if ($last_attr->underline != $cur_attr->underline) {
500
  if ($cur_attr->underline) {
501
+ $open .= '<u>';
502
  } else {
503
  $close = '</u>' . $close;
504
  }
505
  }
506
  if ($last_attr->blink != $cur_attr->blink) {
507
  if ($cur_attr->blink) {
508
+ $open .= '<blink>';
509
  } else {
510
  $close = '</blink>' . $close;
511
  }
512
  }
513
+ $output .= $close . $open;
514
  }
515
 
516
+ $output .= htmlspecialchars($char);
517
 
518
  return $output;
519
  }
531
  for ($i = 0; $i <= $this->max_y; $i++) {
532
  for ($j = 0; $j <= $this->max_x; $j++) {
533
  $cur_attr = $this->attrs[$i][$j];
534
+ $output .= $this->processCoordinate($last_attr, $cur_attr, isset($this->screen[$i][$j]) ? $this->screen[$i][$j] : '');
535
  $last_attr = $this->attrs[$i][$j];
536
  }
537
+ $output .= "\r\n";
538
  }
539
  $output = substr($output, 0, -2);
540
  // close any remaining open tags
541
+ $output .= $this->processCoordinate($last_attr, $this->base_attr_cell, '');
542
  return rtrim($output);
543
  }
544
 
566
  for ($i = 0; $i < count($this->history); $i++) {
567
  for ($j = 0; $j <= $this->max_x + 1; $j++) {
568
  $cur_attr = $this->history_attrs[$i][$j];
569
+ $scrollback .= $this->processCoordinate($last_attr, $cur_attr, isset($this->history[$i][$j]) ? $this->history[$i][$j] : '');
570
  $last_attr = $this->history_attrs[$i][$j];
571
  }
572
+ $scrollback .= "\r\n";
573
  }
574
  $base_attr_cell = $this->base_attr_cell;
575
  $this->base_attr_cell = $last_attr;
576
+ $scrollback .= $this->getScreen();
577
  $this->base_attr_cell = $base_attr_cell;
578
 
579
  return '<pre width="' . ($this->max_x + 1) . '" style="color: white; background: black">' . $scrollback . '</span></pre>';
vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php CHANGED
@@ -23,12 +23,11 @@
23
 
24
  namespace phpseclib3\File;
25
 
 
26
  use ParagonIE\ConstantTime\Base64;
 
27
  use phpseclib3\File\ASN1\Element;
28
  use phpseclib3\Math\BigInteger;
29
- use phpseclib3\Common\Functions\Strings;
30
- use DateTime;
31
- use DateTimeZone;
32
 
33
  /**
34
  * Pure-PHP ASN.1 Parser
@@ -188,7 +187,7 @@ abstract class ASN1
188
  * @var array
189
  * @access public
190
  */
191
- const STRING_TYPE_SIZE = [
192
  self::TYPE_UTF8_STRING => 0,
193
  self::TYPE_BMP_STRING => 2,
194
  self::TYPE_UNIVERSAL_STRING => 4,
@@ -203,7 +202,7 @@ abstract class ASN1
203
  *
204
  * Serves a similar purpose to openssl's asn1parse
205
  *
206
- * @param string $encoded
207
  * @return array
208
  * @access public
209
  */
@@ -238,6 +237,9 @@ abstract class ASN1
238
  {
239
  $current = ['start' => $start];
240
 
 
 
 
241
  $type = ord($encoded[$encoded_pos++]);
242
  $startOffset = 1;
243
 
@@ -248,6 +250,9 @@ abstract class ASN1
248
  $tag = 0;
249
  // process septets (since the eighth bit is ignored, it's not an octet)
250
  do {
 
 
 
251
  $temp = ord($encoded[$encoded_pos++]);
252
  $startOffset++;
253
  $loop = $temp >> 7;
@@ -261,9 +266,12 @@ abstract class ASN1
261
  } while ($loop);
262
  }
263
 
264
- $start+= $startOffset;
265
 
266
  // Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13
 
 
 
267
  $length = ord($encoded[$encoded_pos++]);
268
  $start++;
269
  if ($length == 0x80) { // indefinite length
@@ -273,16 +281,16 @@ abstract class ASN1
273
  } elseif ($length & 0x80) { // definite length, long form
274
  // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only
275
  // support it up to four.
276
- $length&= 0x7F;
277
  $temp = substr($encoded, $encoded_pos, $length);
278
  $encoded_pos += $length;
279
  // tags of indefinte length don't really have a header length; this length includes the tag
280
- $current+= ['headerlength' => $length + 2];
281
- $start+= $length;
282
  extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)));
283
  /** @var integer $length */
284
  } else {
285
- $current+= ['headerlength' => 2];
286
  }
287
 
288
  if ($length > (strlen($encoded) - $encoded_pos)) {
@@ -327,13 +335,13 @@ abstract class ASN1
327
  $length = $temp['length'];
328
  // end-of-content octets - see paragraph 8.1.5
329
  if (substr($content, $content_pos + $length, 2) == "\0\0") {
330
- $length+= 2;
331
- $start+= $length;
332
  $newcontent[] = $temp;
333
  break;
334
  }
335
- $start+= $length;
336
- $remainingLength-= $length;
337
  $newcontent[] = $temp;
338
  $content_pos += $length;
339
  }
@@ -350,7 +358,7 @@ abstract class ASN1
350
  ] + $current;
351
  }
352
 
353
- $current+= ['type' => $tag];
354
 
355
  // decode UNIVERSAL tags
356
  switch ($tag) {
@@ -381,14 +389,14 @@ abstract class ASN1
381
  if ($temp === false) {
382
  return false;
383
  }
384
- $length-= (strlen($content) - $content_pos);
385
  $last = count($temp) - 1;
386
  for ($i = 0; $i < $last; $i++) {
387
  // all subtags should be bit strings
388
  if ($temp[$i]['type'] != self::TYPE_BIT_STRING) {
389
  return false;
390
  }
391
- $current['content'].= substr($temp[$i]['content'], 1);
392
  }
393
  // all subtags should be bit strings
394
  if ($temp[$last]['type'] != self::TYPE_BIT_STRING) {
@@ -413,11 +421,11 @@ abstract class ASN1
413
  if ($temp['type'] != self::TYPE_OCTET_STRING) {
414
  return false;
415
  }
416
- $current['content'].= $temp['content'];
417
- $length+= $temp['length'];
418
  }
419
  if (substr($content, $content_pos, 2) == "\0\0") {
420
- $length+= 2; // +2 for the EOC
421
  }
422
  }
423
  break;
@@ -448,7 +456,7 @@ abstract class ASN1
448
  }
449
  $content_pos += $temp['length'];
450
  $current['content'][] = $temp;
451
- $offset+= $temp['length'];
452
  }
453
  break;
454
  case self::TYPE_OBJECT_IDENTIFIER:
@@ -504,7 +512,7 @@ abstract class ASN1
504
  return false;
505
  }
506
 
507
- $start+= $length;
508
 
509
  // ie. length is the length of the full TLV encoding - it's not just the length of the value
510
  return $current + ['length' => $start - $current['start']];
@@ -520,7 +528,7 @@ abstract class ASN1
520
  * @param array $decoded
521
  * @param array $mapping
522
  * @param array $special
523
- * @return array|bool|Element
524
  * @access public
525
  */
526
  public static function asn1map($decoded, $mapping, $special = [])
@@ -656,7 +664,7 @@ abstract class ASN1
656
  }
657
 
658
  // Fail mapping if all input items have not been consumed.
659
- return $i < $n ? null: $map;
660
 
661
  // the main diff between sets and sequences is the encapsulation of the foreach in another for loop
662
  case self::TYPE_SET:
@@ -779,12 +787,12 @@ abstract class ASN1
779
  }
780
  return $values;
781
  }
 
782
  case self::TYPE_OCTET_STRING:
783
  return $decoded['content'];
784
  case self::TYPE_NULL:
785
  return '';
786
  case self::TYPE_BOOLEAN:
787
- return $decoded['content'];
788
  case self::TYPE_NUMERIC_STRING:
789
  case self::TYPE_PRINTABLE_STRING:
790
  case self::TYPE_TELETEX_STRING:
@@ -827,7 +835,7 @@ abstract class ASN1
827
  {
828
  $length = ord(Strings::shift($string));
829
  if ($length & 0x80) { // definite length, long form
830
- $length&= 0x7F;
831
  $temp = Strings::shift($string, $length);
832
  list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4));
833
  }
@@ -857,7 +865,7 @@ abstract class ASN1
857
  /**
858
  * ASN.1 Encode (Helper function)
859
  *
860
- * @param Element|string|array $source
861
  * @param array $mapping
862
  * @param int $idx
863
  * @param array $special
@@ -887,7 +895,7 @@ abstract class ASN1
887
  switch ($tag) {
888
  case self::TYPE_SET: // Children order is not important, thus process in sequence.
889
  case self::TYPE_SEQUENCE:
890
- $tag|= 0x20; // set the constructed bit
891
 
892
  // ignore the min and max
893
  if (isset($mapping['min']) && isset($mapping['max'])) {
@@ -899,7 +907,7 @@ abstract class ASN1
899
  if ($temp === false) {
900
  return false;
901
  }
902
- $value[]= $temp;
903
  }
904
  /* "The encodings of the component values of a set-of value shall appear in ascending order, the encodings being compared
905
  as octet strings with the shorter components being padded at their trailing end with 0-octets.
@@ -952,7 +960,7 @@ abstract class ASN1
952
  $temp = $subtag . substr($temp, 1);
953
  }
954
  }
955
- $value.= $temp;
956
  }
957
  break;
958
  case self::TYPE_CHOICE:
@@ -1019,11 +1027,11 @@ abstract class ASN1
1019
  case self::TYPE_UTC_TIME:
1020
  case self::TYPE_GENERALIZED_TIME:
1021
  $format = $mapping['type'] == self::TYPE_UTC_TIME ? 'y' : 'Y';
1022
- $format.= 'mdHis';
1023
  // if $source does _not_ include timezone information within it then assume that the timezone is GMT
1024
- $date = new DateTime($source, new DateTimeZone('GMT'));
1025
  // if $source _does_ include timezone information within it then convert the time to GMT
1026
- $date->setTimezone(new DateTimeZone('GMT'));
1027
  $value = $date->format($format) . 'Z';
1028
  break;
1029
  case self::TYPE_BIT_STRING:
@@ -1053,11 +1061,12 @@ abstract class ASN1
1053
  $bits = implode('', array_pad($bits, $size + $offset + 1, 0));
1054
  $bytes = explode(' ', rtrim(chunk_split($bits, 8, ' ')));
1055
  foreach ($bytes as $byte) {
1056
- $value.= chr(bindec($byte));
1057
  }
1058
 
1059
  break;
1060
  }
 
1061
  case self::TYPE_OCTET_STRING:
1062
  /* The initial octet shall encode, as an unsigned binary integer with bit 1 as the least significant bit,
1063
  the number of unused bits in the final subsequent octet. The number shall be in the range zero to seven.
@@ -1248,7 +1257,7 @@ abstract class ASN1
1248
  }
1249
  $temp[strlen($temp) - 1] = $temp[strlen($temp) - 1] & chr(0x7F);
1250
  }
1251
- $value.= $temp;
1252
  }
1253
 
1254
  return $value;
@@ -1262,7 +1271,7 @@ abstract class ASN1
1262
  * @access private
1263
  * @param string $content
1264
  * @param int $tag
1265
- * @return string
1266
  */
1267
  private static function decodeTime($content, $tag)
1268
  {
@@ -1286,7 +1295,7 @@ abstract class ASN1
1286
  $prefix = substr($content, 0, 2) >= 50 ? '19' : '20';
1287
  $content = $prefix . $content;
1288
  } elseif (strpos($content, '.') !== false) {
1289
- $format.= '.u';
1290
  }
1291
 
1292
  if ($content[strlen($content) - 1] == 'Z') {
@@ -1294,12 +1303,12 @@ abstract class ASN1
1294
  }
1295
 
1296
  if (strpos($content, '-') !== false || strpos($content, '+') !== false) {
1297
- $format.= 'O';
1298
  }
1299
 
1300
  // error supression isn't necessary as of PHP 7.0:
1301
  // http://php.net/manual/en/migration70.other-changes.php
1302
- return @DateTime::createFromFormat($format, $content);
1303
  }
1304
 
1305
  /**
@@ -1326,7 +1335,7 @@ abstract class ASN1
1326
  */
1327
  public static function loadOIDs($oids)
1328
  {
1329
- self::$reverseOIDs+= $oids;
1330
  self::$oids = array_flip(self::$reverseOIDs);
1331
  }
1332
 
@@ -1378,8 +1387,10 @@ abstract class ASN1
1378
  case $insize == 4:
1379
  $c = ($c << 8) | ord($in[$i++]);
1380
  $c = ($c << 8) | ord($in[$i++]);
 
1381
  case $insize == 2:
1382
  $c = ($c << 8) | ord($in[$i++]);
 
1383
  case $insize == 1:
1384
  break;
1385
  case ($c & 0x80) == 0x00:
@@ -1408,9 +1419,11 @@ abstract class ASN1
1408
  $c >>= 8;
1409
  $v .= chr($c & 0xFF);
1410
  $c >>= 8;
 
1411
  case $outsize == 2:
1412
  $v .= chr($c & 0xFF);
1413
  $c >>= 8;
 
1414
  case $outsize == 1:
1415
  $v .= chr($c & 0xFF);
1416
  $c >>= 8;
@@ -1423,18 +1436,23 @@ abstract class ASN1
1423
  case $c >= 0x04000000:
1424
  $v .= chr(0x80 | ($c & 0x3F));
1425
  $c = ($c >> 6) | 0x04000000;
 
1426
  case $c >= 0x00200000:
1427
  $v .= chr(0x80 | ($c & 0x3F));
1428
  $c = ($c >> 6) | 0x00200000;
 
1429
  case $c >= 0x00010000:
1430
  $v .= chr(0x80 | ($c & 0x3F));
1431
  $c = ($c >> 6) | 0x00010000;
 
1432
  case $c >= 0x00000800:
1433
  $v .= chr(0x80 | ($c & 0x3F));
1434
  $c = ($c >> 6) | 0x00000800;
 
1435
  case $c >= 0x00000080:
1436
  $v .= chr(0x80 | ($c & 0x3F));
1437
  $c = ($c >> 6) | 0x000000C0;
 
1438
  default:
1439
  $v .= chr($c);
1440
  break;
23
 
24
  namespace phpseclib3\File;
25
 
26
+ use DateTime;
27
  use ParagonIE\ConstantTime\Base64;
28
+ use phpseclib3\Common\Functions\Strings;
29
  use phpseclib3\File\ASN1\Element;
30
  use phpseclib3\Math\BigInteger;
 
 
 
31
 
32
  /**
33
  * Pure-PHP ASN.1 Parser
187
  * @var array
188
  * @access public
189
  */
190
+ const STRING_TYPE_SIZE = [
191
  self::TYPE_UTF8_STRING => 0,
192
  self::TYPE_BMP_STRING => 2,
193
  self::TYPE_UNIVERSAL_STRING => 4,
202
  *
203
  * Serves a similar purpose to openssl's asn1parse
204
  *
205
+ * @param Element|string $encoded
206
  * @return array
207
  * @access public
208
  */
237
  {
238
  $current = ['start' => $start];
239
 
240
+ if (!isset($encoded[$encoded_pos])) {
241
+ return false;
242
+ }
243
  $type = ord($encoded[$encoded_pos++]);
244
  $startOffset = 1;
245
 
250
  $tag = 0;
251
  // process septets (since the eighth bit is ignored, it's not an octet)
252
  do {
253
+ if (!isset($encoded[$encoded_pos])) {
254
+ return false;
255
+ }
256
  $temp = ord($encoded[$encoded_pos++]);
257
  $startOffset++;
258
  $loop = $temp >> 7;
266
  } while ($loop);
267
  }
268
 
269
+ $start += $startOffset;
270
 
271
  // Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13
272
+ if (!isset($encoded[$encoded_pos])) {
273
+ return false;
274
+ }
275
  $length = ord($encoded[$encoded_pos++]);
276
  $start++;
277
  if ($length == 0x80) { // indefinite length
281
  } elseif ($length & 0x80) { // definite length, long form
282
  // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only
283
  // support it up to four.
284
+ $length &= 0x7F;
285
  $temp = substr($encoded, $encoded_pos, $length);
286
  $encoded_pos += $length;
287
  // tags of indefinte length don't really have a header length; this length includes the tag
288
+ $current += ['headerlength' => $length + 2];
289
+ $start += $length;
290
  extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)));
291
  /** @var integer $length */
292
  } else {
293
+ $current += ['headerlength' => 2];
294
  }
295
 
296
  if ($length > (strlen($encoded) - $encoded_pos)) {
335
  $length = $temp['length'];
336
  // end-of-content octets - see paragraph 8.1.5
337
  if (substr($content, $content_pos + $length, 2) == "\0\0") {
338
+ $length += 2;
339
+ $start += $length;
340
  $newcontent[] = $temp;
341
  break;
342
  }
343
+ $start += $length;
344
+ $remainingLength -= $length;
345
  $newcontent[] = $temp;
346
  $content_pos += $length;
347
  }
358
  ] + $current;
359
  }
360
 
361
+ $current += ['type' => $tag];
362
 
363
  // decode UNIVERSAL tags
364
  switch ($tag) {
389
  if ($temp === false) {
390
  return false;
391
  }
392
+ $length -= (strlen($content) - $content_pos);
393
  $last = count($temp) - 1;
394
  for ($i = 0; $i < $last; $i++) {
395
  // all subtags should be bit strings
396
  if ($temp[$i]['type'] != self::TYPE_BIT_STRING) {
397
  return false;
398
  }
399
+ $current['content'] .= substr($temp[$i]['content'], 1);
400
  }
401
  // all subtags should be bit strings
402
  if ($temp[$last]['type'] != self::TYPE_BIT_STRING) {
421
  if ($temp['type'] != self::TYPE_OCTET_STRING) {
422
  return false;
423
  }
424
+ $current['content'] .= $temp['content'];
425
+ $length += $temp['length'];
426
  }
427
  if (substr($content, $content_pos, 2) == "\0\0") {
428
+ $length += 2; // +2 for the EOC
429
  }
430
  }
431
  break;
456
  }
457
  $content_pos += $temp['length'];
458
  $current['content'][] = $temp;
459
+ $offset += $temp['length'];
460
  }
461
  break;
462
  case self::TYPE_OBJECT_IDENTIFIER:
512
  return false;
513
  }
514
 
515
+ $start += $length;
516
 
517
  // ie. length is the length of the full TLV encoding - it's not just the length of the value
518
  return $current + ['length' => $start - $current['start']];
528
  * @param array $decoded
529
  * @param array $mapping
530
  * @param array $special
531
+ * @return array|bool|Element|string|null
532
  * @access public
533
  */
534
  public static function asn1map($decoded, $mapping, $special = [])
664
  }
665
 
666
  // Fail mapping if all input items have not been consumed.
667
+ return $i < $n ? null : $map;
668
 
669
  // the main diff between sets and sequences is the encapsulation of the foreach in another for loop
670
  case self::TYPE_SET:
787
  }
788
  return $values;
789
  }
790
+ // fall-through
791
  case self::TYPE_OCTET_STRING:
792
  return $decoded['content'];
793
  case self::TYPE_NULL:
794
  return '';
795
  case self::TYPE_BOOLEAN:
 
796
  case self::TYPE_NUMERIC_STRING:
797
  case self::TYPE_PRINTABLE_STRING:
798
  case self::TYPE_TELETEX_STRING:
835
  {
836
  $length = ord(Strings::shift($string));
837
  if ($length & 0x80) { // definite length, long form
838
+ $length &= 0x7F;
839
  $temp = Strings::shift($string, $length);
840
  list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4));
841
  }
865
  /**
866
  * ASN.1 Encode (Helper function)
867
  *
868
+ * @param Element|string|array|null $source
869
  * @param array $mapping
870
  * @param int $idx
871
  * @param array $special
895
  switch ($tag) {
896
  case self::TYPE_SET: // Children order is not important, thus process in sequence.
897
  case self::TYPE_SEQUENCE:
898
+ $tag |= 0x20; // set the constructed bit
899
 
900
  // ignore the min and max
901
  if (isset($mapping['min']) && isset($mapping['max'])) {
907
  if ($temp === false) {
908
  return false;
909
  }
910
+ $value[] = $temp;
911
  }
912
  /* "The encodings of the component values of a set-of value shall appear in ascending order, the encodings being compared
913
  as octet strings with the shorter components being padded at their trailing end with 0-octets.
960
  $temp = $subtag . substr($temp, 1);
961
  }
962
  }
963
+ $value .= $temp;
964
  }
965
  break;
966
  case self::TYPE_CHOICE:
1027
  case self::TYPE_UTC_TIME:
1028
  case self::TYPE_GENERALIZED_TIME:
1029
  $format = $mapping['type'] == self::TYPE_UTC_TIME ? 'y' : 'Y';
1030
+ $format .= 'mdHis';
1031
  // if $source does _not_ include timezone information within it then assume that the timezone is GMT
1032
+ $date = new \DateTime($source, new \DateTimeZone('GMT'));
1033
  // if $source _does_ include timezone information within it then convert the time to GMT
1034
+ $date->setTimezone(new \DateTimeZone('GMT'));
1035
  $value = $date->format($format) . 'Z';
1036
  break;
1037
  case self::TYPE_BIT_STRING:
1061
  $bits = implode('', array_pad($bits, $size + $offset + 1, 0));
1062
  $bytes = explode(' ', rtrim(chunk_split($bits, 8, ' ')));
1063
  foreach ($bytes as $byte) {
1064
+ $value .= chr(bindec($byte));
1065
  }
1066
 
1067
  break;
1068
  }
1069
+ // fall-through
1070
  case self::TYPE_OCTET_STRING:
1071
  /* The initial octet shall encode, as an unsigned binary integer with bit 1 as the least significant bit,
1072
  the number of unused bits in the final subsequent octet. The number shall be in the range zero to seven.
1257
  }
1258
  $temp[strlen($temp) - 1] = $temp[strlen($temp) - 1] & chr(0x7F);
1259
  }
1260
+ $value .= $temp;
1261
  }
1262
 
1263
  return $value;
1271
  * @access private
1272
  * @param string $content
1273
  * @param int $tag
1274
+ * @return \DateTime|false
1275
  */
1276
  private static function decodeTime($content, $tag)
1277
  {
1295
  $prefix = substr($content, 0, 2) >= 50 ? '19' : '20';
1296
  $content = $prefix . $content;
1297
  } elseif (strpos($content, '.') !== false) {
1298
+ $format .= '.u';
1299
  }
1300
 
1301
  if ($content[strlen($content) - 1] == 'Z') {
1303
  }
1304
 
1305
  if (strpos($content, '-') !== false || strpos($content, '+') !== false) {
1306
+ $format .= 'O';
1307
  }
1308
 
1309
  // error supression isn't necessary as of PHP 7.0:
1310
  // http://php.net/manual/en/migration70.other-changes.php
1311
+ return @\DateTime::createFromFormat($format, $content);
1312
  }
1313
 
1314
  /**
1335
  */
1336
  public static function loadOIDs($oids)
1337
  {
1338
+ self::$reverseOIDs += $oids;
1339
  self::$oids = array_flip(self::$reverseOIDs);
1340
  }
1341
 
1387
  case $insize == 4:
1388
  $c = ($c << 8) | ord($in[$i++]);
1389
  $c = ($c << 8) | ord($in[$i++]);
1390
+ // fall-through
1391
  case $insize == 2:
1392
  $c = ($c << 8) | ord($in[$i++]);
1393
+ // fall-through
1394
  case $insize == 1:
1395
  break;
1396
  case ($c & 0x80) == 0x00:
1419
  $c >>= 8;
1420
  $v .= chr($c & 0xFF);
1421
  $c >>= 8;
1422
+ // fall-through
1423
  case $outsize == 2:
1424
  $v .= chr($c & 0xFF);
1425
  $c >>= 8;
1426
+ // fall-through
1427
  case $outsize == 1:
1428
  $v .= chr($c & 0xFF);
1429
  $c >>= 8;
1436
  case $c >= 0x04000000:
1437
  $v .= chr(0x80 | ($c & 0x3F));
1438
  $c = ($c >> 6) | 0x04000000;
1439
+ // fall-through
1440
  case $c >= 0x00200000:
1441
  $v .= chr(0x80 | ($c & 0x3F));
1442
  $c = ($c >> 6) | 0x00200000;
1443
+ // fall-through
1444
  case $c >= 0x00010000:
1445
  $v .= chr(0x80 | ($c & 0x3F));
1446
  $c = ($c >> 6) | 0x00010000;
1447
+ // fall-through
1448
  case $c >= 0x00000800:
1449
  $v .= chr(0x80 | ($c & 0x3F));
1450
  $c = ($c >> 6) | 0x00000800;
1451
+ // fall-through
1452
  case $c >= 0x00000080:
1453
  $v .= chr(0x80 | ($c & 0x3F));
1454
  $c = ($c >> 6) | 0x000000C0;
1455
+ // fall-through
1456
  default:
1457
  $v .= chr($c);
1458
  break;
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AccessDescription.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class AccessDescription
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'accessMethod' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
33
  'accessLocation' => GeneralName::MAP
34
  ]
35
  ];
27
  abstract class AccessDescription
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'accessMethod' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
33
  'accessLocation' => GeneralName::MAP
34
  ]
35
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AdministrationDomainName.php CHANGED
@@ -27,13 +27,13 @@ use phpseclib3\File\ASN1;
27
  abstract class AdministrationDomainName
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  // if class isn't present it's assumed to be \phpseclib3\File\ASN1::CLASS_UNIVERSAL or
32
  // (if constant is present) \phpseclib3\File\ASN1::CLASS_CONTEXT_SPECIFIC
33
- 'class' => ASN1::CLASS_APPLICATION,
34
- 'cast' => 2,
35
  'children' => [
36
- 'numeric' => ['type' => ASN1::TYPE_NUMERIC_STRING],
37
  'printable' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
38
  ]
39
  ];
27
  abstract class AdministrationDomainName
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  // if class isn't present it's assumed to be \phpseclib3\File\ASN1::CLASS_UNIVERSAL or
32
  // (if constant is present) \phpseclib3\File\ASN1::CLASS_CONTEXT_SPECIFIC
33
+ 'class' => ASN1::CLASS_APPLICATION,
34
+ 'cast' => 2,
35
  'children' => [
36
+ 'numeric' => ['type' => ASN1::TYPE_NUMERIC_STRING],
37
  'printable' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
38
  ]
39
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AlgorithmIdentifier.php CHANGED
@@ -29,11 +29,11 @@ abstract class AlgorithmIdentifier
29
  const MAP = [
30
  'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'algorithm' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
33
  'parameters' => [
34
- 'type' => ASN1::TYPE_ANY,
35
  'optional' => true
36
- ]
37
  ]
38
  ];
39
  }
29
  const MAP = [
30
  'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'algorithm' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
33
  'parameters' => [
34
+ 'type' => ASN1::TYPE_ANY,
35
  'optional' => true
36
+ ]
37
  ]
38
  ];
39
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AnotherName.php CHANGED
@@ -27,15 +27,15 @@ use phpseclib3\File\ASN1;
27
  abstract class AnotherName
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'type-id' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
33
- 'value' => [
34
- 'type' => ASN1::TYPE_ANY,
35
- 'constant' => 0,
36
- 'optional' => true,
37
- 'explicit' => true
38
- ]
39
  ]
40
  ];
41
  }
27
  abstract class AnotherName
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'type-id' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
33
+ 'value' => [
34
+ 'type' => ASN1::TYPE_ANY,
35
+ 'constant' => 0,
36
+ 'optional' => true,
37
+ 'explicit' => true
38
+ ]
39
  ]
40
  ];
41
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attribute.php CHANGED
@@ -27,14 +27,14 @@ use phpseclib3\File\ASN1;
27
  abstract class Attribute
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'type' => AttributeType::MAP,
33
- 'value'=> [
34
- 'type' => ASN1::TYPE_SET,
35
- 'min' => 1,
36
- 'max' => -1,
37
- 'children' => AttributeValue::MAP
38
  ]
39
  ]
40
  ];
27
  abstract class Attribute
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'type' => AttributeType::MAP,
33
+ 'value' => [
34
+ 'type' => ASN1::TYPE_SET,
35
+ 'min' => 1,
36
+ 'max' => -1,
37
+ 'children' => AttributeValue::MAP
38
  ]
39
  ]
40
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AttributeTypeAndValue.php CHANGED
@@ -27,10 +27,10 @@ use phpseclib3\File\ASN1;
27
  abstract class AttributeTypeAndValue
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'type' => AttributeType::MAP,
33
- 'value'=> AttributeValue::MAP
34
  ]
35
  ];
36
  }
27
  abstract class AttributeTypeAndValue
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'type' => AttributeType::MAP,
33
+ 'value' => AttributeValue::MAP
34
  ]
35
  ];
36
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Attributes.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class Attributes
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SET,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => Attribute::MAP
34
  ];
35
  }
27
  abstract class Attributes
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SET,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => Attribute::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityInfoAccessSyntax.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class AuthorityInfoAccessSyntax
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => AccessDescription::MAP
34
  ];
35
  }
27
  abstract class AuthorityInfoAccessSyntax
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => AccessDescription::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/AuthorityKeyIdentifier.php CHANGED
@@ -27,23 +27,23 @@ use phpseclib3\File\ASN1;
27
  abstract class AuthorityKeyIdentifier
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'keyIdentifier' => [
33
- 'constant' => 0,
34
- 'optional' => true,
35
- 'implicit' => true
36
- ] + KeyIdentifier::MAP,
37
- 'authorityCertIssuer' => [
38
- 'constant' => 1,
39
- 'optional' => true,
40
- 'implicit' => true
41
- ] + GeneralNames::MAP,
42
  'authorityCertSerialNumber' => [
43
- 'constant' => 2,
44
- 'optional' => true,
45
- 'implicit' => true
46
- ] + CertificateSerialNumber::MAP
47
  ]
48
  ];
49
  }
27
  abstract class AuthorityKeyIdentifier
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'keyIdentifier' => [
33
+ 'constant' => 0,
34
+ 'optional' => true,
35
+ 'implicit' => true
36
+ ] + KeyIdentifier::MAP,
37
+ 'authorityCertIssuer' => [
38
+ 'constant' => 1,
39
+ 'optional' => true,
40
+ 'implicit' => true
41
+ ] + GeneralNames::MAP,
42
  'authorityCertSerialNumber' => [
43
+ 'constant' => 2,
44
+ 'optional' => true,
45
+ 'implicit' => true
46
+ ] + CertificateSerialNumber::MAP
47
  ]
48
  ];
49
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BasicConstraints.php CHANGED
@@ -27,17 +27,17 @@ use phpseclib3\File\ASN1;
27
  abstract class BasicConstraints
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'cA' => [
33
- 'type' => ASN1::TYPE_BOOLEAN,
34
- 'optional' => true,
35
- 'default' => false
36
- ],
37
  'pathLenConstraint' => [
38
- 'type' => ASN1::TYPE_INTEGER,
39
- 'optional' => true
40
- ]
41
  ]
42
  ];
43
  }
27
  abstract class BasicConstraints
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'cA' => [
33
+ 'type' => ASN1::TYPE_BOOLEAN,
34
+ 'optional' => true,
35
+ 'default' => false
36
+ ],
37
  'pathLenConstraint' => [
38
+ 'type' => ASN1::TYPE_INTEGER,
39
+ 'optional' => true
40
+ ]
41
  ]
42
  ];
43
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttribute.php CHANGED
@@ -27,10 +27,10 @@ use phpseclib3\File\ASN1;
27
  abstract class BuiltInDomainDefinedAttribute
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'type' => ['type' => ASN1::TYPE_PRINTABLE_STRING],
33
- 'value' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
34
  ]
35
  ];
36
  }
27
  abstract class BuiltInDomainDefinedAttribute
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'type' => ['type' => ASN1::TYPE_PRINTABLE_STRING],
33
+ 'value' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
34
  ]
35
  ];
36
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInDomainDefinedAttributes.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class BuiltInDomainDefinedAttributes
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => 4, // ub-domain-defined-attributes
33
  'children' => BuiltInDomainDefinedAttribute::MAP
34
  ];
35
  }
27
  abstract class BuiltInDomainDefinedAttributes
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => 4, // ub-domain-defined-attributes
33
  'children' => BuiltInDomainDefinedAttribute::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/BuiltInStandardAttributes.php CHANGED
@@ -27,45 +27,45 @@ use phpseclib3\File\ASN1;
27
  abstract class BuiltInStandardAttributes
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'country-name' => ['optional' => true] + CountryName::MAP,
33
  'administration-domain-name' => ['optional' => true] + AdministrationDomainName::MAP,
34
- 'network-address' => [
35
- 'constant' => 0,
36
- 'optional' => true,
37
- 'implicit' => true
38
- ] + NetworkAddress::MAP,
39
- 'terminal-identifier' => [
40
- 'constant' => 1,
41
- 'optional' => true,
42
- 'implicit' => true
43
- ] + TerminalIdentifier::MAP,
44
- 'private-domain-name' => [
45
- 'constant' => 2,
46
- 'optional' => true,
47
- 'explicit' => true
48
- ] + PrivateDomainName::MAP,
49
- 'organization-name' => [
50
- 'constant' => 3,
51
- 'optional' => true,
52
- 'implicit' => true
53
- ] + OrganizationName::MAP,
54
- 'numeric-user-identifier' => [
55
- 'constant' => 4,
56
- 'optional' => true,
57
- 'implicit' => true
58
- ] + NumericUserIdentifier::MAP,
59
- 'personal-name' => [
60
- 'constant' => 5,
61
- 'optional' => true,
62
- 'implicit' => true
63
- ] + PersonalName::MAP,
64
- 'organizational-unit-names' => [
65
- 'constant' => 6,
66
- 'optional' => true,
67
- 'implicit' => true
68
- ] + OrganizationalUnitNames::MAP
69
  ]
70
  ];
71
  }
27
  abstract class BuiltInStandardAttributes
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'country-name' => ['optional' => true] + CountryName::MAP,
33
  'administration-domain-name' => ['optional' => true] + AdministrationDomainName::MAP,
34
+ 'network-address' => [
35
+ 'constant' => 0,
36
+ 'optional' => true,
37
+ 'implicit' => true
38
+ ] + NetworkAddress::MAP,
39
+ 'terminal-identifier' => [
40
+ 'constant' => 1,
41
+ 'optional' => true,
42
+ 'implicit' => true
43
+ ] + TerminalIdentifier::MAP,
44
+ 'private-domain-name' => [
45
+ 'constant' => 2,
46
+ 'optional' => true,
47
+ 'explicit' => true
48
+ ] + PrivateDomainName::MAP,
49
+ 'organization-name' => [
50
+ 'constant' => 3,
51
+ 'optional' => true,
52
+ 'implicit' => true
53
+ ] + OrganizationName::MAP,
54
+ 'numeric-user-identifier' => [
55
+ 'constant' => 4,
56
+ 'optional' => true,
57
+ 'implicit' => true
58
+ ] + NumericUserIdentifier::MAP,
59
+ 'personal-name' => [
60
+ 'constant' => 5,
61
+ 'optional' => true,
62
+ 'implicit' => true
63
+ ] + PersonalName::MAP,
64
+ 'organizational-unit-names' => [
65
+ 'constant' => 6,
66
+ 'optional' => true,
67
+ 'implicit' => true
68
+ ] + OrganizationalUnitNames::MAP
69
  ]
70
  ];
71
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLDistributionPoints.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class CRLDistributionPoints
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => DistributionPoint::MAP
34
  ];
35
  }
27
  abstract class CRLDistributionPoints
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => DistributionPoint::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CRLReason.php CHANGED
@@ -29,17 +29,17 @@ abstract class CRLReason
29
  const MAP = [
30
  'type' => ASN1::TYPE_ENUMERATED,
31
  'mapping' => [
32
- 'unspecified',
33
- 'keyCompromise',
34
- 'cACompromise',
35
- 'affiliationChanged',
36
- 'superseded',
37
- 'cessationOfOperation',
38
- 'certificateHold',
39
- // Value 7 is not used.
40
- 8 => 'removeFromCRL',
41
- 'privilegeWithdrawn',
42
- 'aACompromise'
43
  ]
44
  ];
45
  }
29
  const MAP = [
30
  'type' => ASN1::TYPE_ENUMERATED,
31
  'mapping' => [
32
+ 'unspecified',
33
+ 'keyCompromise',
34
+ 'cACompromise',
35
+ 'affiliationChanged',
36
+ 'superseded',
37
+ 'cessationOfOperation',
38
+ 'certificateHold',
39
+ // Value 7 is not used.
40
+ 8 => 'removeFromCRL',
41
+ 'privilegeWithdrawn',
42
+ 'aACompromise'
43
  ]
44
  ];
45
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Certificate.php CHANGED
@@ -27,11 +27,11 @@ use phpseclib3\File\ASN1;
27
  abstract class Certificate
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'tbsCertificate' => TBSCertificate::MAP,
33
- 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
34
- 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
35
  ]
36
  ];
37
  }
27
  abstract class Certificate
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'tbsCertificate' => TBSCertificate::MAP,
33
+ 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
34
+ 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
35
  ]
36
  ];
37
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificateList.php CHANGED
@@ -27,11 +27,11 @@ use phpseclib3\File\ASN1;
27
  abstract class CertificateList
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'tbsCertList' => TBSCertList::MAP,
33
  'signatureAlgorithm' => AlgorithmIdentifier::MAP,
34
- 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
35
  ]
36
  ];
37
  }
27
  abstract class CertificateList
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'tbsCertList' => TBSCertList::MAP,
33
  'signatureAlgorithm' => AlgorithmIdentifier::MAP,
34
+ 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
35
  ]
36
  ];
37
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificatePolicies.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class CertificatePolicies
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => PolicyInformation::MAP
34
  ];
35
  }
27
  abstract class CertificatePolicies
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => PolicyInformation::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequest.php CHANGED
@@ -27,11 +27,11 @@ use phpseclib3\File\ASN1;
27
  abstract class CertificationRequest
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'certificationRequestInfo' => CertificationRequestInfo::MAP,
33
- 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
34
- 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
35
  ]
36
  ];
37
  }
27
  abstract class CertificationRequest
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'certificationRequestInfo' => CertificationRequestInfo::MAP,
33
+ 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
34
+ 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
35
  ]
36
  ];
37
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CertificationRequestInfo.php CHANGED
@@ -27,19 +27,19 @@ use phpseclib3\File\ASN1;
27
  abstract class CertificationRequestInfo
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'version' => [
33
- 'type' => ASN1::TYPE_INTEGER,
34
- 'mapping' => ['v1']
35
- ],
36
- 'subject' => Name::MAP,
37
  'subjectPKInfo' => SubjectPublicKeyInfo::MAP,
38
- 'attributes' => [
39
- 'constant' => 0,
40
- 'optional' => true,
41
- 'implicit' => true
42
- ] + Attributes::MAP,
43
  ]
44
  ];
45
  }
27
  abstract class CertificationRequestInfo
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'version' => [
33
+ 'type' => ASN1::TYPE_INTEGER,
34
+ 'mapping' => ['v1']
35
+ ],
36
+ 'subject' => Name::MAP,
37
  'subjectPKInfo' => SubjectPublicKeyInfo::MAP,
38
+ 'attributes' => [
39
+ 'constant' => 0,
40
+ 'optional' => true,
41
+ 'implicit' => true
42
+ ] + Attributes::MAP,
43
  ]
44
  ];
45
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Characteristic_two.php CHANGED
@@ -37,4 +37,4 @@ abstract class Characteristic_two
37
  ]
38
  ]
39
  ];
40
- }
37
  ]
38
  ]
39
  ];
40
+ }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/CountryName.php CHANGED
@@ -27,13 +27,13 @@ use phpseclib3\File\ASN1;
27
  abstract class CountryName
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  // if class isn't present it's assumed to be \phpseclib3\File\ASN1::CLASS_UNIVERSAL or
32
  // (if constant is present) \phpseclib3\File\ASN1::CLASS_CONTEXT_SPECIFIC
33
- 'class' => ASN1::CLASS_APPLICATION,
34
- 'cast' => 1,
35
  'children' => [
36
- 'x121-dcc-code' => ['type' => ASN1::TYPE_NUMERIC_STRING],
37
  'iso-3166-alpha2-code' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
38
  ]
39
  ];
27
  abstract class CountryName
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  // if class isn't present it's assumed to be \phpseclib3\File\ASN1::CLASS_UNIVERSAL or
32
  // (if constant is present) \phpseclib3\File\ASN1::CLASS_CONTEXT_SPECIFIC
33
+ 'class' => ASN1::CLASS_APPLICATION,
34
+ 'cast' => 1,
35
  'children' => [
36
+ 'x121-dcc-code' => ['type' => ASN1::TYPE_NUMERIC_STRING],
37
  'iso-3166-alpha2-code' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
38
  ]
39
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DHParameter.php CHANGED
@@ -32,7 +32,7 @@ abstract class DHParameter
32
  'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'prime' => ['type' => ASN1::TYPE_INTEGER],
35
- 'base' => ['type' => ASN1::TYPE_INTEGER],
36
  'privateValueLength' => [
37
  'type' => ASN1::TYPE_INTEGER,
38
  'optional' => true
32
  'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'prime' => ['type' => ASN1::TYPE_INTEGER],
35
+ 'base' => ['type' => ASN1::TYPE_INTEGER],
36
  'privateValueLength' => [
37
  'type' => ASN1::TYPE_INTEGER,
38
  'optional' => true
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DSAPrivateKey.php CHANGED
@@ -37,4 +37,4 @@ abstract class DSAPrivateKey
37
  'x' => ['type' => ASN1::TYPE_INTEGER]
38
  ]
39
  ];
40
- }
37
  'x' => ['type' => ASN1::TYPE_INTEGER]
38
  ]
39
  ];
40
+ }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DigestInfo.php CHANGED
@@ -29,7 +29,7 @@ use phpseclib3\File\ASN1;
29
  abstract class DigestInfo
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'digestAlgorithm' => AlgorithmIdentifier::MAP,
35
  'digest' => ['type' => ASN1::TYPE_OCTET_STRING]
29
  abstract class DigestInfo
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'digestAlgorithm' => AlgorithmIdentifier::MAP,
35
  'digest' => ['type' => ASN1::TYPE_OCTET_STRING]
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DirectoryString.php CHANGED
@@ -27,13 +27,13 @@ use phpseclib3\File\ASN1;
27
  abstract class DirectoryString
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
- 'teletexString' => ['type' => ASN1::TYPE_TELETEX_STRING],
33
  'printableString' => ['type' => ASN1::TYPE_PRINTABLE_STRING],
34
  'universalString' => ['type' => ASN1::TYPE_UNIVERSAL_STRING],
35
- 'utf8String' => ['type' => ASN1::TYPE_UTF8_STRING],
36
- 'bmpString' => ['type' => ASN1::TYPE_BMP_STRING]
37
  ]
38
  ];
39
  }
27
  abstract class DirectoryString
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
+ 'teletexString' => ['type' => ASN1::TYPE_TELETEX_STRING],
33
  'printableString' => ['type' => ASN1::TYPE_PRINTABLE_STRING],
34
  'universalString' => ['type' => ASN1::TYPE_UNIVERSAL_STRING],
35
+ 'utf8String' => ['type' => ASN1::TYPE_UTF8_STRING],
36
+ 'bmpString' => ['type' => ASN1::TYPE_BMP_STRING]
37
  ]
38
  ];
39
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DisplayText.php CHANGED
@@ -27,12 +27,12 @@ use phpseclib3\File\ASN1;
27
  abstract class DisplayText
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
- 'ia5String' => ['type' => ASN1::TYPE_IA5_STRING],
33
  'visibleString' => ['type' => ASN1::TYPE_VISIBLE_STRING],
34
- 'bmpString' => ['type' => ASN1::TYPE_BMP_STRING],
35
- 'utf8String' => ['type' => ASN1::TYPE_UTF8_STRING]
36
  ]
37
  ];
38
  }
27
  abstract class DisplayText
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
+ 'ia5String' => ['type' => ASN1::TYPE_IA5_STRING],
33
  'visibleString' => ['type' => ASN1::TYPE_VISIBLE_STRING],
34
+ 'bmpString' => ['type' => ASN1::TYPE_BMP_STRING],
35
+ 'utf8String' => ['type' => ASN1::TYPE_UTF8_STRING]
36
  ]
37
  ];
38
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPoint.php CHANGED
@@ -27,23 +27,23 @@ use phpseclib3\File\ASN1;
27
  abstract class DistributionPoint
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'distributionPoint' => [
33
- 'constant' => 0,
34
- 'optional' => true,
35
- 'explicit' => true
36
- ] + DistributionPointName::MAP,
37
- 'reasons' => [
38
- 'constant' => 1,
39
- 'optional' => true,
40
- 'implicit' => true
41
- ] + ReasonFlags::MAP,
42
- 'cRLIssuer' => [
43
- 'constant' => 2,
44
- 'optional' => true,
45
- 'implicit' => true
46
- ] + GeneralNames::MAP
47
  ]
48
  ];
49
  }
27
  abstract class DistributionPoint
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'distributionPoint' => [
33
+ 'constant' => 0,
34
+ 'optional' => true,
35
+ 'explicit' => true
36
+ ] + DistributionPointName::MAP,
37
+ 'reasons' => [
38
+ 'constant' => 1,
39
+ 'optional' => true,
40
+ 'implicit' => true
41
+ ] + ReasonFlags::MAP,
42
+ 'cRLIssuer' => [
43
+ 'constant' => 2,
44
+ 'optional' => true,
45
+ 'implicit' => true
46
+ ] + GeneralNames::MAP
47
  ]
48
  ];
49
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DistributionPointName.php CHANGED
@@ -27,18 +27,18 @@ use phpseclib3\File\ASN1;
27
  abstract class DistributionPointName
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
- 'fullName' => [
33
- 'constant' => 0,
34
- 'optional' => true,
35
- 'implicit' => true
36
- ] + GeneralNames::MAP,
37
  'nameRelativeToCRLIssuer' => [
38
- 'constant' => 1,
39
- 'optional' => true,
40
- 'implicit' => true
41
- ] + RelativeDistinguishedName::MAP
42
  ]
43
  ];
44
  }
27
  abstract class DistributionPointName
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
+ 'fullName' => [
33
+ 'constant' => 0,
34
+ 'optional' => true,
35
+ 'implicit' => true
36
+ ] + GeneralNames::MAP,
37
  'nameRelativeToCRLIssuer' => [
38
+ 'constant' => 1,
39
+ 'optional' => true,
40
+ 'implicit' => true
41
+ ] + RelativeDistinguishedName::MAP
42
  ]
43
  ];
44
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/DssSigValue.php CHANGED
@@ -27,7 +27,7 @@ use phpseclib3\File\ASN1;
27
  abstract class DssSigValue
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'r' => ['type' => ASN1::TYPE_INTEGER],
33
  's' => ['type' => ASN1::TYPE_INTEGER]
27
  abstract class DssSigValue
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'r' => ['type' => ASN1::TYPE_INTEGER],
33
  's' => ['type' => ASN1::TYPE_INTEGER]
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ECParameters.php CHANGED
@@ -39,7 +39,7 @@ use phpseclib3\File\ASN1;
39
  abstract class ECParameters
40
  {
41
  const MAP = [
42
- 'type' => ASN1::TYPE_CHOICE,
43
  'children' => [
44
  'namedCurve' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
45
  'implicitCurve' => ['type' => ASN1::TYPE_NULL],
39
  abstract class ECParameters
40
  {
41
  const MAP = [
42
+ 'type' => ASN1::TYPE_CHOICE,
43
  'children' => [
44
  'namedCurve' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
45
  'implicitCurve' => ['type' => ASN1::TYPE_NULL],
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EDIPartyName.php CHANGED
@@ -27,20 +27,20 @@ use phpseclib3\File\ASN1;
27
  abstract class EDIPartyName
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'nameAssigner' => [
33
- 'constant' => 0,
34
- 'optional' => true,
35
- 'implicit' => true
36
- ] + DirectoryString::MAP,
37
- // partyName is technically required but \phpseclib3\File\ASN1 doesn't currently support non-optional constants and
38
- // setting it to optional gets the job done in any event.
39
- 'partyName' => [
40
- 'constant' => 1,
41
- 'optional' => true,
42
- 'implicit' => true
43
- ] + DirectoryString::MAP
44
  ]
45
  ];
46
  }
27
  abstract class EDIPartyName
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'nameAssigner' => [
33
+ 'constant' => 0,
34
+ 'optional' => true,
35
+ 'implicit' => true
36
+ ] + DirectoryString::MAP,
37
+ // partyName is technically required but \phpseclib3\File\ASN1 doesn't currently support non-optional constants and
38
+ // setting it to optional gets the job done in any event.
39
+ 'partyName' => [
40
+ 'constant' => 1,
41
+ 'optional' => true,
42
+ 'implicit' => true
43
+ ] + DirectoryString::MAP
44
  ]
45
  ];
46
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EcdsaSigValue.php CHANGED
@@ -27,7 +27,7 @@ use phpseclib3\File\ASN1;
27
  abstract class EcdsaSigValue
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'r' => ['type' => ASN1::TYPE_INTEGER],
33
  's' => ['type' => ASN1::TYPE_INTEGER]
27
  abstract class EcdsaSigValue
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'r' => ['type' => ASN1::TYPE_INTEGER],
33
  's' => ['type' => ASN1::TYPE_INTEGER]
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/EncryptedPrivateKeyInfo.php CHANGED
@@ -27,10 +27,10 @@ use phpseclib3\File\ASN1;
27
  abstract class EncryptedPrivateKeyInfo
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'encryptionAlgorithm' => AlgorithmIdentifier::MAP,
33
- 'encryptedData' => EncryptedData::MAP
34
  ]
35
  ];
36
  }
27
  abstract class EncryptedPrivateKeyInfo
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'encryptionAlgorithm' => AlgorithmIdentifier::MAP,
33
+ 'encryptedData' => EncryptedData::MAP
34
  ]
35
  ];
36
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtKeyUsageSyntax.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class ExtKeyUsageSyntax
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => KeyPurposeId::MAP
34
  ];
35
  }
27
  abstract class ExtKeyUsageSyntax
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => KeyPurposeId::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extension.php CHANGED
@@ -33,14 +33,14 @@ use phpseclib3\File\ASN1;
33
  abstract class Extension
34
  {
35
  const MAP = [
36
- 'type' => ASN1::TYPE_SEQUENCE,
37
  'children' => [
38
- 'extnId' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
39
  'critical' => [
40
- 'type' => ASN1::TYPE_BOOLEAN,
41
- 'optional' => true,
42
- 'default' => false
43
- ],
44
  'extnValue' => ['type' => ASN1::TYPE_OCTET_STRING]
45
  ]
46
  ];
33
  abstract class Extension
34
  {
35
  const MAP = [
36
+ 'type' => ASN1::TYPE_SEQUENCE,
37
  'children' => [
38
+ 'extnId' => ['type' => ASN1::TYPE_OBJECT_IDENTIFIER],
39
  'critical' => [
40
+ 'type' => ASN1::TYPE_BOOLEAN,
41
+ 'optional' => true,
42
+ 'default' => false
43
+ ],
44
  'extnValue' => ['type' => ASN1::TYPE_OCTET_STRING]
45
  ]
46
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttribute.php CHANGED
@@ -27,20 +27,20 @@ use phpseclib3\File\ASN1;
27
  abstract class ExtensionAttribute
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'extension-attribute-type' => [
33
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
34
- 'constant' => 0,
35
- 'optional' => true,
36
- 'implicit' => true
37
- ],
38
- 'extension-attribute-value' => [
39
- 'type' => ASN1::TYPE_ANY,
40
- 'constant' => 1,
41
- 'optional' => true,
42
- 'explicit' => true
43
- ]
44
  ]
45
  ];
46
  }
27
  abstract class ExtensionAttribute
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'extension-attribute-type' => [
33
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
34
+ 'constant' => 0,
35
+ 'optional' => true,
36
+ 'implicit' => true
37
+ ],
38
+ 'extension-attribute-value' => [
39
+ 'type' => ASN1::TYPE_ANY,
40
+ 'constant' => 1,
41
+ 'optional' => true,
42
+ 'explicit' => true
43
+ ]
44
  ]
45
  ];
46
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ExtensionAttributes.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class ExtensionAttributes
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SET,
31
- 'min' => 1,
32
- 'max' => 256, // ub-extension-attributes
33
  'children' => ExtensionAttribute::MAP
34
  ];
35
  }
27
  abstract class ExtensionAttributes
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SET,
31
+ 'min' => 1,
32
+ 'max' => 256, // ub-extension-attributes
33
  'children' => ExtensionAttribute::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Extensions.php CHANGED
@@ -27,10 +27,10 @@ use phpseclib3\File\ASN1;
27
  abstract class Extensions
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
  // technically, it's MAX, but we'll assume anything < 0 is MAX
33
- 'max' => -1,
34
  // if 'children' isn't an array then 'min' and 'max' must be defined
35
  'children' => Extension::MAP
36
  ];
27
  abstract class Extensions
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
  // technically, it's MAX, but we'll assume anything < 0 is MAX
33
+ 'max' => -1,
34
  // if 'children' isn't an array then 'min' and 'max' must be defined
35
  'children' => Extension::MAP
36
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/FieldID.php CHANGED
@@ -36,4 +36,4 @@ abstract class FieldID
36
  ]
37
  ]
38
  ];
39
- }
36
  ]
37
  ]
38
  ];
39
+ }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralName.php CHANGED
@@ -27,58 +27,58 @@ use phpseclib3\File\ASN1;
27
  abstract class GeneralName
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
- 'otherName' => [
33
- 'constant' => 0,
34
- 'optional' => true,
35
- 'implicit' => true
36
- ] + AnotherName::MAP,
37
- 'rfc822Name' => [
38
- 'type' => ASN1::TYPE_IA5_STRING,
39
- 'constant' => 1,
40
- 'optional' => true,
41
- 'implicit' => true
42
- ],
43
- 'dNSName' => [
44
- 'type' => ASN1::TYPE_IA5_STRING,
45
- 'constant' => 2,
46
- 'optional' => true,
47
- 'implicit' => true
48
- ],
49
- 'x400Address' => [
50
- 'constant' => 3,
51
- 'optional' => true,
52
- 'implicit' => true
53
- ] + ORAddress::MAP,
54
- 'directoryName' => [
55
- 'constant' => 4,
56
- 'optional' => true,
57
- 'explicit' => true
58
- ] + Name::MAP,
59
- 'ediPartyName' => [
60
- 'constant' => 5,
61
- 'optional' => true,
62
- 'implicit' => true
63
- ] + EDIPartyName::MAP,
64
  'uniformResourceIdentifier' => [
65
- 'type' => ASN1::TYPE_IA5_STRING,
66
- 'constant' => 6,
67
- 'optional' => true,
68
- 'implicit' => true
69
- ],
70
- 'iPAddress' => [
71
- 'type' => ASN1::TYPE_OCTET_STRING,
72
- 'constant' => 7,
73
- 'optional' => true,
74
- 'implicit' => true
75
- ],
76
- 'registeredID' => [
77
- 'type' => ASN1::TYPE_OBJECT_IDENTIFIER,
78
- 'constant' => 8,
79
- 'optional' => true,
80
- 'implicit' => true
81
- ]
82
  ]
83
  ];
84
  }
27
  abstract class GeneralName
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
+ 'otherName' => [
33
+ 'constant' => 0,
34
+ 'optional' => true,
35
+ 'implicit' => true
36
+ ] + AnotherName::MAP,
37
+ 'rfc822Name' => [
38
+ 'type' => ASN1::TYPE_IA5_STRING,
39
+ 'constant' => 1,
40
+ 'optional' => true,
41
+ 'implicit' => true
42
+ ],
43
+ 'dNSName' => [
44
+ 'type' => ASN1::TYPE_IA5_STRING,
45
+ 'constant' => 2,
46
+ 'optional' => true,
47
+ 'implicit' => true
48
+ ],
49
+ 'x400Address' => [
50
+ 'constant' => 3,
51
+ 'optional' => true,
52
+ 'implicit' => true
53
+ ] + ORAddress::MAP,
54
+ 'directoryName' => [
55
+ 'constant' => 4,
56
+ 'optional' => true,
57
+ 'explicit' => true
58
+ ] + Name::MAP,
59
+ 'ediPartyName' => [
60
+ 'constant' => 5,
61
+ 'optional' => true,
62
+ 'implicit' => true
63
+ ] + EDIPartyName::MAP,
64
  'uniformResourceIdentifier' => [
65
+ 'type' => ASN1::TYPE_IA5_STRING,
66
+ 'constant' => 6,
67
+ 'optional' => true,
68
+ 'implicit' => true
69
+ ],
70
+ 'iPAddress' => [
71
+ 'type' => ASN1::TYPE_OCTET_STRING,
72
+ 'constant' => 7,
73
+ 'optional' => true,
74
+ 'implicit' => true
75
+ ],
76
+ 'registeredID' => [
77
+ 'type' => ASN1::TYPE_OBJECT_IDENTIFIER,
78
+ 'constant' => 8,
79
+ 'optional' => true,
80
+ 'implicit' => true
81
+ ]
82
  ]
83
  ];
84
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralNames.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class GeneralNames
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => GeneralName::MAP
34
  ];
35
  }
27
  abstract class GeneralNames
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => GeneralName::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtree.php CHANGED
@@ -27,20 +27,20 @@ use phpseclib3\File\ASN1;
27
  abstract class GeneralSubtree
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'base' => GeneralName::MAP,
33
  'minimum' => [
34
- 'constant' => 0,
35
- 'optional' => true,
36
- 'implicit' => true,
37
- 'default' => '0'
38
- ] + BaseDistance::MAP,
39
  'maximum' => [
40
- 'constant' => 1,
41
- 'optional' => true,
42
- 'implicit' => true,
43
- ] + BaseDistance::MAP
44
  ]
45
  ];
46
  }
27
  abstract class GeneralSubtree
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'base' => GeneralName::MAP,
33
  'minimum' => [
34
+ 'constant' => 0,
35
+ 'optional' => true,
36
+ 'implicit' => true,
37
+ 'default' => '0'
38
+ ] + BaseDistance::MAP,
39
  'maximum' => [
40
+ 'constant' => 1,
41
+ 'optional' => true,
42
+ 'implicit' => true,
43
+ ] + BaseDistance::MAP
44
  ]
45
  ];
46
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/GeneralSubtrees.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class GeneralSubtrees
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => GeneralSubtree::MAP
34
  ];
35
  }
27
  abstract class GeneralSubtrees
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => GeneralSubtree::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/HashAlgorithm.php CHANGED
@@ -27,4 +27,4 @@ use phpseclib3\File\ASN1;
27
  abstract class HashAlgorithm
28
  {
29
  const MAP = AlgorithmIdentifier::MAP;
30
- }
27
  abstract class HashAlgorithm
28
  {
29
  const MAP = AlgorithmIdentifier::MAP;
30
+ }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/IssuingDistributionPoint.php CHANGED
@@ -29,44 +29,44 @@ abstract class IssuingDistributionPoint
29
  const MAP = [
30
  'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'distributionPoint' => [
33
- 'constant' => 0,
34
- 'optional' => true,
35
- 'explicit' => true
36
- ] + DistributionPointName::MAP,
37
- 'onlyContainsUserCerts' => [
38
- 'type' => ASN1::TYPE_BOOLEAN,
39
- 'constant' => 1,
40
- 'optional' => true,
41
- 'default' => false,
42
- 'implicit' => true
43
- ],
44
- 'onlyContainsCACerts' => [
45
- 'type' => ASN1::TYPE_BOOLEAN,
46
- 'constant' => 2,
47
- 'optional' => true,
48
- 'default' => false,
49
- 'implicit' => true
50
- ],
51
- 'onlySomeReasons' => [
52
- 'constant' => 3,
53
- 'optional' => true,
54
- 'implicit' => true
55
- ] + ReasonFlags::MAP,
56
- 'indirectCRL' => [
57
- 'type' => ASN1::TYPE_BOOLEAN,
58
- 'constant' => 4,
59
- 'optional' => true,
60
- 'default' => false,
61
- 'implicit' => true
62
- ],
63
- 'onlyContainsAttributeCerts' =>[
64
- 'type' => ASN1::TYPE_BOOLEAN,
65
- 'constant' => 5,
66
- 'optional' => true,
67
- 'default' => false,
68
- 'implicit' => true
69
- ]
70
- ]
71
  ];
72
  }
29
  const MAP = [
30
  'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'distributionPoint' => [
33
+ 'constant' => 0,
34
+ 'optional' => true,
35
+ 'explicit' => true
36
+ ] + DistributionPointName::MAP,
37
+ 'onlyContainsUserCerts' => [
38
+ 'type' => ASN1::TYPE_BOOLEAN,
39
+ 'constant' => 1,
40
+ 'optional' => true,
41
+ 'default' => false,
42
+ 'implicit' => true
43
+ ],
44
+ 'onlyContainsCACerts' => [
45
+ 'type' => ASN1::TYPE_BOOLEAN,
46
+ 'constant' => 2,
47
+ 'optional' => true,
48
+ 'default' => false,
49
+ 'implicit' => true
50
+ ],
51
+ 'onlySomeReasons' => [
52
+ 'constant' => 3,
53
+ 'optional' => true,
54
+ 'implicit' => true
55
+ ] + ReasonFlags::MAP,
56
+ 'indirectCRL' => [
57
+ 'type' => ASN1::TYPE_BOOLEAN,
58
+ 'constant' => 4,
59
+ 'optional' => true,
60
+ 'default' => false,
61
+ 'implicit' => true
62
+ ],
63
+ 'onlyContainsAttributeCerts' => [
64
+ 'type' => ASN1::TYPE_BOOLEAN,
65
+ 'constant' => 5,
66
+ 'optional' => true,
67
+ 'default' => false,
68
+ 'implicit' => true
69
+ ]
70
+ ]
71
  ];
72
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/KeyUsage.php CHANGED
@@ -27,7 +27,7 @@ use phpseclib3\File\ASN1;
27
  abstract class KeyUsage
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_BIT_STRING,
31
  'mapping' => [
32
  'digitalSignature',
33
  'nonRepudiation',
27
  abstract class KeyUsage
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_BIT_STRING,
31
  'mapping' => [
32
  'digitalSignature',
33
  'nonRepudiation',
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/MaskGenAlgorithm.php CHANGED
@@ -27,4 +27,4 @@ use phpseclib3\File\ASN1;
27
  abstract class MaskGenAlgorithm
28
  {
29
  const MAP = AlgorithmIdentifier::MAP;
30
- }
27
  abstract class MaskGenAlgorithm
28
  {
29
  const MAP = AlgorithmIdentifier::MAP;
30
+ }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Name.php CHANGED
@@ -27,7 +27,7 @@ use phpseclib3\File\ASN1;
27
  abstract class Name
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
  'rdnSequence' => RDNSequence::MAP
33
  ]
27
  abstract class Name
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
  'rdnSequence' => RDNSequence::MAP
33
  ]
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NameConstraints.php CHANGED
@@ -27,18 +27,18 @@ use phpseclib3\File\ASN1;
27
  abstract class NameConstraints
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'permittedSubtrees' => [
33
- 'constant' => 0,
34
- 'optional' => true,
35
- 'implicit' => true
36
- ] + GeneralSubtrees::MAP,
37
- 'excludedSubtrees' => [
38
- 'constant' => 1,
39
- 'optional' => true,
40
- 'implicit' => true
41
- ] + GeneralSubtrees::MAP
42
  ]
43
  ];
44
  }
27
  abstract class NameConstraints
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'permittedSubtrees' => [
33
+ 'constant' => 0,
34
+ 'optional' => true,
35
+ 'implicit' => true
36
+ ] + GeneralSubtrees::MAP,
37
+ 'excludedSubtrees' => [
38
+ 'constant' => 1,
39
+ 'optional' => true,
40
+ 'implicit' => true
41
+ ] + GeneralSubtrees::MAP
42
  ]
43
  ];
44
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/NoticeReference.php CHANGED
@@ -27,15 +27,15 @@ use phpseclib3\File\ASN1;
27
  abstract class NoticeReference
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'organization' => DisplayText::MAP,
33
  'noticeNumbers' => [
34
- 'type' => ASN1::TYPE_SEQUENCE,
35
- 'min' => 1,
36
- 'max' => 200,
37
- 'children' => ['type' => ASN1::TYPE_INTEGER]
38
- ]
39
  ]
40
  ];
41
  }
27
  abstract class NoticeReference
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'organization' => DisplayText::MAP,
33
  'noticeNumbers' => [
34
+ 'type' => ASN1::TYPE_SEQUENCE,
35
+ 'min' => 1,
36
+ 'max' => 200,
37
+ 'children' => ['type' => ASN1::TYPE_INTEGER]
38
+ ]
39
  ]
40
  ];
41
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ORAddress.php CHANGED
@@ -27,11 +27,11 @@ use phpseclib3\File\ASN1;
27
  abstract class ORAddress
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'built-in-standard-attributes' => BuiltInStandardAttributes::MAP,
33
- 'built-in-domain-defined-attributes' => ['optional' => true] + BuiltInDomainDefinedAttributes::MAP,
34
- 'extension-attributes' => ['optional' => true] + ExtensionAttributes::MAP
35
  ]
36
  ];
37
  }
27
  abstract class ORAddress
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'built-in-standard-attributes' => BuiltInStandardAttributes::MAP,
33
+ 'built-in-domain-defined-attributes' => ['optional' => true] + BuiltInDomainDefinedAttributes::MAP,
34
+ 'extension-attributes' => ['optional' => true] + ExtensionAttributes::MAP
35
  ]
36
  ];
37
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OneAsymmetricKey.php CHANGED
@@ -29,13 +29,13 @@ use phpseclib3\File\ASN1;
29
  abstract class OneAsymmetricKey
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'version' => [
35
  'type' => ASN1::TYPE_INTEGER,
36
  'mapping' => ['v1', 'v2']
37
  ],
38
- 'privateKeyAlgorithm'=> AlgorithmIdentifier::MAP,
39
  'privateKey' => PrivateKey::MAP,
40
  'attributes' => [
41
  'constant' => 0,
29
  abstract class OneAsymmetricKey
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'version' => [
35
  'type' => ASN1::TYPE_INTEGER,
36
  'mapping' => ['v1', 'v2']
37
  ],
38
+ 'privateKeyAlgorithm' => AlgorithmIdentifier::MAP,
39
  'privateKey' => PrivateKey::MAP,
40
  'attributes' => [
41
  'constant' => 0,
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OrganizationalUnitNames.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class OrganizationalUnitNames
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => 4, // ub-organizational-units
33
  'children' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
34
  ];
35
  }
27
  abstract class OrganizationalUnitNames
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => 4, // ub-organizational-units
33
  'children' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/OtherPrimeInfo.php CHANGED
@@ -30,9 +30,9 @@ abstract class OtherPrimeInfo
30
  const MAP = [
31
  'type' => ASN1::TYPE_SEQUENCE,
32
  'children' => [
33
- 'prime' => ['type' => ASN1::TYPE_INTEGER], // ri
34
- 'exponent' => ['type' => ASN1::TYPE_INTEGER], // di
35
- 'coefficient' => ['type' => ASN1::TYPE_INTEGER] // ti
36
  ]
37
  ];
38
  }
30
  const MAP = [
31
  'type' => ASN1::TYPE_SEQUENCE,
32
  'children' => [
33
+ 'prime' => ['type' => ASN1::TYPE_INTEGER], // ri
34
+ 'exponent' => ['type' => ASN1::TYPE_INTEGER], // di
35
+ 'coefficient' => ['type' => ASN1::TYPE_INTEGER] // ti
36
  ]
37
  ];
38
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBEParameter.php CHANGED
@@ -29,7 +29,7 @@ use phpseclib3\File\ASN1;
29
  abstract class PBEParameter
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'salt' => ['type' => ASN1::TYPE_OCTET_STRING],
35
  'iterationCount' => ['type' => ASN1::TYPE_INTEGER]
29
  abstract class PBEParameter
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'salt' => ['type' => ASN1::TYPE_OCTET_STRING],
35
  'iterationCount' => ['type' => ASN1::TYPE_INTEGER]
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBES2params.php CHANGED
@@ -29,9 +29,9 @@ use phpseclib3\File\ASN1;
29
  abstract class PBES2params
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
- 'keyDerivationFunc'=> AlgorithmIdentifier::MAP,
35
  'encryptionScheme' => AlgorithmIdentifier::MAP
36
  ]
37
  ];
29
  abstract class PBES2params
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
+ 'keyDerivationFunc' => AlgorithmIdentifier::MAP,
35
  'encryptionScheme' => AlgorithmIdentifier::MAP
36
  ]
37
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBKDF2params.php CHANGED
@@ -29,14 +29,14 @@ use phpseclib3\File\ASN1;
29
  abstract class PBKDF2params
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  // technically, this is a CHOICE in RFC2898 but the other "choice" is, currently, more of a placeholder
35
  // in the RFC
36
- 'salt'=> ['type' => ASN1::TYPE_OCTET_STRING],
37
- 'iterationCount'=> ['type' => ASN1::TYPE_INTEGER],
38
  'keyLength' => [
39
- 'type' => ASN1::TYPE_INTEGER,
40
  'optional' => true
41
  ],
42
  'prf' => AlgorithmIdentifier::MAP + ['optional' => true]
29
  abstract class PBKDF2params
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  // technically, this is a CHOICE in RFC2898 but the other "choice" is, currently, more of a placeholder
35
  // in the RFC
36
+ 'salt' => ['type' => ASN1::TYPE_OCTET_STRING],
37
+ 'iterationCount' => ['type' => ASN1::TYPE_INTEGER],
38
  'keyLength' => [
39
+ 'type' => ASN1::TYPE_INTEGER,
40
  'optional' => true
41
  ],
42
  'prf' => AlgorithmIdentifier::MAP + ['optional' => true]
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PBMAC1params.php CHANGED
@@ -29,10 +29,10 @@ use phpseclib3\File\ASN1;
29
  abstract class PBMAC1params
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
- 'keyDerivationFunc'=> AlgorithmIdentifier::MAP,
35
- 'messageAuthScheme'=> AlgorithmIdentifier::MAP
36
  ]
37
  ];
38
  }
29
  abstract class PBMAC1params
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
+ 'keyDerivationFunc' => AlgorithmIdentifier::MAP,
35
+ 'messageAuthScheme' => AlgorithmIdentifier::MAP
36
  ]
37
  ];
38
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PKCS9String.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  /**
4
- * PKCS9String
5
  *
6
  * PHP version 5
7
  *
@@ -18,18 +18,18 @@ namespace phpseclib3\File\ASN1\Maps;
18
  use phpseclib3\File\ASN1;
19
 
20
  /**
21
- * PKCS9String
22
  *
23
  * @package ASN1
24
  * @author Jim Wigginton <terrafrost@php.net>
25
  * @access public
26
  */
27
- abstract class PKCS9String
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
- 'ia5String' => ['type' => ASN1::TYPE_IA5_STRING],
33
  'directoryString' => DirectoryString::MAP
34
  ]
35
  ];
1
  <?php
2
 
3
  /**
4
+ * PKCS9String
5
  *
6
  * PHP version 5
7
  *
18
  use phpseclib3\File\ASN1;
19
 
20
  /**
21
+ * PKCS9String
22
  *
23
  * @package ASN1
24
  * @author Jim Wigginton <terrafrost@php.net>
25
  * @access public
26
  */
27
+ abstract class PKCS9String
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
+ 'ia5String' => ['type' => ASN1::TYPE_IA5_STRING],
33
  'directoryString' => DirectoryString::MAP
34
  ]
35
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Pentanomial.php CHANGED
@@ -29,9 +29,9 @@ abstract class Pentanomial
29
  const MAP = [
30
  'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'k1' => ['type' => ASN1::TYPE_INTEGER], // k1 > 0
33
- 'k2' => ['type' => ASN1::TYPE_INTEGER], // k2 > k1
34
- 'k3' => ['type' => ASN1::TYPE_INTEGER], // k3 > h2
35
  ]
36
  ];
37
- }
29
  const MAP = [
30
  'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'k1' => ['type' => ASN1::TYPE_INTEGER], // k1 > 0
33
+ 'k2' => ['type' => ASN1::TYPE_INTEGER], // k2 > k1
34
+ 'k3' => ['type' => ASN1::TYPE_INTEGER], // k3 > h2
35
  ]
36
  ];
37
+ }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PersonalName.php CHANGED
@@ -27,32 +27,32 @@ use phpseclib3\File\ASN1;
27
  abstract class PersonalName
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SET,
31
  'children' => [
32
- 'surname' => [
33
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
34
- 'constant' => 0,
35
- 'optional' => true,
36
- 'implicit' => true
37
- ],
38
- 'given-name' => [
39
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
40
- 'constant' => 1,
41
- 'optional' => true,
42
- 'implicit' => true
43
- ],
44
- 'initials' => [
45
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
46
- 'constant' => 2,
47
- 'optional' => true,
48
- 'implicit' => true
49
- ],
50
  'generation-qualifier' => [
51
- 'type' => ASN1::TYPE_PRINTABLE_STRING,
52
- 'constant' => 3,
53
- 'optional' => true,
54
- 'implicit' => true
55
- ]
56
  ]
57
  ];
58
  }
27
  abstract class PersonalName
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SET,
31
  'children' => [
32
+ 'surname' => [
33
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
34
+ 'constant' => 0,
35
+ 'optional' => true,
36
+ 'implicit' => true
37
+ ],
38
+ 'given-name' => [
39
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
40
+ 'constant' => 1,
41
+ 'optional' => true,
42
+ 'implicit' => true
43
+ ],
44
+ 'initials' => [
45
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
46
+ 'constant' => 2,
47
+ 'optional' => true,
48
+ 'implicit' => true
49
+ ],
50
  'generation-qualifier' => [
51
+ 'type' => ASN1::TYPE_PRINTABLE_STRING,
52
+ 'constant' => 3,
53
+ 'optional' => true,
54
+ 'implicit' => true
55
+ ]
56
  ]
57
  ];
58
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyInformation.php CHANGED
@@ -27,16 +27,16 @@ use phpseclib3\File\ASN1;
27
  abstract class PolicyInformation
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'policyIdentifier' => CertPolicyId::MAP,
33
  'policyQualifiers' => [
34
- 'type' => ASN1::TYPE_SEQUENCE,
35
- 'min' => 0,
36
- 'max' => -1,
37
- 'optional' => true,
38
- 'children' => PolicyQualifierInfo::MAP
39
- ]
40
  ]
41
  ];
42
  }
27
  abstract class PolicyInformation
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'policyIdentifier' => CertPolicyId::MAP,
33
  'policyQualifiers' => [
34
+ 'type' => ASN1::TYPE_SEQUENCE,
35
+ 'min' => 0,
36
+ 'max' => -1,
37
+ 'optional' => true,
38
+ 'children' => PolicyQualifierInfo::MAP
39
+ ]
40
  ]
41
  ];
42
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyMappings.php CHANGED
@@ -27,15 +27,15 @@ use phpseclib3\File\ASN1;
27
  abstract class PolicyMappings
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => [
34
- 'type' => ASN1::TYPE_SEQUENCE,
35
- 'children' => [
36
- 'issuerDomainPolicy' => CertPolicyId::MAP,
37
- 'subjectDomainPolicy' => CertPolicyId::MAP
38
- ]
39
- ]
40
  ];
41
  }
27
  abstract class PolicyMappings
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => [
34
+ 'type' => ASN1::TYPE_SEQUENCE,
35
+ 'children' => [
36
+ 'issuerDomainPolicy' => CertPolicyId::MAP,
37
+ 'subjectDomainPolicy' => CertPolicyId::MAP
38
+ ]
39
+ ]
40
  ];
41
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PolicyQualifierInfo.php CHANGED
@@ -27,10 +27,10 @@ use phpseclib3\File\ASN1;
27
  abstract class PolicyQualifierInfo
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'policyQualifierId' => PolicyQualifierId::MAP,
33
- 'qualifier' => ['type' => ASN1::TYPE_ANY]
34
  ]
35
  ];
36
  }
27
  abstract class PolicyQualifierInfo
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'policyQualifierId' => PolicyQualifierId::MAP,
33
+ 'qualifier' => ['type' => ASN1::TYPE_ANY]
34
  ]
35
  ];
36
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PostalAddress.php CHANGED
@@ -27,10 +27,10 @@ use phpseclib3\File\ASN1;
27
  abstract class PostalAddress
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'optional' => true,
32
- 'min' => 1,
33
- 'max' => -1,
34
  'children' => DirectoryString::MAP
35
  ];
36
  }
27
  abstract class PostalAddress
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'optional' => true,
32
+ 'min' => 1,
33
+ 'max' => -1,
34
  'children' => DirectoryString::MAP
35
  ];
36
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Prime_p.php CHANGED
@@ -27,4 +27,4 @@ use phpseclib3\File\ASN1;
27
  abstract class Prime_p
28
  {
29
  const MAP = ['type' => ASN1::TYPE_INTEGER];
30
- }
27
  abstract class Prime_p
28
  {
29
  const MAP = ['type' => ASN1::TYPE_INTEGER];
30
+ }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateDomainName.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class PrivateDomainName
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
- 'numeric' => ['type' => ASN1::TYPE_NUMERIC_STRING],
33
  'printable' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
34
  ]
35
  ];
27
  abstract class PrivateDomainName
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
+ 'numeric' => ['type' => ASN1::TYPE_NUMERIC_STRING],
33
  'printable' => ['type' => ASN1::TYPE_PRINTABLE_STRING]
34
  ]
35
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyInfo.php CHANGED
@@ -27,13 +27,13 @@ use phpseclib3\File\ASN1;
27
  abstract class PrivateKeyInfo
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'version' => [
33
  'type' => ASN1::TYPE_INTEGER,
34
  'mapping' => ['v1']
35
  ],
36
- 'privateKeyAlgorithm'=> AlgorithmIdentifier::MAP,
37
  'privateKey' => PrivateKey::MAP,
38
  'attributes' => [
39
  'constant' => 0,
27
  abstract class PrivateKeyInfo
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'version' => [
33
  'type' => ASN1::TYPE_INTEGER,
34
  'mapping' => ['v1']
35
  ],
36
+ 'privateKeyAlgorithm' => AlgorithmIdentifier::MAP,
37
  'privateKey' => PrivateKey::MAP,
38
  'attributes' => [
39
  'constant' => 0,
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PrivateKeyUsagePeriod.php CHANGED
@@ -27,18 +27,18 @@ use phpseclib3\File\ASN1;
27
  abstract class PrivateKeyUsagePeriod
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'notBefore' => [
33
- 'constant' => 0,
34
- 'optional' => true,
35
- 'implicit' => true,
36
- 'type' => ASN1::TYPE_GENERALIZED_TIME],
37
- 'notAfter' => [
38
- 'constant' => 1,
39
- 'optional' => true,
40
- 'implicit' => true,
41
- 'type' => ASN1::TYPE_GENERALIZED_TIME]
42
  ]
43
  ];
44
  }
27
  abstract class PrivateKeyUsagePeriod
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'notBefore' => [
33
+ 'constant' => 0,
34
+ 'optional' => true,
35
+ 'implicit' => true,
36
+ 'type' => ASN1::TYPE_GENERALIZED_TIME],
37
+ 'notAfter' => [
38
+ 'constant' => 1,
39
+ 'optional' => true,
40
+ 'implicit' => true,
41
+ 'type' => ASN1::TYPE_GENERALIZED_TIME]
42
  ]
43
  ];
44
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyAndChallenge.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class PublicKeyAndChallenge
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'spki' => SubjectPublicKeyInfo::MAP,
33
  'challenge' => ['type' => ASN1::TYPE_IA5_STRING]
34
  ]
35
  ];
27
  abstract class PublicKeyAndChallenge
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'spki' => SubjectPublicKeyInfo::MAP,
33
  'challenge' => ['type' => ASN1::TYPE_IA5_STRING]
34
  ]
35
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/PublicKeyInfo.php CHANGED
@@ -30,9 +30,9 @@ use phpseclib3\File\ASN1;
30
  abstract class PublicKeyInfo
31
  {
32
  const MAP = [
33
- 'type' => ASN1::TYPE_SEQUENCE,
34
  'children' => [
35
- 'publicKeyAlgorithm'=> AlgorithmIdentifier::MAP,
36
  'publicKey' => ['type' => ASN1::TYPE_BIT_STRING]
37
  ]
38
  ];
30
  abstract class PublicKeyInfo
31
  {
32
  const MAP = [
33
+ 'type' => ASN1::TYPE_SEQUENCE,
34
  'children' => [
35
+ 'publicKeyAlgorithm' => AlgorithmIdentifier::MAP,
36
  'publicKey' => ['type' => ASN1::TYPE_BIT_STRING]
37
  ]
38
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RC2CBCParameter.php CHANGED
@@ -29,13 +29,13 @@ use phpseclib3\File\ASN1;
29
  abstract class RC2CBCParameter
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
- 'rc2ParametersVersion'=> [
35
- 'type' => ASN1::TYPE_INTEGER,
36
  'optional' => true
37
  ],
38
- 'iv'=> ['type' => ASN1::TYPE_OCTET_STRING]
39
  ]
40
  ];
41
  }
29
  abstract class RC2CBCParameter
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
+ 'rc2ParametersVersion' => [
35
+ 'type' => ASN1::TYPE_INTEGER,
36
  'optional' => true
37
  ],
38
+ 'iv' => ['type' => ASN1::TYPE_OCTET_STRING]
39
  ]
40
  ];
41
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RDNSequence.php CHANGED
@@ -33,10 +33,10 @@ use phpseclib3\File\ASN1;
33
  abstract class RDNSequence
34
  {
35
  const MAP = [
36
- 'type' => ASN1::TYPE_SEQUENCE,
37
  // RDNSequence does not define a min or a max, which means it doesn't have one
38
- 'min' => 0,
39
- 'max' => -1,
40
  'children' => RelativeDistinguishedName::MAP
41
  ];
42
  }
33
  abstract class RDNSequence
34
  {
35
  const MAP = [
36
+ 'type' => ASN1::TYPE_SEQUENCE,
37
  // RDNSequence does not define a min or a max, which means it doesn't have one
38
+ 'min' => 0,
39
+ 'max' => -1,
40
  'children' => RelativeDistinguishedName::MAP
41
  ];
42
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPrivateKey.php CHANGED
@@ -34,14 +34,14 @@ abstract class RSAPrivateKey
34
  'type' => ASN1::TYPE_INTEGER,
35
  'mapping' => ['two-prime', 'multi']
36
  ],
37
- 'modulus' => ['type' => ASN1::TYPE_INTEGER], // n
38
- 'publicExponent' => ['type' => ASN1::TYPE_INTEGER], // e
39
  'privateExponent' => ['type' => ASN1::TYPE_INTEGER], // d
40
- 'prime1' => ['type' => ASN1::TYPE_INTEGER], // p
41
- 'prime2' => ['type' => ASN1::TYPE_INTEGER], // q
42
- 'exponent1' => ['type' => ASN1::TYPE_INTEGER], // d mod (p-1)
43
- 'exponent2' => ['type' => ASN1::TYPE_INTEGER], // d mod (q-1)
44
- 'coefficient' => ['type' => ASN1::TYPE_INTEGER], // (inverse of q) mod p
45
  'otherPrimeInfos' => OtherPrimeInfos::MAP + ['optional' => true]
46
  ]
47
  ];
34
  'type' => ASN1::TYPE_INTEGER,
35
  'mapping' => ['two-prime', 'multi']
36
  ],
37
+ 'modulus' => ['type' => ASN1::TYPE_INTEGER], // n
38
+ 'publicExponent' => ['type' => ASN1::TYPE_INTEGER], // e
39
  'privateExponent' => ['type' => ASN1::TYPE_INTEGER], // d
40
+ 'prime1' => ['type' => ASN1::TYPE_INTEGER], // p
41
+ 'prime2' => ['type' => ASN1::TYPE_INTEGER], // q
42
+ 'exponent1' => ['type' => ASN1::TYPE_INTEGER], // d mod (p-1)
43
+ 'exponent2' => ['type' => ASN1::TYPE_INTEGER], // d mod (q-1)
44
+ 'coefficient' => ['type' => ASN1::TYPE_INTEGER], // (inverse of q) mod p
45
  'otherPrimeInfos' => OtherPrimeInfos::MAP + ['optional' => true]
46
  ]
47
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSAPublicKey.php CHANGED
@@ -29,8 +29,8 @@ abstract class RSAPublicKey
29
  const MAP = [
30
  'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'modulus' => ['type' => ASN1::TYPE_INTEGER],
33
- 'publicExponent' => ['type' => ASN1::TYPE_INTEGER]
34
  ]
35
  ];
36
  }
29
  const MAP = [
30
  'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'modulus' => ['type' => ASN1::TYPE_INTEGER],
33
+ 'publicExponent' => ['type' => ASN1::TYPE_INTEGER]
34
  ]
35
  ];
36
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RSASSA_PSS_params.php CHANGED
@@ -29,9 +29,9 @@ use phpseclib3\File\ASN1;
29
  abstract class RSASSA_PSS_params
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
- 'hashAlgorithm' => [
35
  'constant' => 0,
36
  'optional' => true,
37
  'explicit' => true,
@@ -43,19 +43,19 @@ abstract class RSASSA_PSS_params
43
  'explicit' => true,
44
  //'default' => 'mgf1SHA1Identifier'
45
  ] + MaskGenAlgorithm::MAP,
46
- 'saltLength' => [
47
- 'type' => ASN1::TYPE_INTEGER,
48
  'constant' => 2,
49
  'optional' => true,
50
  'explicit' => true,
51
- 'default' => 20
52
  ],
53
- 'trailerField' => [
54
- 'type' => ASN1::TYPE_INTEGER,
55
  'constant' => 3,
56
  'optional' => true,
57
  'explicit' => true,
58
- 'default' => 1
59
  ]
60
  ]
61
  ];
29
  abstract class RSASSA_PSS_params
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
+ 'hashAlgorithm' => [
35
  'constant' => 0,
36
  'optional' => true,
37
  'explicit' => true,
43
  'explicit' => true,
44
  //'default' => 'mgf1SHA1Identifier'
45
  ] + MaskGenAlgorithm::MAP,
46
+ 'saltLength' => [
47
+ 'type' => ASN1::TYPE_INTEGER,
48
  'constant' => 2,
49
  'optional' => true,
50
  'explicit' => true,
51
+ 'default' => 20
52
  ],
53
+ 'trailerField' => [
54
+ 'type' => ASN1::TYPE_INTEGER,
55
  'constant' => 3,
56
  'optional' => true,
57
  'explicit' => true,
58
+ 'default' => 1
59
  ]
60
  ]
61
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/ReasonFlags.php CHANGED
@@ -27,7 +27,7 @@ use phpseclib3\File\ASN1;
27
  abstract class ReasonFlags
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_BIT_STRING,
31
  'mapping' => [
32
  'unused',
33
  'keyCompromise',
27
  abstract class ReasonFlags
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_BIT_STRING,
31
  'mapping' => [
32
  'unused',
33
  'keyCompromise',
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RelativeDistinguishedName.php CHANGED
@@ -33,9 +33,9 @@ use phpseclib3\File\ASN1;
33
  abstract class RelativeDistinguishedName
34
  {
35
  const MAP = [
36
- 'type' => ASN1::TYPE_SET,
37
- 'min' => 1,
38
- 'max' => -1,
39
  'children' => AttributeTypeAndValue::MAP
40
  ];
41
  }
33
  abstract class RelativeDistinguishedName
34
  {
35
  const MAP = [
36
+ 'type' => ASN1::TYPE_SET,
37
+ 'min' => 1,
38
+ 'max' => -1,
39
  'children' => AttributeTypeAndValue::MAP
40
  ];
41
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/RevokedCertificate.php CHANGED
@@ -27,13 +27,13 @@ use phpseclib3\File\ASN1;
27
  abstract class RevokedCertificate
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'userCertificate' => CertificateSerialNumber::MAP,
33
- 'revocationDate' => Time::MAP,
34
- 'crlEntryExtensions' => [
35
- 'optional' => true
36
- ] + Extensions::MAP
37
- ]
38
  ];
39
  }
27
  abstract class RevokedCertificate
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'userCertificate' => CertificateSerialNumber::MAP,
33
+ 'revocationDate' => Time::MAP,
34
+ 'crlEntryExtensions' => [
35
+ 'optional' => true
36
+ ] + Extensions::MAP
37
+ ]
38
  ];
39
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SignedPublicKeyAndChallenge.php CHANGED
@@ -27,11 +27,11 @@ use phpseclib3\File\ASN1;
27
  abstract class SignedPublicKeyAndChallenge
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'publicKeyAndChallenge' => PublicKeyAndChallenge::MAP,
33
- 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
34
- 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
35
  ]
36
  ];
37
  }
27
  abstract class SignedPublicKeyAndChallenge
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'publicKeyAndChallenge' => PublicKeyAndChallenge::MAP,
33
+ 'signatureAlgorithm' => AlgorithmIdentifier::MAP,
34
+ 'signature' => ['type' => ASN1::TYPE_BIT_STRING]
35
  ]
36
  ];
37
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SpecifiedECDomain.php CHANGED
@@ -29,7 +29,7 @@ use phpseclib3\File\ASN1;
29
  abstract class SpecifiedECDomain
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'version' => [
35
  'type' => ASN1::TYPE_INTEGER,
29
  abstract class SpecifiedECDomain
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_SEQUENCE,
33
  'children' => [
34
  'version' => [
35
  'type' => ASN1::TYPE_INTEGER,
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectDirectoryAttributes.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class SubjectDirectoryAttributes
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => Attribute::MAP
34
  ];
35
  }
27
  abstract class SubjectDirectoryAttributes
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => Attribute::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectInfoAccessSyntax.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class SubjectInfoAccessSyntax
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
- 'min' => 1,
32
- 'max' => -1,
33
  'children' => AccessDescription::MAP
34
  ];
35
  }
27
  abstract class SubjectInfoAccessSyntax
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
+ 'min' => 1,
32
+ 'max' => -1,
33
  'children' => AccessDescription::MAP
34
  ];
35
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/SubjectPublicKeyInfo.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class SubjectPublicKeyInfo
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'algorithm' => AlgorithmIdentifier::MAP,
33
  'subjectPublicKey' => ['type' => ASN1::TYPE_BIT_STRING]
34
  ]
35
  ];
27
  abstract class SubjectPublicKeyInfo
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'algorithm' => AlgorithmIdentifier::MAP,
33
  'subjectPublicKey' => ['type' => ASN1::TYPE_BIT_STRING]
34
  ]
35
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertList.php CHANGED
@@ -27,32 +27,32 @@ use phpseclib3\File\ASN1;
27
  abstract class TBSCertList
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
- 'version' => [
33
- 'type' => ASN1::TYPE_INTEGER,
34
- 'mapping' => ['v1', 'v2', 'v3'],
35
- 'optional' => true,
36
- 'default' => 'v2'
37
- ],
38
- 'signature' => AlgorithmIdentifier::MAP,
39
- 'issuer' => Name::MAP,
40
- 'thisUpdate' => Time::MAP,
41
- 'nextUpdate' => [
42
- 'optional' => true
43
- ] + Time::MAP,
44
  'revokedCertificates' => [
45
- 'type' => ASN1::TYPE_SEQUENCE,
46
- 'optional' => true,
47
- 'min' => 0,
48
- 'max' => -1,
49
- 'children' => RevokedCertificate::MAP
50
- ],
51
- 'crlExtensions' => [
52
- 'constant' => 0,
53
- 'optional' => true,
54
- 'explicit' => true
55
- ] + Extensions::MAP
56
  ]
57
  ];
58
  }
27
  abstract class TBSCertList
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
+ 'version' => [
33
+ 'type' => ASN1::TYPE_INTEGER,
34
+ 'mapping' => ['v1', 'v2', 'v3'],
35
+ 'optional' => true,
36
+ 'default' => 'v2'
37
+ ],
38
+ 'signature' => AlgorithmIdentifier::MAP,
39
+ 'issuer' => Name::MAP,
40
+ 'thisUpdate' => Time::MAP,
41
+ 'nextUpdate' => [
42
+ 'optional' => true
43
+ ] + Time::MAP,
44
  'revokedCertificates' => [
45
+ 'type' => ASN1::TYPE_SEQUENCE,
46
+ 'optional' => true,
47
+ 'min' => 0,
48
+ 'max' => -1,
49
+ 'children' => RevokedCertificate::MAP
50
+ ],
51
+ 'crlExtensions' => [
52
+ 'constant' => 0,
53
+ 'optional' => true,
54
+ 'explicit' => true
55
+ ] + Extensions::MAP
56
  ]
57
  ];
58
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/TBSCertificate.php CHANGED
@@ -28,42 +28,42 @@ abstract class TBSCertificate
28
  {
29
  // assert($TBSCertificate['children']['signature'] == $Certificate['children']['signatureAlgorithm'])
30
  const MAP = [
31
- 'type' => ASN1::TYPE_SEQUENCE,
32
  'children' => [
33
  // technically, default implies optional, but we'll define it as being optional, none-the-less, just to
34
  // reenforce that fact
35
- 'version' => [
36
- 'type' => ASN1::TYPE_INTEGER,
37
- 'constant' => 0,
38
- 'optional' => true,
39
- 'explicit' => true,
40
- 'mapping' => ['v1', 'v2', 'v3'],
41
- 'default' => 'v1'
42
- ],
43
- 'serialNumber' => CertificateSerialNumber::MAP,
44
- 'signature' => AlgorithmIdentifier::MAP,
45
- 'issuer' => Name::MAP,
46
- 'validity' => Validity::MAP,
47
- 'subject' => Name::MAP,
48
  'subjectPublicKeyInfo' => SubjectPublicKeyInfo::MAP,
49
  // implicit means that the T in the TLV structure is to be rewritten, regardless of the type
50
- 'issuerUniqueID' => [
51
- 'constant' => 1,
52
- 'optional' => true,
53
- 'implicit' => true
54
- ] + UniqueIdentifier::MAP,
55
- 'subjectUniqueID' => [
56
- 'constant' => 2,
57
- 'optional' => true,
58
- 'implicit' => true
59
- ] + UniqueIdentifier::MAP,
60
  // <http://tools.ietf.org/html/rfc2459#page-74> doesn't use the EXPLICIT keyword but if
61
  // it's not IMPLICIT, it's EXPLICIT
62
- 'extensions' => [
63
- 'constant' => 3,
64
- 'optional' => true,
65
- 'explicit' => true
66
- ] + Extensions::MAP
67
  ]
68
  ];
69
  }
28
  {
29
  // assert($TBSCertificate['children']['signature'] == $Certificate['children']['signatureAlgorithm'])
30
  const MAP = [
31
+ 'type' => ASN1::TYPE_SEQUENCE,
32
  'children' => [
33
  // technically, default implies optional, but we'll define it as being optional, none-the-less, just to
34
  // reenforce that fact
35
+ 'version' => [
36
+ 'type' => ASN1::TYPE_INTEGER,
37
+ 'constant' => 0,
38
+ 'optional' => true,
39
+ 'explicit' => true,
40
+ 'mapping' => ['v1', 'v2', 'v3'],
41
+ 'default' => 'v1'
42
+ ],
43
+ 'serialNumber' => CertificateSerialNumber::MAP,
44
+ 'signature' => AlgorithmIdentifier::MAP,
45
+ 'issuer' => Name::MAP,
46
+ 'validity' => Validity::MAP,
47
+ 'subject' => Name::MAP,
48
  'subjectPublicKeyInfo' => SubjectPublicKeyInfo::MAP,
49
  // implicit means that the T in the TLV structure is to be rewritten, regardless of the type
50
+ 'issuerUniqueID' => [
51
+ 'constant' => 1,
52
+ 'optional' => true,
53
+ 'implicit' => true
54
+ ] + UniqueIdentifier::MAP,
55
+ 'subjectUniqueID' => [
56
+ 'constant' => 2,
57
+ 'optional' => true,
58
+ 'implicit' => true
59
+ ] + UniqueIdentifier::MAP,
60
  // <http://tools.ietf.org/html/rfc2459#page-74> doesn't use the EXPLICIT keyword but if
61
  // it's not IMPLICIT, it's EXPLICIT
62
+ 'extensions' => [
63
+ 'constant' => 3,
64
+ 'optional' => true,
65
+ 'explicit' => true
66
+ ] + Extensions::MAP
67
  ]
68
  ];
69
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Time.php CHANGED
@@ -27,9 +27,9 @@ use phpseclib3\File\ASN1;
27
  abstract class Time
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
- 'utcTime' => ['type' => ASN1::TYPE_UTC_TIME],
33
  'generalTime' => ['type' => ASN1::TYPE_GENERALIZED_TIME]
34
  ]
35
  ];
27
  abstract class Time
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_CHOICE,
31
  'children' => [
32
+ 'utcTime' => ['type' => ASN1::TYPE_UTC_TIME],
33
  'generalTime' => ['type' => ASN1::TYPE_GENERALIZED_TIME]
34
  ]
35
  ];
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Trinomial.php CHANGED
@@ -27,4 +27,4 @@ use phpseclib3\File\ASN1;
27
  abstract class Trinomial
28
  {
29
  const MAP = ['type' => ASN1::TYPE_INTEGER];
30
- }
27
  abstract class Trinomial
28
  {
29
  const MAP = ['type' => ASN1::TYPE_INTEGER];
30
+ }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/UserNotice.php CHANGED
@@ -27,16 +27,16 @@ use phpseclib3\File\ASN1;
27
  abstract class UserNotice
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'noticeRef' => [
33
- 'optional' => true,
34
- 'implicit' => true
35
- ] + NoticeReference::MAP,
36
- 'explicitText' => [
37
- 'optional' => true,
38
- 'implicit' => true
39
- ] + DisplayText::MAP
40
  ]
41
  ];
42
  }
27
  abstract class UserNotice
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'noticeRef' => [
33
+ 'optional' => true,
34
+ 'implicit' => true
35
+ ] + NoticeReference::MAP,
36
+ 'explicitText' => [
37
+ 'optional' => true,
38
+ 'implicit' => true
39
+ ] + DisplayText::MAP
40
  ]
41
  ];
42
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/Validity.php CHANGED
@@ -27,10 +27,10 @@ use phpseclib3\File\ASN1;
27
  abstract class Validity
28
  {
29
  const MAP = [
30
- 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'notBefore' => Time::MAP,
33
- 'notAfter' => Time::MAP
34
  ]
35
  ];
36
  }
27
  abstract class Validity
28
  {
29
  const MAP = [
30
+ 'type' => ASN1::TYPE_SEQUENCE,
31
  'children' => [
32
  'notBefore' => Time::MAP,
33
+ 'notAfter' => Time::MAP
34
  ]
35
  ];
36
  }
vendor/phpseclib/phpseclib/phpseclib/File/ASN1/Maps/netscape_cert_type.php CHANGED
@@ -29,7 +29,7 @@ use phpseclib3\File\ASN1;
29
  abstract class netscape_cert_type
30
  {
31
  const MAP = [
32
- 'type' => ASN1::TYPE_BIT_STRING,
33
  'mapping' => [
34
  'SSLClient',
35
  'SSLServer',
29
  abstract class netscape_cert_type
30
  {
31
  const MAP = [
32
+ 'type' => ASN1::TYPE_BIT_STRING,
33
  'mapping' => [
34
  'SSLClient',
35
  'SSLServer',
vendor/phpseclib/phpseclib/phpseclib/File/X509.php CHANGED
@@ -26,9 +26,6 @@
26
 
27
  namespace phpseclib3\File;
28
 
29
- use DateTimeImmutable;
30
- use DateTimeInterface;
31
- use DateTimeZone;
32
  use ParagonIE\ConstantTime\Base64;
33
  use ParagonIE\ConstantTime\Hex;
34
  use phpseclib3\Crypt\Common\PrivateKey;
@@ -36,6 +33,7 @@ use phpseclib3\Crypt\Common\PublicKey;
36
  use phpseclib3\Crypt\DSA;
37
  use phpseclib3\Crypt\EC;
38
  use phpseclib3\Crypt\Hash;
 
39
  use phpseclib3\Crypt\Random;
40
  use phpseclib3\Crypt\RSA;
41
  use phpseclib3\Crypt\RSA\Formats\Keys\PSS;
@@ -43,7 +41,6 @@ use phpseclib3\Exception\UnsupportedAlgorithmException;
43
  use phpseclib3\File\ASN1\Element;
44
  use phpseclib3\File\ASN1\Maps;
45
  use phpseclib3\Math\BigInteger;
46
- use phpseclib3\Crypt\PublicKeyLoader;
47
 
48
  /**
49
  * Pure-PHP X.509 Parser
@@ -168,7 +165,7 @@ class X509
168
  /**
169
  * Public key
170
  *
171
- * @var string
172
  * @access private
173
  */
174
  private $publicKey;
@@ -176,7 +173,7 @@ class X509
176
  /**
177
  * Private key
178
  *
179
- * @var string
180
  * @access private
181
  */
182
  private $privateKey;
@@ -228,7 +225,7 @@ class X509
228
  /**
229
  * Certificate End Date
230
  *
231
- * @var string
232
  * @access private
233
  */
234
  private $endDate;
@@ -337,7 +334,7 @@ class X509
337
  //'id-ad' => '1.3.6.1.5.5.7.48',
338
  'id-qt-cps' => '1.3.6.1.5.5.7.2.1',
339
  'id-qt-unotice' => '1.3.6.1.5.5.7.2.2',
340
- 'id-ad-ocsp' =>'1.3.6.1.5.5.7.48.1',
341
  'id-ad-caIssuers' => '1.3.6.1.5.5.7.48.2',
342
  'id-ad-timeStamping' => '1.3.6.1.5.5.7.48.3',
343
  'id-ad-caRepository' => '1.3.6.1.5.5.7.48.5',
@@ -627,7 +624,6 @@ class X509
627
  for ($i = 0; $i < count($extensions); $i++) {
628
  $id = $extensions[$i]['extnId'];
629
  $value = &$extensions[$i]['extnValue'];
630
- $decoded = ASN1::decodeBER($value);
631
  /* [extnValue] contains the DER encoding of an ASN.1 value
632
  corresponding to the extension type identified by extnID */
633
  $map = $this->getMapping($id);
@@ -635,6 +631,7 @@ class X509
635
  $decoder = $id == 'id-ce-nameConstraints' ?
636
  [static::class, 'decodeNameConstraintIP'] :
637
  [static::class, 'decodeIP'];
 
638
  $mapped = ASN1::asn1map($decoded[0], $map, ['iPAddress' => $decoder]);
639
  $value = $mapped === false ? $decoded[0] : $mapped;
640
 
@@ -684,7 +681,7 @@ class X509
684
  if ($value['extnId'] == $id) {
685
  $extensions[$key] = $newext;
686
  continue 2;
687
- }
688
  }
689
  }
690
  $extensions[] = $newext;
@@ -1113,7 +1110,7 @@ class X509
1113
 
1114
  if ($value = $this->getDNProp('id-at-commonName')) {
1115
  $value = str_replace(['.', '*'], ['\.', '[^.]*'], $value[0]);
1116
- return preg_match('#^' . $value . '$#', $components['host']);
1117
  }
1118
 
1119
  return false;
@@ -1124,9 +1121,9 @@ class X509
1124
  *
1125
  * If $date isn't defined it is assumed to be the current date.
1126
  *
1127
- * @param DateTimeInterface|string $date optional
1128
  * @access public
1129
- * @return boolean
1130
  */
1131
  public function validateDate($date = null)
1132
  {
@@ -1135,7 +1132,7 @@ class X509
1135
  }
1136
 
1137
  if (!isset($date)) {
1138
- $date = new DateTimeImmutable(null, new DateTimeZone(@date_default_timezone_get()));
1139
  }
1140
 
1141
  $notBefore = $this->currentCert['tbsCertificate']['validity']['notBefore'];
@@ -1145,13 +1142,13 @@ class X509
1145
  $notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime'];
1146
 
1147
  if (is_string($date)) {
1148
- $date = new DateTimeImmutable($date, new DateTimeZone(@date_default_timezone_get()));
1149
  }
1150
 
1151
- $notBefore = new DateTimeImmutable($notBefore, new DateTimeZone(@date_default_timezone_get()));
1152
- $notAfter = new DateTimeImmutable($notAfter, new DateTimeZone(@date_default_timezone_get()));
1153
 
1154
- return $date >= $notBefore && $date<= $notAfter;
1155
  }
1156
 
1157
  /**
@@ -1195,7 +1192,7 @@ class X509
1195
  if ($temp === false) {
1196
  return false;
1197
  }
1198
- $data.= $temp;
1199
  }
1200
 
1201
  break;
@@ -1697,7 +1694,7 @@ class X509
1697
  $this->dn['rdnSequence'][] = [
1698
  [
1699
  'type' => $propName,
1700
- 'value'=> $v
1701
  ]
1702
  ];
1703
  }
@@ -1830,7 +1827,7 @@ class X509
1830
 
1831
  // handles everything else
1832
  $results = preg_split('#((?:^|, *|/)(?:C=|O=|OU=|CN=|L=|ST=|SN=|postalCode=|streetAddress=|emailAddress=|serialNumber=|organizationalUnitName=|title=|description=|role=|x500UniqueIdentifier=|postalAddress=))#', $dn, -1, PREG_SPLIT_DELIM_CAPTURE);
1833
- for ($i = 1; $i < count($results); $i+=2) {
1834
  $prop = trim($results[$i], ', =/');
1835
  $value = $results[$i + 1];
1836
  if (!$this->setDNProp($prop, $value, $type)) {
@@ -1847,7 +1844,7 @@ class X509
1847
  * @param mixed $format optional
1848
  * @param array $dn optional
1849
  * @access public
1850
- * @return array|bool
1851
  */
1852
  public function getDN($format = self::DN_ARRAY, $dn = null)
1853
  {
@@ -1952,7 +1949,7 @@ class X509
1952
  }
1953
 
1954
  if (!$start) {
1955
- $output.= $delim;
1956
  }
1957
  if (is_array($value)) {
1958
  foreach ($value as $type => $v) {
@@ -1969,10 +1966,12 @@ class X509
1969
  $value = array_pop($value); // Always strip data type.
1970
  }
1971
  } elseif (is_object($value) && $value instanceof Element) {
1972
- $callback = function($x) { return '\x' . bin2hex($x[0]); };
 
 
1973
  $value = strtoupper(preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element));
1974
  }
1975
- $output.= $desc . '=' . $value;
1976
  $result[$desc] = isset($result[$desc]) ?
1977
  array_merge((array) $result[$desc], [$value]) :
1978
  $value;
@@ -2136,7 +2135,7 @@ class X509
2136
  *
2137
  * @param PublicKey $key
2138
  * @access public
2139
- * @return bool
2140
  */
2141
  public function setPublicKey(PublicKey $key)
2142
  {
@@ -2203,8 +2202,10 @@ class X509
2203
  $key = $keyinfo['subjectPublicKey'];
2204
 
2205
  switch ($keyinfo['algorithm']['algorithm']) {
 
 
2206
  case 'rsaEncryption':
2207
- return RSA::loadFormat('PKCS8', $key);
2208
  case 'id-ecPublicKey':
2209
  case 'id-Ed25519':
2210
  case 'id-Ed448':
@@ -2379,7 +2380,7 @@ class X509
2379
 
2380
  $spkac = ASN1::asn1map($decoded[0], Maps\SignedPublicKeyAndChallenge::MAP);
2381
 
2382
- if (!isset($spkac) || $spkac === false) {
2383
  $this->currentCert = false;
2384
  return false;
2385
  }
@@ -2578,7 +2579,7 @@ class X509
2578
  if ($date instanceof Element) {
2579
  return $date;
2580
  }
2581
- $dateObj = new DateTimeImmutable($date, new DateTimeZone('GMT'));
2582
  $year = $dateObj->format('Y'); // the same way ASN1.php parses this
2583
  if ($year < 2050) {
2584
  return ['utcTime' => $date];
@@ -2654,10 +2655,10 @@ class X509
2654
  return false;
2655
  }
2656
 
2657
- $startDate = new DateTimeImmutable('now', new DateTimeZone(@date_default_timezone_get()));
2658
  $startDate = !empty($this->startDate) ? $this->startDate : $startDate->format('D, d M Y H:i:s O');
2659
 
2660
- $endDate = new DateTimeImmutable('+1 year', new DateTimeZone(@date_default_timezone_get()));
2661
  $endDate = !empty($this->endDate) ? $this->endDate : $endDate->format('D, d M Y H:i:s O');
2662
 
2663
  /* "The serial number MUST be a positive integer"
@@ -2922,7 +2923,7 @@ class X509
2922
  $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null;
2923
  $signatureAlgorithm = self::identifySignatureAlgorithm($issuer->privateKey);
2924
 
2925
- $thisUpdate = new DateTimeImmutable('now', new DateTimeZone(@date_default_timezone_get()));
2926
  $thisUpdate = !empty($this->startDate) ? $this->startDate : $thisUpdate->format('D, d M Y H:i:s O');
2927
 
2928
  if (isset($crl->currentCert) && is_array($crl->currentCert) && isset($crl->currentCert['tbsCertList'])) {
@@ -3096,13 +3097,13 @@ class X509
3096
  /**
3097
  * Set certificate start date
3098
  *
3099
- * @param DateTimeInterface|string $date
3100
  * @access public
3101
  */
3102
  public function setStartDate($date)
3103
  {
3104
- if (!is_object($date) || !($date instanceof DateTimeInterface)) {
3105
- $date = new DateTimeImmutable($date, new DateTimeZone(@date_default_timezone_get()));
3106
  }
3107
 
3108
  $this->startDate = $date->format('D, d M Y H:i:s O');
@@ -3111,7 +3112,7 @@ class X509
3111
  /**
3112
  * Set certificate end date
3113
  *
3114
- * @param DateTimeInterface|string $date
3115
  * @access public
3116
  */
3117
  public function setEndDate($date)
@@ -3128,8 +3129,8 @@ class X509
3128
  $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . ASN1::encodeLength(strlen($temp)) . $temp;
3129
  $this->endDate = new Element($temp);
3130
  } else {
3131
- if (!is_object($date) || !($date instanceof DateTimeInterface)) {
3132
- $date = new DateTimeImmutable($date, new DateTimeZone(@date_default_timezone_get()));
3133
  }
3134
 
3135
  $this->endDate = $date->format('D, d M Y H:i:s O');
@@ -3458,7 +3459,7 @@ class X509
3458
  * @access public
3459
  * @return mixed
3460
  */
3461
- public function getExtension($id, $cert = null, $path=null)
3462
  {
3463
  return $this->getExtensionHelper($id, $cert, $path);
3464
  }
@@ -3628,6 +3629,7 @@ class X509
3628
  switch ($disposition) {
3629
  case self::ATTR_REPLACE:
3630
  $disposition = self::ATTR_APPEND;
 
3631
  case self::ATTR_ALL:
3632
  $this->removeAttribute($id);
3633
  break;
@@ -3657,7 +3659,7 @@ class X509
3657
  $attributes[$last]['value'][] = $value;
3658
  break;
3659
  default:
3660
- $attributes[] = ['type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value: [$value]];
3661
  break;
3662
  }
3663
 
@@ -3766,7 +3768,7 @@ class X509
3766
  * Format a public key as appropriate
3767
  *
3768
  * @access private
3769
- * @return array|bool
3770
  */
3771
  private function formatSubjectPublicKey()
3772
  {
@@ -3778,6 +3780,9 @@ class X509
3778
 
3779
  $decoded = ASN1::decodeBER($publicKey);
3780
  $mapped = ASN1::asn1map($decoded[0], Maps\SubjectPublicKeyInfo::MAP);
 
 
 
3781
 
3782
  $mapped['subjectPublicKey'] = $this->publicKey->toString($format);
3783
 
@@ -3787,9 +3792,9 @@ class X509
3787
  /**
3788
  * Set the domain name's which the cert is to be valid for
3789
  *
3790
- * @param mixed[] ...$domains
3791
  * @access public
3792
- * @return array
3793
  */
3794
  public function setDomain(...$domains)
3795
  {
@@ -3865,7 +3870,7 @@ class X509
3865
  }
3866
 
3867
  $i = count($rclist);
3868
- $revocationDate = new DateTimeImmutable('now', new DateTimeZone(@date_default_timezone_get()));
3869
  $rclist[] = ['userCertificate' => $serial,
3870
  'revocationDate' => $this->timeField($revocationDate->format('D, d M Y H:i:s O'))];
3871
  return $i;
@@ -4002,7 +4007,7 @@ class X509
4002
 
4003
  if (is_array($rclist = $this->subArray($crl, 'tbsCertList/revokedCertificates'))) {
4004
  if (($i = $this->revokedCertificate($rclist, $serial)) !== false) {
4005
- return $this->getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
4006
  }
4007
  }
4008
 
26
 
27
  namespace phpseclib3\File;
28
 
 
 
 
29
  use ParagonIE\ConstantTime\Base64;
30
  use ParagonIE\ConstantTime\Hex;
31
  use phpseclib3\Crypt\Common\PrivateKey;
33
  use phpseclib3\Crypt\DSA;
34
  use phpseclib3\Crypt\EC;
35
  use phpseclib3\Crypt\Hash;
36
+ use phpseclib3\Crypt\PublicKeyLoader;
37
  use phpseclib3\Crypt\Random;
38
  use phpseclib3\Crypt\RSA;
39
  use phpseclib3\Crypt\RSA\Formats\Keys\PSS;
41
  use phpseclib3\File\ASN1\Element;
42
  use phpseclib3\File\ASN1\Maps;
43
  use phpseclib3\Math\BigInteger;
 
44
 
45
  /**
46
  * Pure-PHP X.509 Parser
165
  /**
166
  * Public key
167
  *
168
+ * @var string|PublicKey
169
  * @access private
170
  */
171
  private $publicKey;
173
  /**
174
  * Private key
175
  *
176
+ * @var string|PrivateKey
177
  * @access private
178
  */
179
  private $privateKey;
225
  /**
226
  * Certificate End Date
227
  *
228
+ * @var string|Element
229
  * @access private
230
  */
231
  private $endDate;
334
  //'id-ad' => '1.3.6.1.5.5.7.48',
335
  'id-qt-cps' => '1.3.6.1.5.5.7.2.1',
336
  'id-qt-unotice' => '1.3.6.1.5.5.7.2.2',
337
+ 'id-ad-ocsp' => '1.3.6.1.5.5.7.48.1',
338
  'id-ad-caIssuers' => '1.3.6.1.5.5.7.48.2',
339
  'id-ad-timeStamping' => '1.3.6.1.5.5.7.48.3',
340
  'id-ad-caRepository' => '1.3.6.1.5.5.7.48.5',
624
  for ($i = 0; $i < count($extensions); $i++) {
625
  $id = $extensions[$i]['extnId'];
626
  $value = &$extensions[$i]['extnValue'];
 
627
  /* [extnValue] contains the DER encoding of an ASN.1 value
628
  corresponding to the extension type identified by extnID */
629
  $map = $this->getMapping($id);
631
  $decoder = $id == 'id-ce-nameConstraints' ?
632
  [static::class, 'decodeNameConstraintIP'] :
633
  [static::class, 'decodeIP'];
634
+ $decoded = ASN1::decodeBER($value);
635
  $mapped = ASN1::asn1map($decoded[0], $map, ['iPAddress' => $decoder]);
636
  $value = $mapped === false ? $decoded[0] : $mapped;
637
 
681
  if ($value['extnId'] == $id) {
682
  $extensions[$key] = $newext;
683
  continue 2;
684
+ }
685
  }
686
  }
687
  $extensions[] = $newext;
1110
 
1111
  if ($value = $this->getDNProp('id-at-commonName')) {
1112
  $value = str_replace(['.', '*'], ['\.', '[^.]*'], $value[0]);
1113
+ return preg_match('#^' . $value . '$#', $components['host']) === 1;
1114
  }
1115
 
1116
  return false;
1121
  *
1122
  * If $date isn't defined it is assumed to be the current date.
1123
  *
1124
+ * @param \DateTimeInterface|string $date optional
1125
  * @access public
1126
+ * @return bool
1127
  */
1128
  public function validateDate($date = null)
1129
  {
1132
  }
1133
 
1134
  if (!isset($date)) {
1135
+ $date = new \DateTimeImmutable('now', new \DateTimeZone(@date_default_timezone_get()));
1136
  }
1137
 
1138
  $notBefore = $this->currentCert['tbsCertificate']['validity']['notBefore'];
1142
  $notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime'];
1143
 
1144
  if (is_string($date)) {
1145
+ $date = new \DateTimeImmutable($date, new \DateTimeZone(@date_default_timezone_get()));
1146
  }
1147
 
1148
+ $notBefore = new \DateTimeImmutable($notBefore, new \DateTimeZone(@date_default_timezone_get()));
1149
+ $notAfter = new \DateTimeImmutable($notAfter, new \DateTimeZone(@date_default_timezone_get()));
1150
 
1151
+ return $date >= $notBefore && $date <= $notAfter;
1152
  }
1153
 
1154
  /**
1192
  if ($temp === false) {
1193
  return false;
1194
  }
1195
+ $data .= $temp;
1196
  }
1197
 
1198
  break;
1694
  $this->dn['rdnSequence'][] = [
1695
  [
1696
  'type' => $propName,
1697
+ 'value' => $v
1698
  ]
1699
  ];
1700
  }
1827
 
1828
  // handles everything else
1829
  $results = preg_split('#((?:^|, *|/)(?:C=|O=|OU=|CN=|L=|ST=|SN=|postalCode=|streetAddress=|emailAddress=|serialNumber=|organizationalUnitName=|title=|description=|role=|x500UniqueIdentifier=|postalAddress=))#', $dn, -1, PREG_SPLIT_DELIM_CAPTURE);
1830
+ for ($i = 1; $i < count($results); $i += 2) {
1831
  $prop = trim($results[$i], ', =/');
1832
  $value = $results[$i + 1];
1833
  if (!$this->setDNProp($prop, $value, $type)) {
1844
  * @param mixed $format optional
1845
  * @param array $dn optional
1846
  * @access public
1847
+ * @return array|bool|string
1848
  */
1849
  public function getDN($format = self::DN_ARRAY, $dn = null)
1850
  {
1949
  }
1950
 
1951
  if (!$start) {
1952
+ $output .= $delim;
1953
  }
1954
  if (is_array($value)) {
1955
  foreach ($value as $type => $v) {
1966
  $value = array_pop($value); // Always strip data type.
1967
  }
1968
  } elseif (is_object($value) && $value instanceof Element) {
1969
+ $callback = function ($x) {
1970
+ return '\x' . bin2hex($x[0]);
1971
+ };
1972
  $value = strtoupper(preg_replace_callback('#[^\x20-\x7E]#', $callback, $value->element));
1973
  }
1974
+ $output .= $desc . '=' . $value;
1975
  $result[$desc] = isset($result[$desc]) ?
1976
  array_merge((array) $result[$desc], [$value]) :
1977
  $value;
2135
  *
2136
  * @param PublicKey $key
2137
  * @access public
2138
+ * @return void
2139
  */
2140
  public function setPublicKey(PublicKey $key)
2141
  {
2202
  $key = $keyinfo['subjectPublicKey'];
2203
 
2204
  switch ($keyinfo['algorithm']['algorithm']) {
2205
+ case 'id-RSASSA-PSS':
2206
+ return RSA::loadFormat('PSS', $key);
2207
  case 'rsaEncryption':
2208
+ return RSA::loadFormat('PKCS8', $key)->withPadding(RSA::SIGNATURE_PKCS1);
2209
  case 'id-ecPublicKey':
2210
  case 'id-Ed25519':
2211
  case 'id-Ed448':
2380
 
2381
  $spkac = ASN1::asn1map($decoded[0], Maps\SignedPublicKeyAndChallenge::MAP);
2382
 
2383
+ if (!isset($spkac) || !is_array($spkac)) {
2384
  $this->currentCert = false;
2385
  return false;
2386
  }
2579
  if ($date instanceof Element) {
2580
  return $date;
2581
  }
2582
+ $dateObj = new \DateTimeImmutable($date, new \DateTimeZone('GMT'));
2583
  $year = $dateObj->format('Y'); // the same way ASN1.php parses this
2584
  if ($year < 2050) {
2585
  return ['utcTime' => $date];
2655
  return false;
2656
  }
2657
 
2658
+ $startDate = new \DateTimeImmutable('now', new \DateTimeZone(@date_default_timezone_get()));
2659
  $startDate = !empty($this->startDate) ? $this->startDate : $startDate->format('D, d M Y H:i:s O');
2660
 
2661
+ $endDate = new \DateTimeImmutable('+1 year', new \DateTimeZone(@date_default_timezone_get()));
2662
  $endDate = !empty($this->endDate) ? $this->endDate : $endDate->format('D, d M Y H:i:s O');
2663
 
2664
  /* "The serial number MUST be a positive integer"
2923
  $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null;
2924
  $signatureAlgorithm = self::identifySignatureAlgorithm($issuer->privateKey);
2925
 
2926
+ $thisUpdate = new \DateTimeImmutable('now', new \DateTimeZone(@date_default_timezone_get()));
2927
  $thisUpdate = !empty($this->startDate) ? $this->startDate : $thisUpdate->format('D, d M Y H:i:s O');
2928
 
2929
  if (isset($crl->currentCert) && is_array($crl->currentCert) && isset($crl->currentCert['tbsCertList'])) {
3097
  /**
3098
  * Set certificate start date
3099
  *
3100
+ * @param \DateTimeInterface|string $date
3101
  * @access public
3102
  */
3103
  public function setStartDate($date)
3104
  {
3105
+ if (!is_object($date) || !($date instanceof \DateTimeInterface)) {
3106
+ $date = new \DateTimeImmutable($date, new \DateTimeZone(@date_default_timezone_get()));
3107
  }
3108
 
3109
  $this->startDate = $date->format('D, d M Y H:i:s O');
3112
  /**
3113
  * Set certificate end date
3114
  *
3115
+ * @param \DateTimeInterface|string $date
3116
  * @access public
3117
  */
3118
  public function setEndDate($date)
3129
  $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . ASN1::encodeLength(strlen($temp)) . $temp;
3130
  $this->endDate = new Element($temp);
3131
  } else {
3132
+ if (!is_object($date) || !($date instanceof \DateTimeInterface)) {
3133
+ $date = new \DateTimeImmutable($date, new \DateTimeZone(@date_default_timezone_get()));
3134
  }
3135
 
3136
  $this->endDate = $date->format('D, d M Y H:i:s O');
3459
  * @access public
3460
  * @return mixed
3461
  */
3462
+ public function getExtension($id, $cert = null, $path = null)
3463
  {
3464
  return $this->getExtensionHelper($id, $cert, $path);
3465
  }
3629
  switch ($disposition) {
3630
  case self::ATTR_REPLACE:
3631
  $disposition = self::ATTR_APPEND;
3632
+ // fall-through
3633
  case self::ATTR_ALL:
3634
  $this->removeAttribute($id);
3635
  break;
3659
  $attributes[$last]['value'][] = $value;
3660
  break;
3661
  default:
3662
+ $attributes[] = ['type' => $id, 'value' => $disposition == self::ATTR_ALL ? $value : [$value]];
3663
  break;
3664
  }
3665
 
3768
  * Format a public key as appropriate
3769
  *
3770
  * @access private
3771
+ * @return array|false
3772
  */
3773
  private function formatSubjectPublicKey()
3774
  {
3780
 
3781
  $decoded = ASN1::decodeBER($publicKey);
3782
  $mapped = ASN1::asn1map($decoded[0], Maps\SubjectPublicKeyInfo::MAP);
3783
+ if (!is_array($mapped)) {
3784
+ return false;
3785
+ }
3786
 
3787
  $mapped['subjectPublicKey'] = $this->publicKey->toString($format);
3788
 
3792
  /**
3793
  * Set the domain name's which the cert is to be valid for
3794
  *
3795
+ * @param mixed ...$domains
3796
  * @access public
3797
+ * @return void
3798
  */
3799
  public function setDomain(...$domains)
3800
  {
3870
  }
3871
 
3872
  $i = count($rclist);
3873
+ $revocationDate = new \DateTimeImmutable('now', new \DateTimeZone(@date_default_timezone_get()));
3874
  $rclist[] = ['userCertificate' => $serial,
3875
  'revocationDate' => $this->timeField($revocationDate->format('D, d M Y H:i:s O'))];
3876
  return $i;
4007
 
4008
  if (is_array($rclist = $this->subArray($crl, 'tbsCertList/revokedCertificates'))) {
4009
  if (($i = $this->revokedCertificate($rclist, $serial)) !== false) {
4010
+ return $this->getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions");
4011
  }
4012
  }
4013
 
vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php CHANGED
@@ -30,6 +30,7 @@
30
  namespace phpseclib3\Math;
31
 
32
  use phpseclib3\Exception\BadConfigurationException;
 
33
 
34
  /**
35
  * Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256
@@ -39,26 +40,19 @@ use phpseclib3\Exception\BadConfigurationException;
39
  * @author Jim Wigginton <terrafrost@php.net>
40
  * @access public
41
  */
42
- class BigInteger implements \Serializable
43
  {
44
  /**
45
  * Main Engine
46
  *
47
- * @var string
48
  */
49
  private static $mainEngine;
50
 
51
- /**
52
- * Modular Exponentiation Engine
53
- *
54
- * @var string
55
- */
56
- private static $modexpEngine;
57
-
58
  /**
59
  * Selected Engines
60
  *
61
- * @var array
62
  */
63
  private static $engines;
64
 
@@ -69,15 +63,34 @@ class BigInteger implements \Serializable
69
  */
70
  private $value;
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  /**
73
  * Sets engine type.
74
  *
75
  * Throws an exception if the type is invalid
76
  *
77
  * @param string $main
78
- * @param array $modexps optional
 
79
  */
80
- public static function setEngine($main, $modexps = ['DefaultEngine'])
81
  {
82
  self::$engines = [];
83
 
@@ -88,6 +101,7 @@ class BigInteger implements \Serializable
88
  if (!$fqmain::isValidEngine()) {
89
  throw new BadConfigurationException("$main is not setup correctly on this system");
90
  }
 
91
  self::$mainEngine = $fqmain;
92
 
93
  if (!in_array('Default', $modexps)) {
@@ -108,8 +122,6 @@ class BigInteger implements \Serializable
108
  throw new BadConfigurationException("No valid modular exponentiation engine found for $main");
109
  }
110
 
111
- self::$modexpEngine = $modexp;
112
-
113
  self::$engines = [$main, $modexp];
114
  }
115
 
@@ -155,7 +167,6 @@ class BigInteger implements \Serializable
155
  *
156
  * @param string|int|BigInteger\Engines\Engine $x Base-10 number or base-$base number if $base set.
157
  * @param int $base
158
- * @return BigInteger
159
  */
160
  public function __construct($x = 0, $base = 10)
161
  {
@@ -186,7 +197,7 @@ class BigInteger implements \Serializable
186
  */
187
  public function __toString()
188
  {
189
- return (string) $this->value;
190
  }
191
 
192
  /**
@@ -230,7 +241,7 @@ class BigInteger implements \Serializable
230
  * @param bool $twos_compliment
231
  * @return string
232
  */
233
- function toBits($twos_compliment = false)
234
  {
235
  return $this->value->toBits($twos_compliment);
236
  }
@@ -252,7 +263,7 @@ class BigInteger implements \Serializable
252
  * @param BigInteger $y
253
  * @return BigInteger
254
  */
255
- function subtract(BigInteger $y)
256
  {
257
  return new static($this->value->subtract($y->value));
258
  }
@@ -306,8 +317,9 @@ class BigInteger implements \Serializable
306
  * Calculates modular inverses.
307
  *
308
  * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
309
- * @return BigInteger
310
  * @param BigInteger $n
 
311
  */
312
  public function modInverse(BigInteger $n)
313
  {
@@ -318,8 +330,9 @@ class BigInteger implements \Serializable
318
  * Calculates modular inverses.
319
  *
320
  * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
321
- * @return BigInteger[]
322
  * @param BigInteger $n
 
323
  */
324
  public function extendedGCD(BigInteger $n)
325
  {
@@ -357,7 +370,7 @@ class BigInteger implements \Serializable
357
  */
358
  public function abs()
359
  {
360
- return new static($this->value->abs());
361
  }
362
 
363
  /**
@@ -390,40 +403,54 @@ class BigInteger implements \Serializable
390
  *
391
  * Will be called, automatically, when serialize() is called on a BigInteger object.
392
  *
393
- * phpseclib 1.0 serialized strings look like this:
394
- * O:15:"Math_BigInteger":1:{s:3:"hex";s:18:"00ab54a98ceb1f0ad2";}
395
  *
396
- * phpseclib 3.0 serialized strings look like this:
397
- * C:25:"phpseclib\Math\BigInteger":42:{a:1:{s:3:"hex";s:18:"00ab54a98ceb1f0ad2";}}
398
  *
399
- * @return string
 
 
 
400
  */
401
- public function serialize()
402
  {
403
- $val = ['hex' => $this->toHex(true)];
404
- $precision = $this->value->getPrecision();
405
- if ($precision > 0) {
406
- $val['precision'] = $precision;
407
  }
408
- return serialize($val);
409
  }
410
 
411
  /**
412
  * Serialize
413
  *
414
  * Will be called, automatically, when unserialize() is called on a BigInteger object.
415
- *
416
- * @param string $serialized
417
  */
418
- public function unserialize($serialized)
419
  {
420
- $r = unserialize($serialized);
421
- $temp = new static($r['hex'], -16);
422
  $this->value = $temp->value;
423
- if (isset($r['precision'])) {
424
  // recalculate $this->bitmask
425
- $this->setPrecision($r['precision']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
  }
 
427
  }
428
 
429
  /**
@@ -453,8 +480,8 @@ class BigInteger implements \Serializable
453
  /**
454
  * Compares two numbers.
455
  *
456
- * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is
457
- * demonstrated thusly:
458
  *
459
  * $x > $y: $x->compare($y) > 0
460
  * $x < $y: $x->compare($y) < 0
@@ -595,7 +622,7 @@ class BigInteger implements \Serializable
595
  $class = self::$mainEngine;
596
  extract($class::minMaxBits($bits));
597
  /** @var BigInteger $min
598
- * @var BigInteger $max
599
  */
600
  return [
601
  'min' => new static($min),
@@ -737,7 +764,9 @@ class BigInteger implements \Serializable
737
  public static function min(BigInteger ...$nums)
738
  {
739
  $class = self::$mainEngine;
740
- $nums = array_map(function($num) { return $num->value; }, $nums);
 
 
741
  return new static($class::min(...$nums));
742
  }
743
 
@@ -750,7 +779,9 @@ class BigInteger implements \Serializable
750
  public static function max(BigInteger ...$nums)
751
  {
752
  $class = self::$mainEngine;
753
- $nums = array_map(function($num) { return $num->value; }, $nums);
 
 
754
  return new static($class::max(...$nums));
755
  }
756
 
@@ -777,7 +808,7 @@ class BigInteger implements \Serializable
777
  /**
778
  * Is Odd?
779
  *
780
- * @return boolean
781
  */
782
  public function isOdd()
783
  {
@@ -788,7 +819,7 @@ class BigInteger implements \Serializable
788
  * Tests if a bit is set
789
  *
790
  * @param int $x
791
- * @return boolean
792
  */
793
  public function testBit($x)
794
  {
@@ -798,7 +829,7 @@ class BigInteger implements \Serializable
798
  /**
799
  * Is Negative?
800
  *
801
- * @return boolean
802
  */
803
  public function isNegative()
804
  {
@@ -842,7 +873,7 @@ class BigInteger implements \Serializable
842
  public function createRecurringModuloFunction()
843
  {
844
  $func = $this->value->createRecurringModuloFunction();
845
- return function(BigInteger $x) use ($func) {
846
  return new static($func($x->value));
847
  };
848
  }
@@ -853,11 +884,11 @@ class BigInteger implements \Serializable
853
  * Splits BigInteger's into chunks of $split bits
854
  *
855
  * @param int $split
856
- * @return \phpseclib3\Math\BigInteger[]
857
  */
858
  public function bitwise_split($split)
859
  {
860
- return array_map(function($val) {
861
  return new static($val);
862
  }, $this->value->bitwise_split($split));
863
  }
30
  namespace phpseclib3\Math;
31
 
32
  use phpseclib3\Exception\BadConfigurationException;
33
+ use phpseclib3\Math\BigInteger\Engines\Engine;
34
 
35
  /**
36
  * Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256
40
  * @author Jim Wigginton <terrafrost@php.net>
41
  * @access public
42
  */
43
+ class BigInteger implements \JsonSerializable
44
  {
45
  /**
46
  * Main Engine
47
  *
48
+ * @var class-string<Engine>
49
  */
50
  private static $mainEngine;
51
 
 
 
 
 
 
 
 
52
  /**
53
  * Selected Engines
54
  *
55
+ * @var list<string>
56
  */
57
  private static $engines;
58
 
63
  */
64
  private $value;
65
 
66
+ /**
67
+ * Mode independent value used for serialization.
68
+ *
69
+ * @see self::__sleep()
70
+ * @see self::__wakeup()
71
+ * @var string
72
+ */
73
+ private $hex;
74
+
75
+ /**
76
+ * Precision (used only for serialization)
77
+ *
78
+ * @see self::__sleep()
79
+ * @see self::__wakeup()
80
+ * @var int
81
+ */
82
+ private $precision;
83
+
84
  /**
85
  * Sets engine type.
86
  *
87
  * Throws an exception if the type is invalid
88
  *
89
  * @param string $main
90
+ * @param list<string> $modexps optional
91
+ * @return void
92
  */
93
+ public static function setEngine($main, array $modexps = ['DefaultEngine'])
94
  {
95
  self::$engines = [];
96
 
101
  if (!$fqmain::isValidEngine()) {
102
  throw new BadConfigurationException("$main is not setup correctly on this system");
103
  }
104
+ /** @var class-string<Engine> $fqmain */
105
  self::$mainEngine = $fqmain;
106
 
107
  if (!in_array('Default', $modexps)) {
122
  throw new BadConfigurationException("No valid modular exponentiation engine found for $main");
123
  }
124
 
 
 
125
  self::$engines = [$main, $modexp];
126
  }
127
 
167
  *
168
  * @param string|int|BigInteger\Engines\Engine $x Base-10 number or base-$base number if $base set.
169
  * @param int $base
 
170
  */
171
  public function __construct($x = 0, $base = 10)
172
  {
197
  */
198
  public function __toString()
199
  {
200
+ return (string)$this->value;
201
  }
202
 
203
  /**
241
  * @param bool $twos_compliment
242
  * @return string
243
  */
244
+ public function toBits($twos_compliment = false)
245
  {
246
  return $this->value->toBits($twos_compliment);
247
  }
263
  * @param BigInteger $y
264
  * @return BigInteger
265
  */
266
+ public function subtract(BigInteger $y)
267
  {
268
  return new static($this->value->subtract($y->value));
269
  }
317
  * Calculates modular inverses.
318
  *
319
  * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
320
+ *
321
  * @param BigInteger $n
322
+ * @return BigInteger
323
  */
324
  public function modInverse(BigInteger $n)
325
  {
330
  * Calculates modular inverses.
331
  *
332
  * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
333
+ *
334
  * @param BigInteger $n
335
+ * @return BigInteger[]
336
  */
337
  public function extendedGCD(BigInteger $n)
338
  {
370
  */
371
  public function abs()
372
  {
373
+ return new static($this->value->abs());
374
  }
375
 
376
  /**
403
  *
404
  * Will be called, automatically, when serialize() is called on a BigInteger object.
405
  *
406
+ * __sleep() / __wakeup() have been around since PHP 4.0
 
407
  *
408
+ * \Serializable was introduced in PHP 5.1 and deprecated in PHP 8.1:
409
+ * https://wiki.php.net/rfc/phase_out_serializable
410
  *
411
+ * __serialize() / __unserialize() were introduced in PHP 7.4:
412
+ * https://wiki.php.net/rfc/custom_object_serialization
413
+ *
414
+ * @return array
415
  */
416
+ public function __sleep()
417
  {
418
+ $this->hex = $this->toHex(true);
419
+ $vars = ['hex'];
420
+ if ($this->getPrecision() > 0) {
421
+ $vars[] = 'precision';
422
  }
423
+ return $vars;
424
  }
425
 
426
  /**
427
  * Serialize
428
  *
429
  * Will be called, automatically, when unserialize() is called on a BigInteger object.
 
 
430
  */
431
+ public function __wakeup()
432
  {
433
+ $temp = new static($this->hex, -16);
 
434
  $this->value = $temp->value;
435
+ if ($this->precision > 0) {
436
  // recalculate $this->bitmask
437
+ $this->setPrecision($this->precision);
438
+ }
439
+ }
440
+
441
+ /**
442
+ * JSON Serialize
443
+ *
444
+ * Will be called, automatically, when json_encode() is called on a BigInteger object.
445
+ */
446
+ #[\ReturnTypeWillChange]
447
+ public function jsonSerialize()
448
+ {
449
+ $result = ['hex' => $this->toHex(true)];
450
+ if ($this->precision > 0) {
451
+ $result['precision'] = $this->getPrecision();
452
  }
453
+ return $result;
454
  }
455
 
456
  /**
480
  /**
481
  * Compares two numbers.
482
  *
483
+ * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this
484
+ * is demonstrated thusly:
485
  *
486
  * $x > $y: $x->compare($y) > 0
487
  * $x < $y: $x->compare($y) < 0
622
  $class = self::$mainEngine;
623
  extract($class::minMaxBits($bits));
624
  /** @var BigInteger $min
625
+ * @var BigInteger $max
626
  */
627
  return [
628
  'min' => new static($min),
764
  public static function min(BigInteger ...$nums)
765
  {
766
  $class = self::$mainEngine;
767
+ $nums = array_map(function ($num) {
768
+ return $num->value;
769
+ }, $nums);
770
  return new static($class::min(...$nums));
771
  }
772
 
779
  public static function max(BigInteger ...$nums)
780
  {
781
  $class = self::$mainEngine;
782
+ $nums = array_map(function ($num) {
783
+ return $num->value;
784
+ }, $nums);
785
  return new static($class::max(...$nums));
786
  }
787
 
808
  /**
809
  * Is Odd?
810
  *
811
+ * @return bool
812
  */
813
  public function isOdd()
814
  {
819
  * Tests if a bit is set
820
  *
821
  * @param int $x
822
+ * @return bool
823
  */
824
  public function testBit($x)
825
  {
829
  /**
830
  * Is Negative?
831
  *
832
+ * @return bool
833
  */
834
  public function isNegative()
835
  {
873
  public function createRecurringModuloFunction()
874
  {
875
  $func = $this->value->createRecurringModuloFunction();
876
+ return function (BigInteger $x) use ($func) {
877
  return new static($func($x->value));
878
  };
879
  }
884
  * Splits BigInteger's into chunks of $split bits
885
  *
886
  * @param int $split
887
+ * @return BigInteger[]
888
  */
889
  public function bitwise_split($split)
890
  {
891
+ return array_map(function ($val) {
892
  return new static($val);
893
  }, $this->value->bitwise_split($split));
894
  }
vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath.php CHANGED
@@ -44,53 +44,11 @@ class BCMath extends Engine
44
  */
45
  const ENGINE_DIR = 'BCMath';
46
 
47
- /**
48
- * Modular Exponentiation Engine
49
- *
50
- * @var string
51
- */
52
- protected static $modexpEngine;
53
-
54
- /**
55
- * Engine Validity Flag
56
- *
57
- * @var bool
58
- */
59
- protected static $isValidEngine;
60
-
61
- /**
62
- * BigInteger(0)
63
- *
64
- * @var \phpseclib3\Math\BigInteger\Engines\BCMath
65
- */
66
- protected static $zero;
67
-
68
- /**
69
- * BigInteger(1)
70
- *
71
- * @var \phpseclib3\Math\BigInteger\Engines\BCMath
72
- */
73
- protected static $one;
74
-
75
- /**
76
- * BigInteger(2)
77
- *
78
- * @var \phpseclib3\Math\BigInteger\Engines\BCMath
79
- */
80
- protected static $two;
81
-
82
- /**
83
- * Primes > 2 and < 1000
84
- *
85
- * @var array
86
- */
87
- protected static $primes;
88
-
89
  /**
90
  * Test for engine validity
91
  *
92
- * @see parent::__construct()
93
  * @return bool
 
94
  */
95
  public static function isValidEngine()
96
  {
@@ -103,14 +61,13 @@ class BCMath extends Engine
103
  * @param mixed $x integer Base-10 number or base-$base number if $base set.
104
  * @param int $base
105
  * @see parent::__construct()
106
- * @return \phpseclib3\Math\BigInteger\Engines\BCMath
107
  */
108
  public function __construct($x = 0, $base = 10)
109
  {
110
- if (!isset(self::$isValidEngine)) {
111
- self::$isValidEngine = self::isValidEngine();
112
  }
113
- if (!self::$isValidEngine) {
114
  throw new BadConfigurationException('BCMath is not setup correctly on this system');
115
  }
116
 
@@ -135,9 +92,15 @@ class BCMath extends Engine
135
  $x = str_pad($this->value, $len, chr(0), STR_PAD_LEFT);
136
 
137
  $this->value = '0';
138
- for ($i = 0; $i < $len; $i+= 4) {
139
  $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32
140
- $this->value = bcadd($this->value, 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3])), 0);
 
 
 
 
 
 
141
  }
142
 
143
  if ($this->is_negative) {
@@ -153,7 +116,7 @@ class BCMath extends Engine
153
  case 10:
154
  // explicitly casting $x to a string is necessary, here, since doing $x[0] on -1 yields different
155
  // results then doing it on '-1' does (modInverse does $x[0])
156
- $this->value = $this->value === '-' ? '0' : (string) $this->value;
157
  }
158
  }
159
 
@@ -177,7 +140,7 @@ class BCMath extends Engine
177
  * @param bool $twos_compliment
178
  * @return string
179
  */
180
- function toBytes($twos_compliment = false)
181
  {
182
  if ($twos_compliment) {
183
  return $this->toBytesHelper();
@@ -252,7 +215,7 @@ class BCMath extends Engine
252
  * and the divisor (basically, the "common residue" is the first positive modulo).
253
  *
254
  * @param BCMath $y
255
- * @return BCMath
256
  */
257
  public function divide(BCMath $y)
258
  {
@@ -274,8 +237,8 @@ class BCMath extends Engine
274
  *
275
  * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
276
  *
 
277
  * @return false|BCMath
278
- * @param \phpseclib3\Math\BigInteger\Engines\BCMath $n
279
  */
280
  public function modInverse(BCMath $n)
281
  {
@@ -291,7 +254,7 @@ class BCMath extends Engine
291
  * {@link http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity Bezout's identity - Wikipedia} for more information.
292
  *
293
  * @param BCMath $n
294
- * @return BCMath
295
  */
296
  public function extendedGCD(BCMath $n)
297
  {
@@ -325,8 +288,8 @@ class BCMath extends Engine
325
 
326
  return [
327
  'gcd' => $this->normalize(new static($u)),
328
- 'x' => $this->normalize(new static($a)),
329
- 'y' => $this->normalize(new static($b))
330
  ];
331
  }
332
 
@@ -348,7 +311,7 @@ class BCMath extends Engine
348
  /**
349
  * Absolute value.
350
  *
351
- * @return \phpseclib3\Math\BigInteger\Engines\BCMath
352
  */
353
  public function abs()
354
  {
@@ -399,7 +362,7 @@ class BCMath extends Engine
399
  * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift.
400
  *
401
  * @param int $shift
402
- * @return \phpseclib3\Math\BigInteger\Engines\BCMath
403
  */
404
  public function bitwise_rightShift($shift)
405
  {
@@ -415,7 +378,7 @@ class BCMath extends Engine
415
  * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift.
416
  *
417
  * @param int $shift
418
- * @return \phpseclib3\Math\BigInteger\Engines\BCMath
419
  */
420
  public function bitwise_leftShift($shift)
421
  {
@@ -428,8 +391,8 @@ class BCMath extends Engine
428
  /**
429
  * Compares two numbers.
430
  *
431
- * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is
432
- * demonstrated thusly:
433
  *
434
  * $x > $y: $x->compare($y) > 0
435
  * $x < $y: $x->compare($y) < 0
@@ -497,7 +460,7 @@ class BCMath extends Engine
497
  protected function powModInner(BCMath $e, BCMath $n)
498
  {
499
  try {
500
- $class = self::$modexpEngine;
501
  return $class::powModHelper($this, $e, $n, static::class);
502
  } catch (\Exception $err) {
503
  return BCMath\DefaultEngine::powModHelper($this, $e, $n, static::class);
@@ -514,8 +477,6 @@ class BCMath extends Engine
514
  */
515
  protected function normalize(BCMath $result)
516
  {
517
- unset($result->reduce);
518
-
519
  $result->precision = $this->precision;
520
  $result->bitmask = $this->bitmask;
521
 
@@ -591,7 +552,7 @@ class BCMath extends Engine
591
 
592
  $value = $this->value;
593
 
594
- foreach (self::$primes as $prime) {
595
  $r = bcmod($this->value, $prime);
596
  if ($r == '0') {
597
  return $this->value == $prime;
@@ -606,15 +567,15 @@ class BCMath extends Engine
606
  *
607
  * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s));
608
  *
609
- * @see self::isPrime()
610
  * @param BCMath $r
611
  * @return int
 
612
  */
613
  public static function scan1divide(BCMath $r)
614
  {
615
  $r_value = &$r->value;
616
  $s = 0;
617
- // if $n was 1, $r would be 0 and this would be an infinite loop, hence our $this->equals(static::$one) check earlier
618
  while ($r_value[strlen($r_value) - 1] % 2 == 0) {
619
  $r_value = bcdiv($r_value, '2', 0);
620
  ++$s;
@@ -674,20 +635,20 @@ class BCMath extends Engine
674
  /**
675
  * Set Bitmask
676
  *
677
- * @return Engine
678
  * @param int $bits
 
679
  * @see self::setPrecision()
680
  */
681
  protected static function setBitmask($bits)
682
  {
683
  $temp = parent::setBitmask($bits);
684
- return $temp->add(static::$one);
685
  }
686
 
687
  /**
688
  * Is Odd?
689
  *
690
- * @return boolean
691
  */
692
  public function isOdd()
693
  {
@@ -697,12 +658,12 @@ class BCMath extends Engine
697
  /**
698
  * Tests if a bit is set
699
  *
700
- * @return boolean
701
  */
702
  public function testBit($x)
703
  {
704
  return bccomp(
705
- bcmod($this->value, bcpow('2', $x + 1, 0), 0),
706
  bcpow('2', $x, 0),
707
  0
708
  ) >= 0;
@@ -711,7 +672,7 @@ class BCMath extends Engine
711
  /**
712
  * Is Negative?
713
  *
714
- * @return boolean
715
  */
716
  public function isNegative()
717
  {
@@ -739,4 +700,4 @@ class BCMath extends Engine
739
 
740
  return $temp;
741
  }
742
- }
44
  */
45
  const ENGINE_DIR = 'BCMath';
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  /**
48
  * Test for engine validity
49
  *
 
50
  * @return bool
51
+ * @see parent::__construct()
52
  */
53
  public static function isValidEngine()
54
  {
61
  * @param mixed $x integer Base-10 number or base-$base number if $base set.
62
  * @param int $base
63
  * @see parent::__construct()
 
64
  */
65
  public function __construct($x = 0, $base = 10)
66
  {
67
+ if (!isset(static::$isValidEngine[static::class])) {
68
+ static::$isValidEngine[static::class] = self::isValidEngine();
69
  }
70
+ if (!static::$isValidEngine[static::class]) {
71
  throw new BadConfigurationException('BCMath is not setup correctly on this system');
72
  }
73
 
92
  $x = str_pad($this->value, $len, chr(0), STR_PAD_LEFT);
93
 
94
  $this->value = '0';
95
+ for ($i = 0; $i < $len; $i += 4) {
96
  $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32
97
+ $this->value = bcadd(
98
+ $this->value,
99
+ 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord(
100
+ $x[$i + 2]
101
+ ) << 8) | ord($x[$i + 3])),
102
+ 0
103
+ );
104
  }
105
 
106
  if ($this->is_negative) {
116
  case 10:
117
  // explicitly casting $x to a string is necessary, here, since doing $x[0] on -1 yields different
118
  // results then doing it on '-1' does (modInverse does $x[0])
119
+ $this->value = $this->value === '-' ? '0' : (string)$this->value;
120
  }
121
  }
122
 
140
  * @param bool $twos_compliment
141
  * @return string
142
  */
143
+ public function toBytes($twos_compliment = false)
144
  {
145
  if ($twos_compliment) {
146
  return $this->toBytesHelper();
215
  * and the divisor (basically, the "common residue" is the first positive modulo).
216
  *
217
  * @param BCMath $y
218
+ * @return array{static, static}
219
  */
220
  public function divide(BCMath $y)
221
  {
237
  *
238
  * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses.
239
  *
240
+ * @param BCMath $n
241
  * @return false|BCMath
 
242
  */
243
  public function modInverse(BCMath $n)
244
  {
254
  * {@link http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity Bezout's identity - Wikipedia} for more information.
255
  *
256
  * @param BCMath $n
257
+ * @return array{gcd: static, x: static, y: static}
258
  */
259
  public function extendedGCD(BCMath $n)
260
  {
288
 
289
  return [
290
  'gcd' => $this->normalize(new static($u)),
291
+ 'x' => $this->normalize(new static($a)),
292
+ 'y' => $this->normalize(new static($b))
293
  ];
294
  }
295
 
311
  /**
312
  * Absolute value.
313
  *
314
+ * @return BCMath
315
  */
316
  public function abs()
317
  {
362
  * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift.
363
  *
364
  * @param int $shift
365
+ * @return BCMath
366
  */
367
  public function bitwise_rightShift($shift)
368
  {
378
  * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift.
379
  *
380
  * @param int $shift
381
+ * @return BCMath
382
  */
383
  public function bitwise_leftShift($shift)
384
  {
391
  /**
392
  * Compares two numbers.
393
  *
394
+ * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this
395
+ * is demonstrated thusly:
396
  *
397
  * $x > $y: $x->compare($y) > 0
398
  * $x < $y: $x->compare($y) < 0
460
  protected function powModInner(BCMath $e, BCMath $n)
461
  {
462
  try {
463
+ $class = static::$modexpEngine[static::class];
464
  return $class::powModHelper($this, $e, $n, static::class);
465
  } catch (\Exception $err) {
466
  return BCMath\DefaultEngine::powModHelper($this, $e, $n, static::class);
477
  */
478
  protected function normalize(BCMath $result)
479
  {
 
 
480
  $result->precision = $this->precision;
481
  $result->bitmask = $this->bitmask;
482
 
552
 
553
  $value = $this->value;
554
 
555
+ foreach (self::PRIMES as $prime) {
556
  $r = bcmod($this->value, $prime);
557
  if ($r == '0') {
558
  return $this->value == $prime;
567
  *
568
  * ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s));
569
  *
 
570
  * @param BCMath $r
571
  * @return int
572
+ * @see self::isPrime()
573
  */
574
  public static function scan1divide(BCMath $r)
575
  {
576
  $r_value = &$r->value;
577
  $s = 0;
578
+ // if $n was 1, $r would be 0 and this would be an infinite loop, hence our $this->equals(static::$one[static::class]) check earlier
579
  while ($r_value[strlen($r_value) - 1] % 2 == 0) {
580
  $r_value = bcdiv($r_value, '2', 0);
581
  ++$s;
635
  /**
636
  * Set Bitmask
637
  *
 
638
  * @param int $bits
639
+ * @return Engine
640
  * @see self::setPrecision()
641
  */
642
  protected static function setBitmask($bits)
643
  {
644
  $temp = parent::setBitmask($bits);
645
+ return $temp->add(static::$one[static::class]);
646
  }
647
 
648
  /**
649
  * Is Odd?
650
  *
651
+ * @return bool
652
  */
653
  public function isOdd()
654
  {
658
  /**
659
  * Tests if a bit is set
660
  *
661
+ * @return bool
662
  */
663
  public function testBit($x)
664
  {
665
  return bccomp(
666
+ bcmod($this->value, bcpow('2', $x + 1, 0)),
667
  bcpow('2', $x, 0),
668
  0
669
  ) >= 0;
672
  /**
673
  * Is Negative?
674
  *
675
+ * @return bool
676
  */
677
  public function isNegative()
678
  {
700
 
701
  return $temp;
702
  }
703
+ }
vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Base.php CHANGED
@@ -54,11 +54,11 @@ abstract class Base extends BCMath
54
  /**
55
  * Performs modular exponentiation.
56
  *
57
- * @param \phpseclib3\Math\BigInteger\Engines\BCMath $x
58
- * @param \phpseclib3\Math\BigInteger\Engines\BCMath $e
59
- * @param \phpseclib3\Math\BigInteger\Engines\BCMath $n
60
  * @param string $class
61
- * @return \phpseclib3\Math\BigInteger\Engines\BCMath
62
  */
63
  protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n, $class)
64
  {
@@ -113,4 +113,4 @@ abstract class Base extends BCMath
113
  {
114
  return static::reduce(bcmul($x, $x), $n);
115
  }
116
- }
54
  /**
55
  * Performs modular exponentiation.
56
  *
57
+ * @param BCMath $x
58
+ * @param BCMath $e
59
+ * @param BCMath $n
60
  * @param string $class
61
+ * @return BCMath
62
  */
63
  protected static function powModHelper(BCMath $x, BCMath $e, BCMath $n, $class)
64
  {
113
  {
114
  return static::reduce(bcmul($x, $x), $n);
115
  }
116
+ }
vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/BuiltIn.php CHANGED
@@ -41,4 +41,4 @@ abstract class BuiltIn extends BCMath
41
 
42
  return $x->normalize($temp);
43
  }
44
- }
41
 
42
  return $x->normalize($temp);
43
  }
44
+ }
vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/DefaultEngine.php CHANGED
@@ -26,4 +26,4 @@ use phpseclib3\Math\BigInteger\Engines\BCMath\Reductions\Barrett;
26
  */
27
  abstract class DefaultEngine extends Barrett
28
  {
29
- }
26
  */
27
  abstract class DefaultEngine extends Barrett
28
  {
29
+ }
vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/OpenSSL.php CHANGED
@@ -26,4 +26,4 @@ use phpseclib3\Math\BigInteger\Engines\OpenSSL as Progenitor;
26
  */
27
  abstract class OpenSSL extends Progenitor
28
  {
29
- }
26
  */
27
  abstract class OpenSSL extends Progenitor
28
  {
29
+ }
vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/Barrett.php CHANGED
@@ -61,7 +61,7 @@ abstract class Barrett extends Base
61
  *
62
  * @param string $n
63
  * @param string $m
64
- * @return array|string
65
  */
66
  protected static function reduce($n, $m)
67
  {
@@ -92,7 +92,7 @@ abstract class Barrett extends Base
92
 
93
  $cache[self::DATA][] = [
94
  'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1)
95
- 'm1'=> $m1 // m.length
96
  ];
97
  } else {
98
  extract($cache[self::DATA][$key]);
@@ -190,4 +190,4 @@ abstract class Barrett extends Base
190
 
191
  return $result;
192
  }
193
- }
61
  *
62
  * @param string $n
63
  * @param string $m
64
+ * @return string
65
  */
66
  protected static function reduce($n, $m)
67
  {
92
 
93
  $cache[self::DATA][] = [
94
  'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1)
95
+ 'm1' => $m1 // m.length
96
  ];
97
  } else {
98
  extract($cache[self::DATA][$key]);
190
 
191
  return $result;
192
  }
193
+ }
vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/BCMath/Reductions/EvalBarrett.php CHANGED
@@ -15,8 +15,8 @@
15
 
16
  namespace phpseclib3\Math\BigInteger\Engines\BCMath\Reductions;
17
 
18
- use phpseclib3\Math\BigInteger\Engines\BCMath\Base;
19
  use phpseclib3\Math\BigInteger\Engines\BCMath;
 
20
 
21
  /**
22
  * PHP Barrett Modular Exponentiation Engine
@@ -59,11 +59,6 @@ abstract class EvalBarrett extends Base
59
  */
60
  protected static function generateCustomReduction(BCMath $m, $class)
61
  {
62
- if (isset($n->reduce)) {
63
- self::$custom_reduction = $n->reduce;
64
- return $n->reduce;
65
- }
66
-
67
  $m_length = strlen($m);
68
 
69
  if ($m_length < 5) {
@@ -81,9 +76,9 @@ abstract class EvalBarrett extends Base
81
 
82
  $m = "'$m'";
83
  $u = "'$u'";
84
- $m1= "'$m1'";
85
 
86
- $code.= '
87
  $lsd = substr($n, -' . $cutoff . ');
88
  $msd = substr($n, 0, -' . $cutoff . ');
89
 
@@ -114,4 +109,4 @@ abstract class EvalBarrett extends Base
114
 
115
  return $func;
116
  }
117
- }
15
 
16
  namespace phpseclib3\Math\BigInteger\Engines\BCMath\Reductions;
17
 
 
18
  use phpseclib3\Math\BigInteger\Engines\BCMath;
19
+ use phpseclib3\Math\BigInteger\Engines\BCMath\Base;
20
 
21
  /**
22
  * PHP Barrett Modular Exponentiation Engine
59
  */
60
  protected static function generateCustomReduction(BCMath $m, $class)
61
  {
 
 
 
 
 
62
  $m_length = strlen($m);
63
 
64
  if ($m_length < 5) {
76
 
77
  $m = "'$m'";
78
  $u = "'$u'";
79
+ $m1 = "'$m1'";
80
 
81
+ $code = '
82
  $lsd = substr($n, -' . $cutoff . ');
83
  $msd = substr($n, 0, -' . $cutoff . ');
84
 
109
 
110
  return $func;
111
  }
112
+ }
vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/Engine.php CHANGED
@@ -16,10 +16,10 @@
16
  namespace phpseclib3\Math\BigInteger\Engines;
17
 
18
  use ParagonIE\ConstantTime\Hex;
19
- use phpseclib3\Exception\BadConfigurationException;
20
  use phpseclib3\Crypt\Random;
 
21
  use phpseclib3\Math\BigInteger;
22
- use phpseclib3\Common\Functions\Strings;
23
 
24
  /**
25
  * Base Engine.
@@ -28,12 +28,61 @@ use phpseclib3\Common\Functions\Strings;
28
  * @author Jim Wigginton <terrafrost@php.net>
29
  * @access public
30
  */
31
- abstract class Engine implements \Serializable
32
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  /**
34
  * Holds the BigInteger's value
35
  *
36
- * @var mixed
37
  */
38
  protected $value;
39
 
@@ -48,6 +97,7 @@ abstract class Engine implements \Serializable
48
  * Precision
49
  *
50
  * @see static::setPrecision()
 
51
  */
52
  protected $precision = -1;
53
 
@@ -55,6 +105,7 @@ abstract class Engine implements \Serializable
55
  * Precision Bitmask
56
  *
57
  * @see static::setPrecision()
 
58
  */
59
  protected $bitmask = false;
60
 
@@ -65,31 +116,28 @@ abstract class Engine implements \Serializable
65
  */
66
  protected $reduce;
67
 
 
 
 
 
 
 
 
 
 
68
  /**
69
  * Default constructor
70
  *
71
- * @param mixed $x integer Base-10 number or base-$base number if $base set.
72
  * @param int $base
73
  */
74
- public function __construct($x, $base)
75
  {
76
- if (!isset(static::$primes)) {
77
- static::$primes = [
78
- 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
79
- 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137,
80
- 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227,
81
- 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313,
82
- 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419,
83
- 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509,
84
- 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617,
85
- 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727,
86
- 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829,
87
- 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947,
88
- 953, 967, 971, 977, 983, 991, 997
89
- ];
90
- static::$zero = new static(0);
91
- static::$one = new static(1);
92
- static::$two = new static(2);
16
  namespace phpseclib3\Math\BigInteger\Engines;
17
 
18
  use ParagonIE\ConstantTime\Hex;
19
+ use phpseclib3\Common\Functions\Strings;
20
  use phpseclib3\Crypt\Random;
21
+ use phpseclib3\Exception\BadConfigurationException;
22
  use phpseclib3\Math\BigInteger;
 
23
 
24
  /**
25
  * Base Engine.
28
  * @author Jim Wigginton <terrafrost@php.net>
29
  * @access public
30
  */
31
+ abstract class Engine implements \JsonSerializable
32
  {
33
+ /* final protected */ const PRIMES = [
34
+ 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
35
+ 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137,
36
+ 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227,
37
+ 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313,
38
+ 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419,
39
+ 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509,
40
+ 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617,
41
+ 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727,
42
+ 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829,
43
+ 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947,
44
+ 953, 967, 971, 977, 983, 991, 997,
45
+ ];
46
+
47
+ /**
48
+ * BigInteger(0)
49
+ *
50
+ * @var array<class-string<static>, static>
51
+ */
52
+ protected static $zero = [];
53
+
54
+ /**
55
+ * BigInteger(1)
56
+ *
57
+ * @var array<class-string<static>, static>
58
+ */
59
+ protected static $one = [];
60
+
61
+ /**
62
+ * BigInteger(2)
63
+ *
64
+ * @var array<class-string<static>, static>
65
+ */
66
+ protected static $two = [];
67
+
68
+ /**
69
+ * Modular Exponentiation Engine
70
+ *
71
+ * @var array<class-string<static>, class-string<static>>
72
+ */
73
+ protected static $modexpEngine;
74
+
75
+ /**
76
+ * Engine Validity Flag
77
+ *
78
+ * @var array<class-string<static>, bool>
79
+ */
80
+ protected static $isValidEngine;
81
+
82
  /**
83
  * Holds the BigInteger's value
84
  *
85
+ * @var \GMP|string|array|int
86
  */
87
  protected $value;
88
 
97
  * Precision
98
  *
99
  * @see static::setPrecision()
100
+ * @var int
101
  */
102
  protected $precision = -1;
103
 
105
  * Precision Bitmask
106
  *
107
  * @see static::setPrecision()
108
+ * @var static|false
109
  */
110
  protected $bitmask = false;
111
 
116
  */
117
  protected $reduce;
118
 
119
+ /**
120
+ * Mode independent value used for serialization.
121
+ *
122
+ * @see self::__sleep()
123
+ * @see self::__wakeup()
124
+ * @var string
125
+ */
126
+ protected $hex;
127
+
128
  /**
129
  * Default constructor
130
  *
131
+ * @param int|numeric-string $x integer Base-10 number or base-$base number if $base set.
132
  * @param int $base
133
  */
134
+ public function __construct($x = 0, $base = 10)
135
  {
136
+ if (!array_key_exists(static::class, static::$zero)) {
137
+ static::$zero[static::class] = null; // Placeholder to prevent infinite