Merged Ns
Merged Ns
Network Security
    Overview
        Fifth Edition
     by William Stallings
 Mutual Trust
  • Key Management
  • Digital Certificates/User Authentication
 Network Security
  • Transport and IP level Security
  • Wireless Security
    Why Do I Need Security?
https://en.wikipedia.org/wiki/List_of_cyberattacks
https://en.wikipedia.org/wiki/List_of_data_breaches
Average economic cost of cyber attacks -
$10.4 million
  Direct cost - $0.9 million
   Indirect loss due to job losses and loss
  of reputation - $3.1 million
  Macroeconomic impact such as reduced
  customer and enterprise spending - $6.3
  million.
Source: ‘Understanding the Cyber security threat landscape in Asia Pacific:
  securing modern enterprise in the digital world’ by Microsoft and Frost and
  Sullivan
         Computer Security
 The protection afforded to an automated
  information system in order to attain the
  applicable objectives of preserving the
  integrity, availability and confidentiality of
  information system resources (includes
  hardware,          software,       firmware,
  information/data, and telecommunications)
Confidentiality:
     Data confidentiality: Assures that private or confidential
      information is not made available or disclosed to
      unauthorized individuals.
Integrity:
     Data integrity: Assures that information and programs are
      changed only in a specified and authorized manner.
Key Security Concepts
Accountability:
The security goal that generates the requirement for
actions of an entity to be traced uniquely to that entity.
This    supports    nonrepudiation,   deterrence,    fault
isolation, intrusion detection and prevention, and after
action recovery and legal action.
  Low
  Moderate
  High
                  Low Impact
 The loss could be expected to have a limited adverse
  effect on organizational operations, organizational
  assets, or individuals.
 A limited adverse effect means that, for example, the
  loss of confidentiality, integrity, or availability might
   Cause a degradation in mission capability to an
     extent and duration that the organization is able to
     perform its primary functions, but the effectiveness of
     the functions is noticeably reduced;
   Result in minor damage to organizational assets;
   Result in minor financial loss; or
   Result in minor harm to individuals.
              Moderate Impact
 The loss could be expected to have a serious adverse
  effect on organizational operations, organizational
  assets, or individuals.
 A serious adverse effect means that, for example, the
  loss might
   Cause a significant degradation in mission capability
     to an extent and duration that the organization is able
     to perform its primary functions, but the effectiveness
     of the functions is significantly reduced.
   Result in significant damage to organizational assets.
   Result in significant financial loss.
   Result in significant harm to individuals that does not
     involve loss of life or serious, life-threatening injuries.
                   High Impact
 The loss could be expected to have a severe or
  catastrophic adverse effect on organizational operations,
  organizational assets, or individuals.
 A severe or catastrophic adverse effect means that, for
  example, the loss might
   Cause a severe degradation in or loss of mission
     capability to an extent and duration that the
     organization is not able to perform one or more of its
     primary functions.
   Result in major damage to organizational assets.
   Result in major financial loss.
   Result in severe or catastrophic harm to individuals
     involving loss of life or serious life threatening injuries.
    Examples of Security
Requirements: Confidentiality
  Student grade information is an asset whose
confidentiality is considered to be very high
    The US FERPA Act: grades should only be
   available to students, their parents, and their
   employers (when required for the job)
     Student enrollment information: May have
moderate confidentiality rating; less damage if
disclosed
  Directory information: Low confidentiality rating;
often available publicly
     Examples of Security
    Requirements: Integrity
  A hospital patient’s allergy information (high integrity
data): a doctor should be able to trust that the info is
correct and current
   If anyone deliberately falsifies the data, the database
   should be restored to a trusted basis and the falsified
   information traced back to the person who did it
 An online newsgroup registration data: moderate level
of integrity
 An example of low integrity requirement: anonymous
online poll (inaccuracy is well understood)
     Examples of Security
   Requirements: Availability
     A system that provides authentication: high
availability requirement
  If customers cannot access resources, the loss of
  services could result in financial loss
   A public website for a university: a moderate
availably requirement; not critical but causes
embarrassment
    An online telephone directory lookup: a low
availability requirement because unavailability is
mostly annoyance (there are alternative sources)
      Examples of Security
         Requirements
 Confidentiality – student grades
 Integrity       – patient information
 Availability    – authentication service
 Authenticity    – admission ticket
 Non-repudiation – stock sell order
Computer Security Challenges
1. Not simple – easy to get it wrong
   • Mechanism required to implement CIA are
     complex.
2. Must consider potential attacks
   • Successful attack exploit      an unexpected
     weakness.
3. Procedures used counter-intuitive
   • Proper evaluation of any threat to evolve
     security mechanism.
4. Involve algorithms and secret info
   • i.e. encryption keys. How to create, distribute
     and protect secret information. Protocol
     design challenges.
Computer Security Challenges
5. Must decide where to deploy mechanisms
   • Physical placement. Implement in which
     protocol layer?
6. Battle of wits between attacker / security admin
   • Attacker at advantage. Single weakness
     necessary to mount an attack.
7. Not perceived on benefit until fails
8. Requires regular monitoring
   • Difficult in short term, overloaded environment
9. Security is a process, not an event
Computer Security Challenges
9. Too often an after-thought
10. Needs to be integral part of system design.
   • Most old Internet Protocol had no build in
      security mechanism.
11. Regarded as impediment to using system in
    user friendly and efficient manner.
        “Security verses Convenience”
    “Security and Moral issues”
    “Security and Privacy issues”
 Computer
  Security
Terminology
Security Concepts and
   Relationships
    OSI Security Architecture
Software    architecture     refers  to    the
fundamental structures of a software system
and the discipline of creating such structures
and systems.
               Modify message
Active Attack: Masquerade
Active Attack: Replay
        Handling Attacks
Passive attacks – focus on Prevention
  • Easy to stop
  • Hard to detect
Active attacks – focus on Detection and
 Recovery
  • Hard to stop
  • Easy to detect
• Attack surface         – Reachable and exploitable
 vulnerabilities in system.
  • Network attack surface, Software attack surface,
    Human attack surface
        Threat Consequences
• Unauthorized disclosure: Threat to confidentiality
• Exposure (release data), interception, inference, intrusion
• Deception: Threat to integrity
• Masquerade, falsification (alter data), repudiation
• Disruption: Threat to integrity and availability
• Incapacitation (destruction), corruption (backdoor logic),
  obstruction (infer with communication, overload a line)
• Usurpation: Threat to integrity
• Misappropriation (theft of service), misuse (hacker
  gaining unauthorized access)
        Security Service
Enhance security of data processing systems
 and information transfers of an organization
Intended to counter security attacks
Using one or more security mechanisms
Often     replicates     functions    normally
 associated with physical documents
  • For example, have signatures, dates; need
    protection from disclosure, tampering, or
    destruction; be notarized or witnessed; be
    recorded or licensed
           Security Services
 X.800:
  “A service provided by a protocol layer of
    communicating open systems, which ensures
    adequate security of the systems or of data
    transfers”
 RFC 2828:
  “A processing or communication service
    provided by a system to give a specific kind of
    protection to system resources”
    Security Services (X.800)
 Authentication - assurance that communicating
  entity is the one claimed
  have both peer-entity & data origin authentication
 Access Control - prevention of the
  unauthorized use of a resource
 Data Confidentiality –protection of data from
  unauthorized disclosure.
   • Connectionless confidentiality
   • Connection confidentiality
   • Selective-Field confidentiality
   • Traffic flow confidentiality
    Security Services (X.800)
 Data Integrity - assurance that data received is
  as sent by an authorized entity
  • Connection integrity with recovery
  • Connection integrity without recovery
  • Selective-Field Connection integrity
  • Connectionless integrity
  • Selective-Field Connectionless integrity.
 Non-Repudiation - protection against denial by
  one of the parties in a communication
  • Nonrepudiation, Origin
  • Nonrepudiation, Destination
 Availability – resource accessible/usable
      Security Mechanism
 Key Size (bits)   Number of Alternative         Time required at 1            Time required at 106
                          Keys                     decryption/µs                 decryptions/µs
128 2128 = 3.4  1038 2127 µs = 5.4  1024 years 5.4  1018 years
168 2168 = 3.7  1050 2167 µs = 5.9  1036 years 5.9  1030 years
 26 characters     26! = 4  1026          2  1026 µs = 6.4  1012 years   6.4  106 years
 (permutation)
      Classical Substitution
             Ciphers
 where letters of plaintext are replaced by
  other letters or by numbers or symbols
 or if plaintext is viewed as a sequence of
  bits, then substitution involves replacing
  plaintext bit patterns with ciphertext bit
  patterns
            Caesar Cipher
 earliest known substitution cipher
 by Julius Caesar
 first attested use in military affairs
 replaces each letter by 3rd letter on
 example:
  meet me after the toga party
  PHHW PH DIWHU WKH WRJD SDUWB
                 Caesar Cipher
 can define transformation as:
  a b c d e f g h i j k l m n o p q r s t u v w x y z =
    IN
  D E F G H I J K L M N O P Q R S T U V W X Y Z A B C =
    OUT
  Plain: abcdefghijklmnopqrstuvwxyz
  Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN
  Plaintext: ifwewishtoreplaceletters
  Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA
     Monoalphabetic Cipher
           Security
 key size is now 25 characters…
 now have a total of 26! = 4 x 1026 keys
 with so many keys, might think is secure
 but would be !!!WRONG!!!
 problem is language characteristics
    Language Redundancy and
         Cryptanalysis
 human languages are redundant
 e.g., "th lrd s m shphrd shll nt wnt"
 letters are not equally commonly used
 in English E is by far the most common letter
   followed by T,R,N,I,O,A,S
 other letters like Z,J,K,Q,X are fairly rare
 have tables of single, double & triple letter
  frequencies for various languages
English Letter Frequencies
         Use in Cryptanalysis
 key concept - monoalphabetic substitution
  ciphers do not change relative letter frequencies
 discovered by Arabian scientists in 9th century
 calculate letter frequencies for ciphertext
 compare counts/plots against known values
 if caesar cipher look for common peaks/troughs
   peaks at: A-E-I triple, N-O pair, R-S-T triple
   troughs at: J-K, U-V-W-X-Y-Z
 for monoalphabetic must identify each letter
   tables of common double/triple letters help
    (digrams and trigrams)
 amount of ciphertext is important – statistics!
     Example Cryptanalysis
 given ciphertext:
  UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
  VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
  EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
 count relative letter frequencies (see text)
      Example Cryptanalysis
 given ciphertext:
  UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZ
  VUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
  EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
 guess P & Z are e and t
 guess ZW is th and hence ZWP is “the”
 proceeding with trial and error finally get:
  it was disclosed yesterday that several informal
    but
  direct contacts have been made with political
  representatives of the viet cong in moscow
          Playfair Cipher
 not even the large number of keys in a
  monoalphabetic cipher provides security
 one approach to improving security was to
  encrypt multiple letters
 the Playfair Cipher is an example
 invented by Charles Wheatstone in 1854,
  but named after his friend Baron Playfair
        Playfair Key Matrix
 a 5X5 matrix of letters based on a keyword
 fill in letters of keyword (sans duplicates)
 fill rest of matrix with other letters
 eg. using the keyword MONARCHY
          M    O    N     A     R
          C    H    Y     B     D
          E    F    G     I/J   K
          L    P    Q     S     T
          U    V    W     X     Z
  Encrypting and Decrypting
 plaintext is encrypted two letters at a time
  1. if a pair is a repeated letter, insert filler like 'X’
  2. if both letters fall in the same row, replace
     each with letter to right (wrapping back to start
     from end)
  3. if both letters fall in the same column, replace
     each with the letter below it (wrapping to top
     from bottom)
  4. otherwise each letter is replaced by the letter
     in the same row and in the column of the other
     letter of the pair
            Playfair Example
 Message = Move forward
 Plaintext = mo ve fo rw ar dx
 Here x is just a filler, message is padded and segmented
mo -> ON; ve -> UF; fo -> PH, etc.
 Ciphertext = ON UF PH NZ RM BZ
            M      O      N      A      R
            C      H      Y      B      D
            E      F      G      I/J    K
            L      P      Q      S      T
            U      V      W      X      Z
   Security of Playfair Cipher
 security much improved over monoalphabetic
 since have 26 x 26 = 676 digrams
 would need a 676 entry frequency table to
  analyse (versus 26 for a monoalphabetic)
 and correspondingly more ciphertext
 was widely used for many years
  eg. by US & British military in WW1
 it can be broken, given a few hundred letters
 since still has much of plaintext structure
     Polyalphabetic Ciphers
 polyalphabetic substitution ciphers
 improve security using multiple cipher alphabets
 make cryptanalysis harder with more alphabets
  to guess and flatter frequency distribution
 use a key to select which alphabet is used for
  each letter of the message
 use each alphabet in turn
 repeat from start after end of key is reached
           Vigenère Cipher
 simplest polyalphabetic substitution cipher
 effectively multiple caesar ciphers
 key is multiple letters long K = k1 k2 ... kd
 ith letter specifies ith alphabet to use
 use each alphabet in turn
 repeat from start after d letters in message
 decryption simply works in reverse
 Example of Vigenère Cipher
 write the plaintext out
 write the keyword repeated above it
 use each key letter as a caesar cipher key
 encrypt the corresponding plaintext letter
 eg using keyword deceptive
  key:       deceptivedeceptivedeceptive
  plaintext: wearediscoveredsaveyourself
  ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
                      Aids
 simple aids can assist with en/decryption
 a Saint-Cyr Slide is a simple manual aid
  a slide with repeated alphabet
  line up plaintext 'A' with key letter, eg 'C'
  then read off any mapping for key letter
 can bend round into a cipher disk
 or expand into a Vigenère Tableau
Cipher Disk
Vigenère Tableau
 Security of Vigenère Ciphers
 have multiple ciphertext letters for each
  plaintext letter
 hence letter frequencies are obscured
 but not totally lost
 start with letter frequencies
  see if it looks monoalphabetic or not
 if not, then need to determine number of
  alphabets, since then can attack each
            Kasiski Method
 method developed by Babbage / Kasiski
 repetitions in ciphertext give clues to period
 so find same plaintext a multiple of key length
  apart
 which results in the same ciphertext
 of course, could also be random fluke
 e.g. repeated “VTW” in previous example
 distance of 9 suggests key size of 3 or 9
 then attack each monoalphabetic cipher
  individually using same techniques as before
   Example of Kasiski Attack
 Find repeated ciphertext trigrams (e.g., VTW)
 May be result of same key sequence and same
  plaintext sequence (or not)
 Find distance(s)
 Common factors are likely key lengths
  key:       deceptivedeceptivedeceptive
  plaintext: wearediscoveredsaveyourself
  ciphertext:ZICVTWQNGRZGVTWAVZHCQYGLMGJ
             Autokey Cipher
 ideally want a key as long as the message
 Vigenère proposed the autokey cipher
 with keyword is prefixed to message as key
 knowing keyword can recover the first few letters
 use these in turn on the rest of the message
 but still have frequency characteristics to attack
 eg. given key deceptive
   key:       deceptivewearediscoveredsav
   plaintext: wearediscoveredsaveyourself
   ciphertext:ZICVTWQNGKZEIIGASXSTSLVVWLA
            Vernam Cipher
 ultimate defense is to use a key as long as the
  plaintext
 with no statistical relationship to it
 invented by AT&T engineer Gilbert Vernam in
  1918
 specified in U.S. Patent 1,310,719, issued July
  22, 1919
 originally proposed using a very long but
  eventually repeating key
 used electromechanical relays
             One-Time Pad
 if a truly random key as long as the message is
  used, the cipher will be secure
 called a One-Time pad (OTP)
 is unbreakable since ciphertext bears no
  statistical relationship to the plaintext
 since for any plaintext & any ciphertext there
  exists a key mapping one to other
 can only use the key once though
 problems in generation & safe distribution of key
Ciphertext:ANKYODKYUREPFJBYOJDSPLREYIUNOFDOIUERF
           PLUYTS
key:       pxlmvmsydofuyrvzwctnlebnecvgdupahfzzl
           mnyih
plaintext: mr mustard wit the candlestick in
           the hall
key:      mfugpmiydgaxgoufhklllmhsqdqogtewbqfgyo
          vuhwt
plaintext: miss scarlet with the knife in the li
           brary
      Transposition Ciphers
 now consider classical transposition or
  permutation ciphers
 these hide the message by rearranging
  the letter order
 without altering the actual letters used
 can recognise these since have the same
  frequency distribution as the original text
           Rail Fence cipher
 write message letters out diagonally over a
  number of rows
 then read off cipher row by row
 Message: meetmeafterthetogaparty
 eg. write message out as:
   m e m a t r h t g p r y
    e t e f e t e o a a t
 giving ciphertext
   MEMATRHTGPRYETEFETEOAAT
  Row Transposition Ciphers
 is a more complex transposition
 write letters of message out in rows over a
  specified number of columns
 then reorder the columns according to
  some key before reading off the rows
  Key: 4312567
  Column Out 4 3 1 2 5 6 7
  Plaintext: a t t a c k p
             o s t p o n e
             d u n t i l t
             w o a m x y z
  Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
 Block Transposition Ciphers
arbitrary block transposition may be used
specify permutation on block
repeat for each block of plaintext
  Key: 4931285607
  Plaintext: attackpost poneduntil twoamxyzab
                          K1
                    K1
    M3                           C3       Plaintext pre-image of Ci is
               K1
                                           unique to Ci under k
                                       Notation
                                             A            A
                    K1
                                              key k and Mi in M, Ǝ! Cj
    Mi                           Ci
                                           in C such that E(k,Mi) = Cj
                                             A            A
                                          key k and ciphertext Ci
                    K1
                                           in C, Ǝ! Mj in M such that
                                           E(k,Mj) = Ci
    Mn
                                 Cn       Ek(.) is “one-to-one” (injective)
M=set of all             C=set of all
                                          If |M|=|C| it is also “onto”
  plaintexts               ciphertexts     (surjective), and hence
                                           bijective.
     Encryption Mappings (2)
                                     A given plaintext (Mi)
M1                             C1
                                        Mi is mapped to some ciphertext
                                         E(K,Mi) by every key k
                                        Different keys may map Mi to the
M2               Kj            C2
                                         same ciphertext
                                        There may be some ciphertexts to
M3       K2,K89,...            C3
                                         which Mi is never mapped by any
      K3,K
                                         key
          j’,.
       Km ..                         Notation
                                           A            A
                                             key k and Mi in M, Ǝ!
         K1
            ,   K7                       ciphertext Cj in C such that
Mi                57           Ci        E(k,Mi) = Cj
                       ,..
                           .            It is possible that there are keys k
                                         and k’ such that E(k,Mi) = E(k’,Mi)
                                        There may be some ciphertext Cj
Mn                                       for which Ǝ key k such that
                               Cn        E(k,Mi) = Cj
      Encryption Mappings (3)
M1                                     C1     A ciphertext (Ci)
                                                 Has a unique plaintext pre-
             K1
               ,K 1
                                                  image under each k
M2                    7,.              C2        May have two keys that map
                         ..
                                                  the same plaintext to it
                                                 There may be some plaintext
M3           K2,K89,...                C3         Mj such that no key maps Mj
                    Km                            to Ci
                                ,...
                              4               Notation
...
                                       ...
      ...         Kj     , K9
                      K3
                                                    A          A
                                                    key k and ciphertext Ci
Mi          ...                        Ci         in C, Ǝ! Mj in M such that
                                                  E(k,Mj) = Ci
                                                 There may exist keys k, k’
...
...
                     permutation
Claude Shannon and Substitution-
      Permutation Ciphers
   Claude Shannon introduced idea of substitution-
    permutation (S-P) networks in 1949 paper
   Form basis of modern block ciphers
   S-P nets are based on the two primitive
    cryptographic operations seen before:
    
        substitution (S-box)
    
        permutation (P-box)
   Provide confusion & diffusion of message & key
    Confusion and Diffusion
 Cipher    needs to completely obscure
  statistical properties of original message
 A one-time pad does this
 More     practically Shannon suggested
  combining S & P elements to obtain:
 Diffusion – dissipates statistical structure
  of plaintext over bulk of ciphertext
 Confusion – makes relationship between
  ciphertext and key as complex as possible
      Feistel Cipher Structure
 Horst Feistel devised the     feistel cipher
  
      based on concept of invertible product cipher
 Partitions input block into two halves
  
      process through multiple rounds which
  
      perform a substitution on left data half
  
      based on round function of right half & subkey
  
      then have permutation swapping halves
 Implements Shannon’s S-P net concept
Feistel Cipher Structure
Feistel Cipher Design Elements
 Block size
 Key size
 Number of rounds
 Subkey generation algorithm
 Round function
 Fast software en/decryption
 Ease of analysis
Data Encryption Standard (DES)
 Most widely used block cipher in world
 Adopted in 1977 by NBS (now NIST)
  
      as FIPS PUB 46
 Encrypts 64-bit data using 56-bit key
 Has widespread use
 Has  been considerable controversy over
 its security
                DES History
 IBM developed Lucifer cipher
  
      by team led by Feistel in late 60’s
  
      used 64-bit data blocks with 128-bit key
 Then   redeveloped as a commercial cipher
  with input from NSA and others
 In 1973 NBS issued request for proposals
  for a national cipher standard
 IBM submitted their revised Lucifer which
  was eventually accepted as the DES
      DES Design Controversy
 Although DES standard is public
 Was    considerable controversy over design
  
      in choice of 56-bit key (vs Lucifer 128-bit)
  
      and because design criteria were classified
 Subsequent    events and public analysis
  show in fact design was appropriate
 Use of DES has flourished
  
      especially in financial applications
  
      still standardised for legacy application use
DES Encryption Overview
       Initial Permutation IP
 First step of the data computation
 IP reorders the input data bits
 Even bits to LH half, odd bits to RH half
 Quite regular in structure (easy in h/w)
 No cryptographic value
 example:
 IP(675a6967 5e5a6b5a) = (ffb2194d 004df6fb)
              Initial Permutation
               58   50   42   34   26   18   10   2
               60   52   44   36   28   20   12   4
               62   54   46   38   30   22   14   6
               64   56   48   40   32   24   16   8
               57   49   41   33   25   17    9   1
               59   51   43   35   27   19   11   3
               61   53   45   37   29   21   13   5
               63   55   47   39   31   23   15   7
32 1 2 3 4 5 4 5 6 7 8 9 8 9 10 11 12 13 12 13 14 15 16 17 16 17 18 19 20 21 20 21 22 23 24 25 24 25 26 27 28 29 28 29 30 31 32 1
  32    1  2 3   4    5
   4    5  6 7   8    9
   8    9 10 11 12   13
  12   13 14 15 16   17
  16   17 18 19 20   21
  20   21 22 23 24   25
  24   25 26 27 28   29
  28   29 30 31 32    1
         Substitution Boxes S
 Have eight S-boxes which map 6 to 4 bits
 Each S-box is actually 4 little 4 bit boxes
  
      outer bits 1 & 6 (row bits) select one row of 4
  
      inner bits 2-5 (col bits) are substituted
  
      result is 8 lots of 4 bits, or 32 bits
 Row selection depends on both data & key
  
      feature known as autoclaving (autokeying)
 example:
  
      S(18 09 12 3d 11 17 38 39) = 5fd25e03
   Substitution Boxes S
                             Each of the eight s-
                              boxes is different
          input symbol       Each s-box reduces
                              6 bits to 4 bits
control
               Si            So the 8 s-boxes
                              implement the 48-bit
          output symbol       to 32-bit contraction
                              substitution
                                      101101
                                           0010
                                 Permutation Box P
         S1                     S2                 S3                  S4                     S5               S6                  S7                  S8
16   7    20      21   29   12   28      17   1   15   23   26   5    18   31   10   2    8    24   14   32   27    3   9    19   13   30   6    22   11    4   25
Permutation Function (P)
16    7    20   21   29   12   28
17
  1   15   23   26    5   18   31
10
  2    8   24   14   32   27    3
9
19    13   30   6    22   11    4
25
                                                                           DES Round in Full
                           Right Half i-1                    1        2    3     4    5        6        7        8   9    10   11      12       13    14     15   16   17      18        19   20     21   22   23      24       25   26      27   28   29      30        31   32
32 1 2 3 4 5 4 5 6 7 8 9 8 9 10 11 12 13 12 13 14 15 16 17 16 17 18 19 20 21 20 21 22 23 24 25 24 25 26 27 28 29 28 29 30 31 32 1
Round Key i
+
O   1         2       3        4   5    6   7       8        9    10       11   12    13      14       15    16      17   18   19      20       21    22     23   24   25      26        27   28     29   30   31      32       33   34      35   36   37      38        39   40     41   42   43      44       45   46      47   48
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
                   input symbol                           input symbol                               input symbol                             input symbol                            input symbol                            input symbol                            input symbol                            input symbol
         control
control
control
control
control
control
control
                                                                                                                                                                                                                                                                                                    control
                          S1                                     S2                                         S3                                       S4                                    S5                                      S6                                        S7                                    S8
output symbol output symbol output symbol output symbol output symbol output symbol output symbol output symbol
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10 2 8 24 14 32 27 3 9 19 13 30 6 22 11 4 25
                                                +
                                                O            1        2    3     4    5        6        7        8   9    10   11      12       13    14     15   16   17      18        19   20     21   22   23      24       25   26      27   28   29      30        31   32
Right Half i
                                                             1        2    3     4    5        6        7        8   9    10   11      12       13    14     15   16   17      18        19   20     21   22   23      24       25   26      27   28   29      30        31   32
          DES Key Schedule
 Forms subkeys used in each round
  
      initial permutation of the key (PC1) which
      selects 56-bits in two 28-bit halves
  
      16 stages consisting of:
      • rotating each half separately either 1 or 2 places
        depending on the key rotation schedule K
      • selecting 24-bits from each half & permuting them
        by PC2 for use in round function F
 Note practical use issues in h/w vs s/w
          Key
 1    2    3    4   5     6    7    8
 9   10   11   12   13   14   15   16
17   18   19   20   21   22   23   24
25   26   27   28   29   30   31   32
33   34   35   36   37   38   39   40
41   42   43   44   45   46   47   48
49   50   51   52   53   54   55   56
57   58   59   60   61   62   63   64
                              Discarded bits
      Initial permutation - PC1
                 57 49 41 33 25 17 9
                  1 58 50 42 34 26 18
                 10 2 59 51 43 35 27
                 19 11 3 60 52 44 36
                 63   55 47 39 31 23 15
                  7   62 54 46 38 30 22
                 14    6 61 53 45 37 29
                 21   13 5 28 20 12 4
       14   17   11   24    1    5    3   28
       15    6   21   10   23   19   12    4
       26    8   16    7   27   20   13    2
       41   52   31   37   47   55   30   40
       51   45   33   48   44   49   39   56
       34   53   46   42   50   36   29   32
                                                         DES Key Schedule
                 64-bit key with parity bits
1    2   3   4   5   6   7   8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    permuted
    choice 1
                 57 49 41 33 25 17 9         1 58 50 42 34 26 18 10 2 59 51 43 35 27 19 11 3 60 52 44 36 63 55 47 39 31 23 15 7 62 54 46 38 30 22 14 6 61 53 45 37 29 21 13 5 28 20 12 4
56-bit key 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
             1   2   3   4   5   6   7   8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28          29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
     Left
     Shift
             2   3   4   5   6   7   8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1            30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    permuted
    choice 2
                 14 17 11 24 1       5   3 28 15 6 21 10 23 19 12 4 26 8 16 7 27 20 13 2                      41 52 31 37 47 55 30 40 51 45 33 48 44 49 39 56 34 53 46 42 50 36 29 32
48-bit subkey            1   2   3   4   5   6   7   8   9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
                DES Decryption
   decrypt must unwind steps of data computation
   with Feistel design, do encryption steps again
    using subkeys in reverse order (SK16 … SK1)
    
        IP undoes final FP step of encryption
    
        1st round with SK16 undoes 16th encrypt round
    
        ….
    
        16th round with SK1 undoes 1st encrypt round
    
        then final FP undoes initial encryption IP
    
        thus recovering original data value
  DES Round Decryption
Left half i-1                Right half i-1
                               Mangler
                               Function       Round key i
                                  F
                                 +
                                 O
                Decryption
DES Example
Avalanche in DES
          Avalanche Effect
 Key desirable property of encryption alg
 Where    a change of one input or key bit
  results in changing approx half output bits
 Making attempts to “home-in” by guessing
  keys impossible
 DES exhibits strong avalanche
Change in Plaintext                Change in Key
Round Number of bits that differ Round Number of bits that differ
 0                1                  0                0
 1                6                  1                2
 2               21                  2               14
 3               35                  3               28
 4               39                  4               32
 5               34                  5               30
 6               32                  6               32
 7               31                  7               35
 8               29                  8               34
 9               42                  9               40
10               44                 10               38
11               32                 11               31
12               30                 12               33
13               30                 13               28
14               26                 14               26
15               29                 15               34
16               34                 16               35
          DES Design Criteria
 As reported by Coppersmith in [COPP94]
 7 criteria for S-boxes provide for
  
      non-linearity
  
      resistance to differential cryptanalysis
  
      good confusion
 3 criteria for permutation P provide for
  
      increased diffusion
(S-1)
Each S-box has six bits of input and four bits of output. (This was the largest
size that we could accommodate and still fit all of DES onto a single chip in
1974 technology.)
(S-2)
No output bit of an S-box should be too close to a linear function of the input
bits. (That is, if we select any output bit position and any subset of the six
input bit positions, the fraction of inputs for which this output bit equals the
XOR of these input bits should not be close to 0 or 1, but rather should be
near 1/2.)
(S-3)
If we fix the leftmost and rightmost input bits of the S-box and vary the four
middle bits, each possible 4-bit output is attained exactly once as the middle
four input bits range over their 16 possibilities.
(S-4)
If two inputs to an S-box differ in exactly one bit, the outputs must differ in at
least two bits.
(S-5)
If two inputs to an S-box differ in the two middle bits exactly, the outputs must
differ in at least two bits.
(S-6)
If two inputs to an S-box differ in their first two bits and are identical in their
last two bits, the two outputs must not be the same.
(S-7)
For any nonzero 6-bit difference between inputs, ΔIij no more than 8 of the
32 pairs of inputs exhibiting ΔIij may result in the same output difference
ΔOij
(S-8)
Similar to (S-7), but with stronger restrictions in the case ΔOij = 0, for the
case of three active S-boxes on round i
(P-1)
The four output bits from each S-box at round i are distributed so that two of
them affect (provide input for) “middle bits” of S-boxes at round i + 1 (the two
middle bits of input to an S-box, not shared with adjacent S-boxes), and the
other two affect “end bits” (the two left-hand bits or the two righthand bits,
which are shared with adjacent S-boxes).
(P-2)
The four output bits from each S-box affect six different S-boxes; no two affect
the same S-box. (Remember that each “end bit” affects two adjacent S-boxes.)
(P-3)
For two S-boxes j , k, if an output bit from S, affects a middle bit of Sk, then an
output bit from Sk cannot affect a middle bit of Sj. This implies that in the case j =
k, an output bit from Sj must not affect a middle bit of Sj.
  Strength of DES – Key Size
 56-bit keys have 256 = 7.2 x 1016 values
 Brute force search looks hard
 Recent advances have shown is possible
  
      in 1997 on Internet in a few months
  
      in 1998 on dedicated h/w (EFF) in a few days
  
      in 1999 above combined in 22hrs!
 Still must be able to recognize plaintext
 Must now consider alternatives to DES
        Strength of DES – Analytic
                 Attacks
   Now have several analytic attacks on DES
   These utilise some deep structure of the cipher
    
        by gathering information about encryptions
    
        can eventually recover some/all of the sub-key bits
    
        if necessary then exhaustively search for the rest
   Generally these are statistical attacks
    
        differential cryptanalysis
    
        linear cryptanalysis
    
        related key attacks
     Strength of DES – Timing
             Attacks
 Attacks actual implementation of cipher
 Use    knowledge of consequences of
  implementation to derive information about
   some/all subkey bits
 Specifically use fact that calculations can
  take varying times depending on the value
  of the inputs to it
 Particularly problematic on smartcards
   Differential Cryptanalysis
 One  of the most significant recent (public)
  advances in cryptanalysis
 Known by NSA in 70's cf DES design
 Murphy, Biham & Shamir published in 90’s
 Powerful method to analyse block ciphers
 Used to analyse most current block
  ciphers with varying degrees of success
 DES reasonably resistant to it, cf Lucifer
   Differential Cryptanalysis
 A statistical attack against Feistel ciphers
 Uses cipher structure not previously used
 Design   of S-P networks has output of
  function f influenced by both input & key
 Hence cannot trace values back through
  cipher without knowing value of the key
 Differential cryptanalysis compares two
  related pairs of encryptions
         Linear Cryptanalysis
 Another recent development
 Also a statistical method
 Must   be iterated over rounds, with
  decreasing probabilities
 Developed by Matsui et al in early 90's
 Based on finding linear approximations
 Can attack DES with 243 known plaintexts,
  easier but still in practise infeasible
          DES Design Criteria
 As reported by Coppersmith in [COPP94]
 7 criteria for S-boxes provide for
  
      non-linearity
  
      resistance to differential cryptanalysis
  
      good confusion
 3 criteria for permutation P provide for
  
      increased diffusion
         Block Cipher Design
 Basic principles still like Feistel’s in 1970’s
 Number of rounds
  
      more is better, exhaustive search best attack
 function f:
  
      provides “confusion”, is nonlinear, avalanche
  
      have issues of how S-boxes are selected
 Key schedule
  
      complex subkey creation, key avalanche
         Design Of Function F
 Function F provides confusion.
 Should be nonlinear
 Achieved by Avalanche effect
  
      Strict Avalanche Criterion (SAC)
       • Any output bit j of substitution box should change
         with probability ½ when any single input bit i is
         inverted for all i, j.
  
      Bit Independence Criterion (BIC)
       • Output bit j and k should change independently
         when input bit i is inverted for all i,j,k.
                    Summary
 have considered:
  
      block vs stream ciphers
  
      Feistel cipher design & structure
  
      DES
       • details
       • strength
  
      Differential & Linear Cryptanalysis
  
      block cipher design principles
Cryptography and
Network Security
    Chapter 4
      Fifth Edition
  by William Stallings
Chapter 4 – Basic Concepts in
 Number Theory and Finite
            Fields
 The next morning at daybreak, Star flew indoors, seemingly keen for
 a lesson. I said, "Tap eight." She did a brilliant exhibition, first
 tapping it in 4, 4, then giving me a hasty glance and doing it in 2, 2,
 2, 2, before coming for her nut. It is astonishing that Star learned to
 count up to 8 with no difficulty, and of her own accord discovered
 that each number could be given with various different divisions, this
 leaving no doubt that she was consciously thinking each number. In
 fact, she did mental arithmetic, although unable, like humans, to
 name the numbers. But she learned to recognize their spoken
 names almost immediately and was able to remember the sounds of
 the names. Star is unique as a wild bird, who of her own free will
 pursued the science of numbers with keen interest and astonishing
 intelligence.
                    — Living with Birds, Len Howard
                Introduction
 will now introduce finite fields
 of increasing importance in cryptography
  
      AES, Elliptic Curve, IDEA, Public Key
 concern operations on “numbers”
  
      where what constitutes a “number” and the
      type of operations varies considerably
 start with basic number theory concepts
                  Divisors
 say a non-zero number     b divides a if for
  some m have a=mb (a,b,m all integers)
 that is b divides into a with no remainder
 denote this b|a
 and say that b is a divisor of a
 eg. all of 1,2,3,4,6,8,12,24 divide 24
 eg. 13 | 182; –5 | 30; 17 | 289; –3 | 33; 17 | 0
        Properties of Divisibility
  If a|1, then a = ±1.
 If a|b and b|a, then a = ±b.
 Any b /= 0 divides 0.
 If a | b and b | c, then a | c
    
        e.g. 11 | 66 and 66 | 198 so 11 | 198
 If b|g and b|h, then b|(mg + nh)
    for arbitrary integers m and n
      e.g. b = 7; g = 14; h = 63; m = 3; n = 2
             7|14 and 7|63 hence 7 | 42+126 = 168
           Division Algorithm
 if divide a by n get integer quotient     q and
  integer remainder r such that:
  
      a = qn + r where 0 <= r < n; q = floor(a/n)
 remainder r often referred to as a      residue
Greatest Common Divisor (GCD)
 a common problem in number theory
 GCD (a,b) of a and b is the largest integer
 that divides evenly into both a and b
  
      eg GCD(60,24) = 12
 define gcd(0, 0) = 0
 often want no common factors (except 1)
 define such numbers as relatively prime
  
      eg GCD(8,15) = 1
  
      hence 8 & 15 are relatively prime
  Example GCD(1970,1066)
1970 = 1 x 1066 + 904      gcd(1066, 904)
1066 = 1 x 904 + 162 gcd(904, 162)
904 = 5 x 162 + 94    gcd(162, 94)
162 = 1 x 94 + 68     gcd(94, 68)
94 = 1 x 68 + 26      gcd(68, 26)
68 = 2 x 26 + 16      gcd(26, 16)
26 = 1 x 16 + 10      gcd(16, 10)
16 = 1 x 10 + 6 gcd(10, 6)
10 = 1 x 6 + 4   gcd(6, 4)
6 = 1 x 4 + 2    gcd(4, 2)
4 = 2 x 2 + 0    gcd(2, 0)
 GCD(1160718174, 316258250)
Dividend         Divisor          Quotient   Remainder
a = 1160718174   b = 316258250    q1 = 3     r1 = 211943424
b = 316258250    r1 = 211943424   q2 = 1     r2 = 104314826
r1 = 211943424   r2 = 104314826   q3 = 2     r3 = 3313772
r2 = 104314826   r3 = 3313772     q4 = 31    r4 = 1587894
r3 = 3313772     r4 = 1587894     q5 = 2     r5 = 137984
r4 = 1587894     r5 = 137984      q6 = 11    r6 = 70070
r5 = 137984      r6 = 70070       q7 = 1     r7 = 67914
r6 = 70070       r7 = 67914       q8 = 1     r8 = 2156
r7 = 67914       r8 = 2156        q9 = 31    r9 = 1078
r8 = 2156        r9 = 1078        q10 = 2    r10 = 0
             Modular Arithmetic
   define modulo operator “a mod n” to be
    remainder when a is divided by n
    
        where integer n is called the modulus
   b is called a residue of a mod n
    
        since with integers can always write: a = qn + b
    
        usually chose smallest positive remainder as residue
         • ie. 0 <= b <= n-1
    
        process is known as modulo reduction
         • eg. -12 mod 7 = -5 mod 7 = 2 mod 7 = 9 mod 7
   a & b are congruent if: a mod n = b mod n
    
        when divided by n, a & b have same remainder
    
        eg. 100 mod 11 = 34 mod 11
                     so 100 is congruent to 34 mod 11
Modular Arithmetic Operations
 can perform arithmetic with residues
 uses a finite number of values, and loops
 back from either end
  Zn = {0, 1, . . . , (n – 1)}
 modular arithmetic is when do addition &
  multiplication and modulo reduce answer
 can do reduction at any point, ie
  
      a+b mod n = [a mod n + b mod n] mod n
Modular Arithmetic Operations
1. [(a mod n) + (b                             mod n)] mod n
   = (a + b) mod n
2. [(a mod n) – (b                             mod n)] mod n
   = (a – b) mod n
3. [(a mod n) x (b                             mod n)] mod n
   = (a x b) mod n
     e.g.
     [(11 mod 8) + (15 mod 8)] mod 8 = 10 mod 8 = 2 (11 + 15) mod 8 = 26 mod 8 = 2
     [(11 mod 8) – (15 mod 8)] mod 8 = –4 mod 8 = 4 (11 – 15) mod 8 = –4 mod 8 = 4
     [(11 mod 8) x (15 mod 8)] mod 8 = 21 mod 8 = 5 (11 x 15) mod 8 = 165 mod 8 = 5
Modulo 8 Addition Example
     + 0 1 2 3 4 5 6 7
     0 0 1 2 3 4 5 6 7
     1 1 2 3 4 5 6 7 0
     2 2 3 4 5 6 7 0 1
     3 3 4 5 6 7 0 1 2
     4 4 5 6 7 0 1 2 3
     5 5 6 7 0 1 2 3 4
     6 6 7 0 1 2 3 4 5
     7 7 0 1 2 3 4 5 6
Modulo 8 Multiplication
   + 0 1 2 3 4 5 6 7
   0 0 0 0 0 0 0 0 0
   1 0 1 2 3 4 5 6 7
   2 0 2 4 6 0 2 4 6
   3 0 3 6 1 4 7 2 5
   4 0 4 0 4 0 4 0 4
   5 0 5 2 7 4 1 6 3
   6 0 6 4 2 0 6 4 2
   7 0 7 6 5 4 3 2 1
Modular Arithmetic Properties
           Euclidean Algorithm
   an efficient way to find the GCD(a,b)
   uses theorem that:
    
        GCD(a,b) = GCD(b, a mod b)
   Euclidean Algorithm to compute GCD(a,b) is:
    Euclid(a,b)
      if (b=0) then return a;
      else return Euclid(b, a mod b);
Extended Euclidean Algorithm
 calculates not only GCD but x & y:
    ax + by = d = gcd(a, b)
 useful for later crypto computations
 follow sequence of divisions for GCD but
  assume at each step i, can find x &y:
  r = ax + by
 at end find GCD value and also x & y
 if GCD(a,b)=1 these values are inverses
        Finding Inverses
EXTENDED EUCLID(m, b)
1. (A1, A2, A3)=(1, 0, m);
  (B1, B2, B3)=(0, 1, b)
2. if B3 = 0
  return A3 = gcd(m, b); no inverse
3. if B3 = 1
  return B3 = gcd(m, b); B2 = b–1 mod m
4. Q = A3 div B3
5. (T1, T2, T3)=(A1 – Q B1, A2 – Q B2, A3 – Q B3)
6. (A1, A2, A3)=(B1, B2, B3)
7. (B1, B2, B3)=(T1, T2, T3)
8. goto 2
Inverse of 550 in GF(1759)
Q    A1    A2     A3     B1     B2     B3
—     1     0     1759    0      1     550
3     0     1     550     1      –3    109
5     1     –3    109    –5      16    5
21   –5    16      5     106    –339   4
1    106   –339    4     –111   355    1
                       Group
 a set S of elements or “numbers”
  
      may be finite or infinite
 with some operation ‘.’ so G=(S,.)
 Obeys CAIN:
  
      Closure: a,b in S, then a.b in S
  
      Associative law: (a.b).c = a.(b.c)
  
      has Identity e: e.a = a.e = a
  
      has iNverses a-1: a.a-1 = e
 if commutative      a.b = b.a
  
      then forms an abelian group
                 Cyclic Group
 define exponentiation as repeated
  application of operator
  
      example:    a3 = a.a.a
 and let identity be:   e=a0
 a group is cyclic if every element is a
  power of some fixed element a
  
      i.e., b = ak for some a and every b in group
 a is said to be a generator of the group
                         Ring
   a set of “numbers”
   with two operations (addition and multiplication)
    which form:
   an abelian group with addition operation
   and multiplication:
    
        has closure
    
        is associative
    
        distributive over addition: a(b+c) = ab + ac
   if multiplication operation is commutative, it
    forms a commutative ring
   if multiplication operation has an identity and no
    zero divisors, it forms an integral domain
                       Field
 a set of numbers
 with two operations which form:
  
      abelian group for addition
  
      abelian group for multiplication (ignoring 0)
  
      ring
 have hierarchy with more axioms/laws
  
      group -> ring -> field
Group, Ring, Field
         Finite (Galois) Fields
 finite fields play a key role in cryptography
 can show number of elements in a finite
  field must be a power of a prime pn
 known as Galois fields
 denoted GF(pn)
 in particular often use the fields:
  
      GF(p)
  
      GF(2n)
           Galois Fields GF(p)
 GF(p) is the set of integers {0,1, … , p-1}
  with arithmetic operations modulo prime p
 these form a finite field
  
      since have multiplicative inverses
  
      find inverse with Extended Euclidean algorithm
 hence arithmetic is “well-behaved” and can
  do addition, subtraction, multiplication, and
  division without leaving the field GF(p)
GF(7) Multiplication Example
       0 1 2 3 4 5 6
      0 0 0 0 0 0 0 0
      1 0 1 2 3 4 5 6
      2 0 2 4 6 1 3 5
      3 0 3 6 2 5 1 4
      4 0 4 1 5 2 6 3
      5 0 5 3 1 6 4 2
      6 0 6 5 4 3 2 1
        Polynomial Arithmetic
 can compute using polynomials
  f(x) = anxn + an-1xn-1 + … + a1x + a0 = ∑ aixi
       • n.b. not interested in any specific value of x
       • which is known as the indeterminate
 several alternatives available
  
      ordinary polynomial arithmetic
  
      poly arithmetic with coefs mod p
  
      poly arithmetic with coefs mod p and
      polynomials mod m(x)
Ordinary Polynomial Arithmetic
 add or subtract corresponding coefficients
 multiply all terms by each other
 eg
  let f(x) = x3 + x2 + 2 and g(x) = x2 – x + 1
  f(x) + g(x) = x3 + 2x2 – x + 3
  f(x) – g(x) = x3 + x + 1
  f(x) x g(x) = x5 + 3x2 – 2x + 2
      Polynomial Arithmetic with
         Modulo Coefficients
 when computing value of each coefficient
 do calculation modulo some value
  
      forms a polynomial ring
 could be modulo any prime
 but we are most interested in mod 2
  
      ie all coefficients are 0 or 1
  
      eg. let f(x) = x3 + x2 and g(x) = x2 + x + 1
                    f(x) + g(x) = x3 + x + 1
                    f(x) x g(x) = x5 + x2
          Polynomial Division
 can write any polynomial in the form:
  
      f(x) = q(x) g(x) + r(x)
  
      can interpret r(x) as being a remainder
  
      r(x) = f(x) mod g(x)
 if have no remainder say   g(x) divides f(x)
 if g(x) has no divisors other than itself & 1
  say it is irreducible (or prime) polynomial
 arithmetic modulo an irreducible
  polynomial forms a field
               Polynomial GCD
   can find greatest common divisor for polys
    
        c(x) = GCD(a(x), b(x)) if c(x) is the poly of greatest
        degree which divides both a(x), b(x)
   can adapt Euclid’s Algorithm to find it:
    Euclid(a(x), b(x))
      if (b(x)=0) then return a(x);
      else return
      Euclid(b(x), a(x) mod b(x));
   all foundation for polynomial fields as see next
          Modular Polynomial
             Arithmetic
 can compute in field GF(2n)
  
      polynomials with coefficients modulo 2
  
      whose degree is less than n
  
      hence must reduce modulo an irreducible poly
      of degree n (for multiplication only)
 form a finite field
 can always find an inverse
  
      can extend Euclid’s Inverse algorithm to find
Example GF(23)
              Computational
              Considerations
 since coefficients are 0 or 1, can represent
  any such polynomial as a bit string
 addition becomes XOR of these bit strings
 multiplication is shift & XOR
  
      cf long-hand multiplication
 modulo reduction done by repeatedly
 substituting highest power with remainder
 of irreducible poly (also shift & XOR)
         Computational Example
    in GF(23) have (x2+1) is 1012 & (x2+x+1) is 1112
   so addition is
    
        (x2+1) + (x2+x+1) = x
    
        101 XOR 111 = 0102
   and multiplication is
    
        (x+1).(x2+1) = x.(x2+1) + 1.(x2+1)
        = x3+x+x2+1 = x3+x2+x+1
    
         011.101 = (101)<<1 XOR (101)<<0 =
        1010 XOR 101 = 11112
   polynomial modulo reduction (get q(x) & r(x)) is
    
        (x3+x2+x+1 ) mod (x3+x+1) = 1.(x3+x+1) + (x2) = x2
    
        1111 mod 1011 = 1111 XOR 1011 = 01002
           Using a Generator
 equivalent definition of a finite field
 a generator g is an element whose
  powers generate all non-zero elements
  
      in F have 0, g0, g1, …, gq-2
 can create generator from          root of the
  irreducible polynomial
 then implement multiplication by adding
  exponents of generator
                  Summary
 have considered:
  
      divisibility & GCD
  
      modular arithmetic with integers
  
      concept of groups, rings, fields
  
      Euclid’s algorithm for GCD & Inverse
  
      finite fields GF(p)
  
      polynomial arithmetic in general and in GF(2n)
Cryptography and
Network Security
    Chapter 5
      Fifth Edition
  by William Stallings
Chapter 5 –Advanced Encryption
           Standard
Number of Rounds                           10         12         14
Round Key Size ( word/byte/bits)         4/16/128   4/16/128   4/16/128
Expanded Key Size ( word/byte)           44/176     52/208     60/240
   AES
Encryption
 Process
                 AES Structure
   data block of 4 columns of 4 bytes is state
   key is expanded to array of words
   has 9/11/13 rounds in which state undergoes:
    
        byte substitution (1 S-box used on every byte)
    
        shift rows (permute bytes between groups/columns)
    
        mix columns (subs using matrix multiply of groups)
    
        add round key (XOR state with key material)
    
        view as alternating XOR key & scramble data bytes
   initial XOR key material & incomplete last round
   with fast XOR & table lookup implementation
AES Structure
           Some Comments on AES
1.    an iterative rather than Feistel cipher
2.    key expanded into array of 32-bit words
      1.   four words form round key in each round
3.    4 different stages are used as shown
4.    has a simple structure
5.    only AddRoundKey uses key
6.    AddRoundKey a form of Vernam cipher
7.    each stage is easily reversible
8.    decryption uses keys in reverse order
9.    decryption does recover plaintext
10.   final round has only 3 stages
                Substitute Bytes
   a simple substitution of each byte
   uses one table of 16x16 bytes containing a
    permutation of all 256 8-bit values
   each byte of state is replaced by byte indexed
    by row (left 4-bits) & column (right 4-bits)
    
        eg. byte {95} is replaced by byte in row 9 column 5
    
        which has value {2A}
   S-box constructed using defined transformation
    of values in GF(28)
   designed to be resistant to all known attacks
Substitute Bytes
Substitute Bytes Example
                      Shift Rows
   a circular byte shift in each each
    
        1st row is unchanged
    
        2nd row does 1 byte circular shift to left
    
        3rd row does 2 byte circular shift to left
    
        4th row does 3 byte circular shift to left
   decrypt inverts using shifts to right
   since state is processed by columns, this step
    permutes bytes between the columns
Shift Rows
             Mix Columns
 each column is processed separately
 each byte is replaced by a value
  dependent on all 4 bytes in the column
 effectively a matrix multiplication in GF(28)
  using prime poly m(x) =x8+x4+x3+x+1
Mix Columns
Mix Columns Example
             AES Arithmetic
 uses arithmetic in the finite field GF(28)
 with irreducible polynomial
    m(x) = x8 + x4 + x3    + x + 1
    which is (100011011)   or {11b}
   e.g.
    {02} • {87} mod {11b} = (1 0000 1110) mod {11b}
    = (1 0000 1110) xor (1 0001 1011) = (0001 0101)
                    Mix Columns
   can express each col as 4 equations
    
        to derive each new byte in col
   decryption requires use of inverse matrix
    
        with larger coefficients, hence a little harder
   have an alternate characterisation
    
        each column a 4-term polynomial
    
        with coefficients in GF(28)
    
        and polynomials multiplied modulo (x4+1)
 coefficients based on linear code with
    maximal distance between codewords
Mix Columns - Decryption
             Add Round Key
 XOR state with 128-bits of the round key
 again processed by column (though
  effectively a series of byte operations)
 inverse for decryption identical
  
      since XOR own inverse, with reversed keys
 designed to be as simple as possible
  
      a form of Vernam cipher on expanded key
  
      requires other stages for complexity / security
Add Round Key
AES Round
         AES Key Expansion
 takes 128-bit (16-byte) key and expands
  into array of 44/52/60 32-bit words
 start by copying key into first 4 words
 then loop creating words that depend on
  values in previous & 4 places back
  
      in 3 of 4 cases just XOR these together
  
      1st word in 4 has rotate + S-box + XOR round
      constant on previous, before XOR 4th back
AES Key Expansion
      Key Expansion Rationale
 designed to resist known attacks
 design criteria included
  
      knowing part key insufficient to find many more
  
      invertible transformation
  
      fast on wide range of CPU’s
  
      use round constants to break symmetry
  
      diffuse key bits into round keys
  
      enough non-linearity to hinder analysis
  
      simplicity of description
   AES
 Example
   Key
Expansion
   AES
 Example
Encryption
   AES
 Example
Avalanche
             AES Decryption
 AES decryption is not identical to
  encryption since steps done in reverse
 but can define an equivalent inverse
  cipher with steps as for encryption
  
      but using inverses of each step
  
      with a different key schedule
 works since result is unchanged when
  
      swap byte substitution & shift rows
  
      swap mix columns & add (tweaked) round key
AES Decryption
      Implementation Aspects
 can efficiently implement on 8-bit CPU
  
      byte substitution works on bytes using a table
      of 256 entries
  
      shift rows is simple byte shift
  
      add round key works on byte XOR’s
  
      mix columns requires matrix multiply in GF(28)
      which works on byte values, can be simplified
      to use table lookups & byte XOR’s
      Implementation Aspects
 can efficiently implement on 32-bit CPU
  
      redefine steps to use 32-bit words
  
      can precompute 4 tables of 256-words
  
      then each column in each round can be
      computed using 4 table lookups + 4 XORs
  
      at a cost of 4Kb to store tables
 designers believe this very efficient
  implementation was a key factor in its
  selection as the AES cipher
General Security
Rijndael has no known security attacks. Rijndael uses S-boxes as nonlinear
components. Rijndael appears to have an adequate security margin, but
has received some criticism suggesting that its mathematical structure may
lead to attacks. On the other hand, the simple structure may have facilitated
its security analysis during the timeframe of the AES development process.
Software Implementations
Rijndael performs encryption and decryption very well across a variety of
platforms,
including 8-bit and 64-bit platforms, and DSPs. However, there is a
decrease in performance with the higher key sizes because of the increased
number of rounds that are performed. Rijndael’s high inherent parallelism
facilitates the efficient use of processor resources, resulting in very good
software performance even when implemented in a mode not capable of
interleaving. Rijndael’s key setup time is fast.
Restricted-Space Environments
In general, Rijndael is very well suited for restricted-space environments
where either
encryption or decryption is implemented (but not both). It has very low RAM
and ROM requirements. A drawback is that ROM requirements will increase
if both encryption and decryption are implemented simultaneously, although
it appears to remain suitable for these environments. The key schedule for
decryption is separate from encryption.
Hardware Implementations
Rijndael has the highest throughput of any of the finalists for feedback
modes and second highest for non-feedback modes. For the 192 and 256-
bit key sizes, throughput falls in standard and unrolled implementations
because of the additional number of rounds. For fully pipelined
implementations, the area requirement increases, but the throughput is
unaffected.
Attacks on Implementations
The operations used by Rijndael are among the easiest to defend against
power and timing attacks. The use of masking techniques to provide
Rijndael with some defense against these attacks does not cause significant
performance degradation relative to the other finalists, and its RAM
requirement remains reasonable. Rijndael appears to gain a major speed
advantage over its competitors when such protections are considered.
En-1
  Head n   T
                   Pn      T
    En-1          Head n
 Advantages and Limitations of
            CBC
A   ciphertext block depends on all blocks
  before it
 Any change to a block affects all following
  ciphertext blocks...   avalanche effect
 need Initialization Vector (IV)
  
      which must be known to sender & receiver
  
      if sent in clear, attacker can change bits of first block, by
      changing corresponding bits of IV
  
      hence IV must either be a fixed value (as in EFTPOS)
  
      or derived in way hard to manipulate
  
      or sent encrypted in ECB mode before rest of message
  
      or message integrity must be checked otherwise
  Stream Modes of Operation
 Block modes encrypt entire block
 May need to operate on smaller units
  
      real time data
 Convert block cipher into   stream cipher
  
      cipher feedback (CFB) mode
  
      output feedback (OFB) mode
  
      counter (CTR) mode
 Use block cipher as some form of
 pseudo-random number generator...
                        Vernam cipher
           Cipher FeedBack (CFB)
 Message is treated as a stream of bits
 Added to the output of the block cipher
 Result is feed back for next stage (hence
  name)
 Standard allows any number of bits (1,8, 64 or
  128 etc) to be feed back
    
        denoted CFB-1, CFB-8, CFB-64, CFB-128, etc.
 Most efficient to use all bits in block (64 or 128)
    Ci = Pi XOR EK(Ci-1)
    C-1 = IV
   s-bit
  Cipher
FeedBack
 (CFB-s)
 Advantages and Limitations of
             CFB
 Most common stream mode
 Appropriate   when data arrives in bits/bytes
 Limitation is need to stall while do block
  encryption after every s-bits
 Note that the block cipher is used in
  encryption mode at both ends (XOR)
 Errors propagate for several blocks after
  the error ... how many?
     Output FeedBack (OFB)
 Message is treated as a stream of bits
 Output of cipher is added to message
 Output is then feed back (hence name)
  Oi = EK(Oi-1)
  Ci = Pi XOR Oi
  O-1 = IV
 Feedback is independent of message
 Can be computed in advance
 uses: stream encryption on noisy channels
   Why noisy channels?
 Output
FeedBack
  (OFB)
    Advantages and Limitations of
                OFB
 Needs an IV which is unique for each use
  
     if ever reuse attacker can recover outputs...
  
     OTP
 Can pre-compute
 Bit errors do not propagate
 More vulnerable to message stream modification...
    
        change arbitrary bits by changing ciphertext
 Sender & receiver must remain in sync
 Only use with full block feedback
    
        subsequent research has shown that only full block feedback
        (ie CFB-64 or CFB-128) should ever be used
               Counter (CTR)
 A “new” mode, though proposed early on
 Similar to OFB but encrypts counter value rather
 than any feedback value
  Oi = EK(i)
  Ci = Pi XOR Oi
 Must have a different key & counter value for
 every plaintext block (never reused)
  
      again, OTP issue
 uses: high-speed network encryptions
Counter
 (CTR)
  Advantages and Limitations of
              CTR
 Efficiency
  
      can do parallel encryptions in h/w or s/w
  
      can preprocess in advance of need
  
      good for bursty high speed links
 Random access to encrypted data blocks
 Provable security (good as other modes)
 Never have cycle less than 2 b
 But must ensure never reuse key/counter
 values, otherwise could break (cf OFB)
Feedback
Character-
  istics
              XTS-AES Mode
 New mode, for block oriented storage use
  
      in IEEE Std 1619-2007
 Concept of tweakable block cipher
 Different requirements to transmitted data
 Uses AES twice for each block
  Tj = EK2(i) XOR αj
  Cj = EK1(Pj XOR Tj) XOR Tj
  where i is tweak & j is sector no
 Each sector may have multiple blocks
XTS-AES
  Mode
per block
XTS-AES
 Mode
Overview
 Advantages and Limitations of
          XTS-AES
 Eiciency
  
      can do parallel encryptions in h/w or s/w
  
      random access to encrypted data blocks
 Has both nonce & counter
 Addresses      security concerns related to
 stored data
    Criteria For Comparison
 Can     a random block be encrypted or
  decrypted?
 How much does a error in transmission
  affect the receiver?
 Is parallel encryption/decryption possible?
 Can the keystream be pre computed?
                Summary
 Multiple Encryption & Triple-DES
 Modes of Operation
  
      ECB, CBC, CFB, OFB, CTR, XTS-AES
 Next – Stream ciphers (Ch 7), then hash
 functions (Ch 11)
Cryptography and
Network Security
    Chapter 8
      Fifth Edition
  by William Stallings
      Chapter 8 – Introduction to
           Number Theory
The Devil said to Daniel Webster: "Set me a task I can't carry out, and
   I'll give you anything in the world you ask for."
Daniel Webster: "Fair enough. Prove that for n greater than 2, the
   equation an + bn = cn has no non-trivial solution in the integers."
They agreed on a three-day period for the labor, and the Devil
   disappeared.
At the end of three days, the Devil presented himself, haggard, jumpy,
   biting his lip. Daniel Webster said to him, "Well, how did you do at
   my task? Did you prove the theorem?'
"Eh? No . . . no, I haven't proved it."
"Then I can have whatever I ask for? Money? The Presidency?'
"What? Oh, that—of course. But listen! If we could just prove the
   following two lemmas—"
   —The Mathematical Magpie, Clifton Fadiman
                Prime Numbers
   prime numbers only have divisors of 1 and self
    
        they cannot be written as a product of other numbers
    
        note: 1 is prime, but is generally not of interest
   eg. 2,3,5,7 are prime, 4,6,8,9,10 are not
   prime numbers are central to number theory
   list of prime number less than 200 is:
        2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59
        61 67 71 73 79 83 89 97 101 103 107 109 113 127
        131 137 139 149 151 157 163 167 173 179 181 191
        193 197 199
         Prime Factorisation
 to factor a number n is to write it as a
  product of other numbers: n=a x b x c
 note that factoring a number is relatively
  hard compared to multiplying the factors
  together to generate the number
 the prime factorisation of a number n is
  when its written as a product of primes
  
      eg. 91=7x13 ; 3600=24x32x52
Relatively Prime Numbers & GCD
   two numbers a, b are relatively prime if have
    no common divisors apart from 1
    
        eg. 8 & 15 are relatively prime since factors of 8 are
        1,2,4,8 and of 15 are 1,3,5,15 and 1 is the only
        common factor
   conversely can determine the greatest common
    divisor by comparing their prime factorizations
    and using least powers
    
        eg. 300=21x31x52 18=21x32 hence
        GCD(18,300)=21x31x50=6
          Fermat's Theorem
 ap-1   ≡ 1 (mod p)
  
      where p is prime and gcd(a,p)=1
 also known as Fermat’s Little Theorem
 also have: ap   ≡ a (mod p)
 useful in public key and primality testing
    Euler Totient Function ø(n)
   when doing arithmetic modulo n
   complete set of residues is: 0..n-1
   reduced set of residues is those numbers
    (residues) which are relatively prime to n
    
        eg for n=10,
    
        complete set of residues is {0,1,2,3,4,5,6,7,8,9}
    
        reduced set of residues is {1,3,7,9}
   number of elements in reduced set of residues is
    called the Euler Totient Function ø(n)
 Euler Totient Function ø(n)
 to compute ø(n) need to count number of
  residues to be excluded
 in general need prime factorization, but
  
      for p (p prime)    ø(p)=p-1
  
      for p.q (p,q prime) ø(p.q)=(p-1)x(q-1)
 eg.
  ø(37) = 36
  ø(21) = (3–1)x(7–1) = 2x6 = 12
              Euler's Theorem
   a generalisation of Fermat's Theorem
   aø(n) ≡ 1 (mod n)
    
        for any a,n where gcd(a,n)=1
   eg.
    a=3;n=10; ø(10)=4;
      hence 34 = 81 = 1 mod 10
    a=2;n=11; ø(11)=10;
      hence 210 = 1024 = 1 mod 11
   also have: aø(n)+1 ≡ a (mod n)
                Primality Testing
   often need to find large prime numbers
   traditionally sieve using trial division
    
        ie. divide by all numbers (primes) in turn less than the
        square root of the number
    
        only works for small numbers
   alternatively can use statistical primality tests
    based on properties of primes
    
        for which all primes numbers satisfy property
    
        but some composite numbers, called pseudo-primes,
        also satisfy the property
   can use a slower deterministic primality test
        Miller Rabin Algorithm
   a test based on prime properties that result from
    Fermat’s Theorem
   algorithm is:
    TEST (n) is:
    1. Find integers k, q, k > 0, q odd, so that (n–1)=2kq
    2. Select a random integer a, 1<a<n–1
    3. if aq mod n = 1 then return (“inconclusive");
    4. for j = 0 to k – 1 do
               j
      5. if (a2 q mod n = n-1)
        then return(“inconclusive")
    6. return (“composite")
 Probabilistic Considerations
 ifMiller-Rabin returns “composite” the number
  is definitely not prime
 otherwise is a prime or a pseudo-prime
 chance it detects a pseudo-prime is < 1/4
 hence  if repeat test with different random a
  then chance n is prime after t tests is:
  
       Pr(n prime after t tests) = 1-4-t
  
       eg. for t=10 this probability is > 0.99999
 could  then use the deterministic                 AKS
  (Agrawal–Kayal–Saxena) test
           Prime Distribution
 prime number theorem states that primes
  occur roughly every (ln n) integers
 but can immediately ignore evens
 so in practice need only test 0.5 ln(n)
  numbers of size n to locate a prime
  
      note this is only the “average”
  
      sometimes primes are close together
  
      other times are quite far apart
Chinese Remainder Theorem
 used to speed up modulo computations
 if working modulo a product of numbers
     eg. mod M = m1m2..mk
 Chinese Remainder theorem lets us work
 in each moduli mi separately
 since computational cost is proportional to
 size, this is faster than working in the full
 modulus M
Chinese Remainder Theorem
 can implement CRT in several ways
 to compute A(mod M)
    
        first compute all ai = A mod mi separately
    
        determine constants ci below, where Mi = M/mi
    
        then combine results to get answer using:
       CRT Example – Addition 1/2
Given 973 mod 1813
Now 1813 = 37 x 49
  = ( 11, 42)
            CRT Example – Addition 2/2
We wish to add 678 to 973 i.e. calculate S = ( 678 + 973 ) mod 1813
Let B = 678
= ( 12, 41)
= (23, 34)
   in RSA have:
    
        n=p.q
    
        ø(n)=(p-1)(q-1)
    
        carefully chose e & d to be inverses mod ø(n)
    
        hence e.d=1+k.ø(n) for some k
   hence                                               :
         Cd = Me.d = M1+k.ø(n) = M1.(Mø(n))k
      = M1.(1)k = M1 = M mod n
     RSA Example - Key Setup
1.   Select primes: p=17 & q=11
2.   Calculate n = pq =17 x 11=187
3.   Calculate ø(n)=(p–1)(q-1)=16x10=160
4.   Select e: gcd(e,160)=1; choose e=7
5.   Determine d: de=1 mod 160 and d < 160
     Value is d=23 since 23x7=161= 10x160+1
6.   Publish public key PU={7,187}
7.   Keep secret private key PR={23,187}
RSA Example - En/Decryption
 sample RSA encryption/decryption is:
 given message M   = 88 (nb. 88<187)
 encryption:
  C = 887 mod 187 = 11
 decryption:
  M = 1123 mod 187 = 88
               Exponentiation
   can use the Square and Multiply Algorithm
   a fast, efficient algorithm for exponentiation
   concept is based on repeatedly squaring base
   and multiplying in the ones that are needed to
    compute the result
   look at binary representation of exponent
   only takes O(log2 n) multiples for number n
    
        eg. 75 = 74.71 = 3.7 = 10 mod 11
    
        eg. 3129 = 3128.31 = 5.3 = 4 mod 11
        Exponentiation
c = 0; f = 1
for i = k downto 0
    do c = 2 x c
       f = (f x f)    mod n
    if bi == 1 then
       c = c + 1
       f = (f x a)    mod n
return f
          Efficient Encryption
 encryption uses exponentiation to power e
 hence if e small, this will be faster
  
      often choose e=65537 (216-1)
  
      also see choices of e=3 or e=17
 but if e too small (eg e=3) can attack
  
      using Chinese remainder theorem & 3
      messages with different modulii
 if e fixed must ensure      gcd(e,ø(n))=1
  
      ie reject any p or q not relatively prime to e
          Efficient Decryption
 decryption uses exponentiation to power d
  
      this is likely large, insecure if not
 canuse the Chinese Remainder Theorem
 (CRT) to compute mod p & q separately.
 then combine to get desired answer
  
      approx 4 times faster than doing directly
 onlyowner of private key who knows
 values of p & q can use this technique
         RSA Key Generation
 users of RSA must:
  
      determine two primes at random - p, q
  
      select either e or d and compute the other
 primesp,q must not be easily derived
 from modulus n=p.q
  
      means must be sufficiently large
  
      typically guess and use probabilistic test
 exponents  e, d are inverses, so use
 Inverse algorithm to compute the other
               RSA Security
 possible approaches to attacking RSA are:
  
      brute force key search - infeasible given size
      of numbers
  
      mathematical attacks - based on difficulty of
      computing ø(n), by factoring modulus n
  
      timing attacks - on running of decryption
  
      chosen ciphertext attacks - given properties of
      RSA
               Factoring Problem
   mathematical approach takes 3 forms:
    
        factor n=p.q, hence compute ø(n) and then d
    
        determine ø(n) directly and compute d
    
        find d directly
    
        encrypt M as a pair of integers (C1,C2) where
         • C1 = ak mod q ; C2 = KM mod q
   A then recovers message by
    
        recovering key K as K = C1xA mod q
    
        computing M as M = C2 K-1 mod q
   a unique k must be used each time
    
        otherwise result is insecure
              ElGamal Example
   use field GF(19) q=19 and a=10
   Alice computes her key:
                                          5
    
        A chooses xA=5 & computes yA=10 mod 19 = 3
   Bob send message m=17 as (11,5) by
    
        chosing random k=6
    
        computing K = yAk mod q = 36 mod 19 = 7
    
        computing C1 = ak mod q = 106 mod 19 = 11;
        C2 = KM mod q = 7.17 mod 19 = 5
   Alice recovers original message by computing:
                                     5
    
        recover K = C1
                       xA
                         mod q = 11 mod 19 = 7
    
        compute inverse K-1 = 7-1 = 11
    
        recover M = C2 K-1 mod q = 5.11 mod 19 = 17
 Elliptic Curve Cryptography
 majority of public-key crypto (RSA, D-H)
  use either integer or polynomial arithmetic
  with very large numbers/polynomials
 imposes a significant load in storing and
  processing keys and messages
 an alternative is to use elliptic curves
 offers same security with smaller bit sizes
 newer, but not as well analysed
         Real Elliptic Curves
 an elliptic curve is defined by an equation
  in two variables x & y, with coefficients
 consider a cubic elliptic curve of form
  
      y2 = x3 + ax + b
  
      where x,y,a,b are all real numbers
  
      also define zero point O
 consider set of points E(a,b) that satisfy
 have addition operation for elliptic curve
  
      geometrically sum of P+Q is reflection of the
      intersection R
Real Elliptic Curve Example
            Finite Elliptic Curves
 Elliptic curve cryptography uses curves
  whose variables & coefficients are finite
 have two families commonly used:
     prime curves Ep(a,b) defined over Zp
       •   use integers modulo a prime
       •   best in software
       •   y2 = (x3 + ax + b) mod p
     binary curves E2m(a,b) defined over GF(2n)
       • use polynomials with binary coefficients
       • best in hardware
 Elliptic Curve Cryptography
 ECC addition is analog of modulo multiply
 ECC repeated addition is analog of modulo
  exponentiation
 need “hard” problem equiv to discrete log
  
      Q=kP, where Q,P belong to a prime curve
  
      is “easy” to compute Q given k,P
  
      but “hard” to find k given Q,P
  
      known as the elliptic curve logarithm problem
 Example: E      (1,1)
                23
Point of E23(1,1)
           ECC Diffie-Hellman
 can do key exchange analogous to D-H
 users select a suitable curve       Eq(a,b)
 select base point     G=(x1,y1)
  
      with large order n s.t. nG=O
 A & B select private keys
                          nA<n, nB<n
 compute public keys: P =n G, P =n G
                        A  A    B   B
 compute shared key: K=n P , K=n P
                          A B     B A
  
      same since K=nAnBG
 attacker would need to find        k, hard
    ECC Encryption/Decryption
   several alternatives, will consider simplest
   must first encode any message M as a point on the
    elliptic curve Pm
   select suitable curve & point G as in D-H
   each user chooses private key nA<n, nB<n
   and computes public key PA=nAG, PB=nBG
   When A send data to B
   to encrypt Pm : Cm={kG, Pm+kPB}, k random
   decrypt Cm compute:
    Pm+kPb–nB(kG) = Pm+k(nBG)–nB(kG) = Pm
             ECC Security
 relies on elliptic curve logarithm problem
 fastest method is “Pollard rho method”
 compared to factoring, can use much
  smaller key sizes than with RSA etc
 for equivalent key lengths computations
  are roughly equivalent
 hence for similar security ECC offers
  significant computational advantages
   Comparable Key Sizes for
     Equivalent Security
  Symmetric           ECC-based          RSA/DSA
    scheme              scheme         (modulus size in
(key size in bits) (size of n in bits)     bits)
       56                112                512
       80                160               1024
      112                224               2048
      128                256               3072
      192                384               7680
      256                512               15360
                 Summary
 have considered:
  
      Diffie-Hellman key exchange
  
      ElGamal cryptography
  
      Elliptic Curve cryptography
Cryptography and
Network Security
   Chapter 11
      Fifth Edition
  by William Stallings
 Chapter 11 – Cryptographic
      Hash Functions
Each of the messages, like each one he had ever
  read of Stern's commands, began with a number
  and ended with a number or row of numbers. No
  efforts on the part of Mungo or any of his experts
  had been able to break Stern's code, nor was
  there any clue as to what the preliminary number
  and those ultimate numbers signified.
  —Talking to Strange Men, Ruth Rendell
              Hash Functions
 condenses arbitrary message to fixed size
  h = H(M)
 usually assume hash function is public
 hash used to detect changes to message
 want a cryptographic hash function
  
      computationally infeasible to find data mapping
      to specific hash (one-way property)
  
      computationally infeasible to find two data to
      same hash (collision-free property)
Cryptographic Hash Function
          Hash Function Uses
 Message Integrity     Check (MIC)
  
      send hash of message (digest)
  
      MIC always encrypted, message optionally
 Message Authentication Code (MAC)
  
      send keyed hash of message
  
      MAC, message optionally encrypted
 Digital Signature (non-repudiation)
  
      Encrypt hash with private (signing) key
  
      Verify with public (verification) key
       Hash Functions & Message
            Authentication
ymmetric Key
nkeyed Hash
) Message
  encrypted
) Message
 unencrypted
       Hash Functions & Message
            Authentication
ymmetric Key
Keyed Hash
  Message
 unencrypted
) Message
  encrypted
Hash Functions & Digital
      Signatures
    Other Hash Function Uses
 pseudorandom function (PRF)
    
        Generate session keys, nonces
    
        Produce key from password
    
        Derive keys from master key cooperatively
    pseudorandom number generator
    (PRNG)
    
        Vernam Cipher/OTP
    
        S/Key, proof of “what you have” via messages
   More Hash Function Uses
 to create a one-way password file
  
      store hash of password not actual password
  
      e.g., Unix, Windows NT, etc.
  
      salt to deter precomputation attacks
  
      Rainbow tables
 for intrusion detection and virus detection
  
      keep & check hash of files on system
  
      e.g., Tripwire
Lamport One-time Passwords
 Password safety in distributed system
  
      server compromise does not compromise P
  
      interception of authentication exchange does
      not compromise password either
 Alice picks Password PA
                              A
     Hashes password N times, HN(PA)
     Server stores (Alice, N, HN(PA))
     Attacker can’t get PA from HN(PA)
Lamport One-time Passwords
 Protocol
  
      Alice sends “I’m Alice”
  
      Server sends “N-1”
     Alice sends “X” where X=HN-1(PA)
     Server verifies H(X) = HN(PA)
  
      Server updates to (Alice, N-1, X)
 Attacker still can’t get PA or authenticate as
  Alice
      Two Simple Insecure Hash
             Functions
 consider two simple insecure hash functions
 bit-by-bit exclusive-OR (XOR) of every block
     Ci = bi1 xor bi2 xor . . . xor bim
  
      a longitudinal redundancy check
  
      reasonably effective as data integrity check
 one-bit circular shift on hash value
  
      for each successive n-bit block
       • rotate current hash value to left by1bit and XOR block
  
      good for data integrity but useless for security
    What If We Hash and Encrypt
 Hash   h = XN+1 = X1 xor X2 xor ... xor XN
 Encrypt the message along with hash
 Y1, Y2, … , YN+1 where
 Y1   = IV xor E(K, X1)]
 Y2   = Y1 xor E(K, X2)] ….
 YN+1 = YN xor E(K, XN+1)] = Encrypted h
 XN+1 = X1 xor X2 xor ... xor XN
      = [ IV xor D(K, Y1)] xor [Y1 xor D(K, Y2)]
         xor … xor [YN-1 xor D(K, YN)]
Hash Function Requirements
  Hash Function Resistance
    Properties Required
  
      If an m-bit MAC is used, then there are 2m
      possible MACs.
  
      N possible messages with N >> 2m
  
      With a k-bit key, there are 2k possible keys.
              Security of MACs
 Like block ciphers have:
 Brute-force attacks exploiting
                                                          m/
  
      Strong collision resistance hash have cost 2          2
   Hash’=H(Hash,ML+1)
 Unless formatting prevents it…
  … but still best to use HMAC!
    HMAC Design Objectives
 Use, without modifications, hash functions
 Allow  for easy replaceability of embedded
  hash function
 Preserve original performance of hash
  function without significant degradation
 Use and handle keys in a simple way.
 Have well understood cryptographic analysis
  of authentication mechanism strength
                        HMAC
   Specified as Internet standard RFC2104
   Uses hash function on the message:
    HMACK(M)= Hash[(K+ XOR opad) ||
      Hash[(K+ XOR ipad) || M)] ]
    
      where K+ is the key padded out to block size
    
      opad, ipad are specified padding constants
   Overhead is just 3 more hash block calculations
    than the message needs alone
   Any hash function can be used
    
        eg. MD5, SHA-1, RIPEMD-160, Whirlpool
 HMAC
Overview
             HMAC Security
 Proved  security of HMAC relates to that of
  the underlying hash algorithm
 Attacking HMAC requires either:
  
      brute force attack on key used
  
      birthday attack (but since keyed would need
      to observe a very large number of messages)
 Choose hash function used based on
 speed verses security constraints
                  Summary
 Have considered:
  
      Message authentication requirements
  
      Message authentication using encryption
  
      MACs
  
      HMAC authentication using a hash function
Cryptography and
Network Security
   Chapter 13
      Fifth Edition
  by William Stallings
 Chapter 13 – Digital Signatures
1. A->B: IDA || Na
2. B -> KDC: IDB||Nb|| E(Kb,[IDA||Na|| Tb])
3. KDC -> A: E(Ka, [IDB||Na||Ks||Tb]) ||
                     E(Kb, [IDA||Ks||Tb])||Nb
4. A -> B: E(Kb, [IDA||Ks||Tb]) || E(Ks, Nb)
    One-Way Authentication
 Use refinement of KDC to secure email
  since B no online, drop steps 4 & 5
 Protocol becomes:
  1. A->KDC: IDA || IDB || N1
  2. KDC -> A: E(Ka, [Ks||IDB||N1 || E(Kb,[Ks||IDA])])
  3. A -> B: E(Kb, [Ks||IDA]) || E(Ks, M)
 Provides encryption & some authentication
 Does not protect from replay attack
                 Kerberos
 Trusted key server system from MIT
 Provides centralised private-key third-party
  authentication in a distributed network
  allows users access to services distributed
   through network
  without needing to trust all workstations
  rather all trust a central authentication server
 Two versions in use: 4 & 5
                Threats
 A user may gain access to a particular
  workstation and pretend to be another user
  operating from that workstation.
 A user may alter the network address of a
  workstation so that the requests sent from
  the altered workstation appear to come
  from the impersonated workstation.
 A user may eavesdrop on exchanges and
  use a replay attack to gain entrance to a
  server or to disrupt operations.
     Kerberos Requirements
 Its first report identified requirements as:
  Secure - eavesdropping/impersanation.
  Reliable – availability/distributed architecture.
  Transparent – one time password.
  Scalable – large number of servers and
   clients.
 Implemented using an authentication
  protocol based on Needham-Schroeder
                Sample Dialogue 1
1. C -> AS : IDC || PC || IDV
2. AS -> C : Ticket
3. C -> V : IDC || Ticket
Ticket = E(Kv, [IDC || ADC || IDV])
where
C = client
                              Issues:
AS = authentication server
                              Password sent in plaintext.
V = server
                              Password needs to be entered each
IDV = server identifier
                              time for new session or different
IDC = identifier of user on C
                              service.
PC = client password
ADC = network address of C
KV = secret encryption key shared between AS and V
                    Sample Dialogue 2
Once per user logon session:
                              te
                  certifica                    Phase 2
                                        e
                      k  e y _ e xchang         Server may send certificate, key exchange
           server_                             and request certificate.
                                     est
                 rt if ic a te_requ
              ce
                                     ne
                r v  e  r_ h ello_do
             se
Time
                   certific
                            a   te             Phase 3
           client_k                            Client sends certificate if requested. Client
                   e   y_exch
                              a       n ge     sends key exchange.
              certific
                      a   te_verif
                                  y
             change
                   _      cipher_
                                      specs    Phase 4
                     finished                  Change cipher suit and finish handshake
                                               protocol.
                         r_          specs
                 _ciphe
           change
                          d
                  finishe
                client_h
  Client                 e    llo           Server
                                               Phase 1
                        hello                  Protocol version, session ID, cipher
                server_                        suit,compression method, initial random
                                               numbers.
                            te
                certifica
                                               Phase 2
                                               certificate_request message is optional.
                                               Required only if client is to be authenticated
                                    est
                r t if ic a te_requ            using a certificate.
             ce
                                     ne
                rv   e  r_ h ello_do
             se
Time
                 certific                      Phase 3
                          a   te
           client_k                            certificate message is optional. Required
                   e   y_exch                  only if certificate_request message was sent
                              a     n ge
                                               earlier by server.
             certific
                     a   te_verif              client_key_exchange message will contain
                                 y
                                               48 byte pre-master-secret encrypted using
                                               public key of server (taken from server
                                               certificate).
            change
                  _      cipher_
                                    specs      Phase 4
                   finished                    Change cipher suit and finish handshake
                                               protocol.
                              te                 Phase 2
                  certifica                      Server certificate can only be used for
                                        e
                      k  e y _ e xchang          signature verification.
           server_                               Server creates         temporary RSA public-
                                     est
                 rt if ic a te_requ              private    key pair for the purpose of
              ce                                 encryption/decryption       and     signs    this
                                     ne
                r v  e  r_ h ello_do             temporary public key using his private key
             se                                  and     sends       it    to    client    inside
Time                                             server_key_exchange message.
                   certific
                            a   te               Phase 3
           client_k                              client_key_exchange message will contain
                   e   y_exch
                              a       n ge       48 byte pre-master-secret encrypted using
              certific                           temporary RSA public key sent by server.
                      a   te_verif
                                  y              Temporary RSA public key is verified by
                                                 using RSA key contained in Server certificate
                                                 message.
             change
                   _      cipher_
                                      specs      Phase 4
                     finished                    Change cipher suit and finish handshake
                                                 protocol.
                            te
                certifica                     Phase 2
                                              Server     certificate message    contains
                                              certificate containing  servers DH public
                                              parameters (a, p, Y).
                     hello_       done
             server_
Time
                certific
                         a   te               Phase 3
                                              Client certificate message contains certificate
                                              containing clients DH public parameters.
            change
                  _   cipher_
                                   specs      Phase 4
                  finished                    Change cipher suit and finish handshake
                                              protocol.
                              te
                  certifica                      Phase 2
                                        e
                      k  e y _ e xchang          Server certificate can only be used for
           server_                               signature verification.
                                     est         Server creates temporary DH public-private
                 rt if ic a te_requ
              ce                                 key pair signs this temporary public key
                                     ne
                r v  e  r_ h ello_do             using his private key and sends all public
             se                                  parameters (a, p, Y) to client inside
Time                                             server_key_exchange message.
                   certific                      Phase 3
                            a   te
                                                 Clients creates temporary DH public-private
           client_k
                   e   y_exch                    key pair and sends public key to server
                              a       n ge
                                                 inside client_key_exchange message.
              certific
                      a   te_verif
                                  y
                                                 Shared temparory DH public parameters are
                                                 used to compute pre-master-secret.
             change
                   _      cipher_
                                      specs      Phase 4
                     finished                    Change cipher suit and finish handshake
                                                 protocol.
                                              Phase 2
                                   e
                   ke y _ e xchang            Server creates temporary DH public-private
           server_                            key pair and sends all public parameters (a,
                                              p, Y) to client inside server_key_exchange
                                              message. (not encrypted, not signed)
                      hello_   done
              server_
Time
                                              Phase 3
           client_k                           Client creates temporary DH public-private
                   e   y_exch                 key pair and sends public key to server
                              a    n ge
                                              inside client_key_exchange message. (not
                                              encrypted, not signed).
  802.11i
Discovery and
Authentication
   Phases        Authentication
IEEE 802.1X Access Control
        Approach
        Extensible Authentication
                Protocol
   EAP is an authentication framework frequently
    used in network and internet connections.
    •   EAP-TLS
    •   EAP-TTLS/MSCHAPv2
    •   PEAPv0/EAP-MSCHAPv2
    •   PEAPv1/EAP-GTC
    •   PEAP-TLS
    •   EAP-SIM
    •   EAP-AKA
    •   EAP-FAST
          Pairwise Master Key
   In PSK authentication, the PMK is actually the
    PSK.
   If an 802.1X EAP exchange was carried out, the
    PMK is derived from the EAP parameters
    provided by the authentication server.
   The four-way handshake is performed so that
    the access point (or authenticator) and wireless
    client (or supplicant) can independently prove to
    each other that they know the PSK/PMK, without
    ever disclosing the key
       Pairwise Transient Key
 The PMK is designed to last the entire session and
  should be exposed as little as possible; therefore,
  keys to encrypt the traffic need to be derived.
 A four-way handshake is used to establish another
  key called the Pairwise Transient Key (PTK).
 The PTK is generated by concatenating the
  following attributes: PMK, AP nonce (ANonce), STA
  nonce (SNonce), AP MAC address, and STA MAC
  address.
   The handshake also yields the GTK (Group
    Temporal Key), used to decrypt multicast and
    broadcast traffic
             Four Way Handshake
802.11i
   Key
Management
  Phase
   The Pairwise Transient Key (64 bytes) is divided
    into five separate keys:
    1.   16 bytes of EAPOL-Key Confirmation Key (KCK) –
         Used to compute MIC on WPA EAPOL Key message
    2.   16 bytes of EAPOL-Key Encryption Key (KEK) – AP
         uses this key to encrypt additional data sent to the
         client (for example, the GTK)
    3.   16 bytes of Temporal Key (TK) – Used to
         encrypt/decrypt Unicast data packets
    4.   8 bytes of Michael MIC Authenticator Tx Key – Used
         to compute MIC on unicast data packets transmitted
         by the AP
    5.   8 bytes of Michael MIC Authenticator Rx Key – Used
         to compute MIC on unicast data packets transmitted
         by the station
   The Group Temporal Key (32 bytes) is divided
    into three separate keys:
    1.   16 bytes of Group Temporal Encryption Key – used to
         encrypt/decrypt Multicast and Broadcast data packets
    2.   8 bytes of Michael MIC Authenticator Tx Key – used
         to compute MIC on Multicast and Broadcast packets
         transmitted by AP
    3.   8 bytes of Michael MIC Authenticator Rx Key –
         currently unused as stations do not send multicast
         traffic
The Michael MIC Authenticator Tx/Rx Keys in both the
  PTK and GTK are only used if the network is using
  TKIP to encrypt the data.
Four-way handshake has been shown to be vulnerable
  to KRACK attack in 2017.
802.11i
  Key
Manage-
 ment
 Phase
            WPA/WPA2 Attack
Offline Dictionary Attack Overview: