8
Cryptography and Cryptography and Network Security Network Security Chapter 11 Chapter 11 Fifth Edition Fifth Edition by William Stallings by William Stallings Lecture slides by Lecture slides by Lawrie Lawrie Brown Brown (with edits by RHB) (with edits by RHB) Chapter 11 Chapter 11 Cryptographic Cryptographic Hash Functions Hash Functions Each of the messages, like each one he had ever Each of the messages, like each one he had ever read of Stern's commands, began with a number read of Stern's commands, began with a number and ended with a number or row of numbers. No and ended with a number or row of numbers. No efforts on the part of Mungo or any of his experts efforts on the part of Mungo or any of his experts had been able to break Stern's code, nor was had been able to break Stern's code, nor was there any clue as to what the preliminary number there any clue as to what the preliminary number and those ultimate numbers signified. and those ultimate numbers signified. Talking to Strange Men, Talking to Strange Men, Ruth Rendell Ruth Rendell Outline Outline will consider: will consider: hash functions hash functions uses, requirements, security uses, requirements, security hash functions based on block ciphers hash functions based on block ciphers SHA SHA - - 1, SHA 1, SHA - - 2, SHA 2, SHA - - 3 3 Hash Functions Hash Functions condenses arbitrary message to fixed size condenses arbitrary message to fixed size h = H(M) h = H(M) usually assume hash function is public usually assume hash function is public hash used to detect changes to message hash used to detect changes to message want a cryptographic hash function want a cryptographic hash function computationally infeasible to find data mapping computationally infeasible to find data mapping to specific hash (one to specific hash (one - - way property) way property) computationally infeasible to find two different computationally infeasible to find two different data with same hash (collision data with same hash (collision - - free property) free property)

Cryptography and Chapter 11 – Cryptographic Network ...banach/COMP61411.Info/Course... · Cryptography and Network Security Chapter 11 Fifth Edition by William Stallings Lecture

  • Upload
    others

  • View
    17

  • Download
    0

Embed Size (px)

Citation preview

Cryptography and Cryptography and

Network SecurityNetwork Security

Chapter 11Chapter 11

Fifth EditionFifth Edition

by William Stallingsby William Stallings

Lecture slides by Lecture slides by LawrieLawrie BrownBrown

(with edits by RHB)(with edits by RHB)

Chapter 11 Chapter 11 –– Cryptographic Cryptographic

Hash FunctionsHash Functions

Each of the messages, like each one he had ever Each of the messages, like each one he had ever read of Stern's commands, began with a number read of Stern's commands, began with a number and ended with a number or row of numbers. No and ended with a number or row of numbers. No efforts on the part of Mungo or any of his experts efforts on the part of Mungo or any of his experts had been able to break Stern's code, nor was had been able to break Stern's code, nor was there any clue as to what the preliminary number there any clue as to what the preliminary number and those ultimate numbers signified.and those ultimate numbers signified.

——Talking to Strange Men, Talking to Strange Men, Ruth RendellRuth Rendell

OutlineOutline

•• will consider:will consider:

•• hash functionshash functions

•• uses, requirements, securityuses, requirements, security

•• hash functions based on block ciphershash functions based on block ciphers

•• SHASHA--1, SHA1, SHA--2, SHA2, SHA--33

Hash FunctionsHash Functions

•• condenses arbitrary message to fixed sizecondenses arbitrary message to fixed size

h = H(M)h = H(M)

•• usually assume hash function is publicusually assume hash function is public

•• hash used to detect changes to messagehash used to detect changes to message

•• want a cryptographic hash functionwant a cryptographic hash function

•• computationally infeasible to find data mapping computationally infeasible to find data mapping

to specific hash (oneto specific hash (one--way property)way property)

•• computationally infeasible to find two different computationally infeasible to find two different

data with same hash (collisiondata with same hash (collision--free property)free property)

王博文�
哈希函数•用途,要求,安全性•基于分组密码的哈希函数•SHA-1,SHA-2,SHA-3툀
王博文�
•将任意消息压缩为固定大小h = H(M)•通常假设哈希函数是公共的•hash用于检测消息的更改•想要加密哈希函数•计算上不可行的查找数据映射到特定哈希(单向属性)•计算上不可能找到具有相同散列的两个不同数据(无碰撞属性)�

Cryptographic Hash FunctionCryptographic Hash Function

Hash Hash

Functions & Functions &

Message Message

AuthentAuthent--

icationication

Hash Functions & Digital Hash Functions & Digital

SignaturesSignaturesOther Hash Function UsesOther Hash Function Uses

•• to create a oneto create a one--way password fileway password file

•• store hash of password not actual store hash of password not actual passwordpassword

•• for intrusion detection and virus detectionfor intrusion detection and virus detection

•• keep & check hash of files on systemkeep & check hash of files on system

•• pseudorandom function (PRF) or pseudorandom function (PRF) or

pseudorandom number generator (PRNG)pseudorandom number generator (PRNG)

王博文�
创建单向密码文件 - 存储密码的哈希值而不是实际密码•用于入侵检测和病毒检测 - 保持并检查系统上的文件哈希值•伪随机函数(PRF)或伪随机数发生器(PRNG)�

Two Simple Insecure Hash Two Simple Insecure Hash

FunctionsFunctions

•• consider two simple insecure hash functionsconsider two simple insecure hash functions

•• bitbit--byby--bit exclusivebit exclusive--OR (XOR) of every blockOR (XOR) of every block

•• CCii == bbi1i1 XORXOR bbi2i2 XORXOR ...... XORXOR bbimim

•• a longitudinal redundancy checka longitudinal redundancy check

•• reasonably effective as data integrity checkreasonably effective as data integrity check

•• oneone--bit circular shift on hash valuebit circular shift on hash value

•• for each successive nfor each successive n--bitbit blockblock

•• rotate current hash value left by 1 bit and XOR blockrotate current hash value left by 1 bit and XOR block

•• good for data integrity but useless for securitygood for data integrity but useless for security 06/03/10

Hash Function RequirementsHash Function Requirements Attacks on Hash FunctionsAttacks on Hash Functions

•• have brutehave brute--force attacks and cryptanalysisforce attacks and cryptanalysis

•• a a preimagepreimage or second or second preimagepreimage attackattack

•• find find yy s.ts.t. . H(yH(y)) equals a given hash value equals a given hash value

•• collision resistancecollision resistance

•• find two messages find two messages xx and and yy with same hash with same hash

H(xH(x)) == H(yH(y))

•• hence value hence value 22m/2m/2 determines strength of determines strength of

hash code against brutehash code against brute--force attacksforce attacks

•• 128128--bits inadequate, 160bits inadequate, 160--bits suspectbits suspect

王博文�
两个简单的不安全哈希函数•考虑两个简单的不安全哈希函数•每个块的逐位异或(XOR)-C= bi1XORbi2XOR... XORbim - 纵向冗余检查 - 作为数据完整性检查合理有效•哈希值的一位循环移位 - 对于每个连续的n位块 - 将当前哈希值旋转1位和XOR块•有利于数据完整性,但对安全性无用�
王博文�
王博文�
可变输入大小固定输出尺寸效率前像抗性第二个前像抗性防碰撞伪随机性�
王博文�
•进行暴力攻击和密码分析•preimage或第二次preimage攻击  ••找到s.t. H(y)等于给定的哈希值•抗碰撞性•找到两条消息x和y,它们具有相同的散列H(x)= H(y)•因此,值2确定哈希码对强力攻击的强度••128位不足,160位可疑�

06/03/10

Birthday AttacksBirthday Attacks

•• might think a 64might think a 64--bit hash is securebit hash is secure

•• but by but by Birthday ParadoxBirthday Paradox is notis not

•• birthday attack birthday attack works thus:works thus:•• given user prepared to sign a valid message xgiven user prepared to sign a valid message x

•• opponent generates 2opponent generates 2mm//22 variations xvariations x’’ of x, all with of x, all with

essentially the same meaning, and saves themessentially the same meaning, and saves them

•• opponent generates 2opponent generates 2mm//22 variations yvariations y’’ of a desired of a desired

fraudulent message yfraudulent message y

•• two sets of messages are compared to find pair with two sets of messages are compared to find pair with same hash (probability > 0.5 by birthday paradox)same hash (probability > 0.5 by birthday paradox)

•• have user sign the valid message, then substitute the have user sign the valid message, then substitute the forgery which will have a valid signatureforgery which will have a valid signature

•• conclusion is that need to use larger MAC/hashconclusion is that need to use larger MAC/hash

06/03/10 06/03/10

王博文�
散列函数属性之间的关系�
王博文�
王博文�
•可能认为64位哈希是安全的•但生日悖论不是•生日攻击如此起作用: - 给定用户准备签署有效消息x - 对手产生x的2m / 2变化x',所有变量具有基本相同的含义,并保存它们 - 对手产生所需欺诈性消息y的2m / 2变化y' - 比较两组消息以找到具有相同散列的对(生日悖论的概率> 0.5) - 让用户签署有效消息,然后替换将具有有效签名的伪造•结论是需要使用更大的MAC / hash�

Hash Function CryptanalysisHash Function Cryptanalysis

•• cryptanalytic attacks exploit some property cryptanalytic attacks exploit some property

of of algalg, so faster than exhaustive search, so faster than exhaustive search

•• hash functions use iterative structurehash functions use iterative structure

•• process message in blocks (process message in blocks (inclincl length)length)

•• attacks focus on collisions in function fattacks focus on collisions in function f

Block Ciphers as Hash FunctionsBlock Ciphers as Hash Functions

•• can use block ciphers as hash functionscan use block ciphers as hash functions

•• using using HH00 == 00 and zeroand zero--pad of final blockpad of final block

•• compute: compute: HHii == EEmmii(H(Hii--11))

•• and use final block as the hash valueand use final block as the hash value

•• similar to CBC but without a keysimilar to CBC but without a key

•• resulting hash is too small (64resulting hash is too small (64--bit)bit)

•• both due to direct birthday attackboth due to direct birthday attack

•• and to and to ““meetmeet--inin--thethe--middlemiddle”” attackattack

•• other variants also susceptible to attackother variants also susceptible to attack

Secure Hash AlgorithmSecure Hash Algorithm

•• SHA originally designed by NIST & NSA in 1993SHA originally designed by NIST & NSA in 1993

•• was revised in 1995 as SHAwas revised in 1995 as SHA--11

•• US standard for use with DSA signature scheme US standard for use with DSA signature scheme

•• standard is FIPS 180standard is FIPS 180--1 1995, also Internet RFC31741 1995, also Internet RFC3174

•• nbnb. the algorithm is SHA, the standard is SHS . the algorithm is SHA, the standard is SHS

•• based on design of MD4 with key differences based on design of MD4 with key differences

•• produces 160produces 160--bit hash values bit hash values

•• recent 2005 results on security of SHArecent 2005 results on security of SHA--1 have 1 have

raised concerns on its use in future applicationsraised concerns on its use in future applications

王博文�
•密码分析攻击利用了alg的某些属性,因此比穷举搜索更快•哈希函数使用迭代结构•处理块中的消息(包括长度)•攻击侧重于功能f中的冲突�
王博文�
可以使用块密码作为哈希函数•使用H0 = 0和最终块的零填充•compute:H = E i(H)i m i-1•并使用final块作为哈希值•类似于CBC但没有钥匙•结果哈希值太小(64位)•由于直接生日袭击•以及“中间相遇”攻击•其他变体也容易受到攻击�
王博文�
安全哈希算法•SHA最初由NIST和NSA于1993年设计•在1995年被修订为SHA-1•美国标准用于DSA签名方案•标准是FIPS 180-1 1995,也是因特网RFC3174•nb。算法为SHA,标准为SHS•基于MD4的设计,具有关键差异•生成160位哈希值•最近2005年关于SHA-1安全性的结果引起了对其在未来应用中的使用的担忧�

Revised Secure Hash StandardRevised Secure Hash Standard

•• NIST issued revision FIPS 180NIST issued revision FIPS 180--2 in 20022 in 2002

•• adds 3 additional versions of SHA adds 3 additional versions of SHA

•• SHASHA--256, SHA256, SHA--384, SHA384, SHA--512512

•• designed for compatibility with increased designed for compatibility with increased security provided by the AES ciphersecurity provided by the AES cipher

•• structure and detail is similar to SHAstructure and detail is similar to SHA--11

•• hence analysis should be similarhence analysis should be similar

•• but security levels are rather higherbut security levels are rather higher

SHA VersionsSHA Versions

SHASHA--512 Compression Function512 Compression Function

•• heart of the algorithmheart of the algorithm

•• processing message in 1024processing message in 1024--bit blocksbit blocks

•• consists of 80 rounds per blockconsists of 80 rounds per block

•• updating a 512updating a 512--bit buffer bit buffer

•• using a 64using a 64--bit value Wt derived from the bit value Wt derived from the

current message blockcurrent message block

•• and a round constant based on cube root of and a round constant based on cube root of

first 80 prime numbersfirst 80 prime numbers

SHASHA--512 Overview512 Overview

王博文�
修订安全哈希标准•NIST于2002年发布了FIPS 180-2修订版•增加3个额外版本的SHA     •SHA-256,SHA-384,SHA-512•旨在兼容AES密码提供的更高安全性•结构和细节类似于SHA-1•因此分析应该类似•但安全级别相当高�
王博文�
压缩功能�
王博文�
•算法的核心•以1024位块处理消息•每个区块包含80发子弹•更新512位缓冲区•使用从当前消息块派生的64位值Wt•和基于前80个素数的立方根的圆常数�

06/03/10

Processing

one 1024

bit block

06/03/10

Hi Initial Values

06/03/10

Ki

SHASHA--512 Round Function512 Round Function

XOR

of 3

ROTR

Bitw.

Maj

vote

Bitw.

If-t-e

Addition

mod 264

王博文�
初始值�

SHASHA--512 512 Round FunctionRound Function

Addition

mod 264

XOR of 3

ROTR/SHR

SHASHA--33

•• In hashes, nothing secret, easier to attackIn hashes, nothing secret, easier to attack

•• SHASHA--1 not yet 1 not yet ““brokenbroken””, but similar to MD5 , but similar to MD5

and SHAand SHA--0, so considered insecure0, so considered insecure

•• SHASHA--2 (esp. SHA2 (esp. SHA--512) seems secure512) seems secure

•• shares same structure and mathematical shares same structure and mathematical

operations as predecessors so have concernoperations as predecessors so have concern

•• NIST announced in 2007 a competition for NIST announced in 2007 a competition for

the SHAthe SHA--3 next gen NIST hash function3 next gen NIST hash function

•• goal to have in place by 2012 but not fixedgoal to have in place by 2012 but not fixed

SHASHA--3 Requirements3 Requirements

•• replace SHAreplace SHA--2 with SHA2 with SHA--3 in any use3 in any use

•• so use same hash sizesso use same hash sizes

•• preserve the online nature of SHApreserve the online nature of SHA--22

•• so must process small blocks (512 / 1024 bits)so must process small blocks (512 / 1024 bits)

•• evaluation criteriaevaluation criteria

•• security close to theoretical max for hash sizessecurity close to theoretical max for hash sizes

•• cost in time and memory cost in time and memory

•• characteristics: such as flexibility and simplicitycharacteristics: such as flexibility and simplicity

王博文�
•在哈希中,没什么秘密,更容易攻击•SHA-1尚未“损坏”,但与MD5和SHA-0类似,因此被认为是不安全的•SHA-2(特别是SHA-512)似乎很安全 - 与前人共享相同的结构和数学运算,因此需要关注•NIST在2007年宣布了针对SHA-3下一代NIST散列函数的竞赛 - 到2012年实现的目标,但不是固定的�
王博文�
•在任何使用中用SHA-3替换SHA-2 - 所以使用相同的哈希值•保留SHA-2的在线性质 - 所以必须处理小块(512/1024位)• 评估标准 - 安全性接近哈希大小的理论最大值 - 花费时间和记忆 - 特点:如灵活性和简单性�