Acaz Souza
Acaz Souza

Reputation: 8641

How works Public-key cryptography on Github?

In Public-key cryptography is generated a pair of key, one private and one public, the public I put in the Github.

The Private-key decrypts the data and the Public-key encrypts the data. This means when I sent data to github this data is not encrypted because only Private-key decrypts the data?

Update:

Thanks guys, i'm understanding now.

I'm was thinking my data is encypted with that way in github when I send push/pulls. This case is used for login/verification/signing. That's all completely different from the encrypted transmission stream that the SSH connection sets up to send my datas.

Thanks everyone for your responses...

Upvotes: 8

Views: 2110

Answers (3)

Aseem Jain
Aseem Jain

Reputation: 351

Data encrypted with a private key can be decrypted using the public key (and vice versa)

PKI is based upon two keys (public and private) Data can be securely encrypted using either the public or private keys Data can only be decrypted when using the opposite key to that which encrypted the data

Note: A public key can be generated from a private key (not the other way around) source: https://github.com/topics/public-private-key

Upvotes: 0

KingCrunch
KingCrunch

Reputation: 132031

Not wrong at all, but wrong. (a) The private key decrypts the data encrypted by the public key and (b) the public key decrypts the data encrypted by the private key.

(a): Everybody can encrypt something, but only the owner of the private key can decrypt it.

(b): The owner "encrypt" something with his private key and everybody can decrypt it, what ensures, the it were really the owner, that encrypts the data and not somebody else.

git(hub) makes use of the second scenario: If you push something, it its signed with your private key. The receiver now validates the signature againts the public key it knows from you. If its match, everything is fine.

Update: A (maybe too) simplified description on what happens (when using github with ssh)

  • Github sends you something random, that is encrypted with his _private_ key (Maybe its not that random, I dont know, but doesnt matter here)
  • You receive it and decrypt it with his _public_ key. If this is possible, you are sure, that you are really talking to the official github server
  • Then you send the same random stuff encrypted with your _private_ key to the github-server
  • He tries to encrypt it with your _public_ key. If this is possible and its the random stuff he has sent you before, he knows for sure, that you are you.
  • Then you send you stuff encrypted with his _public_ key. Now only the github server can decrypt. Also he will answer with messages/data encrypted with your _public_ key, because only you can decrypt it.

Even if its not completely correct, it should describe the idea.

Upvotes: 10

hammar
hammar

Reputation: 139890

A gross simplification is that when you try to push something, GitHub will send you a challenge by encrypting some random stuff with your public key and seeing if you can decrypt it or not, which you will only be able to do if you have the private key.

Upvotes: 2

Related Questions