{ "metadata": { "name": "", "signature": "sha256:0963e656a45b56e87c82b1b894058e0c0c5d5a3acfd1e2f8850678ef319681b0" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 13: Security in Wireless Systems" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 13.1, Page 424" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Variable declaration\n", "#Two prime numbers\n", "p=5;\n", "q=7;\n", "\n", "#Calculations\n", "n=p*q;\n", "z=(p-1)*(q-1);\n", "e=5\n", "d=29\n", "\n", "#Results\n", "print 'Public keys is (%d, %d)'%(n,e);\n", "print 'Private key is (%d, %d)'%(n,d);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Public keys is (35, 5)\n", "Private key is (35, 29)\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 13.2, Page 425" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Variable declaration\n", "p=23; #prime number that both parties agreed upon\n", "g=5;# g is primitive mod p\n", "a=6; #party A choosen number\n", "b=15; #party B choosen number\n", "\n", "#Calculations&Results\n", "print 'Party A sends to party B as (g**a mod p) = %d'%(g**a%23);\n", "print 'Party B sends to party A as (g**b mod p) = %d'%(g**b%23);\n", "print 'Party A computes secret key as ((g**b modp)**a mod p) = %d'%(((g**b%23)**a)%p);\n", "print 'Party B computes secret key as ((g**a modp)**b mod p) = %d'%(((g**a%23)**b)%p);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Party A sends to party B as (g**a mod p) = 8\n", "Party B sends to party A as (g**b mod p) = 19\n", "Party A computes secret key as ((g**b modp)**a mod p) = 2\n", "Party B computes secret key as ((g**a modp)**b mod p) = 2\n" ] } ], "prompt_number": 2 } ], "metadata": {} } ] }