2. 密码学笔记-流密码(Stream ciphers)

流密码(Stream ciphers)

1. Pseudo-random generators

Stream Ciphers: making OTP practical

idea: replace “random” key by “pseudorandom” key

The string s is stretched using some efficient, deterministic algorithm G that maps ‘l-bit strings to L-bit strings. Thus, the key space for this modified one-time pad is \{0,1\}^l, while the message and ciphertext spaces are \{0,1\}^L

For s ∈ \{0,1\}^land m, c ∈ \{0,1\}^L, encryption and decryption are defined as follows:

E(s, m) := G(s) ⊕ m and D(s, c) := G(s) ⊕ c.

This modified one-time pad is called a stream cipher, and the function G is called a pseudorandom generator.

If l < L, then by Shannon’s Theorem, this stream cipher cannot achieve perfect security;

however, if G satisfies an appropriate security property, then this cipher is semantically secure.

PRG must be unpredictable

PRG is unpredictable if it is not predictable

⇒ ∀i: no “eff” adv. can predict bit (i+1) for “non-neg” ε

2. Negligible vs. non-negligible

In practice: ε is a scalar and

– ε non-neg: ε ≥ 1/2^{30} (likely to happen over 1GB of data)

– ε negligible: ε ≤ 1/2^{80} (won’t happen over life of key)

In theory: ε is a function ε: Z^{≥0} ⟶ R^{≥0} and

– ε non-neg: ∃d: ε(λ) ≥ 1/λ^d (ε ≥ 1/poly, for many λ)

– ε negligible: ∀d, λ≥λ_d : ε(λ) ≤ 1/λ^d (ε ≤ 1/poly, for large λ)

PRGs: the rigorous theory view

PRGs are “parameterized” by a security parameter λ

PRG becomes “more secure” as λ increases

Seed lengths and output lengths grow with λ

For every λ=1,2,3,… there is a different PRG Gλ :

Gλ : K_λ ⟶ \{0,1\}^{n(λ)}

(in the lectures we will always ignore λ )

3. Attacks on OTP and stream ciphers

Attack 1: two time pad is insecure !!

Never use stream cipher key more than once !!

C_1 \leftarrow m_1 ⊕ PRG(k)

C_2 \leftarrow m_2 ⊕ PRG(k)

C_1 ⊕ C_2 \rightarrow m_1⊕ m_2

Enough redundancy in English and ASCII encoding that:

m_1⊕ m_2 \rightarrow m_1, m_2

Real world examples

  • Project Venona
  • MS-PPTP (windows NT)
  • 802.11b WEP

Attack 2: no integrity (OTP is malleable)

Modifications to ciphertext are undetected and have predictable impact on plaintext

enc: m ⊕ k

(m ⊕ k) ⊕ p

dec: ((m ⊕ k) ⊕ p )⊕ k \rightarrow m⊕p

4. Real-world Stream Ciphers

Old example (software): RC4 (1987)

Weaknesses:

  1. Bias in initial output: Pr[ 2^{nd}\ byte = 0 ] = 2/256
  2. Prob. of (0,0) is 1/256^2 + 1/256
  3. Related key attacks

Old example (hardware): CSS (badly broken)

Linear feedback shift register (LFSR):

  • DVD encryption (CSS): 2 LFSRs

  • GSM encryption (A5/1,2): 3 LFSRs

  • Bluetooth (E0): 4 LFSRs

all broken

CSS: seed = 5 bytes = 40 bits

加密DVD电影,混淆系统CSS,面向硬件设计的流密码,基于线性反馈移位寄存器LFSR。右移,最后一位扔掉,第一位是之前的异或结果。 LFSR的种子就是寄存器的初始状态。

CSS用了两个LFSR,一个17位一个25位。

种子是,第一个的是1+key的前两个字节=17bits; 第二个是1+key的后三个字节=25bits

两个LFSR运行8次,输出8位,相加,mod256,一轮输出一个字节。这个字节和电影数据里的字节进行异或加密,CSS是个简单的流密码。2^17次可以破解。很容易。

Modern stream ciphers: eStream

PRG: \{0,1\}^s × R ⟶ \{0,1\}^n

seed × nonce

Nonce: a non-repeating value for a given key.

E(k, m ; r) = m ⊕ PRG(k ; r)

The pair (k, r) is never used more than once.

eStream: Salsa 20

Salsa20: \{0,1\}^{128\ or\ 256} × \{0,1\}^{64} ⟶ \{0,1\}^n

Salsa20( k ; r) := H( k , (r, 0)) ll H( k , (r, 1)) ll …

5. PRG Security Defs

如果无法区分G(s) 和 r,就说明G(s)是安全的,流密码也是安全的

Intuitively, if an adversary cannot effectively tell the difference between G(s) and r, then he should not be able to tell the difference between this stream cipher and a one-time pad; moreover, since the latter cipher is semantically secure, so should be the former.

Statistical Tests

一种用于区分伪随机串和真正随机串的算法被称为统计测试。它以一个字符串作为输入,输出0或1。如果在伪随机输入上输出1的概率与在真正随机输入上输出1的概率显著不同,则这种测试称为有效

An algorithm that is used to distinguish a pseudo-random string G(s) from a truly random string r is called a statistical test. It takes a string as input, and outputs 0 or 1. Such a test is called effective if the probability that it outputs 1 on a pseudo-random input is significantly different than the probability that it outputs 1 on a truly random input.

Advantage

Given r, the adversary computes and outputs a bit b ∈ {0,1}.

For b = 0,1, let W_b be the event that A outputs 1 in Experiment b.

We define A’s advantage with respect to G as

PRGadv[A, G] := |Pr[W_0] − Pr[W_1] |

Secure PRGs: crypto definition

Def: We say that G:K ⟶\{0,1\}^n is a secure PRG if

PRGadv[A, G] is negligible for all efficient adversaries A.

Easy fact: a secure PRG is unpredictable

We show: PRG predictable ⇒ PRG is insecure

Thm (Yao’82): an unpredictable PRG is secure

Let G:K ⟶\{0,1\}^n be PRG

“Thm”: if ∀ i ∈ ,0, … , n-1} PRG G is unpredictable at pos. i

then G is a secure PRG.

If next-bit predictors cannot distinguish G from random then no statistical test can !!

6. Semantic security

What is a secure cipher?

Attacker’s abilities: obtains one ciphertext (for now)

Possible security requirements:

  • attempt #1: attacker cannot recover secret key

  • attempt #2: attacker cannot recover all of plaintext

  • Recall Shannon’s idea: CT should reveal no “info” about PT

Semantic Security (one-time key)

攻击者A发出等长的m0和m1,挑战者选取随机密钥k发出m0或m1的加密结果。

在实验0里,挑战者输出m0的加密

在实验1里,挑战者输出m1的加密

攻击者视图试图去猜他得到的是m0还是m1的加密

定义事件Wb为在实验b中攻击者输出1的所有事件

接下来,这就是攻击者A对加密机制E的语义安全的优势

定义两个事件概率的差距

Adv趋近于1,意味着攻击者能很好地区分实验0和1,也就是可以区分M0和M1的加密。

Adv趋近于0,意味着攻击者不能区分实验0和1

E是一个对称加密机制,是语义安全的。对所有有效的攻击者(破解成功),优势可以忽略(Adv~0)。

总的来说,就是攻击者获得m0和m1,无法区分这两个分布。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 220,063评论 6 510
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,805评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 166,403评论 0 357
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,110评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,130评论 6 395
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,877评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,533评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,429评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,947评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,078评论 3 340
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,204评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,894评论 5 347
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,546评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,086评论 0 23
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,195评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,519评论 3 375
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,198评论 2 357

推荐阅读更多精彩内容

  • 今天感恩节哎,感谢一直在我身边的亲朋好友。感恩相遇!感恩不离不弃。 中午开了第一次的党会,身份的转变要...
    迷月闪星情阅读 10,567评论 0 11
  • 彩排完,天已黑
    刘凯书法阅读 4,220评论 1 3
  • 表情是什么,我认为表情就是表现出来的情绪。表情可以传达很多信息。高兴了当然就笑了,难过就哭了。两者是相互影响密不可...
    Persistenc_6aea阅读 125,200评论 2 7