Exemple #1
0
 /**
  * Sets the key length.
  *
  * Key lengths can be between 32 and 448 bits.
  *
  * @access public
  * @param int $length
  */
 function setKeyLength($length)
 {
     if ($length < 32 || $length > 448) {
         throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys of sizes between 32 and 448 bits are supported');
     }
     $this->key_length = $length >> 3;
     parent::setKeyLength($length);
 }
Exemple #2
0
 /**
  * Sets the key length.
  *
  * Valid key lengths are 128, 192 or 256 bits
  *
  * @access public
  * @param int $length
  */
 function setKeyLength($length)
 {
     switch ($length) {
         case 128:
         case 192:
         case 256:
             break;
         default:
             throw new \LengthException('Key of size ' . strlen($key) . ' not supported by this algorithm. Only keys of sizes 16, 24 or 32 supported');
     }
     parent::setKeyLength($length);
 }
Exemple #3
0
 /**
  * Sets the key length.
  *
  * Valid key lengths are 128, 160, 192, 224, and 256.
  *
  * Note: phpseclib extends Rijndael (and AES) for using 160- and 224-bit keys but they are officially not defined
  *       and the most (if not all) implementations are not able using 160/224-bit keys but round/pad them up to
  *       192/256 bits as, for example, mcrypt will do.
  *
  *       That said, if you want be compatible with other Rijndael and AES implementations,
  *       you should not setKeyLength(160) or setKeyLength(224).
  *
  * Additional: In case of 160- and 224-bit keys, phpseclib will/can, for that reason, not use
  *             the mcrypt php extension, even if available.
  *             This results then in slower encryption.
  *
  * @access public
  * @throws \LengthException if the key length is invalid
  * @param int $length
  */
 function setKeyLength($length)
 {
     switch ($length) {
         case 128:
         case 160:
         case 192:
         case 224:
         case 256:
             $this->key_length = $length >> 3;
             break;
         default:
             throw new \LengthException('Key size of ' . $length . ' bits is not supported by this algorithm. Only keys of sizes 128, 160, 192, 224 or 256 bits are supported');
     }
     parent::setKeyLength($length);
 }