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 );
65 if ( $this->params[$i] !==
'' ) {
66 $params = $this->params[$i] . $passObj->getDelimiter();
68 if ( isset( $this->
args[$i] ) && $this->
args[$i] !==
'' ) {
69 $args = $this->
args[$i] . $passObj->getDelimiter();
74 $passObj = $this->factory->newFromCiphertext( $existingHash );
75 $passObj->crypt( $lastHash );
78 $this->params[$i] = implode( $passObj->getDelimiter(), $passObj->params );
79 $this->
args[$i] = implode( $passObj->getDelimiter(), $passObj->args );
80 $lastHash = $passObj->hash;
83 $this->hash = $lastHash;
98 $type = $passObj->config[
'type'];
99 if (
$type !== $this->config[
'types'][0] ) {
100 throw new MWException(
'Only a hash in the first layer can be finished.' );
104 $this->params[0] = implode( $passObj->
getDelimiter(), $passObj->params );
106 $lastHash = $passObj->hash;
109 foreach ( $this->config[
'types']
as $i =>
$type ) {
116 $passObj = $this->factory->newFromType(
$type );
120 if ( $this->params[$i] !==
'' ) {
123 if ( isset( $this->args[$i] ) && $this->args[$i] !==
'' ) {
129 $passObj = $this->factory->newFromCiphertext( $existingHash );
130 $passObj->
crypt( $lastHash );
133 $this->params[$i] = implode( $passObj->
getDelimiter(), $passObj->params );
134 $this->args[$i] = implode( $passObj->
getDelimiter(), $passObj->args );
135 $lastHash = $passObj->hash;
138 $this->hash = $lastHash;