谁帮我实现下 场景2 或者给点提示也行 我是没有弄好的 另外对 gpg --edit-key这个不熟
查了是说 确定公钥是分发者A分发的 然后给公钥签名 这样接收者B就可以放心使用了
可是我在接收者B系统上根本就没有生成密钥对 所以 无法执行gpg --edit-key的sign操作 或者 gpg --sign-key public.key的操作
咋整 忘指点
求助:数字签名 或 文件完整性检测
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
-
- 帖子: 125
- 注册时间: 2007-10-22 22:40
Re: 求助:数字签名 或 文件完整性检测
不懂就别乱说,写那么多你也是没看清楚明白。eexpress 写了:写这么多。。。 seahorse里面看,搜索别人发布的公钥,然后用公钥验证收到的文件,就完了。
基本解决。公钥可以加密并签名,密钥然后解密。
具体问题不是一个seahorse就解决的。
场景2
接收者B生成加密后的文件返回到分发者A,分发者A验证文件的正确性
1.在接收者B上生成test.txt,将test.txt打包生成test.tar.gz,然后对test.tar.gz加密并签名,生成test.gpg
[user@localhost ~]$ cat > test.txt << EOF
> gpg
> EOF
[user@localhost ~]$ tar -zcvf test.tar.gz test.txt
test.txt
[user@localhost ~]$ gpg --output test.gpg --encrypt --recipient [email protected] test.tar.gz
gpg: CB3645CF: There is no assurance this key belongs to the named user
pub 2048R/CB3645CF 2011-09-27 huiwu.li (gpg) <[email protected]>
Primary key fingerprint: 7C7D 281A 5D6A 8A58 84D0 21FC 6B80 4F43 5977 ABD5
Subkey fingerprint: 2747 22DF 0B16 E67E 88B9 263F FAFD 69D7 CB36 45CF
It is NOT certain that the key belongs to the person named
in the user ID. If you *really* know what you are doing,
you may answer the next question with yes.
Use this key anyway? (y/N) y
[user@localhost ~]$ [ -e test.gpg ] && echo "1" || echo "0"
1
[user@localhost ~]$
2.分发者A得到了接收者B上的文件test.gpg;分发者A解密该文件且验证正确性
[speed@localhost ~]$ gpg --output test.tar.gz --decrypt test.gpg
You need a passphrase to unlock the secret key for
user: "huiwu.li (gpg) <[email protected]>"
2048-bit RSA key, ID CB3645CF, created 2011-09-27 (main key ID 5977ABD5)
can't connect to `/home/speed/.gnupg/S.gpg-agent': No such file or directory
#弹出 pinentry-gtk-2 窗口,提示 Please enter the passphrase to unlock the secret key for the OpenPGP certificate: "huiwu.li (gpg) <[email protected]>" 2048-bit RSA key, ID CB3645CF, created 2011-09-27 (main key ID 5977ABD5).,输入passphrase为qwe123。点击 OK。
gpg: encrypted with 2048-bit RSA key, ID CB3645CF, created 2011-09-27
"huiwu.li (gpg) <[email protected]>"
[speed@localhost ~]$ [ -e test.tar.gz ] && echo "1" || echo "0"
1
[speed@localhost ~]$ tar -zxvf test.tar.gz
test.txt
[speed@localhost ~]$ cat test.txt
gpg
[speed@localhost ~]$
- link_01
- 帖子: 1024
- 注册时间: 2008-11-05 13:24
Re: 求助:数字签名 或 文件完整性检测
你不就是不让别人改结果吗?程序里写个转换为不可读的结果,同时输出可读的给客户看,自己这边要求接受编码过的再转回来
笔记
-------------------------------------
http://blog.163.com/wqt_1101
-------------------------------------
http://blog.163.com/wqt_1101
-
- 帖子: 125
- 注册时间: 2007-10-22 22:40
Re: 求助:数字签名 或 文件完整性检测
嗯 是的 别人可以看 结果不可修改(或者修改了,我能发现)link_01 写了:你不就是不让别人改结果吗?程序里写个转换为不可读的结果,同时输出可读的给客户看,自己这边要求接受编码过的再转回来
确实 最后使用gpg的公钥加密和签名 就是让结果文件不可见 然后使用私钥文件解密查看
谢谢大家 大致弄明白了 就可以实现了