使用gpg对加密密钥进行数字签名

时间:2013-02-17 22:42:47

标签: encryption aes rsa gnupg

我正在为我的计算机安全课做一个实验室,一步就是给我带来麻烦。 Here is the assignment. And here is all the work I've done up until step 11.我遇到了麻烦,这是第11步。

11.  Use gpg and your own private RSA key to digitally sign aes.key.asc.
Digital signature must be appendedto cipher and stored in
key_signed.txt

问题是当我执行以下命令时

gpg --sign -o key_signed.txt -a aes.key.asc

预期输出(按作业分配):

Example output

我的输出看起来像这样:

root@bt:~/lab2# cat key_signed.txt 
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.4.10 (GNU/Linux)

owFl0l2I2wQAwPFe9+Vy3Hanc2woszsO3cy8Num37IZpkyZpk7Rp2iatTEibz/ba
pvlo0p4OPEFxgpuCHPOEMbhDkfPpThHFKQhyE5FxB3ObIuhAwSETwcncPcgGPvl/
/D//zo5t8/lH4PXKpjC8NDHygX+zPirK1nRLHkyLVoM9PD7x1L1SGE4ygQJeCNAY
xyE4dv8CFdm09G7n6QDecQp4oA9NR6ahUOAIzpSDlN5xvKMAoLEYjUQwgjW8Dl63
2girgLSjiyasQSEQUnSGBHNEYqBKBJ5xgyittmIxMdEX23aCK5YloNVqZgwiVnXp
nleudpOFrKOS4VmIAbNxvu+CTFQcGGXHLcj1aDHJtsR62KONBKVGzY6DWgYwSFCR
uqJ4kmIQ5CxPihZkcbJcEKJIsiLhrWK3LIAVZ5bvcnCiojIFOS/YkZQDd6l0xaiF
AJPCa5moZTWUVh9EaDetxtksbVJOJIFDZFvkbQKuZodSpFHKMPVKFgqlzSZKpXXZ
hijdsoEUVBOdODzMDVuxZqqDgVXdrYZ4zgkyTtMjI/WiiQsuR9swGs6jVC1YcglW
iIN2123CBaoKDHGP08iYgqkVXO0FkyBaqeFVsdELSyZLx3FKJfJ2wyCwZK6PyIZc
6pNefRaV0STSaAvlPpAv6kok35cLhBbSLTyL5aSEW7ZKDlwqixk8Ey+FwJzsdvRY
z2W6GI9ZEgGl9W4KroXUeNYBOnqeSGQHHDvweIblgskcj1JlIYkh6aHhSEKe0ayB
Ggl3zKGRSGl9WshRIS9sRxOOqeUlDUhKStNCLC3DGgOpQbZcNzhsm66d4mu2WeUb
sbYiK4UQBUVdEu1JmIDnpbAdVqP5ZtGtZcKAKkV4LRuuVsoUJzAQnCNls+jOzAAz
PbeiAvdFYgz6f6Wvjjy63Tfi9+3c4b8H2gfsHv9PPLZ3192drXNfn159e+fa+cdO
oSs/TI59863/l5W1z5bPPOfLH/yyCh64sfsvjZDetc+uDVen9p67dmHsqruAXXy/
5d9YKl7fton8+NF+y395Abk7svLV+WOfcovro0tHkat7tr7nrh8XPpw7+Ru0n89d
GEy99dON5uLnD792wtq6CF+7/Ypve+DI7BP2k7fihQcu828i1M2lE3Ppv/Hl9V2/
v+A486t3rpxS3qBPxzKPHN/x5+O+Q/b8sfk2v3HTe+ZSe9+tZw+vPr+nKLz8xZVD
L0rguL61oB+gJhdHT05MDt+5/c/PzYD2qzX+EsPpZ6b8370+t5x+sM7MPPTenU82
Ph4N7ftj/OBCBP0X
=ZfM8
-----END PGP MESSAGE-----

我想我只需要使用>>流重定向运算符将签名附加到加密,但我尝试的所有内容都不会导致以

开头的内容
-----BEGIN PGP SIGNATURE-----

如何获得预期的输出?

2 个答案:

答案 0 :(得分:2)

查看您的预期输出,尽可能地告诉分配是要求您“清除签名”加密文件。所以试试这个命令:

gpg --clearsign -o key_signed.txt aes.key.asc

我发现this pretty good reference可能会有所帮助。如果您进行网络搜索,还有许多其他可用。

答案 1 :(得分:2)

看一下GnuPG的--clearsign标志。从手册页:

   --clearsign
          Make a clear text signature.  The content in a clear text signature is read-
          able without any special software. OpenPGP software is only needed to verify
          the signature.  Clear text signatures may modify end-of-line whitespace  for
          platform  independence and are not intended to be reversible.  The key to be
          used for signing is chosen by default or can be set  with  the  --local-user
          and --default-key options.

使用此命令获得预期输出:

gpg --clearsign -o key_signed.txt aes.key.asc