問題描述
我有一個使用 mycrypt 的加密方法,密碼是 3des
,模式 ecb
:
mcrypt_module_open ( MCRYPT_3DES, '', 'ecb', '' )
現(xiàn)在想用openssl_encrypt
加密,在openssl_get_cipher_methods()
列表中沒有找到des3-ecb
.
現(xiàn)在我想用
openssl_encrypt
加密它,在openssl_get_cipher_methods()
列表中沒有找到des3-ecb
.
它是des-ede3
.使用分組密碼的對稱加密需要某種操作模式.如果您查看列表,您會看到類似 des-ede3
、des-ede3-cbc
、des-ede3-cfb
和 <代碼>des-ede3-ofb.CBC、CFB 和 OFB 都已命名,而未命名密碼必須是唯一的其他常見操作模式:ECB.
切勿使用ECB模式.它是確定性的,因此在語義上不安全.你至少應(yīng)該使用像 CBC 或 點擊率.最好對您的密文進行身份驗證,這樣像填充預言機攻擊這樣的攻擊是不可能的.這可以通過 GCM 或 EAX 等身份驗證模式或 encrypt-then-MAC 方案來完成.>
現(xiàn)在不要使用三重 DES.即使您使用最大的 192 位密鑰,它也最多只能提供 112 位的安全性.如果使用較短的密鑰大小,則它僅提供 56 或 57 位的安全性.AES 會更快(處理器有一個特殊的 AES-NI 指令集),并且使用 128 位的最低密鑰大小甚至更安全.3DES 的最大密文大小也有實際限制.請參閱3DES 和 AES 的安全性比較.
I have an encryption method with mycrypt and the cipher is 3des
, mode ecb
:
mcrypt_module_open ( MCRYPT_3DES, '', 'ecb', '' )
Now I want to encrypt it using openssl_encrypt
, and I did not find des3-ecb
in openssl_get_cipher_methods()
list.
now I want to encrypt it use
openssl_encrypt
, and I did not finddes3-ecb
inopenssl_get_cipher_methods()
list.
It's des-ede3
. Symmetric encryption with a block cipher needs some kind of mode of operation. If you look through the list, you will see something like des-ede3
, des-ede3-cbc
, des-ede3-cfb
and des-ede3-ofb
. CBC, CFB and OFB are all named and the unnamed cipher must be the only other common mode of operation: ECB.
Never use ECB mode. It's deterministic and therefore not semantically secure. You should at the very least use a randomized mode like CBC or CTR. It is better to authenticate your ciphertexts so that attacks like a padding oracle attack are not possible. This can be done with authenticated modes like GCM or EAX, or with an encrypt-then-MAC scheme.
Don't use Triple DES nowadays. It only provides at best 112 bit of security even if you use the largest key size of 192 bit. If a shorter key size is used, then it only provides 56 or 57 bits of security. AES would be faster (processors have a special AES-NI instruction set) and even more secure with the lowest key size of 128 bit. There is also a practical limit on the maximum ciphertext size with 3DES. See Security comparison of 3DES and AES.
這篇關(guān)于使用 openssl_encrypt 替換 Mcrypt 進行 3DES-ECB 加密的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!