DES算法填充问题?? [英] DES Algorithm padding problem??

查看:228
本文介绍了DES算法填充问题??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在使用56位密钥和64位块来实现DES。

现在问题是当最后一组从文件中读取字节,并说它剩下2个字节,然后我必须填充剩余的6个字节来获取我的8个字节的块进行加密。


所以当我解密文件后,这些填充的字节也会被解密(这不应该发生),导致解密后文件损坏。


所以,请告诉我如何克服这个问题。


我正在使用OpenSSL库进行DES。


另外,我可以将输入块大小从64位增加到更高的值,因为它在加密/解密过程中需要花费大量时间。


Pawan

Hello,

I am making an implementation of DES using 56bit key and 64 bit block.
Now the problem is that when the last set of bytes are read from the file, and say it comes out to be 2bytes remaining, then I have to pad remaining 6 bytes to get my 8 bytes of block for encryption.

So when I decrypt the file, these padded bytes also gets decrypted(which should not happen), resulting in corruption of the file after decryption.

So, please tell me how can I overcome this problem.

I am using OpenSSL libraries for DES.

Also, can I increase the input block size from 64bit to some higher value, because it takes a lot of time during encryption/decryption.

Pawan

推荐答案

分组密码的问题在于它们必须运行在块大小的倍数。您遇到了一个较差的分组密码操作模式的问题。除非您可以找到文件的原始大小,否则简单地填充块可能不起作用。您应该选择更好的操作模式。


链接: http://en.wikipedia.org/wiki/Block_c...s_of_operation
The problem with block ciphers is that they must operate on multiples of their block size. You are running into an issue with a poor block cipher mode of operation. Simply padding the block might not work unless you can find the original size of the file to begin with. You should choose a better mode of operation.

Link: http://en.wikipedia.org/wiki/Block_c...s_of_operation



问题分组密码是指它们必须以其块大小的倍数运行。您遇到了一个较差的分组密码操作模式的问题。除非您可以找到文件的原始大小,否则简单地填充块可能不起作用。您应该选择更好的操作模式。


链接: http://en.wikipedia.org/wiki/Block_c...s_of_operation



Wiki链接很棒,谢谢。

另外我想我必须将原始文件长度存储在文件的开头,并在解密过程中使用它来获取文件长度。


你能告诉我,如何评价一个帖子。

Pawan

The Wiki link is great, thanks.
Also I think I will have to store the original file length at the beginning of the file and use it to get the file length during decryption.

Also can you tell me, how to rate a post.
Pawan


祝你好运,让我知道结果如何。
Good luck, let me know how it turns out.


这篇关于DES算法填充问题??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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