Add Diffie-Hellman II write up
This commit is contained in:
		
							parent
							
								
									1c5fe4ee1c
								
							
						
					
					
						commit
						489a4fb680
					
				
					 1 changed files with 39 additions and 0 deletions
				
			
		
							
								
								
									
										39
									
								
								diffie-hellman-ii.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								diffie-hellman-ii.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| # Diffie-Hellman II | ||||
| 
 | ||||
| Gegegen sind die Parameter für den Diffie-Hellman-Algorithmus: | ||||
| 
 | ||||
|     In [1]: a = 6 | ||||
|        ...: b = 4 | ||||
|        ...: g = 16 | ||||
|        ...: P = 19 | ||||
| 
 | ||||
| Dabei kennt Alice die Zahlen a, g und P. | ||||
| Bob kennt analog b, g, und P. | ||||
| 
 | ||||
| # Lösung | ||||
| 
 | ||||
| Alice und Bob gerechnen jeweils ihren | ||||
| Zwichenexponenten und übertragen ihn. | ||||
| 
 | ||||
|     A = g^a mod P | ||||
|     B = g^b mod P | ||||
| 
 | ||||
| Damit können beide den Schlüssel berechnen: | ||||
| 
 | ||||
|     K = A^b mod P | ||||
|       = (g^a)^b mod P  | ||||
|       = g^(a*b) mod P  | ||||
|       = g^(b*a) mod P  | ||||
|       = (g^b)^a mod P  | ||||
|       = B^a mod P  | ||||
| 
 | ||||
| Das gibt uns (siehe [modpow](modmath.py)): | ||||
| 
 | ||||
|     In [3]: A = modpow(g, a, P) | ||||
| 
 | ||||
|     In [4]: B = modpow(g, b, P) | ||||
| 
 | ||||
|     In [5]: K = modpow(B, a, P) | ||||
| 
 | ||||
|     In [6]: A, B, K | ||||
|     Out[6]: (7, 5, 7) | ||||
		Reference in a new issue