Mcrypt ciphers

Aqui está uma lista de cifras que são atualmente suportadas pela extensão mcrypt. Para uma lista completa de cifras suportadas, consulte as definições em mcrypt.h. A regra geral com a API mcrypt-2.2.x é que você pode acessar a cifra no PHP com MCRYPT_ciphername. Com as APIs libmcrypt-2.4.x e libmcrypt-2.5.x, essas constantes também funcionam, mas é possível especificar o nome da cifra como uma string com uma chamada para mcrypt_module_open().

  • MCRYPT_3DES
  • MCRYPT_ARCFOUR_IV (libmcrypt > 2.4.x somente)
  • MCRYPT_ARCFOUR (libmcrypt > 2.4.x somente)
  • MCRYPT_BLOWFISH
  • MCRYPT_CAST_128
  • MCRYPT_CAST_256
  • MCRYPT_CRYPT
  • MCRYPT_DES
  • MCRYPT_DES_COMPAT (libmcrypt 2.2.x somente)
  • MCRYPT_ENIGMA (libmcrypt > 2.4.x somente, alias para MCRYPT_CRYPT)
  • MCRYPT_GOST
  • MCRYPT_IDEA (não livre)
  • MCRYPT_LOKI97 (libmcrypt > 2.4.x somente)
  • MCRYPT_MARS (libmcrypt > 2.4.x somente, não livre)
  • MCRYPT_PANAMA (libmcrypt > 2.4.x somente)
  • MCRYPT_RIJNDAEL_128 (libmcrypt > 2.4.x somente)
  • MCRYPT_RIJNDAEL_192 (libmcrypt > 2.4.x somente)
  • MCRYPT_RIJNDAEL_256 (libmcrypt > 2.4.x somente)
  • MCRYPT_RC2
  • MCRYPT_RC4 (libmcrypt 2.2.x somente)
  • MCRYPT_RC6 (libmcrypt > 2.4.x somente)
  • MCRYPT_RC6_128 (libmcrypt 2.2.x somente)
  • MCRYPT_RC6_192 (libmcrypt 2.2.x somente)
  • MCRYPT_RC6_256 (libmcrypt 2.2.x somente)
  • MCRYPT_SAFER64
  • MCRYPT_SAFER128
  • MCRYPT_SAFERPLUS (libmcrypt > 2.4.x somente)
  • MCRYPT_SERPENT(libmcrypt > 2.4.x somente)
  • MCRYPT_SERPENT_128 (libmcrypt 2.2.x somente)
  • MCRYPT_SERPENT_192 (libmcrypt 2.2.x somente)
  • MCRYPT_SERPENT_256 (libmcrypt 2.2.x somente)
  • MCRYPT_SKIPJACK (libmcrypt > 2.4.x somente)
  • MCRYPT_TEAN (libmcrypt 2.2.x somente)
  • MCRYPT_THREEWAY
  • MCRYPT_TRIPLEDES (libmcrypt > 2.4.x somente)
  • MCRYPT_TWOFISH (para versões antigas do mcrypt 2.x ou mcrypt > 2.4.x)
  • MCRYPT_TWOFISH128 (TWOFISHxxx estão disponíveis em versões mais recentes 2.x versions, mas não nas versões 2.4.x)
  • MCRYPT_TWOFISH192
  • MCRYPT_TWOFISH256
  • MCRYPT_WAKE (libmcrypt > 2.4.x somente)
  • MCRYPT_XTEA (libmcrypt > 2.4.x somente)

Você deve (em modo CFB e OFB) ou pode (em modo CBC) fornecer um vetor de inicialização (IV) para a função de cifra respectiva. O IV deve ser único e deve ser o mesmo ao descriptografar/criptografar. Com dados que são armazenados criptografados, você pode pegar a saída de uma função do índice sob o qual o dados são armazenados (por exemplo, a chave MD5 do nome do arquivo). Alternativamente, você pode transmitir o IV junto com os dados criptografados (consulte o capítulo 9.3 de Applied Cryptography by Schneier (ISBN 0-471-11709-9) para uma discussão sobre esse tópico).

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