CakeFest 2024: The Official CakePHP Conference

Шифры Mcrypt

Здесь перечислены шифры, поддерживаемые модулем mcrypt. Для полного списка поддерживаемых шифров смотрите список в конце файла mcrypt.h. Главное правило API mcrypt-2.2.x API состоит в том, что доступ к шифрам из PHP осуществляется путём использования констант MCRYPT_имя_шифра. Эти константы также работают с AI libmcrypt-2.4.x и libmcrypt-2.5.x, но также можно задать шифр по имени с помощью функции mcrypt_module_open().

  • MCRYPT_3DES
  • MCRYPT_ARCFOUR_IV (только для libmcrypt > 2.4.x)
  • MCRYPT_ARCFOUR (только для libmcrypt > 2.4.x)
  • MCRYPT_BLOWFISH
  • MCRYPT_CAST_128
  • MCRYPT_CAST_256
  • MCRYPT_CRYPT
  • MCRYPT_DES
  • MCRYPT_DES_COMPAT (только для libmcrypt 2.2.x)
  • MCRYPT_ENIGMA (только для libmcrypt > 2.4.x, псевдоним для MCRYPT_CRYPT)
  • MCRYPT_GOST
  • MCRYPT_IDEA (не свободный)
  • MCRYPT_LOKI97 (только для libmcrypt > 2.4.x)
  • MCRYPT_MARS (только для libmcrypt > 2.4.x, не свободный)
  • MCRYPT_PANAMA (только для libmcrypt > 2.4.x)
  • MCRYPT_RIJNDAEL_128 (только для libmcrypt > 2.4.x)
  • MCRYPT_RIJNDAEL_192 (только для libmcrypt > 2.4.x)
  • MCRYPT_RIJNDAEL_256 (только для libmcrypt > 2.4.x)
  • MCRYPT_RC2
  • MCRYPT_RC4 (только для libmcrypt 2.2.x)
  • MCRYPT_RC6 (только для libmcrypt > 2.4.x)
  • MCRYPT_RC6_128 (только для libmcrypt 2.2.x)
  • MCRYPT_RC6_192 (только для libmcrypt 2.2.x)
  • MCRYPT_RC6_256 (только для libmcrypt 2.2.x)
  • MCRYPT_SAFER64
  • MCRYPT_SAFER128
  • MCRYPT_SAFERPLUS (только для libmcrypt > 2.4.x)
  • MCRYPT_SERPENT(только для libmcrypt > 2.4.x)
  • MCRYPT_SERPENT_128 (только для libmcrypt 2.2.x)
  • MCRYPT_SERPENT_192 (только для libmcrypt 2.2.x)
  • MCRYPT_SERPENT_256 (только для libmcrypt 2.2.x)
  • MCRYPT_SKIPJACK (только для libmcrypt > 2.4.x)
  • MCRYPT_TEAN (только для libmcrypt 2.2.x)
  • MCRYPT_THREEWAY
  • MCRYPT_TRIPLEDES (только для libmcrypt > 2.4.x)
  • MCRYPT_TWOFISH (для старых версий mcrypt 2.x или mcrypt > 2.4.x )
  • MCRYPT_TWOFISH128 (TWOFISHxxx доступен в новых версиях 2.x, но не в 2.4.x)
  • MCRYPT_TWOFISH192
  • MCRYPT_TWOFISH256
  • MCRYPT_WAKE (только для libmcrypt > 2.4.x)
  • MCRYPT_XTEA (только для libmcrypt > 2.4.x)

Вы должны (в режимах CFB и OFB) или можете (в режиме CBC) предоставить инициализирующий вектор (IV) для выбранной функции шифрования. IV должен быть уникальным и должен быть одинаковым для шифрования и дешифрования. Для данных, которые хранятся в шифрованном виде вы можете получить вывод функции для индекса, под которым данные были сохранены (например, MD5 хеш имени файла). Или вы можете передать IV вместе с зашифрованными данными (смотрите раздел 9.3 Applied Cryptography by Schneier (ISBN 0-471-11709-9)).

add a note

User Contributed Notes 5 notes

up
6
robin
13 years ago
The MCRYPT_TWOFISH constant when defined by mcrypt version 2.4.x and later is the 256 bit version of Twofish; it uses a 1-32 byte key, a 16 byte IV, and outputs 16 byte blocks in CBC mode.
up
2
Rob
10 years ago
These constants can in fact be used as input to the function mcrypt_module_open() because mcrypt.php contains defines that map these constants to the appropriate string values obtained from mcrypt_list_algorithms().
up
0
Mark
11 years ago
Note, these are not the names you use in the function mcrypt_module_open to specify the algorithm.

Use mcrypt_list_algorithms to get the right names to stick in there
up
-3
stanislav dot eckert at vizson dot de
8 years ago
The latest patents for the IDEA algorithm have expired in 2012 and the cipher is now patent-free and free to use.
up
-5
dan at zaph dot com
8 years ago
Interpretability:

mcrypt does not support PKCS#7 padding, it uses non-standard and insecure null padding. This means that for interoperability with most other implementations PKCS#7 padding will have to be added prior to encryption and/or removed after decryption. This is a major source of interoperability issues.

When interoperating with AES the mcrypt algorithm must be specified as MCRYPT_RIJNDAEL_128 since AES only supports a block size of 128-bits. There is often confusion that this specifies the key size which it does not.
To Top