0961d3a3a3ed837288d64b425ead745632587677
[Packages/TYPO3.CMS.git] / typo3 / sysext / saltedpasswords / classes / salts / interfaces / interface.tx_saltedpasswords_salts.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2010 Marcus Krause <marcus#exp2009@t3sec.info>
6 * (c) 2009-2010 Steffen Ritter <info@rs-websystems.de>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
29 * Contains interface "tx_saltedpasswords_salts" to be used in
30 * classes that provide salted hashing.
31 *
32 * $Id$
33 */
34
35
36 /**
37 * Interface with public methods needed to be implemented
38 * in a salting hashing class.
39 *
40 * @author Marcus Krause <marcus#exp2009@t3sec.info>
41 * @author Steffen Ritter <info@rs-websystems.de>
42 *
43 * @since 2009-09-06
44 * @package TYPO3
45 * @subpackage tx_saltedpasswords
46 */
47 interface tx_saltedpasswords_salts {
48 /**
49 * Method checks if a given plaintext password is correct by comparing it with
50 * a given salted hashed password.
51 *
52 * @param string $plainPW: plain-text password to compare with salted hash
53 * @param string $saltedHashPW: salted hash to compare plain-text password with
54 * @return boolean TRUE, if plaintext password is correct, otherwise FALSE
55 */
56 public function checkPassword($plainPW, $saltedHashPW);
57
58 /**
59 * Returns length of required salt.
60 *
61 * @return integer length of required salt
62 */
63 public function getSaltLength();
64
65 /**
66 * Returns wether all prequesites for the hashing methods are matched
67 *
68 * @return boolean method available
69 */
70 public function isAvailable();
71
72
73 /**
74 * Method creates a salted hash for a given plaintext password
75 *
76 * @param string $password: plaintext password to create a salted hash from
77 * @param string $salt: optional custom salt to use
78 * @return string salted hashed password
79 */
80 public function getHashedPassword($password, $salt = NULL);
81
82 /**
83 * Checks whether a user's hashed password needs to be replaced with a new hash.
84 *
85 * This is typically called during the login process when the plain text
86 * password is available. A new hash is needed when the desired iteration
87 * count has changed through a change in the variable $hashCount or
88 * HASH_COUNT or if the user's password hash was generated in an bulk update
89 * with class ext_update.
90 *
91 * @param string $passString salted hash to check if it needs an update
92 * @return boolean TRUE if salted hash needs an update, otherwise FALSE
93 */
94 public function isHashUpdateNeeded($passString);
95
96 /**
97 * Method determines if a given string is a valid salt
98 *
99 * @param string $salt: string to check
100 * @return boolean TRUE if it's valid salt, otherwise FALSE
101 */
102 public function isValidSalt($salt);
103
104 /**
105 * Method determines if a given string is a valid salted hashed password.
106 *
107 * @param string $saltedPW: string to check
108 * @return boolean TRUE if it's valid salted hashed password, otherwise FALSE
109 */
110 public function isValidSaltedPW($saltedPW);
111 }
112
113
114 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/saltedpasswords/classes/salts/interfaces/interface.tx_saltedpasswords_salts.php'])) {
115 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/saltedpasswords/classes/salts/interfaces/interface.tx_saltedpasswords_salts.php']);
116 }
117 ?>