CakeFest 2024: The Official CakePHP Conference

Mcrypt 暗号

以下に、mcrypt 拡張モジュールにより現在サポートされている暗号のリストを 示します。サポートされる暗号の完全なリストについては、 mcrypt.h の最後にある define を参照ください。 mcrypt-2.2.x API に関する一般的な規則は、 MCRYPT_暗号名で PHP から暗号をアクセス可能であるということです。 mcrypt-2.4.x および mcrypt-2.5.x の API についてもこれらの定数は 使用できますが、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 モードでは)それぞれの暗号関数に初期化ベクトル(IV) を指定する必要があり、(CBC モードでは)IV を指定することが可能です。 IV はユニークである必要があり、暗号化/復号化の際に同じである 必要があります。暗号化されて保存されたデータの場合、関数の出力を (ファイル名の MD5 キーのように) 保存されたデータの位置を表す インデックスとして使用することができます。もしくは、暗号化された データと共に IV を渡すことができます(このトピックに関する議論については、 Applied Cryptography by Schneier (ISBN 0-471-11709-9) の 9.3 章を参照ください)。

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