Secure Communication of Voice

download Secure Communication of Voice

of 16

Transcript of Secure Communication of Voice

  • 8/7/2019 Secure Communication of Voice

    1/16

    Department of Electrical EngineerHITEC University Tax

    Project Supervisor:

    MS Sehrish Mehmood

    Dated: Wednesday, February 10, 2010

    Secure Communication of Voice

    by Symmetric Encryption

    Group Members:

    Nisar Ahmed Rana

    Sheikh M Arshad

    Ghazal Arshad

    Maria Minhas

    Hira Batool Rizvi

  • 8/7/2019 Secure Communication of Voice

    2/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    I dedicate this project to my dearest

    friend Sheikh M Arshad.Nisar Ahmed Rana

    Dedicated to my sincere friend Nisar

    Ahmed Rana.Sheikh M Arshad

  • 8/7/2019 Secure Communication of Voice

    3/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Transmittal Message

    We have made our best efforts to make this project

    report to come up with your standards. We used best

    sources of knowledge up to standard level. We may have

    many shortcomings in its design and layout. But if any

    mistake takes place while making the report we hope

    that you will ignore it and you will not consider it as a

    major mistake and we expect courtesy from your side.

    Thank you,

  • 8/7/2019 Secure Communication of Voice

    4/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Acknowledgement

    First of all, we pay our thanks to almighty Allah, the most Merciful

    and Beneficial, who is the entire source of aft knowledge and

    wisdom. We have faced a lot of difficulties during this period of

    developing project report. But Allah gave us a lot of courage and our

    teachers encouraged us to do this. We offer thanks from the deepest

    core of our heart to the Holy Prophet Hazrat Muhammad (Peace be

    upon him) who is, forever a torch of guidance and knowledge forhumanity as a whole.

    No words are sufficient to express our gratitude to our loving

    parents for their exemplary patience, understanding and

    cooperation during the preparation of this book.

    We deeply express our sincere thanks to our Head of Department

    Mr. Jamil Ahmed for his cooperation throughout the project work

    and providing in with necessary facilities.

    In completion of this project, we depend on expert input from our

    project adviser, MS Sehrish Mehmood who guided us in each step

    to make our project a better one.

    We would like to thank our friend Talha Naveed, Muhammad Yasir

    and Kashif Hanif for his sincere help.

    In addition we would like to thank our all those friends who helped

    us in any form during the project completion and report writing.

  • 8/7/2019 Secure Communication of Voice

    5/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Table of Contents

    Title 1

    Dedication 2

    Transmittal Message 3

    Acknowledgement 4

    1 Executive Summary 7

    2 Introduction 8

    2.1 Background 8

    2.2 Scope 8

    3 Procedure 9

    3.1 Functions Used in Cryptosystem 9

    3.2 Wavread 9

    3.2.1 Syntax 9

    3.2.1 Description 9

    3.3 Input 10

    3.3.1 Syntax 10

    3.3.2 Description 10

    3.4 Sound 10

    3.4.1 Syntax 10

    3.4.2 Description 10

    3.5 Size 10

    3.5.1 Syntax 10

  • 8/7/2019 Secure Communication of Voice

    6/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    3.5.2 Description 11

    3.6 Zeros 11

    3.6.1 Syntax 11

    3.6.2 Description 11

    3.7 For Loop 11

    3.7.1 Syntax 11

    3.7.2 Description 11

    3.7.3 General Expression 12

    4 Types of Cryptosystem 13

    4.1 Digital Encryption Standard (DES) 13

    4.2 International Data Encryption Algorithm (IDEA) 13

    4.3 RC4 13

    4.4 UNIX Crypt 13

    4.5 RSA 13

    4.6 Diffie Hellman 13

    4.7 PGP 14

    5 Programming Code for Cryptosystem 15

    6 Conclusion 16

  • 8/7/2019 Secure Communication of Voice

    7/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Executive Summary

    Cryptography is science of preparing coded or protected communications intended to be

    intelligible only to the person possessing a key. The term Cryptography (Greek kryptos,

    secret; graphos, writing) refers both to the process or skill of communicating in or

    deciphering secret writings (codes) and to the use of codes to convert computerized data so

    that only a specific recipient will be able to read it using a key.

    In its broadest sense, cryptography includes the use of concealed messages, ciphers, and codes.

    Concealed messages, such as those hidden in otherwise innocent text and those written in

    invisible ink, depend for their success on being unsuspected. Once they are discovered, they

    frequently are easy to decipher. Codes, in which predetermined words, numbers, or symbolsrepresent words and phrases, are usually impossible to read without the key codebook.

    Cryptography also includes the use of computerized encryption to protect transmissions of data

    and messages.

    Cryptography is important for more than just privacy, however. Cryptography protects the

    worlds banking systems as well. Many banks and other financial institutions conduct their

    business over open networks, such as the Internet. Without the ability to protect bank

    transactions and communications, criminals could interfere with the transactions and steal

    money without a trace.

  • 8/7/2019 Secure Communication of Voice

    8/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Introduction

    Our project is sound cryptography (Sound Encryption & Decryption). The user will give an input sound

    and encryption factor. The sound will be converted to an encrypted sound file. This sound is not

    understandable by any one. When the receiver will receive the encrypted file he will decrypt it and enter

    the decryption factor so he will get the original file.

    There are two kinds of cryptosystems.

    1. Symmetric cryptosystem2. A symmetric cryptosystem

    Symmetric cryptosystems use the same key (a secret key) to encrypt and decrypt a message, and

    asymmetric cryptosystems use one key (the public key) to encrypt a message and a different key (the

    private key) to decrypt it, or vice versa.

    BackgroundWe are assigned to make a project of Signal & System course using MAYLAB. We have chosen to design

    a cryptosystem. This cryptosystem will work on sound files whoever it can be used as a cryptosystem for

    other type of data. This is very useful software which can be used for secret data transmission.

    ScopeThis cryptosystem has a wide range of application. We can use it for transmission of secret sound files. It

    can be used for military purposes. All the banks and big companies can use data encryption. It can be

    used to encrypt music files or videos. A slightly changed form of cryptosystem can be used in software

    and online file transfer.

  • 8/7/2019 Secure Communication of Voice

    9/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Procedure

    We have used a simple procedure for our cryptosystem due to limitation of our knowledge of the

    subject. We have used wavread() command which input the windows *.wav sound file. Then the

    software demands the encryption factor. The original sound is then encrypted into a sound which

    contain one bit of original sound and n bits (n is encryption factor) of the carrier sound. Then it asks for

    the decryption factor and save the sound data one bit after n bits into a file which is the reproduced

    original sound.

    Today a large number of cryptosystem are available. Following is a list of popular cryptosystem.

    Functions used in Cryptosystem:

    Wavread:This function read Microsoft WAVE (.wav) sound file and save the data in matrix mxn form. In case of

    mono sound the matrix will be 1xn and for stereo sound the matrix will be 2xn.

    Syntax:

    1. y = wavread(filename)2. [y, Fs, nbits] = wavread(filename)3. [...] = wavread(filename, N)4. [...] = wavread(filename,[N1 N2])5. y = wavread(filename, fmt)

    Description:

    y = wavread(filename) loads a WAVE file specified by filename, returning the sampled data in y.The filename input is a string enclosed in single quotes. The .wav extension is appended if no

    extension is given.

    [y, Fs, nbits] = wavread(filename) returns the sample rate (Fs) in Hertz and the number of bitsper sample (nbits) used to encode the data in the file.

    [...] = wavread(filename, N) returns only the first N samples from each channel in the file. [...] = wavread(filename,[N1 N2]) returns only samples N1 through N2 from each channel in the

    file.

    y = wavread(filename, fmt) specifies the data type format of y used to represent samples readfrom the file. fmt can be either of the following values.

  • 8/7/2019 Secure Communication of Voice

    10/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Input:Input function request user input in command window.

    Syntax:

    1. user_entry = input('prompt')2. user_entry = input('prompt', 's')

    Description:

    The response to the input prompt can be any MATLAB expression, which is evaluated using the variables

    in the current workspace.

    user_entry = input('prompt') displays prompt as a prompt on the screen, waits for input fromthe keyboard, and returns the value entered in user_entry.

    user_entry = input('prompt', 's') returns the entered string as a text variable rather than as avariable name or numerical value.

    Sound:This function converts vector into sound file.

    Syntax:

    1. sound(y,Fs)2. sound(y)3. sound(y,Fs,bits)

    Description:

    Sound(y,Fs) sends the signal in vector y (with sample frequency Fs) to the speaker on PC and most UNIX

    platforms. Values in y are assumed to be in the range. Values outside that range are clipped. Stereo

    sound is played on platforms that support it when y is an n-by-2 matrix. The values in column 1 are

    assigned to the left channel, and those in column 2 to the right.

    Sound(y) plays the sound at the default sample rate or 8192 Hz. Sound(y,Fs,bits) plays the sound using bits number of bits/sample, if possible. Most platforms

    support bits = 8 or bits = 16.

    Size:This function gives us dimension of array.

    Syntax:

    1. d = size(X)

  • 8/7/2019 Secure Communication of Voice

    11/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    2. [m,n] = size(X)3. m = size(X,dim)4. [d1,d2,d3,...,dn] = size(X),

    Description:

    d = size(X) returns the sizes of each dimension of array X in a vector d with ndims(X) elements. If X is ascalar, which MATLAB regards as a 1-by-1 array, size(X) returns the vector [1 1].

    [m,n] = size(X) returns the size of matrix X in separate variables m and n.

    m = size(X,dim) returns the size of the dimension of X specified by scalar dim.

    [d1,d2,d3,...,dn] = size(X), for n > 1, returns the sizes of the dimensions of the array X in the variables

    d1,d2,d3,...,dn, provided the number of output arguments n equals ndims(X). If n does not equal

    ndims(X), the following exceptions hold:

    Zeros:This function creates an array of all zeros.

    Syntax:

    1. B = zeros(n)2. B = zeros(m,n)3. B= zeros([m n])4. B = zeros(m,n,p,...)5. B= zeros([m n p ...])6. B = zeros(size(A))7. zeros(m, n,...,classname)8. zeros([m,n,...],classname)

    Description:

    B = zeros(n) returns an n-by-n matrix of zeros. An error message appears if n is not a scalar. B = zeros(m,n) or B = zeros([m n]) returns an m-by-n matrix of zeros. B = zeros(m,n,p,...) or B = zeros([m n p ...]) returns an m-by-n-by-p-by-... array of zeros. B = zeros(size(A)) returns an array the same size as A consisting of all zeros.

    For Loop:For loop executes a block of code for specified number of times.

    Syntex:

    1. for x=initval:endval, statements, end2. for x=initval:stepval:endval, statements, end

  • 8/7/2019 Secure Communication of Voice

    12/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Description:

    for x=initval:endval, statements, end repeatedly executes one or more MATLAB statements in aloop. Loop counter variable x is initialized to value initval at the start of the first pass through

    the loop, and automatically increments by 1 each time through the loop. The program makes

    repeated passes through statements until either x has incremented to the value endval, or

    MATLAB encounters a break, or return instruction, thus forcing an immediately exit of the loop.

    for x=initval:stepval:endval, statements, end is the same as the above syntax, except that loopcounter x is incremented (or decremented when stepval is negative) by the value stepval on

    each iteration through the loop. The value stepval must be a real number or can also be a call to

    a function that returns a real number.

    General Expression:

    for variable = initval:endval statement

    ...

    statement

    end

  • 8/7/2019 Secure Communication of Voice

    13/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Types of Cryptosystem:

    There are many types of cryptosystems available. Some of the most popular cryptosystems are given

    below with brief description.

    Digital Encryption Standard (DES):The Digital Encryption Standard was developed by IBM and the National Security Agency (NSA) of the

    USA in the 50s. DES uses a key of only 56 bits, and thus it is too weak and easy to be broken with today

    technology.

    International Data Encryption Algorithm (IDEA):International Data Encryption Algorithm (IDEA) is a cryptosystem developed by X. Lai and J. Massey in

    1991 to replace the DES standard. It is a symmetric (same key for encryption and decryption) block

    cipher, operating on 8 bytes at a time, just like DES, but with a key of 128 bits.

    RC4A cipher invented by Ron Rivets, a proprietary system by RSADSI, is used in a number of commercial

    systems like Lotus Notes and secure Netscape.

    UNIX Crypt:

    Many UNIX systems come supplied with an encryption system called crypt. This routine should never be

    used for encrypting anything because there is a program on the net for producing the decrypted text

    and the key.

    RSA:

    A cipher/algorithm based on the concept of a trapdoor function, which is easily calculated, but whose

    inverse is extremely difficult to calculate. The RSA algorithm is named after Ron Rivets, Adi Shamir and

    Len Adelman, who invented it in 1977. The RSA algorithm can be used for both public key encryption

    and digital signatures. Its security is based on the difficulty of factoring large integers.

    Diffie Hellman:Diffie-Hellman is the first published the public key cryptographic algorithm which allows two users to

    exchange a secret key over an insecure medium without any prior secrets. It has two system parameters

    p and g. They are both public and may be used by all the users in a system. Parameter p is a prime

  • 8/7/2019 Secure Communication of Voice

    14/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    number and parameter g is an integer less than p, with the following property: for every number n

    between 1 and p-1 inclusive, there is a power k of g such that n = gk mod p.

    PGP:

    PGP is public key system for encrypting electronic mail using the RSA public key cipher. It encrypts themessage using the IDEA cipher with a randomly generated key. It then encrypts the key using the

    recipients public key. When the recipient receives the message, PGP uses his private RSA key to decrypt

    the IDEA key and then uses that IDEA key to decrypt the message.

    We have used a simple symmetric type cryptosystem for our software. We can change it with a little

    modification into an asymmetric cryptosystem.

  • 8/7/2019 Secure Communication of Voice

    15/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Programming Code for cryptosystem

    function encrypt(a,s)a=wavread('keysound.wav');

    sound(a,8000)

    en=input('Enter the amount of distortion to Encrypt:')

    a1=a';

    [y,u]=size(a1)

    c=wavread('add.wav');

    c1=c';

    c2=c1(1:u*en);

    n=1

    for(m=1:u)

    c2(1,n)=a1(1,m);n=n+en;

    end

    c3=c2';

    sound(c3,8000);

    o=1;

    w=zeros(1,u);

    dec=input('Enter the amount of distortion to Decrypt:')

    for(m=1:u)

    w(1,m)=c2(1,o);

    o=o+dec;

    end

    w1=w';

    sound(w1,8000)

    end

  • 8/7/2019 Secure Communication of Voice

    16/16

    MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

    F

    e

    b

    r

    u

    a

    r

    y

    1

    0

    ,

    2

    0

    1

    0

    Page

    Conclusion

    We have learnt from this project that how to encrypt a sound file. Since this encryption phenomenon

    has a wide range of application so we can encrypt sound files for these applications. We have also learnt

    that how to decrypt a encrypted file. When we shall decrypt a sound file with the same factor we got

    the original sound. We have also learnt to decrypt a sound file by two methods which are symmetric and

    asymmetric. In symmetric we use the same decryption factor as we use to encrypt that sound file. While

    on the other hand we use the different decryption factor.