예제 #1
0
 /**
  * Sets the key length.
  *
  * Valid key lengths are 128, 160, 192, 224, and 256.  If the length is less than 128, it will be rounded up to
  * 128.  If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount.
  *
  * 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
  * @param int $length
  */
 function setKeyLength($length)
 {
     switch (true) {
         case $length <= 128:
             $this->key_length = 16;
             break;
         case $length <= 160:
             $this->key_length = 20;
             break;
         case $length <= 192:
             $this->key_length = 24;
             break;
         case $length <= 224:
             $this->key_length = 28;
             break;
         default:
             $this->key_length = 32;
     }
     parent::setKeyLength($length);
 }
예제 #2
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) {
         $this->key_length = 7;
     } elseif ($length > 448) {
         $this->key_length = 56;
     } else {
         $this->key_length = $length >> 3;
     }
     parent::setKeyLength($length);
 }
예제 #3
0
 /**
  * Sets the key length
  *
  * Keys can be between 1 and 256 bytes long.
  *
  * @access public
  * @param int $length
  */
 function setKeyLength($length)
 {
     if ($length < 8) {
         $this->key_length = 1;
     } elseif ($length > 2048) {
         $this->key_length = 248;
     } else {
         $this->key_length = $length >> 3;
     }
     parent::setKeyLength($length);
 }