SlideShare ist ein Scribd-Unternehmen logo
1 von 21
CHAPTER 15
 MACs and Signatures

Slides adapted from "Foundations of Security: What Every Programmer
Needs To Know" by Neil Daswani, Christoph Kern, and Anita Kesavan
(ISBN 1590597842; http://www.foundationsofsecurity.com). Except as
otherwise noted, the content of this presentation is licensed under the
Creative Commons 3.0 License.
Agenda
   Secure Hash Functions

   Message Authentication Codes (MACs)
     Blockcipher based (CBC-MAC)
     Hash-function based (HMAC)
     Require sender & receiver to share key


   Digital signatures – allows anyone (w/o shared
    key) to verify sender of message
15.1. Secure Hash Functions
   Given arbitrary-length input, M, produce fixed-
    length output (message digest), H(M), such that:

               M           H        MD=H(M)



   Efficiency: Easy to compute H
   One-Way/Pre-Image resistance: Given H(M),
    hard to compute M (pre-image)
   Collision resistance: Hard to find M1 ≠ M2 such
    that H(M1) = H(M2)
15.1. Secure Hash Functions
Examples
   Non-Examples:
     AddASCII values (collisions): H('AB') = H('BA')
     Checksums CRC32 not one-way or collision-resistant


   MD5: “Message Digest 5” invented by Rivest
     Input:
           multiple of 512-bits (padded)
     Output: 128-bits

   SHA1: developed by NIST & NSA
     Input:
           same as MD5, 512 bits
     Output: 160-bits
15.2. MACs
   Used to determine sender of message

   If Alice and Bob share key k, then Alice sends
    message M with MAC tag t = MAC(M,k)

   Then Bob receives M’ and t’ and can check if
    the message or signature has been tampered by
    verifying t’ = MAC(M’, k)
15.2.1. CBC MACs
   Encrypt message with block cipher in CBC mode
   IV = 0, last encrypted block can serve as tag
   Insecure for variable-length messages
        0   M1          M2                 Mn


             +          +                  +

                                …
    k       AES   k    AES          k     AES




                                           tag
15.2.2. HMAC
   Secure hash function to compute MAC
   Hash function takes message as input while
    MAC takes message and key
   Simply prepending key onto message is not
    secure enough (e.g. given MAC of M, attacker
    can compute MAC of M||N for desired N)

   Def: HMAC(M , k ) = H ((K ⊕ opad) || H ((K ⊕ ipad) || M ))
     Where  K is key k padded with zeros
     opad, ipad are hexadecimal constants
15.3. Signatures (1)
   Two major operations: P, principal
     Sign(M, k) – M is message
     Verify(M, sig, P) – sig is signature to be verified
   Signature: sequence of bits produced by Sign()
    such that Verify(M, sig, P) , (sig == Sign(M, k))
     Non-repudiable  evidence that P signed M
     Many applications: SSL, to sign binary code,
      authenticate source of e-mail

   Use asymmetric encryption ops F & F-1
15.3. Signatures (2)
   S() & V() : implement sign & verify functions

   Signature is s = S(M, ks) =F-1(h(M), ks)
     Decrypt hash with secret key
     Only signer (principal with secret key) can sign


   Verify s: V(M, s, kp) = (F(s,kp) == h(M))
     Encrypting with public key
     Allows anyone to verify a signature
     Need to bind principal’s identity to their public key
15.3.1. Certificates & CAs (1)
   Principal needs certificate from CA (i.e. its digital
    signature) to bind his identity to his public key
   CA must first sign own certificate attesting to
    own identity (“root”)
   Certificate, C(P), stored as text: name of
    principal P, public key (kp(P)), expiration date
   C(P) = (Ctext(P), Csig(P))
   Root Certificate, C(CA), looks like
     Ctext(CA)= ("CA", kp(CA), exp)
     Csig(CA) = S(Ctext(CA), ks(CA))
15.3.1. Certificates & CAs (2)
   Alice constructs certificate text:
     Ctext(Alice)=("Alice",
                        kp(Alice), exp)
     Authenticates herself to CA (through “out-of-band”
      mechanism such as driver’s license)

   CA signs Alice’s certificate:
    Csig(Alice)=S(Ctext(Alice),ks(CA))

   Alice has public key certificate
     C(Alice)=(Ctext(Alice),Csig(Alice))
     Can   use to prove that kp(Alice) is her public key
15.3.2. Signing and Verifying
   Signing: sig = Sign(M, ks(P)) = (S(M, ks(P)),C(P))
     Compute S() with secret key: sig.S
     Append certificate: sig.C


   Verifying: Verify(M, sig, P) =
     V(M,    sig.S, kp(P)) &       signature verifies message?
     V(sig.Ctext(P), sig.Csig(P), kp(CA)) &           signed by CA?
     (Ctext(P).name == P) &                 name matches on cert?
     (today < sig.Ctext(P).date)
                                             certificate not expired?
15.3.3. Registration Authorities
   Authenticating every principal can burden CA
   Can authorize RA to authenticate on CA’s behalf
     CA  signs certificate binding RA’s identity to public key
     Signature now includes RA’s certificate too
     Possibly many intermediaries in the verification
      process starting from “root” CA certificate
     More links in chain, more weak points: careful when
      verifying signatures
   Ex: IE would not verify intermediate certificates
    and trust arbitrary domains (anyone could sign)
15.3.4. Web of Trust
   Pretty Good Privacy (PGP): digital signatures
    can be used to sign e-mail
   “Web of trust” model: users sign own certificates
    and other’s certificates to establish trust
   Two unknown people can find a certificate chain
    to a common person trusted by both


                                           Source:
                                           http://xkcd.com/364/
15.4. Attacks Against
Hash Functions
   Researchers have been able to obtain collisions
    for some hash functions
     Collision
              against SHA-1: 263 computations (NIST
      recommends phase out by 2010 to e.g. SHA-256)
     MD5 seriously compromised: phase out now!


   Collision attacks can’t fake arbitrary digital
    signatures (requires finding pre-images)

   However could get 2 documents with same hash
    and sign one and claim other was signed
15.5. SSL
   Handshake: steps client & server perform
    before exchanging sensitive app-level data

   Goal of handshake: client & server agree on
    master secret used for symmetric crypto

   Two round trips:
       1st trip is “hello” messages: what versions of SSL and
        which cryptographic algorithms supported
       2nd varies based on client or mutual authentication
15.5.1. Server-Authenticated
Only (1)
   Client creates random pre-master secret,
    encrypts with server’s public key
   Server decrypts with own private key
   Both compute hashes including random bytes
    exchanged in “hello” to create master secret

   With master secret, symmetric session key and
    integrity key derived (as specified by SSL)
   App Data encrypted with symmetric key
15.5.1. Server-Authenticated
Only (2)
Client                                                   Server
                           ClientHello

            ServerHello, Certificate, ServerHelloDone


         ClientKeyExchange, ChangeCipherSpec, Finished

                  ChangeCipherSpec, Finished



                        Application Data
15.5.2. Mutual Authentication (1)
   Client also sends own certificate to server
   Sends CertificateVerify message to allow server
    to authenticate client’s public key
   Pre-master secret set, compute master secret
   Derive symmetric key & exchange data

   SSL mechanisms prevent many attacks (e.g.
    man-in-the-middle) and has performance
    optimizations (e.g. caching security params)
15.5.2. Mutual Authentication (2)
 Client                                                          Server
                               ClientHello

      ServerHello, Certificate, CertificateRequest, ServerHelloDone


           Certificate, ClientKeyExchange, CertificateVerify,
                      ChangeCipherSpec, Finished

                     ChangeCipherSpec, Finished


                            Application Data
Summary
   MACs - protect integrity of messages
     Compute tag to detect tampering
     Ex: CBC-MAC, HMAC (relies on secure hashes)
   Signatures – binds messages to senders
     Allows anyone to verify sender
     Prevents forged signatures
     Use CAs to bind identities to public keys
     Or use Web of Trust model
   Application: SSL (“Putting it all together”)
     Relies
           on Cryptography: symmetric & public-key
     And MACs & signatures

Weitere ähnliche Inhalte

Was ist angesagt?

Message authentication
Message authenticationMessage authentication
Message authenticationCAS
 
Introduction to SSL/TLS
Introduction to SSL/TLSIntroduction to SSL/TLS
Introduction to SSL/TLSkeithrozario
 
SSL/TLS Introduction with Practical Examples Including Wireshark Captures
SSL/TLS Introduction with Practical Examples Including Wireshark CapturesSSL/TLS Introduction with Practical Examples Including Wireshark Captures
SSL/TLS Introduction with Practical Examples Including Wireshark CapturesJaroslavChmurny
 
Message integrity protocol
Message integrity protocolMessage integrity protocol
Message integrity protocolPriyaKarnan3
 
El Passo - Privacy-preserving single sign on
El Passo - Privacy-preserving single sign onEl Passo - Privacy-preserving single sign on
El Passo - Privacy-preserving single sign onFrank Denis
 
Secure Socket Layer (SSL)
Secure Socket Layer (SSL)Secure Socket Layer (SSL)
Secure Socket Layer (SSL)amanchaurasia
 
[CONFidence 2016] Marco Ortisi - Recover a RSA private key from a TLS session...
[CONFidence 2016] Marco Ortisi - Recover a RSA private key from a TLS session...[CONFidence 2016] Marco Ortisi - Recover a RSA private key from a TLS session...
[CONFidence 2016] Marco Ortisi - Recover a RSA private key from a TLS session...PROIDEA
 
Public Key Cryptography
Public Key CryptographyPublic Key Cryptography
Public Key Cryptographyanusachu .
 
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...Fermin Galan
 
HMAC authentication
HMAC authenticationHMAC authentication
HMAC authenticationSiu Tin
 
Key exchange in crypto
Key exchange in cryptoKey exchange in crypto
Key exchange in cryptoHarry Potter
 

Was ist angesagt? (16)

Message authentication
Message authenticationMessage authentication
Message authentication
 
Message Authentication
Message AuthenticationMessage Authentication
Message Authentication
 
Authentication: keys, MAC
Authentication: keys, MACAuthentication: keys, MAC
Authentication: keys, MAC
 
Kerberos
KerberosKerberos
Kerberos
 
Introduction to SSL/TLS
Introduction to SSL/TLSIntroduction to SSL/TLS
Introduction to SSL/TLS
 
SSL/TLS Introduction with Practical Examples Including Wireshark Captures
SSL/TLS Introduction with Practical Examples Including Wireshark CapturesSSL/TLS Introduction with Practical Examples Including Wireshark Captures
SSL/TLS Introduction with Practical Examples Including Wireshark Captures
 
Lecture 2 Message Authentication
Lecture 2   Message AuthenticationLecture 2   Message Authentication
Lecture 2 Message Authentication
 
Message integrity protocol
Message integrity protocolMessage integrity protocol
Message integrity protocol
 
El Passo - Privacy-preserving single sign on
El Passo - Privacy-preserving single sign onEl Passo - Privacy-preserving single sign on
El Passo - Privacy-preserving single sign on
 
Secure Socket Layer (SSL)
Secure Socket Layer (SSL)Secure Socket Layer (SSL)
Secure Socket Layer (SSL)
 
[CONFidence 2016] Marco Ortisi - Recover a RSA private key from a TLS session...
[CONFidence 2016] Marco Ortisi - Recover a RSA private key from a TLS session...[CONFidence 2016] Marco Ortisi - Recover a RSA private key from a TLS session...
[CONFidence 2016] Marco Ortisi - Recover a RSA private key from a TLS session...
 
Message Authentication: MAC, Hashes
Message Authentication: MAC, HashesMessage Authentication: MAC, Hashes
Message Authentication: MAC, Hashes
 
Public Key Cryptography
Public Key CryptographyPublic Key Cryptography
Public Key Cryptography
 
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
 
HMAC authentication
HMAC authenticationHMAC authentication
HMAC authentication
 
Key exchange in crypto
Key exchange in cryptoKey exchange in crypto
Key exchange in crypto
 

Ähnlich wie 15 ma cs and signatures

Secure instant messanger service
Secure instant messanger serviceSecure instant messanger service
Secure instant messanger serviceAditya Gupta
 
Information and data security cryptography and network security
Information and data security cryptography and network securityInformation and data security cryptography and network security
Information and data security cryptography and network securityMazin Alwaaly
 
Message Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdfMessage Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdfsunil sharma
 
Information and data security digital signatures
Information and data security digital signaturesInformation and data security digital signatures
Information and data security digital signaturesMazin Alwaaly
 
Simple Overview of PKI and Digital signature by Tarek_Gaber
Simple Overview of PKI and Digital signature by Tarek_GaberSimple Overview of PKI and Digital signature by Tarek_Gaber
Simple Overview of PKI and Digital signature by Tarek_GaberTarek Gaber
 
Introduction to Secure Sockets Layer
Introduction to Secure Sockets LayerIntroduction to Secure Sockets Layer
Introduction to Secure Sockets LayerNascenia IT
 
How (un)secure is SSL/TLS?
How (un)secure is SSL/TLS?How (un)secure is SSL/TLS?
How (un)secure is SSL/TLS?Microsoft
 
ET4045-2-cryptography-3
ET4045-2-cryptography-3ET4045-2-cryptography-3
ET4045-2-cryptography-3Tutun Juhana
 
Automated Analysis of TLS 1.3
Automated Analysis of TLS 1.3Automated Analysis of TLS 1.3
Automated Analysis of TLS 1.3vpnmentor
 
03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL ...
03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL ...03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL ...
03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL ...ghorilemin
 
this is ppt this is ppt this is ppt this is ppt
this is ppt this is ppt this is ppt this is pptthis is ppt this is ppt this is ppt this is ppt
this is ppt this is ppt this is ppt this is pptghorilemin
 

Ähnlich wie 15 ma cs and signatures (20)

Chapter 15 - Security
Chapter 15 - SecurityChapter 15 - Security
Chapter 15 - Security
 
SSL
SSLSSL
SSL
 
Secure instant messanger service
Secure instant messanger serviceSecure instant messanger service
Secure instant messanger service
 
SSL/TLS Handshake
SSL/TLS HandshakeSSL/TLS Handshake
SSL/TLS Handshake
 
Information and data security cryptography and network security
Information and data security cryptography and network securityInformation and data security cryptography and network security
Information and data security cryptography and network security
 
Lecture17
Lecture17Lecture17
Lecture17
 
Web Security
Web SecurityWeb Security
Web Security
 
Dsa & Digi Cert
Dsa & Digi CertDsa & Digi Cert
Dsa & Digi Cert
 
Message Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdfMessage Authentication and Hash Function.pdf
Message Authentication and Hash Function.pdf
 
Information and data security digital signatures
Information and data security digital signaturesInformation and data security digital signatures
Information and data security digital signatures
 
Simple Overview of PKI and Digital signature by Tarek_Gaber
Simple Overview of PKI and Digital signature by Tarek_GaberSimple Overview of PKI and Digital signature by Tarek_Gaber
Simple Overview of PKI and Digital signature by Tarek_Gaber
 
Introduction to Secure Sockets Layer
Introduction to Secure Sockets LayerIntroduction to Secure Sockets Layer
Introduction to Secure Sockets Layer
 
How (un)secure is SSL/TLS?
How (un)secure is SSL/TLS?How (un)secure is SSL/TLS?
How (un)secure is SSL/TLS?
 
Iss lecture 4
Iss lecture 4Iss lecture 4
Iss lecture 4
 
ET4045-2-cryptography-3
ET4045-2-cryptography-3ET4045-2-cryptography-3
ET4045-2-cryptography-3
 
Automated Analysis of TLS 1.3
Automated Analysis of TLS 1.3Automated Analysis of TLS 1.3
Automated Analysis of TLS 1.3
 
03-SSL (1).ppt
03-SSL (1).ppt03-SSL (1).ppt
03-SSL (1).ppt
 
03-SSL (2).ppt
03-SSL (2).ppt03-SSL (2).ppt
03-SSL (2).ppt
 
03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL ...
03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL ...03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL ...
03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL (1).ppt03-SSL ...
 
this is ppt this is ppt this is ppt this is ppt
this is ppt this is ppt this is ppt this is pptthis is ppt this is ppt this is ppt this is ppt
this is ppt this is ppt this is ppt this is ppt
 

Mehr von drewz lin

Web security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-kearyWeb security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-kearydrewz lin
 
Via forensics appsecusa-nov-2013
Via forensics appsecusa-nov-2013Via forensics appsecusa-nov-2013
Via forensics appsecusa-nov-2013drewz lin
 
Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13drewz lin
 
Owasp2013 johannesullrich
Owasp2013 johannesullrichOwasp2013 johannesullrich
Owasp2013 johannesullrichdrewz lin
 
Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2drewz lin
 
I mas appsecusa-nov13-v2
I mas appsecusa-nov13-v2I mas appsecusa-nov13-v2
I mas appsecusa-nov13-v2drewz lin
 
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfDefeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfdrewz lin
 
Csrf not-all-defenses-are-created-equal
Csrf not-all-defenses-are-created-equalCsrf not-all-defenses-are-created-equal
Csrf not-all-defenses-are-created-equaldrewz lin
 
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21drewz lin
 
Appsec usa roberthansen
Appsec usa roberthansenAppsec usa roberthansen
Appsec usa roberthansendrewz lin
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaoladrewz lin
 
Appsec2013 presentation-dickson final-with_all_final_edits
Appsec2013 presentation-dickson final-with_all_final_editsAppsec2013 presentation-dickson final-with_all_final_edits
Appsec2013 presentation-dickson final-with_all_final_editsdrewz lin
 
Appsec2013 presentation
Appsec2013 presentationAppsec2013 presentation
Appsec2013 presentationdrewz lin
 
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitationsAppsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitationsdrewz lin
 
Appsec2013 assurance tagging-robert martin
Appsec2013 assurance tagging-robert martinAppsec2013 assurance tagging-robert martin
Appsec2013 assurance tagging-robert martindrewz lin
 
Amol scadaowasp
Amol scadaowaspAmol scadaowasp
Amol scadaowaspdrewz lin
 
Agile sdlc-v1.1-owasp-app sec-usa
Agile sdlc-v1.1-owasp-app sec-usaAgile sdlc-v1.1-owasp-app sec-usa
Agile sdlc-v1.1-owasp-app sec-usadrewz lin
 
Vulnex app secusa2013
Vulnex app secusa2013Vulnex app secusa2013
Vulnex app secusa2013drewz lin
 
基于虚拟化技术的分布式软件测试框架
基于虚拟化技术的分布式软件测试框架基于虚拟化技术的分布式软件测试框架
基于虚拟化技术的分布式软件测试框架drewz lin
 
新浪微博稳定性经验谈
新浪微博稳定性经验谈新浪微博稳定性经验谈
新浪微博稳定性经验谈drewz lin
 

Mehr von drewz lin (20)

Web security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-kearyWeb security-–-everything-we-know-is-wrong-eoin-keary
Web security-–-everything-we-know-is-wrong-eoin-keary
 
Via forensics appsecusa-nov-2013
Via forensics appsecusa-nov-2013Via forensics appsecusa-nov-2013
Via forensics appsecusa-nov-2013
 
Phu appsec13
Phu appsec13Phu appsec13
Phu appsec13
 
Owasp2013 johannesullrich
Owasp2013 johannesullrichOwasp2013 johannesullrich
Owasp2013 johannesullrich
 
Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2Owasp advanced mobile-application-code-review-techniques-v0.2
Owasp advanced mobile-application-code-review-techniques-v0.2
 
I mas appsecusa-nov13-v2
I mas appsecusa-nov13-v2I mas appsecusa-nov13-v2
I mas appsecusa-nov13-v2
 
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolfDefeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
 
Csrf not-all-defenses-are-created-equal
Csrf not-all-defenses-are-created-equalCsrf not-all-defenses-are-created-equal
Csrf not-all-defenses-are-created-equal
 
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
Chuck willis-owaspbwa-beyond-1.0-app secusa-2013-11-21
 
Appsec usa roberthansen
Appsec usa roberthansenAppsec usa roberthansen
Appsec usa roberthansen
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaola
 
Appsec2013 presentation-dickson final-with_all_final_edits
Appsec2013 presentation-dickson final-with_all_final_editsAppsec2013 presentation-dickson final-with_all_final_edits
Appsec2013 presentation-dickson final-with_all_final_edits
 
Appsec2013 presentation
Appsec2013 presentationAppsec2013 presentation
Appsec2013 presentation
 
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitationsAppsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
Appsec 2013-krehel-ondrej-forensic-investigations-of-web-exploitations
 
Appsec2013 assurance tagging-robert martin
Appsec2013 assurance tagging-robert martinAppsec2013 assurance tagging-robert martin
Appsec2013 assurance tagging-robert martin
 
Amol scadaowasp
Amol scadaowaspAmol scadaowasp
Amol scadaowasp
 
Agile sdlc-v1.1-owasp-app sec-usa
Agile sdlc-v1.1-owasp-app sec-usaAgile sdlc-v1.1-owasp-app sec-usa
Agile sdlc-v1.1-owasp-app sec-usa
 
Vulnex app secusa2013
Vulnex app secusa2013Vulnex app secusa2013
Vulnex app secusa2013
 
基于虚拟化技术的分布式软件测试框架
基于虚拟化技术的分布式软件测试框架基于虚拟化技术的分布式软件测试框架
基于虚拟化技术的分布式软件测试框架
 
新浪微博稳定性经验谈
新浪微博稳定性经验谈新浪微博稳定性经验谈
新浪微博稳定性经验谈
 

15 ma cs and signatures

  • 1. CHAPTER 15 MACs and Signatures Slides adapted from "Foundations of Security: What Every Programmer Needs To Know" by Neil Daswani, Christoph Kern, and Anita Kesavan (ISBN 1590597842; http://www.foundationsofsecurity.com). Except as otherwise noted, the content of this presentation is licensed under the Creative Commons 3.0 License.
  • 2. Agenda  Secure Hash Functions  Message Authentication Codes (MACs)  Blockcipher based (CBC-MAC)  Hash-function based (HMAC)  Require sender & receiver to share key  Digital signatures – allows anyone (w/o shared key) to verify sender of message
  • 3. 15.1. Secure Hash Functions  Given arbitrary-length input, M, produce fixed- length output (message digest), H(M), such that: M H MD=H(M)  Efficiency: Easy to compute H  One-Way/Pre-Image resistance: Given H(M), hard to compute M (pre-image)  Collision resistance: Hard to find M1 ≠ M2 such that H(M1) = H(M2)
  • 4. 15.1. Secure Hash Functions Examples  Non-Examples:  AddASCII values (collisions): H('AB') = H('BA')  Checksums CRC32 not one-way or collision-resistant  MD5: “Message Digest 5” invented by Rivest  Input: multiple of 512-bits (padded)  Output: 128-bits  SHA1: developed by NIST & NSA  Input: same as MD5, 512 bits  Output: 160-bits
  • 5. 15.2. MACs  Used to determine sender of message  If Alice and Bob share key k, then Alice sends message M with MAC tag t = MAC(M,k)  Then Bob receives M’ and t’ and can check if the message or signature has been tampered by verifying t’ = MAC(M’, k)
  • 6. 15.2.1. CBC MACs  Encrypt message with block cipher in CBC mode  IV = 0, last encrypted block can serve as tag  Insecure for variable-length messages 0 M1 M2 Mn + + + … k AES k AES k AES tag
  • 7. 15.2.2. HMAC  Secure hash function to compute MAC  Hash function takes message as input while MAC takes message and key  Simply prepending key onto message is not secure enough (e.g. given MAC of M, attacker can compute MAC of M||N for desired N)  Def: HMAC(M , k ) = H ((K ⊕ opad) || H ((K ⊕ ipad) || M ))  Where K is key k padded with zeros  opad, ipad are hexadecimal constants
  • 8. 15.3. Signatures (1)  Two major operations: P, principal  Sign(M, k) – M is message  Verify(M, sig, P) – sig is signature to be verified  Signature: sequence of bits produced by Sign() such that Verify(M, sig, P) , (sig == Sign(M, k))  Non-repudiable evidence that P signed M  Many applications: SSL, to sign binary code, authenticate source of e-mail  Use asymmetric encryption ops F & F-1
  • 9. 15.3. Signatures (2)  S() & V() : implement sign & verify functions  Signature is s = S(M, ks) =F-1(h(M), ks)  Decrypt hash with secret key  Only signer (principal with secret key) can sign  Verify s: V(M, s, kp) = (F(s,kp) == h(M))  Encrypting with public key  Allows anyone to verify a signature  Need to bind principal’s identity to their public key
  • 10. 15.3.1. Certificates & CAs (1)  Principal needs certificate from CA (i.e. its digital signature) to bind his identity to his public key  CA must first sign own certificate attesting to own identity (“root”)  Certificate, C(P), stored as text: name of principal P, public key (kp(P)), expiration date  C(P) = (Ctext(P), Csig(P))  Root Certificate, C(CA), looks like  Ctext(CA)= ("CA", kp(CA), exp)  Csig(CA) = S(Ctext(CA), ks(CA))
  • 11. 15.3.1. Certificates & CAs (2)  Alice constructs certificate text:  Ctext(Alice)=("Alice", kp(Alice), exp)  Authenticates herself to CA (through “out-of-band” mechanism such as driver’s license)  CA signs Alice’s certificate: Csig(Alice)=S(Ctext(Alice),ks(CA))  Alice has public key certificate  C(Alice)=(Ctext(Alice),Csig(Alice))  Can use to prove that kp(Alice) is her public key
  • 12. 15.3.2. Signing and Verifying  Signing: sig = Sign(M, ks(P)) = (S(M, ks(P)),C(P))  Compute S() with secret key: sig.S  Append certificate: sig.C  Verifying: Verify(M, sig, P) =  V(M, sig.S, kp(P)) & signature verifies message?  V(sig.Ctext(P), sig.Csig(P), kp(CA)) & signed by CA?  (Ctext(P).name == P) & name matches on cert?  (today < sig.Ctext(P).date) certificate not expired?
  • 13. 15.3.3. Registration Authorities  Authenticating every principal can burden CA  Can authorize RA to authenticate on CA’s behalf  CA signs certificate binding RA’s identity to public key  Signature now includes RA’s certificate too  Possibly many intermediaries in the verification process starting from “root” CA certificate  More links in chain, more weak points: careful when verifying signatures  Ex: IE would not verify intermediate certificates and trust arbitrary domains (anyone could sign)
  • 14. 15.3.4. Web of Trust  Pretty Good Privacy (PGP): digital signatures can be used to sign e-mail  “Web of trust” model: users sign own certificates and other’s certificates to establish trust  Two unknown people can find a certificate chain to a common person trusted by both Source: http://xkcd.com/364/
  • 15. 15.4. Attacks Against Hash Functions  Researchers have been able to obtain collisions for some hash functions  Collision against SHA-1: 263 computations (NIST recommends phase out by 2010 to e.g. SHA-256)  MD5 seriously compromised: phase out now!  Collision attacks can’t fake arbitrary digital signatures (requires finding pre-images)  However could get 2 documents with same hash and sign one and claim other was signed
  • 16. 15.5. SSL  Handshake: steps client & server perform before exchanging sensitive app-level data  Goal of handshake: client & server agree on master secret used for symmetric crypto  Two round trips:  1st trip is “hello” messages: what versions of SSL and which cryptographic algorithms supported  2nd varies based on client or mutual authentication
  • 17. 15.5.1. Server-Authenticated Only (1)  Client creates random pre-master secret, encrypts with server’s public key  Server decrypts with own private key  Both compute hashes including random bytes exchanged in “hello” to create master secret  With master secret, symmetric session key and integrity key derived (as specified by SSL)  App Data encrypted with symmetric key
  • 18. 15.5.1. Server-Authenticated Only (2) Client Server ClientHello ServerHello, Certificate, ServerHelloDone ClientKeyExchange, ChangeCipherSpec, Finished ChangeCipherSpec, Finished Application Data
  • 19. 15.5.2. Mutual Authentication (1)  Client also sends own certificate to server  Sends CertificateVerify message to allow server to authenticate client’s public key  Pre-master secret set, compute master secret  Derive symmetric key & exchange data  SSL mechanisms prevent many attacks (e.g. man-in-the-middle) and has performance optimizations (e.g. caching security params)
  • 20. 15.5.2. Mutual Authentication (2) Client Server ClientHello ServerHello, Certificate, CertificateRequest, ServerHelloDone Certificate, ClientKeyExchange, CertificateVerify, ChangeCipherSpec, Finished ChangeCipherSpec, Finished Application Data
  • 21. Summary  MACs - protect integrity of messages  Compute tag to detect tampering  Ex: CBC-MAC, HMAC (relies on secure hashes)  Signatures – binds messages to senders  Allows anyone to verify sender  Prevents forged signatures  Use CAs to bind identities to public keys  Or use Web of Trust model  Application: SSL (“Putting it all together”)  Relies on Cryptography: symmetric & public-key  And MACs & signatures

Hinweis der Redaktion

  1. Welcome to SEC103 on Secure Programming Techniques. In this course, I assume that you have some background in computer security, but now you want to put that background to use. For example, in the Computer Security Principles and Introduction To Cryptography courses, we cover topics such concerning trust and encryption. In this course, we put these principles into to practice, and I’ll show you have to write secure code that builds security into your applications from the ground up.
  2. If you are coming from a computer science background, you may have heard of hash functions before. Hash functions, as used in the world of cryptography, have some similarities and differences from other types of hash functions. Like “regular” hash functions, a cryptographic hash function takes as input some (potentially large) message, M. It then computes a “message digest” h(M) that has the property that if two input message M1 and M2 are different, there is an overwhelmingly high probability that the two hashes h(M1) and h(M2) will be different. A hash function that simply adds the ASCII values of the characters in the message together does not have this property because “AB” and “BA” will have the same hash value even though they are different messages. Cryptographic hash functions use much more sophisticated techniques to ensure this property. The requirements that a cryptographic (secure) hash function must satisfy are three-fold: Efficient. Computing h(M) must be very efficient. One-way (Pre-Image Resistance). Given a message digest MD=h(M), it must be very hard to compute the original message, M. Collision resistance. Given a message digest MD=h(M), it must be very hard to compute a second message, M’, such that its message digest h(M’) = MD. MD = Message Digest
  3. Two popular hash functions that are used in many systems are MD5 and SHA-1.