Skip to content

Instantly share code, notes, and snippets.

@coconut49
Created December 31, 2016 13:40
Show Gist options
  • Save coconut49/a65f2f749158fe6b8ae41c2f47e37869 to your computer and use it in GitHub Desktop.
Save coconut49/a65f2f749158fe6b8ae41c2f47e37869 to your computer and use it in GitHub Desktop.
GPG AES/RSA 加密的怪异问题.md

先说结论: gpg 会自动判断文件大小如果文件体积过大,则生成一个 一次性密钥并用 rsa 加密,然后用一次性密钥跑 aes 加密整个大文件。故当需要用 gpg 加密文件的时候不需要考虑文件大小直接加密即可 #加密文件

RSA4096 加密文件

➜ test time gpg -e 1.mp4 gpg2 -e 1.mp4 32.41s user 1.96s system 97% cpu 35.231 total

AES128 加密文件口令长度 7 位

➜ test time gpg -o 1.mp4.aes -c 1.mp4 gpg2 -o 1.mp4.aes -c 1.mp4 33.13s user 1.74s system 88% cpu 39.578 total

RSA4096 加密文件并签名

➜ test time gpg -o 1.mp4.sig.asc -se 1.mp4

You need a passphrase to unlock the secret key for user: "Kevin Zheng i@49.gs" 4096-bit RSA key, ID F2DDF43A, created 2016-12-31 (main key ID 76535990)

gpg2 -o 1.mp4.sig.asc -se 1.mp4 34.79s user 1.50s system 99% cpu 36.614 total

#解密文件

AES128 解密文件

➜ test time gpg -o 1.aes.mp4 1.mp4.aes gpg: CAST5 encrypted data gpg: encrypted with 1 passphrase gpg: WARNING: message was not integrity protected gpg2 -o 1.aes.mp4 1.mp4.aes 19.04s user 1.38s system 99% cpu 20.615 total

RSA4096 解密文件

➜ test time gpg -o 1.gpg.mp4 1.mp4.gpg

You need a passphrase to unlock the secret key for user: "Kevin Zheng i@49.gs" 4096-bit RSA key, ID 814CBB13, created 2016-12-31 (main key ID 76535990)

gpg: encrypted with 4096-bit RSA key, ID 814CBB13, created 2016-12-31 "Kevin Zheng i@49.gs" gpg2 -o 1.gpg.mp4 1.mp4.gpg 11.92s user 1.35s system 70% cpu 18.754 total

RSA4096 解密文件并验证签名

➜ test time gpg -o 1.gpg.sig.mp4 1.mp4.sig.asc

You need a passphrase to unlock the secret key for user: "Kevin Zheng i@49.gs" 4096-bit RSA key, ID 814CBB13, created 2016-12-31 (main key ID 76535990)

gpg: encrypted with 4096-bit RSA key, ID 814CBB13, created 2016-12-31 "Kevin Zheng i@49.gs" gpg: Signature made Sat Dec 31 21:06:25 2016 CST using RSA key ID F2DDF43A gpg: Good signature from "Kevin Zheng i@49.gs" [ultimate] gpg2 -o 1.gpg.sig.mp4 1.mp4.sig.asc 7.18s user 1.34s system 97% cpu 8.714 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment