数字签名(Digital Signature)

 

总结:

私钥:只有自己知道的钥匙。

公钥:与自己私钥配对的可以公开给别人的钥匙叫公钥。

用私钥加密的数据只能用公钥解密,用公钥加密的数据只能用私钥解密。

 

 

数字签名:先对要发送的文件用hash算法生成极小的一段话,这段话叫做message digest。然后对message digest用私钥加密后生成的文件就叫数字签名。(数字签名的作用是验证文件是否被恶意修改过)

 

数字证书:把自己的公钥与CA(certificate authority )的密钥加密生成的文件就叫数字证书。

 

详细介绍见文章:http://www.youdzone.com/signature.html

 

上面链接中的文章为英文版,有些同志不太乐意看英文文档,我根据对英文文档的理解,大致做如下解释:

        从前有个人叫黑宝,他长得很帅。他还有三个漂亮的师姐妹A、B、C,这三个女人都很喜欢黑宝,但是她们不能大声说出来,如果说出来的话其他的两个姐妹都会听到,那样会很难为情。黑宝的师傅给他们留下了4个宝贝,1把神奇的红色钥匙和三个神奇的黄色盒子,这三个神奇的黄色盒子左右两端分别有一把锁,其中左边的锁都是红色的,那把神奇的红色钥匙可以打开这三个盒子左边的红色锁,右边锁是黄色的,黄色的锁各配有一把能打开此锁的黄色钥匙。师傅把神奇的红色钥匙给了黑宝,把三个神奇的黄色盒子和黄色钥匙分别给了A、B、C三个师姐妹。从此黑宝和3姐妹就通过这四件宝贝开始了情感交流。

        一天,A师妹想给黑宝讲句情话,她就写了张字条,字条内容是“黑宝,我爱你,我要给你生猴子!!!”,然后A师妹把字条放在自己的盒子里,然后把锁锁上,放在黑宝的房间里。只要盒子里装了东西,锁就会变亮。黑宝回家后看到A师妹的盒子的锁是亮的,知道里面有东西,然后黑宝用自己的红色钥匙打开箱子,看到了A师妹给他的留言,开心坏了。

上面这个小故事中,黑宝手里的红色钥匙类似私钥,三姐妹手里的黄色钥匙就类似公钥,发信人通过公钥将要发的信息加密后,发送出去,收信人收到信后可以使用自己的密钥解密,从而获取原始信息;同理,拥有私钥的人可以将要发的信息通过私钥加密后发送出去,收信人收到信息后可以通过公钥解密,从而获取原始信息。

下面介绍一下数字签名,首先我们需要知道数字签名的目的是什么?

数字签名的作用就是保证接收者收的文档或数据是数据发送者编写的,中间未经过恶意改动,如果经过恶意改动,哪怕一个字也说明这个文档不是数据发送者最初发送的数据,很可能存在安全隐患。

数字签名需要发送者和接收者,遵循一定的操作准则,首先发送者按照如下操作发送自己的文档:

1、发送者将编辑好的文档(后称为‘原始文件’),通过哈希算法生成一个只包含一两行数据的报文,这个报文称为“消息摘要”(由于哈希算法是不可逆的,所以通过消息摘要无法还原原始文件内容);

2、发送者通过软件用自己的私钥给“消息摘要”加密,生成的结果就是数字签名。

3、发送者把原始文件和数字签名打包发给接收者。

接收者收到数据后,按照如下方法验证文件是不是发送者本人编辑的原始文件

1、用发送者的公钥解密数字签名,得到的结果是“消息摘要”(此步骤如果成功,能确定文件的发送方确实是发送者本人,因为数字签名是通过私钥加密的,他的私钥只有他自己知道,别人无法伪造);

2、对于收到的文件使用与发送者相同的哈希算法生成一个只包含一两行文本的数据报文,也就是“消息摘要”;

3、对比1、2两步得到的“消息摘要”是否是完全一样,如果完全一样,说明该文档是原始文档。

数字签名这么麻烦为什么要使用它呢?考虑一下,这种情况,你从网上下了一个播放器软件,但是安装后才发现他不是播放器,是一个病毒。在软件行业中这种冒名顶替的事常有发生,通过数字签名可以确保你下载的软件确实是你需要的软件,而不是病毒,或者被人修改过的软件。这也就是微软为什么给自己的软件提供SHA1值的原因。

有些地方可能打不开网站http://www.youdzone.com/signature.html    我把网站的内容复制到了分割线下,请参考

*********************************************************************************************************************************


What is a Digital Signature?

An introduction to Digital Signatures, by David Youd


 


Bob

(Bob's public key)


(Bob's private key)

Bob has been given two keys. One of Bob's keys is called a Public Key, the other is called a Private Key.

 

Bob's Co-workers:

Anyone can get Bob's Public Key, but Bob keeps his Private Key to himself

 

Pat Doug Susan

Bob's Public key is available to anyone who needs it, but he keeps his Private Key to himself. Keys are used to encrypt information. Encrypting information means "scrambling it up", so that only a person with the appropriate key can make it readable again. Either one of Bob's two keys can encrypt data, and the other key can decrypt that data.

Susan (shown below) can encrypt a message using Bob's Public Key. Bob uses his Private Key to decrypt the message. Any of Bob's coworkers might have access to the message Susan encrypted, but without Bob's Private Key, the data is worthless.

 

"Hey Bob, how about lunch at Taco Bell. I hear they have free refills!" HNFmsEm6Un BejhhyCGKOK JUxhiygSBCEiC 0QYIh/Hn3xgiK BcyLK1UcYiY lxx2lCFHDC/A

 

HNFmsEm6Un BejhhyCGKOK JUxhiygSBCEiC 0QYIh/Hn3xgiK BcyLK1UcYiY lxx2lCFHDC/A "Hey Bob, how about lunch at Taco Bell. I hear they have free refills!"

With his private key and the right software, Bob can put digital signatures on documents and other data. A digital signature is a "stamp" Bob places on the data which is unique to Bob, and is very difficult to forge. In addition, the signature assures that any changes made to the data that has been signed can not go undetected.

 

 

To sign a document, Bob's software will crunch down the data into just a few lines by a process called "hashing". These few lines are called a message digest. (It is not possible to change a message digest back into the original data from which it was created.)

 

Bob's software then encrypts the message digest with his private key. The result is the digital signature.

 

Finally, Bob's software appends the digital signature to document. All of the data that was hashed has been signed.

 

Bob now passes the document on to Pat.

 

First, Pat's software decrypts the signature (using Bob's public key) changing it back into a message digest. If this worked, then it proves that Bob signed the document, because only Bob has his private key. Pat's software then hashes the document data into a message digest. If the message digest is the same as the message digest created when the signature was decrypted, then Pat knows that the signed data has not been changed.

 

Plot complication...

 

Doug (our disgruntled employee) wishes to deceive Pat. Doug makes sure that Pat receives a signed message and a public key that appears to belong to Bob. Unbeknownst to Pat, Doug deceitfully sent a key pair he created using Bob's name. Short of receiving Bob's public key from him in person, how can Pat be sure that Bob's public key is authentic?

It just so happens that Susan works at the company's certificate authority center. Susan can create a digital certificate for Bob simply by signing Bob's public key as well as some information about Bob.

 

Bob Info:
    Name
    Department
    Cubical Number

Certificate Info:
    Expiration Date
    Serial Number

Bob's Public Key:
    

Now Bob's co-workers can check Bob's trusted certificate to make sure that his public key truly belongs to him. In fact, no one at Bob's company accepts a signature for which there does not exist a certificate generated by Susan. This gives Susan the power to revoke signatures if private keys are compromised, or no longer needed. There are even more widely accepted certificate authorities that certify Susan.

Let's say that Bob sends a signed document to Pat. To verify the signature on the document, Pat's software first uses Susan's (the certificate authority's) public key to check the signature on Bob's certificate. Successful de-encryption of the certificate proves that Susan created it. After the certificate is de-encrypted, Pat's software can check if Bob is in good standing with the certificate authority and that all of the certificate information concerning Bob's identity has not been altered.

Pat's software then takes Bob's public key from the certificate and uses it to check Bob's signature. If Bob's public key de-encrypts the signature successfully, then Pat is assured that the signature was created using Bob's private key, for Susan has certified the matching public key. And of course, if the signature is valid, then we know that Doug didn't try to change the signed content.

 

Although these steps may sound complicated, they are all handled behind the scenes by Pat's user-friendly software. To verify a signature, Pat need only click on it.

 


(c) 1996, David Youd
Permission to change or distribute is at the discretion of the author

Warning: You may be missing a few lines of text if you print this document. This seems to occur on pages following pages that have blank space near the bottom due to moving tables with large graphics in them to the next page so that the images are not split across pages. If this happens to you, simply print out document in sections. (Ex: I have the problem on page 4, so I print pages 1-3, then pages 4-5.)

 


 

你可能感兴趣的:(数字签名)