美文网首页
OpenSSL 密钥加/解密大文件

OpenSSL 密钥加/解密大文件

作者: 肆不肆傻 | 来源:发表于2018-01-13 13:12 被阅读0次

    You can generate RSA public and private keys but when it comes to encrypting a large file using this command:

    openssl rsautl -encrypt -pubin -inkey public.pem -in LargeFile.zip -out LargeFile_encrypted.zip
    

    It generates the following error:

    RSA operation error:
    3020:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size:.\crypto\rsa\rsa_pk1.c:151:
    

    The Solution is SMIME:

    1. Generate private and public keys.
    openssl req -x509 -nodes -days 100000 -newkey rsa:2048  -keyout privatekey.pem  -out publickey.pem
    
    1. Encrypt seemingly endless amount of data.
    openssl  smime  -encrypt -aes256  -in  LargeFile.zip  -binary  -outform DEM  -out  LargeFile_encrypted.zip  publickey.pem
    
    1. Decrypt
    openssl  smime -decrypt  -in  LargeFile_encrypted.zip  -binary -inform DEM -inkey privatekey.pem  -out  LargeFile.zip 
    

    相关文章

      网友评论

          本文标题:OpenSSL 密钥加/解密大文件

          本文链接:https://www.haomeiwen.com/subject/atjcoxtx.html