Chapter 13: Security in Wireless Systems¶

Example 13.1, Page 424¶

In :
#Variable declaration
#Two prime numbers
p=5;
q=7;

#Calculations
n=p*q;
z=(p-1)*(q-1);
e=5
d=29

#Results
print 'Public keys is (%d, %d)'%(n,e);
print 'Private key is (%d, %d)'%(n,d);
Public keys is (35, 5)
Private key is (35, 29)

Example 13.2, Page 425¶

In :
#Variable declaration
p=23; #prime number that both parties agreed upon
g=5;# g is primitive mod p
a=6;  #party A choosen number
b=15;  #party B choosen number

#Calculations&Results
print 'Party A sends to party B as (g**a mod p) = %d'%(g**a%23);
print 'Party B sends to party A as (g**b mod p) = %d'%(g**b%23);
print 'Party A computes secret key as ((g**b modp)**a mod p) = %d'%(((g**b%23)**a)%p);
print 'Party B computes secret key as ((g**a modp)**b mod p) = %d'%(((g**a%23)**b)%p);
Party A sends to party B as (g**a mod p) = 8
Party B sends to party A as (g**b mod p) = 19
Party A computes secret key as ((g**b modp)**a mod p) = 2
Party B computes secret key as ((g**a modp)**b mod p) = 2