Today at the University we learned if Alice gives Bob her private key and vice versa, they can identify them self. It make sense but is this good practice? I always thought that Certificates are made for this scenerio?
-
Nobody should ever give anybody their private key. In PGP people exchange what are called public keys, but are really public keys with signed metadata attached which effectively function as certificates even though the word certificate is not used. (But they are not at all the same as the X.509 certificates used for SSL/TLS/HTTPS/etc S/MIME and codesigning.)– dave_thompson_085Commented Nov 30, 2017 at 2:20
2 Answers
if Alice gives Bob her private key and vice versa, they can identify them self
I think you've misunderstood something. For identification Alice does not give Bob her private key to identity herself.
Instead Bob issues a challenge (i.e. some random message) and Alice signs this challenge with the her private key. Bob then can verify this signature using Alice public key (which is public as the name says, i.e. known to Bob). And since Bob had control of the challenge he can be sure that Alice is currently in possession of the matching private key. Since only Alice should know this secret private key this can be used as a proof that this is Alice at the other end of the connection, i.e. proof of Alice identity.
-
thanks for your answer, It was an exam question, and the only answer possibilities were, public/private key of bob/alice. Question was like: alice verify bob with: ... bobs private key, that's why i was confused, but maybe he meant what you said. Commented Nov 30, 2017 at 13:30
In the real world you have a double wrapped message.
- Alice encrypts the plaintext with Bob's public key so only Bob can read it.
- Then Alice encrypts the cryptotext with her private key to generate cryptotext2.
- Bob then uses Alice's public key to decrypt the cryptotext2.
- Bob then uses his private key to decrypt cryptotext into plaintext.
It is Step 2 and 3 that validate that Alice is the one who sent the message.
-
1Although often misdescribed as such, signing is not 'encryption with the private key' -- that is kind of partly approximately true for RSA, but for DSA (and ECDSA) there is nothing even resembling encryption at all. And 1 depends on the fact that Bob (securely) gave his publickey to Alice, and 3 (corrected to verification) depends on the fact that Alice (securely) gave her publickey to Bob. Commented Nov 30, 2017 at 2:21