相当于mcrypt_get_block_size的Openssl [英] Openssl equivalent to mcrypt_get_block_size

查看:508
本文介绍了相当于mcrypt_get_block_size的Openssl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在用OpenSSL替换Mcrypt,因为Mcrypt将在PHP 7.1中弃用.我需要的是一种按算法获取块大小的方法,例如 .

I am currently in the process of replacing Mcrypt with OpenSSL since Mcrypt will be deprecated in PHP 7.1. I need is a way to get the blocksize per algorithm like mcrypt_get_block_size().

我想知道是否有与mcrypt_get_block_size()等效的功能,但相当糟糕的文档似乎找不到它.

I am wondering if there is an equivalent function to mcrypt_get_block_size() but it's pretty badly documented can't seem to find it.

推荐答案

没有提供密码块大小的API.如果您真的需要它,则必须对blockSize进行硬编码(根据算法).

php-openssl unfortunately doesn't have an API that would give you the cipher blockSize. If you really need it, you'd have to hard-code the blockSize (per algorithm).

但是,典型的应用程序仅需要支持一种加密算法,在这种情况下,您应该已经知道适合您的情况的块大小.

However, typical applications would only need to support a single encryption algorithm, and in that case you should already know what the block size is for your case.

而且,我对mcrypt_get_block_size()mcrypt_enc_get_block_size()的唯一用例是PKCS#7填充,OpenSSL 默认情况下已经针对分组密码算法进行了操作.因此,有可能您根本不需要此.

And also, the only use cases I've had for mcrypt_get_block_size(), mcrypt_enc_get_block_size() is PKCS#7 padding, which OpenSSL already does by default for block cipher algorithms. So it may be the case that you don't need this at all.

这篇关于相当于mcrypt_get_block_size的Openssl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆