具有短明文=>的非对称流密码。短密文 [英] Asymmetric stream cipher with short plaintext => short ciphertext
问题描述
我正在寻找一种非对称密码,其特征是输入很短会导致输出很短。
I am looking for an asymmetric cipher which has the property that very short inputs result in very short outputs.
.NET的标准 RSACryptoService
似乎为任何简短的纯文本(包括空的纯文本)输出最少128个字节。最小支持的BlockSize为128,唯一支持的模式为CBC。
.NET's standard RSACryptoService
seems to output a minimum of 128 bytes for any short plaintext, including the empty plaintext. Minimum supported BlockSize is 128 and the only supported Mode is CBC.
理想的算法在提供非对称属性的同时,根本不会扩展明文。预期的输入大小为50-100字节,肯定不会超过150。
The perfect algorithm would not expand the plaintext at all, while providing the asymmetric property. Expected input size is 50-100 bytes, certainly never more than 150.
推荐答案
当然有可能实现您的目标您可以通过使用椭圆曲线 ElGamal加密和变体来选择大小。 Bouncycastle C#库是一种实现方式。
It is certainly possible to achieve your goals for the sizes you are interested in by using elliptic curve ElGamal encryption and variants. The Bouncycastle C# library is one option for implementation.
例如,使用NIST P-256曲线,您可以加密32字节的数据并获得64字节的结果。如果使用适当的填充,则可以加密较少的数据。我相信PGP曾经考虑过实施此操作,但我不知道他们是否曾经这样做过。
So for example by using the NIST P-256 curve you can encrypt 32 bytes of data and get a 64 byte result. If you use proper padding you can encrypt less data. I believe PGP once considered implementing this but I don't know if they ever did.
这篇关于具有短明文=>的非对称流密码。短密文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!