公钥 私钥 数字证书概念理解
区分三个概念的好方法:
既然是加密,那肯定是不希望别人知道我的消息,所以只有我才能解密,所以可得出公钥负责加密,私钥负责解密;同理,既然是签名,那肯定是不希望有人冒充我发消息,只有我才能发布这个签名,所以可得出私钥负责签名,公钥负责验证。
如下通过图形来更细地说明三者之间的关系(原文http://www.youdzone.com/signature.html):
Bob |
(Bob's public 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.