PHP 8.3.4 Released!

Modes de chiffrement Mcrypt

Voici une liste non exhaustive des modes de chiffrement de l'extension mcrypt. Pour disposer d'une liste complète des chiffrements supportés, voyez les définitions dans le fichier mcrypt.h. La règle générale avec l'API mcrypt-2.2.x est que vous pouvez accéder au mode de chiffrement depuis PHP avec la constante MCRYPT_ciphername. Avec la bibliothèque libmcrypt-2.4.x et libmcrypt-2.5.x, ces constantes fonctionnent toujours, mais il est possible de spécifier le nom du chiffrement dans une chaîne, lors de l'appel à mcrypt_module_open().

  • MCRYPT_3DES
  • MCRYPT_ARCFOUR_IV (libmcrypt > 2.4.x uniquement)
  • MCRYPT_ARCFOUR (libmcrypt > 2.4.x uniquement)
  • MCRYPT_BLOWFISH
  • MCRYPT_CAST_128
  • MCRYPT_CAST_256
  • MCRYPT_CRYPT
  • MCRYPT_DES
  • MCRYPT_DES_COMPAT (libmcrypt 2.2.x uniquement)
  • MCRYPT_ENIGMA (libmcrypt > 2.4.x uniquement, alias de MCRYPT_CRYPT)
  • MCRYPT_GOST
  • MCRYPT_IDEA (non libre)
  • MCRYPT_LOKI97 (libmcrypt > 2.4.x uniquement)
  • MCRYPT_MARS (libmcrypt > 2.4.x uniquement, non libre)
  • MCRYPT_PANAMA (libmcrypt > 2.4.x uniquement)
  • MCRYPT_RIJNDAEL_128 (libmcrypt > 2.4.x uniquement)
  • MCRYPT_RIJNDAEL_192 (libmcrypt > 2.4.x uniquement)
  • MCRYPT_RIJNDAEL_256 (libmcrypt > 2.4.x uniquement)
  • MCRYPT_RC2
  • MCRYPT_RC4 (libmcrypt 2.2.x uniquement)
  • MCRYPT_RC6 (libmcrypt > 2.4.x uniquement)
  • MCRYPT_RC6_128 (libmcrypt 2.2.x uniquement)
  • MCRYPT_RC6_192 (libmcrypt 2.2.x uniquement)
  • MCRYPT_RC6_256 (libmcrypt 2.2.x uniquement)
  • MCRYPT_SAFER64
  • MCRYPT_SAFER128
  • MCRYPT_SAFERPLUS (libmcrypt > 2.4.x uniquement)
  • MCRYPT_SERPENT(libmcrypt > 2.4.x uniquement)
  • MCRYPT_SERPENT_128 (libmcrypt 2.2.x uniquement)
  • MCRYPT_SERPENT_192 (libmcrypt 2.2.x uniquement)
  • MCRYPT_SERPENT_256 (libmcrypt 2.2.x uniquement)
  • MCRYPT_SKIPJACK (libmcrypt > 2.4.x uniquement)
  • MCRYPT_TEAN (libmcrypt 2.2.x uniquement)
  • MCRYPT_THREEWAY
  • MCRYPT_TRIPLEDES (libmcrypt > 2.4.x uniquement)
  • MCRYPT_TWOFISH (pour les anciennes versions de mcrypt 2.x ou mcrypt > 2.4.x )
  • MCRYPT_TWOFISH128 (TWOFISHxxx est disponible dans les nouvelles versions 2.x, mais pas dans les versions 2.4.x)
  • MCRYPT_TWOFISH192
  • MCRYPT_TWOFISH256
  • MCRYPT_WAKE (libmcrypt > 2.4.x uniquement)
  • MCRYPT_XTEA (libmcrypt > 2.4.x uniquement)

Vous devez (mode CFB et OFB) ou pouvez (mode CBC) fournir un vecteur d'initialisation (IV) pour ces modes de chiffrement. IV doit être unique, et avoir la même valeur au chiffrement et au déchiffrement. Pour des données qui seront enregistrées après chiffrement, vous pouvez prendre le résultat d'une fonction telle que MD5, appliquée sur le nom du fichier. Sinon, vous pouvez envoyer IV avec les données chiffrées, (reportez-vous au chapitre 9.3 de Applied Cryptography by Schneier (ISBN 0-471-11709-9) de Schneier (ISBN 0-471-11709-9) pour plus de détails sur le sujet).

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