|
| 1 | +<?php |
| 2 | +/*========================================================================= |
| 3 | + MIDAS Server |
| 4 | + Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE |
| 5 | + All rights reserved. |
| 6 | + More information http://www.kitware.com |
| 7 | +
|
| 8 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | + you may not use this file except in compliance with the License. |
| 10 | + You may obtain a copy of the License at |
| 11 | +
|
| 12 | + http://www.apache.org/licenses/LICENSE-2.0.txt |
| 13 | +
|
| 14 | + Unless required by applicable law or agreed to in writing, software |
| 15 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | + See the License for the specific language governing permissions and |
| 18 | + limitations under the License. |
| 19 | +=========================================================================*/ |
| 20 | + |
| 21 | +/** Extend Zend Form Element Hash to generate a more random hash. */ |
| 22 | +class Midas_Form_Element_Hash extends Zend_Form_Element_Hash |
| 23 | +{ |
| 24 | + /** Generate a CSRF token. */ |
| 25 | + protected function _generateHash() |
| 26 | + { |
| 27 | + $factory = new \RandomLib\Factory; |
| 28 | + $generator = $factory->getMediumStrengthGenerator(); |
| 29 | + $random1 = $generator->generateString(32); |
| 30 | + $random2 = $generator->generateString(32); |
| 31 | + $this->_hash = hash('sha256', $random1.$this->getSalt().$this->getName().$random2); |
| 32 | + $this->setValue($this->_hash); |
| 33 | + } |
| 34 | +} |
0 commit comments