create account

Diffie-Hellman Key Exchange(with sample code) by meysam

View this thread on: hive.blogpeakd.comecency.com
· @meysam · (edited)
$2.06
Diffie-Hellman Key Exchange(with sample code)
http://core0.staticworld.net/images/article/2013/02/encrypt_primary-100022114-gallery-100024895-orig.jpg
[Source]( http://www.pcworld.com/article/2031002/when-you-encrypt-a-file-or-a-hard-drive-is-it-really-secure-.html)
Key exchange is always a concern when security is a priority, now days thanks to asymmetric cryptography we have different solutions but back in 1970s things were a bit different.
https://i.imgsafe.org/f98410e26f.jpg
[Source](http://www.slideshare.net/lineking/key-distribution)
In symmetric type of cryptography (like 3Des) unlike asymmetric (like AES), there must be a shared key between two parties.
There is a lot of ways to do that:
* Meet in person and share the key (not a good option if you are living in different regions)
* Talking on the phone(if you are dumb enough to trust telecommunication’s infrastructure)
* Encryption(which you need another shared key to encrypt your key, so we are on the first place)
* Using different algorithms which are implemented to transfer data  on insecure networks
* …


In 1976 two cryptographer named [Whitfield Diffie](https://en.wikipedia.org/wiki/Whitfield_Diffie)-[Martin Hellman](https://en.wikipedia.org/wiki/Martin_Hellman) addressed one of the fundamental problems of cryptography and came up with an algorithm to distribute keys without sending the key over an insecure network.

https://i.imgsafe.org/f9b1417038.jpg
Ralph Merkle (worked on the Diffie-Hellman project), Martin Hellman and Whitfield Diffie in 1977 
[Source](http://www.theregister.co.uk/2016/03/01/diffie_and_hellman_scoop_turing_award_for_key_work_on_crypto/)


## How it works!
Let’s bring Alice and Bob (cryptographers’ favorite characters) to start a scenario. 
The first thing that Alice and Bob should do is to agree on a prime number (p) and a base (z). We talked and they chose p=23 and z=6(these numbers don’t need to be secure).
Now it is Alice and Bob turn to choose a number, she chooses her lucky number which is a=7, and Bob chooses b=17. 
At this time we have all the needed numbers and keys, let’s share the key
https://i.imgsafe.org/fa4732fa0b.jpg
And 16 is going to be their shared key
As you saw the key never has been transfer directly through the channel, it actually got created by both parties.
 
# The protocol is considered secure against eavesdroppers the inputs are chosen properly.

https://i.imgsafe.org/fa9b88d3cc.jpg
a very basic java code to get a better understanding of the protocol.
it can be done by more than two parties , I am not going through that because it is a bit more complex and but the basic is the same.

## this post is powered up 100%

## I am just trying to simplify technology and security related terms for people who are not geeks :), if you like the way I write please upvote and follow me at @meysam for future posts

have fun :)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 89 others
properties (23)
authormeysam
permlinkdiffie-hellman-key-exchange-with-sample-code
categorytutorial
json_metadata{"tags":["tutorial","education","security","technology"],"users":["meysam"],"image":["http://core0.staticworld.net/images/article/2013/02/encrypt_primary-100022114-gallery-100024895-orig.jpg","https://i.imgsafe.org/f98410e26f.jpg","https://i.imgsafe.org/f9b1417038.jpg","https://i.imgsafe.org/fa4732fa0b.jpg","https://i.imgsafe.org/fa9b88d3cc.jpg"],"links":["http://www.pcworld.com/article/2031002/when-you-encrypt-a-file-or-a-hard-drive-is-it-really-secure-.html","http://www.slideshare.net/lineking/key-distribution","https://en.wikipedia.org/wiki/Whitfield_Diffie","https://en.wikipedia.org/wiki/Martin_Hellman","http://www.theregister.co.uk/2016/03/01/diffie_and_hellman_scoop_turing_award_for_key_work_on_crypto/"],"app":"steemit/0.1","format":"markdown"}
created2017-01-06 14:48:24
last_update2017-01-06 15:03:36
depth0
children1
last_payout2017-02-07 02:59:00
cashout_time1969-12-31 23:59:59
total_payout_value1.553 HBD
curator_payout_value0.504 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,829
author_reputation24,504,907,990,035
root_title"Diffie-Hellman Key Exchange(with sample code)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id2,176,641
net_rshares13,687,840,623,833
author_curate_reward""
vote details (153)
@steemtrail ·
$1.47
Hello @meysam, 

Congratulations! Your post has been chosen by the communities of SteemTrail as one of our top picks today.

Also, as a selection for being a top pick today, you have been [awarded a TRAIL token for your participation](https://discord.gg/w4sdqkS) on our innovative platform...STEEM.
[Please visit SteemTrail](https://discord.gg/w4sdqkS) to get instructions on how to claim your TRAIL token today.

If you wish to [learn more about receiving additional TRAIL tokens and SteemTrail](https://discord.gg/w4sdqkS), stop by and chat with us.
 

Happy TRAIL!
http://i.imgur.com/vs9Ai7I.png
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 90 others
properties (23)
authorsteemtrail
permlinkre-meysam-diffie-hellman-key-exchange-with-sample-code-20170107t022042555z
categorytutorial
json_metadata{"tags":["tutorial"],"users":["meysam"],"image":["http://i.imgur.com/vs9Ai7I.png"],"links":["https://discord.gg/w4sdqkS"]}
created2017-01-07 02:20:42
last_update2017-01-07 02:20:42
depth1
children0
last_payout2017-02-07 02:59:00
cashout_time1969-12-31 23:59:59
total_payout_value1.232 HBD
curator_payout_value0.235 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length598
author_reputation263,209,530,304,931
root_title"Diffie-Hellman Key Exchange(with sample code)"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,182,200
net_rshares11,292,750,551,680
author_curate_reward""
vote details (154)