如何使用 openssl 命令创建大型加密文件

Day*_*aya 8 aix openssl

在 AIX 中创建加密文件期间,我收到此错误:

$ openssl enc -aes-256-cbc -salt -in test.img -out test.img.enc 

test.img: Value too large to be stored in data type
14221428:error:0200107F:system library:fopen:Value too large to be stored in:bss_file.c:356:fopen('test.img','r')
14221428:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:358:
Run Code Online (Sandbox Code Playgroud)

test.img 文件大小为 35GB

相同的命令在 Linux 中适用于 100GB 文件。

Cel*_*ada 4

根据错误,您的副本openssl未使用大文件支持进行编译或链接。fopen可能会失败,因为它试图在打开文件后立即发现文件的大小,但失败了。

那么,诀窍就是openssl从管道中读取数据并将其写入管道。管道没有尺寸,并且fopen知道这一点,所以应该没问题。管道另一端的东西不需要做任何花哨的事情,它们只需要成为openssl实际文件之间的直通过滤器即可。这正是cat工作的意义。cat,现在成为直接暴露于大文件的东西,需要有大文件支持,但作为操作系统提供的基本实用程序,我们假设它确实如此。

cat test.img | openssl enc -aes-256-cbc -salt | cat >test.img.enc
Run Code Online (Sandbox Code Playgroud)