Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

argon2i.php

Zuletzt modifiziert: 02.04.2025, 15:02 - Dateigröße: 2.25 KiB


01  <?php
02  /**
03  *
04  * This file is part of the phpBB Forum Software package.
05  *
06  * @copyright (c) phpBB Limited <https://www.phpbb.com>
07  * @license GNU General Public License, version 2 (GPL-2.0)
08  *
09  * For full copyright and license information, please see
10  * the docs/CREDITS.txt file.
11  *
12  */
13   
14  namespace phpbb\passwords\driver;
15   
16  class argon2i extends base_native
17  {
18      /** @var int Maximum memory (in bytes) that may be used to compute the Argon2 hash */
19      protected $memory_cost;
20   
21      /** @var int Number of threads to use for computing the Argon2 hash */
22      protected $threads;
23   
24      /** @var int Maximum amount of time it may take to compute the Argon2 hash */
25      protected $time_cost;
26   
27      /**
28      * Constructor of passwords driver object
29      *
30      * @param \phpbb\config\config $config phpBB config
31      * @param \phpbb\passwords\driver\helper $helper Password driver helper
32      * @param int $memory_cost Maximum memory (optional)
33      * @param int $threads Number of threads to use (optional)
34      * @param int $time_cost Maximum amount of time (optional)
35      */
36      public function __construct(\phpbb\config\config $config, helper $helper, $memory_cost = 65536, $threads = 2, $time_cost = 4)
37      {
38          parent::__construct($config, $helper);
39   
40          /**
41           * For Sodium implementation of argon2 algorithm (since PHP 7.4), set special value of 1 for "threads" cost factor
42           * See https://wiki.php.net/rfc/sodium.argon.hash and PHPBB3-16266
43           * Don't allow cost factors to be below default settings where possible
44           */
45          $this->memory_cost = max($memory_cost, defined('PASSWORD_ARGON2_DEFAULT_MEMORY_COST') ? PASSWORD_ARGON2_DEFAULT_MEMORY_COST : 65536);
46          $this->time_cost   = max($time_cost, defined('PASSWORD_ARGON2_DEFAULT_TIME_COST') ? PASSWORD_ARGON2_DEFAULT_TIME_COST : 4);
47          $this->threads     = (defined('PASSWORD_ARGON2_PROVIDER') && PASSWORD_ARGON2_PROVIDER == 'sodium') ?
48                                      1 : max($threads, defined('PASSWORD_ARGON2_DEFAULT_THREADS') ? PASSWORD_ARGON2_DEFAULT_THREADS : 1);
49      }
50   
51      /**
52      * {@inheritdoc}
53      */
54      public function get_algo_name()
55      {
56          return 'PASSWORD_ARGON2I';
57      }
58   
59      /**
60      * {@inheritdoc}
61      */
62      public function get_options()
63      {
64          return [
65              'memory_cost' => $this->memory_cost,
66              'time_cost'   => $this->time_cost,
67              'threads'     => $this->threads
68          ];
69      }
70   
71      /**
72      * {@inheritdoc}
73      */
74      public function get_prefix()
75      {
76          return '$argon2i$';
77      }
78  }
79