41 foreach ( $this->config[
'types'] as
$type ) {
42 $passObj = $this->factory->newFromType(
$type );
45 throw new MWException(
'Underlying type must be a parameterized password.' );
46 } elseif ( $passObj->getDelimiter() === $this->
getDelimiter() ) {
47 throw new MWException(
'Underlying type cannot use same delimiter as encapsulating type.' );
50 $params[] = implode( $passObj->getDelimiter(), $passObj->getDefaultParams() );
56 public function crypt( $password ) {
57 $lastHash = $password;
58 foreach ( $this->config[
'types'] as $i =>
$type ) {
61 $passObj = $this->factory->newFromType(
$type );
62 '@phan-var ParameterizedPassword $passObj';
66 if ( $this->params[$i] !==
'' ) {
67 $params = $this->params[$i] . $passObj->getDelimiter();
69 if ( isset( $this->args[$i] ) && $this->args[$i] !==
'' ) {
70 $args = $this->args[$i] . $passObj->getDelimiter();
75 $passObj = $this->factory->newFromCiphertext( $existingHash );
76 '@phan-var ParameterizedPassword $passObj';
77 $passObj->crypt( $lastHash );
80 $this->params[$i] = implode( $passObj->getDelimiter(), $passObj->params );
81 $this->args[$i] = implode( $passObj->getDelimiter(), $passObj->args );
82 $lastHash = $passObj->hash;
85 $this->hash = $lastHash;
100 $type = $passObj->config[
'type'];
101 if (
$type !== $this->config[
'types'][0] ) {
102 throw new MWException(
'Only a hash in the first layer can be finished.' );
106 $this->params[0] = implode( $passObj->
getDelimiter(), $passObj->params );
107 $this->args[0] = implode( $passObj->
getDelimiter(), $passObj->args );
108 $lastHash = $passObj->hash;
111 foreach ( $this->config[
'types'] as $i =>
$type ) {
118 $passObj = $this->factory->newFromType(
$type );
119 '@phan-var ParameterizedPassword $passObj';
123 if ( $this->params[$i] !==
'' ) {
126 if ( isset( $this->args[$i] ) && $this->args[$i] !==
'' ) {
132 $passObj = $this->factory->newFromCiphertext( $existingHash );
133 '@phan-var ParameterizedPassword $passObj';
134 $passObj->
crypt( $lastHash );
137 $this->params[$i] = implode( $passObj->
getDelimiter(), $passObj->params );
138 $this->args[$i] = implode( $passObj->
getDelimiter(), $passObj->args );
139 $lastHash = $passObj->hash;
142 $this->hash = $lastHash;