[密码学复习]Cryptography

整合

Week 2对称加密

Two requirements:

  • A strong encryption algorithm
  • A secret key known only to participants.

1. 有三部分构成:

1.加密算法

2.可能使用的密钥数量:数量越大越安全

3.text文本的处理:分为stream ciphers整段传输和block ciphers, 将文本切成固定块大小传输

2. 密码攻击有以下几种:

Ciphertext only, Known plaintext, Chosen plaintext, Chosen ciphertext, Chosen text:

[密码学复习]Cryptography_第1张图片
已知明文攻击指的是攻击者获取到的明密文对。

而选择明文攻击指的是攻击者可以通过某种手段往其中加入指定明文并由此获取指定密文。

选择密文和选择文本很少见,所以书上没有过多介绍

3. Two important definitions are interesting on which much of the cryptologic research of modern times are based. 两个现代密码学研究的基础

也就是说密码学必须建立在这两个其中之一条件之上:

Unconditional Security (Shannon): The security of the cipher is independent of the computing resource available to the adversaries. 不管对手拥有的计算资源有多强大都无法破解

Computational Security (Turing): Adversaries are provided with constrained computing resources and the security of the cipher determined by the size of the computations required to break the cipher.为对手提供了受限制的计算资源,并且密码的安全性由破解密码所需的计算大小确定。

4. Classical Ciphers

4.1 Substitution Ciphers 代替技术

Here plaintext symbols are substituted or replaced with other symbols
using an unknown key. The substitutions can be performed as sequence of symbols or symbol by symbol. 简单来说就是把当前的字符固定的换成另一个字符

4.1.1 Caser Cipher

最简单的加密技术,给定一个k,把当前字符(所在位置为i)变成i+k个位置的字符。比如k=3,a的i=1,那么i+k=4,所以a就变成d。
[密码学复习]Cryptography_第2张图片
这里其实E(k, p) => (c = p + k) mod 26

所以直接变换(p = c - k) mod 26 => D(k, p)

key space(密钥取值范围)为1~25,因为0就是明文自己,所以不算

Affine Cipher

Caser Cipher的升级版
Encryption: E(k,p) = c = ap + b mod m

Decryption: D(k,p) = a-1(c – b) mod m

⚠️这里的要点是a和m需要互为质数,b的取值范围为[0, m-1]或[1, m],因为取0和取m模出来都是0

举两个例子,如果m=26,也就是说对应的表为26字母表,那么a的取值范围为[1, 25],b为[0, 25],所以key space = 25 * 26

如果m=36,也就是说对应的表为26字母表,那么a的取值范围为{1,5,7,11,13,17,19,23,25,29,31,35},因为需要互质,b为[0, 35],所以key space = 12 * 36

这里引入一个概念叫trival。如果说trival的话就是p不管取什么,c恒等于p。所以如果a=1, b=0那么c=p。non-trivial就是总数-trival

Monalphabetic Cipher

更简单暴力,直接把每一个字母随机对应到不同的字母(可以是自身)。
所以possible keys = 26!

虽然看起来很安全,因为brute-force很难破解,但是其实Language statistics可以作为一种分析方式。分析每个字符的使用频率来计算

4.2 Transposition Ciphers 置换技术

Here plaintexts are organized as a sequence of plaintext blocks and symbol positions in each block are permuted or transposed using a key. The same permutation is used for every block. 在这里,纯文本被组织为一系列的纯文本块,并且每个块中的符号位置使用键进行置换或转置。 每个块使用相同的排列。更通俗一点说,它区别于代替技术,它是直接将明文打散,通过复杂排列进行重新组合

一个例子:Row transposition cipher
plaintext: attackpostponeduntiltwoamxyz
简单来说它就是先把明文一行一行地写成矩阵块,然后打乱列的序号,根据序号从1开始,按列从上到下的顺序依次读取字符拼成新的密文。且可以多次加密。
[密码学复习]Cryptography_第3张图片

4.3 Complex Ciphers - Polyalphabetic Cipher

Vigenère Cipher

假设plaintext P的长度是n,他会先随机定义一个d,然后对应每一个index i(i属于n)获得Ki = i mod d。然后使用Caser Cipher获得
Encryption:E(K,P) = C, where ci = pi + ki mod 26

Decrypton: D(K,C) = P, where pi = ci - ki mod 26

d越大越安全。以下是一个例子:
[密码学复习]Cryptography_第4张图片

Week 3

Modern Symmetric Ciphers
主要分成两种,流加密和块加密

1. One Time Pad

首先我们回顾一下Vigenère Cipher

假设plaintext P的长度是n,他会先随机定义一个d,然后对应每一个index i(i属于n)获得Ki = i mod d。然后使用Caser Cipher获得
Encryption:E(K,P) = C, where ci = pi + ki mod 26

Decrypton: D(K,C) = P, where pi = ci - ki mod 26

d越大越安全。以下是一个例子:
[密码学复习]Cryptography_第5张图片

One time pad其实就是这种cipher的特殊例子,就是当n=d的时候就是one time pad,也叫Vernam。(n是plaintext长度,d是key的长度)

在这里其实就是用XOR来加密解密。

Plaintext ⊕ Key = CipherText

CipherText ⊕ Key = Plaintext

Perfect Secrecy

• An encryption scheme has the property of unconditional security if the cipher text generated by the algorithm does not reveal sufficient information to break the scheme, even with access to an unlimited amount of computational power.

• In other words, the adversary cannot not obtain any knowledge to reverse the encryption by watching any amount of cipher text without access to the key.

It implies: Pr[M = x|C = y] = Pr[M = x]
也可以写成PX|Y(x|y) = PX(x) 大致意思就是,哪怕给定了另一个条件Y,也不会改变/影响原来X的概率

One time pad其实不太practical,因为要保证key的绝对安全。但是two time pad就不够安全,因为

• C1=M1 ⊕ K; C2= M2 ⊕ K; then

• C1 ⊕ C2=M1 ⊕ M2 ⊕ K ⊕ K= M1 ⊕ M2.

Even though M1 ⊕ M2 may not direct meaning, it still leaks information about both M1 and M2.

Block Cipher

Fiestel Block Cipher

首先要了解这是一种密码结构,很多算法都在用这种结构,包括DES

首先会传入一个长度为2w的明文(2的倍数)和一个密钥Key。接下来会决定产生轮次round,图中轮次为16(DES一般就是16)。然后根据传入的key用特殊或者自制算法计算出子key{key1, key2, …, key16}。这些子key和原key没啥直接关系。接下来就是如图,每一轮,让右边part R完全不做处理,直接放在下一轮的L。然后输入keyi和右边部分进函数F获得result,让左边part L和result XOR得到下一轮的R。

所以说Fiestel主要强度来自于:1.F函数强度,2.轮数,3.生成子key的算法的强度
[密码学复习]Cryptography_第6张图片

DES

DES算法的相关参数如下: 

明文分组长度:64 bits,左右各32 bits

密钥长度:64 bits

轮数:16轮

3DES

首先先说一下2DES在本质上并没有比DES安全多少,所以能破解DES大概率也能破解2DES。但是3DES如果在三个过程中使用的key都不一样的话,那么密钥长度可以被认为是192(64*3)位。同时为什么采用加密-解密-加密的模式是因为首先如果3个key都不相同,那么这种方式其实和加密-加密-加密的模式得出来的加密效果是一样的。但是如果3个key一样,又可以向下兼容,变成DES模式。
[密码学复习]Cryptography_第7张图片

几种分组密码的工作模式

[密码学复习]Cryptography_第8张图片

1. ECB

这种模式就是简单粗暴,把密码分成一块一块,每一块单独做加密。这种模式适用于少量文本,比如加密密钥。比如加密DES和AES的Key
[密码学复习]Cryptography_第9张图片

2. CBC

[密码学复习]Cryptography_第10张图片
[密码学复习]Cryptography_第11张图片
CFB就是上一块的结果会作为下一块加密的参数。因此一个bit出问题会propogate,影响很大,但是也只对该bit位造成影响,因为是异或。同时也不能并行操作,因为需要之前的结果。

3. CFB

[密码学复习]Cryptography_第12张图片
[密码学复习]Cryptography_第13张图片
[密码学复习]Cryptography_第14张图片
CFB可以进行并行操作,原理有点像流密码。是因为它的操作原理是这样的,首先生成一个和整个明文一样size的IV。接下来每次从最左侧取块密码size s的大小来和P XOR。XOR之后将整个IV向左移动s,并在尾部,也就是右边插入刚刚得到的C。每次都取IV最左边操作。可以并行操作的原因是,知道固定size s,那么将整个IV平分,并在相应位置填入C即可。填入C的原因是把这个用C填充的Key作为解密的IV,这样很方便。

4. OFB

[密码学复习]Cryptography_第15张图片
[密码学复习]Cryptography_第16张图片
这里我其实一开始不太明白为什么是公式里Ci需要用到Ci-1和Pi-1但是其实跟这两个无关。因为我想要的是某个值X,这个X XOR Pi-1 = Ci-1那么两边同时XOR一个 Pi-1可以得到X = Pi-1 XOR Ci-1,得到公式式子。

优点是容错高,明文C在传输过程中发生的错误不会在加密过程中向后传播

5. CTR

我个人感觉应该不会考。他的概念大致就是首先定一个计数器,和明文分组有同样长度的规模。首先第一个计数器被初始化成为一个值,过了固定时间会加一(或者其他的计数器操作),然后进行加密,最后进行XOR
[密码学复习]Cryptography_第17张图片

Week 4 - Public Key Protocol: Diffie-Hellman and RSA

1. DH Protocol

这是一种交换密钥的算法。同时DH加密算法是建立在一个fact之上:计算离散对数是一件非常困难的是,也就是已知ai = b mod n也难以计算出i。同时要保证这个a够大
[密码学复习]Cryptography_第18张图片
在这幅图中Alice首先自己创建了一个g,一个n,还有一个Na,通过公示gNa mod n = Ma计算出Ma。(图中n=10)接下来Alice将g, n, Ma都发送给Bob,然后Bob随机选择一个Nb,用公式gNb mod n = Mb计算出Mb,然后把Mb发回给Alice。(注意这里Na和Nb都只有各自知道)。接下来两个人可以得到一个共有的Key = MbNa = MaNb,然后可以开始愉快的通信了。

但是这种通信因为没有signature所以很容易被Man-in-the-middle攻击。如下图,中间人Malice可以截取然后跟他们通信,得到各自信息,并且也可以封装发给自己,让他们以为在正常通信。
[密码学复习]Cryptography_第19张图片
所以接下来就需要著名的升级版算法RSA

2. RSA

一个概念: A cryptosystem is a five-tuple ( P,C,K,E,D).

  1. P: Plaintext
  2. C: Ciphertext
  3. K: the space of keys, a finite set of possible keys; 这里面包括 (n, p, q , e, d),在下面使用RSA的时候会介绍
  4. E: Encryption function
  5. D: Decryption func

RSA的做法很简单,如下图:注意这里面的p和q是nearly impossible破解出来的(当n非常大), factorization problem是非常难得问题
[密码学复习]Cryptography_第20张图片

非对称加密的常见攻击有三种:

1. Chosen-plaintext attack(CPA) 就是攻击者获得了加密算法,public key,所以攻击者可以自己输入plaintext去获得ciphertext

2. Chosen-ciphertext attack(CCA)

• Decryption box is available to the attacker before the attack.

3. Adaptive Chosen-ciphertext attack(CCA2)

Decryption box is available to the attacker except for the
challenged ciphertext.

• Here attacker can obtain plaintexts corresponding any chosen
ciphertexts. This means the attacker gets decryption assistance for
any chosen ciphertext. The goal for the attacker is to obtain any
part of the plaintext after the decryption assistance is terminated.

Week 5- RSA Digital Signature

一般public key都存在于权威第三方机构,因此要确保请求的Public Key是准确的,所以会用到签名。一般对于RSA来说有Ciphertext = RF(PU, Message) /RF=RSA Function/ (使用Public key加密message), Message = RF(PR, Ciphertext)。 因为RSA使用的是指数函数的方法加密解密,所以加密解密的方法可以说是都一样的。

非常注意!!这里是使用Private Key去加密Message来获得Signature!!!然后用Public key来解密signature,如果Se=Message - 1⃣️。这是因为S=Md,Mde=Med=M。所以1⃣️成立就说明是有效signature

对于Signature来说,算法变更为:

Ciphertext = RF(PU, Message, Sig), 其中Sig需要等于RF(PR, Message)

所以要判断Sig =? RF(PR, Message), 同时算法在解密的时候会提供一个additional output = 1 or 0作为判断结果。如果是1说明解密成功,0表示解密失败。


**这里主要一点!!!Sig是用来给B看的!**比如A产生消息Ciphertext = RF(PU, Message, Sig),B获得以后解密得到Message和Sig,然后B计算SigPublic key = Message,可以证明是A发来的。这里不是像我之前想象的还要发回给A,而是给B看,让他Verify这是A发来的!

1st version of RSA

给出5个要素:

  1. Ciphertext: S
  2. Plaintext: M
  3. Public Part: Public Key: e, So large number N=e*d
  4. Private Part: Private Key: d
  5. Signature = Md,然后在private key解开以后计算Se ?= M,只有等于才说明签名正确,来自于正确获取源。

但是这个版本的RSA其中一个问题就是: 消息(M1 * M2)d = M1d * M2d = Sig1 * Sig2. 所以这样就会可能导致签名的伪造 forgery of signature!

Blinding

这是一种1st RSA的攻击,比如攻击者想要伪造一个A暂时还不想签名的签名SigA

  1. 选择一个随机数,位于[0, … N-1] N在上面有,是mod N
  2. 创建blinded message Mb = xe M mod N
  3. 假设A想签名Mb,于是会获得SigAb = Mbd mod N
  4. 这时候问题出现了,由于RSA multiplicative property, 因为现在可以计算出SigA了。
    SigA = SigAb / x mod N

    这是因为SigA = Md mod N, SigAb = (xe * M)d mod N = xed * Md mod N,根据RSA性质,xed mod N = x。所以我们有SigA = SigAb / x mod N
  5. 那么SigAe = (SigAb / x)e = (Mb)de / xe = (Mb) / xe = Mxe / xe = M,这样就导致了伪造!

2nd version of RSA

这种方法其实就是在方法1的基础上做一个升级,Sig不再是直接通过Private Key去加密Message来获得,而是两方都要有一个 redundancy function,R
首先先计算出M1 = R(M), Sig = M1d。Func R会让M和M1变得相对无关,这样子就没办法伪造签名了。但是难点在于要让两方都知晓这个Func R。

RSA signature in practice

• 前面说的两个issue,一个是Blinding,一个是在1st结尾提到的multiplicative property导致的forgery of signature
• Messages are generally long.

• RSA signature scheme needs a redundancy function to avoid existential forgery attacks.

• Also repeated messages carry same signature.

3rd version of RSA

对Func R的优化,这里使用的是Hash Function替代Function Redundancy

Securicy of RSA

• Brute force Attack: (infeasible given size of numbers)

• Attack by making use of loopholes in Key distribution.

• Mathematical attacks (Factoring and RSA problem) 在d,e够大的情况下数学攻击和因式分解基本不可能,ppt. 有

• Elementary attacks 这个攻击的主要问题是:首先ed = 1 mod Φ(n)这个难度堪比factoring,但是最重要的问题是所有人都用这一套,所以如果有所记录e和d,那么记录非常多的用户使用的ed可以推出来将来用户的ed

• Advanced Factorization methods

• Network attacks

• Broadcast problem 这个攻击的问题是一个group of entities可能会用同一个public key with different modulo N。一般PU都比较小,比如是e=3,那么给一个group中的3个entities:

• c1 = m3 (mod n1)
• c2 = m3 (mod n2)
• c3 = m3 (mod n3).

• x = c1 (mod n1),

• x = c2 (mod n2),

• x = c3 (mod n3),

• You can use CRT and Then obtain an unique

• x=m3 modulo n1 n2 n3

• m can then be obtained by taking the cube root of x. Finding a cube root in integers is not a hard problem.

CCA Chosen Cipher Attack ?这里怪怪的,如果我是可以随便选择密文的话,那不是直接就可以求得M吗?如果我不能直接选择密文,那怎么解密X?

基本的RSA算法易受选择密文攻击(CCA)。**注意,选择密文攻击是只能获得部分密文的明文!**进行CCA攻击时,攻击者选择一些密文,并获得相应的明文,这些明文是利用目标对象的私钥解密获得的。因此,攻击者可以选择一个明文,运用目标对象的公钥加密,然后再用目标对象的私钥解密而取回明文。显然,这么做并没有给攻击者任何新的信息。可是攻击者可以利用RSA的性质,选择数据块使得当用目标对象的私钥处理时,产生密码分析所需要的信息。

例如利用CCA可以解密C = Me mod n

Step1: 计算X = (C * 2e) mod n
Step2:

Timing Attacks

这种攻击是通过计时来求得的。把数组当作二进制来看的话,因为在计算模乘运算的时候如果该位置是1,时间上比0要慢,通过这种方法来模拟出ciphertext。

常见的解决方法有:
• Constant time: One way is to make sure that your algorithm takes a
constant time for all inputs. This approach requires you to estimate the
longest delay in advance and use appropriate idle time when results take
less than the worst case time. However, this method may still leak power
profile. In general performance decreases in efficiency. 不管输入多长,输出的时间保持一致

• Random delay: You will add a random delay to algorithm execution to
ensures that the relationship between key and the execution time is
uncorrelated. 给定计算时候一个随机延迟,让攻击者计时不问

• Blinding: You can use the blinding technique introduced earlier. With this,
the algorithm takes a random amount time and assures that the relationship
between key and the execution time is uncorrelated.通过blinding的方法让计算模运算前先乘上一个随机数,打乱计算时间

Week 6- Hash Functions

Introduction

It’s different from what we used in program language. In general, the function takes a variable-length data block as input and produces a fixed
length tag or digest satisfying certain properties.将任意长度的输入输出成相同长度或者满足特定属性

The main objective is to obtain data integrity.

• It is referred as unkeyed primitive as does not require any key.

• As assumed in the other cryptographic functions, the definition of Hash function is also public.

• Hash is also referred to as message digest.

Integrity for Hash Function

Modification Detection Codes (MDC).
• The function Hash has a property that a small change in the message introduces unpredictable changes in the hash value, h = Hash (M).意思就是相差很小的两个值经过hash function也会有巨大的变化

• If a message is changed while in transit, then running Hash function at the received message tells you how the value is deviated from the hash value computed at the source, thus assuring integrity with high probability.所以如果用hash function作为签名的话,可以判断消息是否被篡改

Modification of Attacker (Active Setting)

[密码学复习]Cryptography_第21张图片
攻击者Malice整个修改信息,把M变成M’,并且用M’生成签名的话,Bob会以为A发的消息其实是M’
注意一点,Hash Function是没有authentication的,因为他是totally public的!

解决上述问题的一些方法

[密码学复习]Cryptography_第22张图片

  1. 使用对称加密算法对(Message, H(Message))同时加密
  2. 只对H(Message)进行对称加密
  3. 不使用加密算法,而是要求双方同时拥有一个共享秘密值S,对S和Message一起用Hash,H(M || S),从而起到验证的效果
  4. 在3的基础上,对整个信息加密E(Key, [M || H(M || S)]),这样做可以在3的基础上增加保密性。

Comparison:
方案b比起a,d 需要计算的量比较少,这里给出几个方案b的优点:

  1. 加密软件速度慢 2. 加密硬件成本高 3. 加密硬件一般是针对大数据做的优化,因此针对小数据的话大部分时间会浪费在初始化和调用上 4.加密算法可能需要支付专利费

Digital Signature

[密码学复习]Cryptography_第23张图片
图(a),签名不再是像简单RSA那样直接用PR对M进行加密生成,而是用PR对H(M)加密生成
图(b), 则是在图A基础上再对整个消息用公钥进行一次加密,加强保密性

Hash Function Requirement

**最主要三大安全特性:PR (Preimage Resistance), 2nd PR (Second Preimage Resistance), CR (Collision Resistance): **
[密码学复习]Cryptography_第24张图片
[密码学复习]Cryptography_第25张图片
[密码学复习]Cryptography_第26张图片

Attacks on Hash Function

The function should resist brute-force attacks and regular cryptanalysis.
中文论证请参考教材p246-247
brute-force attacks:
• Attack against PR: Given a random hash value, determine y such that H(y)
equals to the hash value. 假设hash长度为m,那么尝试次数为2m-1

• Attack against CR(使用了Birthday attack theory): The task is to determine any two messages whose hashes are same, i.e determine x, y such that H(x) = H(y). 假设hash长度为m,那么尝试次数为2m/2

[密码学复习]Cryptography_第27张图片

Message Authentication(我们一直以来探讨的问题)

Let us look at message authentication issue in practice.

• What is it concerned with?

– To address message authentication

– A dedicated primitive based on symmetric key cryptography

• Issues for message authentication
– Message integrity

– Validation of originator’s identity

– Non-repudiation of the message origin

• Three ways of achieving authentication

– Message Encryption

– Hash functions (we looked at it in the previous lecture)

– Message Authentication Code (MAC) (this lecture)

Security Requirement

[密码学复习]Cryptography_第28张图片
– disclosure

– traffic analysis

– masquerade

– content modification

– sequence modification

– timing modification

– source repudiation

– destination repudiation

MAC(Message Authentication Codes)

• So formally, MAC is a dedicated symmetric key primitive aimed at providing authentication.

• With encryption it can be easily integrated to provide secrecy also.

• They are useful when in some applications you only need authentication.

• There are many situation where the property of authentication requires longer than confidentiality: authenticated sessions where only at times you may exchange secret information.

• MAC is different to Signatures, MAC has many properties similar to Hash.

Properties:
• mac:= MAC(Key, message).

• You can treat it as a cryptographic checksum/digest: It takes a arbitrary
length message as input and outputs a fixed length authenticator using a
key.

• Like hash functions, it is many-to-one function with Preimage resistance
(PR).

• For every key, it satisfies hash function properties.

• So sometimes, MAC is referred to as a family of Hash functions.

首先明确一点,MAC一般也是用来做authentication的。MAC需要发送方A和接收方B共享一个密钥,使用专有的MAC Function- C(…)来创建MAC,

方程式形如:MAC = C(K, M)

MAC- Message Authentication Codes, C- MAC Function, K- Secret Key, M- Message, 在slides上,写作F(M),MAC Function变成F,且少了Key


MAC函数与加密方法类似,但是最大的区别是MAC函数要求不可逆,也就是知道MAC也不知道明文,加密算法则是可以解密的。所以MAC采用的是映射多对一的情况。也就是说多个明文对应一个MAC。但是MAC的基数要求足够大,这样子的话attacker也做不到轻易破解。


常用的方法如下:

  1. 直接加一个MAC(这种方法基本不用,因为明文都是直接暴露的)
  2. 对M, MAC在进行一次对称加密,也被叫做Internal Error Control
  3. 明文部分用对称加密加密,MAC=对用对称加密的密文再进行一次MAC加密得到MAC,也被叫做External Error Control

    [密码学复习]Cryptography_第29张图片

Attack on MAC

• Brute-force attack: Here the objective is to find a collision.

• For cryptanalysis, there are two approaches:

• Attacker may first determine the key, then he can produce MAC value for any message.

• Sometimes, he may just try to determine a valid tag for a given message.

• Similar to Hash functions, you realize that MAC has to have a certain length to defeat brute-force attacks.

• In general you try to create new MAC functions using existing Hash functions.

Week 7- Key Management

Key Management的介绍
[密码学复习]Cryptography_第30张图片

NS介绍
[密码学复习]Cryptography_第31张图片
[密码学复习]Cryptography_第32张图片

Week 8- Public Key Distribution

Stallings discusses four important methods:

– Through Public announcement

– By Using publicly available directory

– With Public-key authority

– Using Public-key certificates

Public announcement(Uncontrilled Public Key Distribution)

[密码学复习]Cryptography_第33张图片
这种分法方式就是直接让个人无控制的向外分法自己的Public Key,谁请求都发。这样子做有一个最大的问题就是所有人都可以获得A的PU,因此别人可以冒充A,向别人发送PUa,直到A发现冒充者并且广播通知其他人之前,冒充者都可以获取本应该向A发送的加密文件,甚至可以用伪造的密钥进行认证

By Using publicly available directory

[密码学复习]Cryptography_第34张图片
A directory service is established, each user contacts the directory through secure methods and places his public address to be downloaded by other users. 公钥目录通过{名字,PU}的键值对方式保存

Each user can update his public key and details. Because public key has been used for multiple times or private key is leaked.

Security is better than the previous method, but still vulnerable. 如果攻击者获取到了目录管理者的密钥,那么他可以假冒任何通讯方。此外还有一种攻击方式是通过修改目录管理员记录来窃取发送给通信方的数据。

With Public-key authority

This method is a further improvement to the directory service. It has following properties:

• The authority server is always online with tight control over the distribution and maintenance of keys.

• Authority also has a public and private key:

• Users will contact the authority whenever they need key service.

• Issues:

– Server needs to be online always.

– Still there is a possibility of tampering and attacks. 最大的问题就是怕目录记录被篡改
[密码学复习]Cryptography_第35张图片
(1) A发送一条带有时间戳的消息给公钥管理员,以请求B的当前公钥。

(2) 管理员给A发送一条用其私钥PRaulh加密的消息,这样A就可用管理员的公钥对接收到的消息解密,因此A可以确信该消息来自管理员。这条消息包含以下内容:

• B的公钥PUA,A用来加密发给B的消息。

•原始请求,这样A可以将该请求与其最初发出的请求进行比较,以确保在管理员收到请求之前,其原始请求未被修改。

•原先的时间戳,A可以确定它收到的不是来自管理员的旧消息。

(3) 存储B的公钥,并用它去加密包含A的身份标志符ID,和临时交互号N1的消息发送给B,
其中N1为该次交互的唯一标志。

(4, 5)与A检索B的公钥一样,B使用同样的方法从管理员处得到A的公钥。

此时,公钥已被安全地传递给A和B,A、B之间的信息交换将会受到保护,尽管如此,最好
还包含以下两步:

(6) B用A的公钥PUa加密包含A的临时交互号N1,和B新产生的临时交互号N2的消息,并发送给A。因为只有B能解密消息(3),所以消息(6)中的N1可以使A确信该消息来自于B。

(7) A用B的公钥加密包含N2的消息给B,这样B就可以知道该消息来自于A。

这样,总共需要7条消息,然而,前面的4条消息不会被频繁使用,因为A、B可以存储彼此
的公钥以备将来之需。用户需要周期性的请求当前公钥信息,以保证通信中使用的是当前的
公钥。

Using Public-key certificates

这种方法是最复杂的一种,和上述都有点不太一样。
[密码学复习]Cryptography_第36张图片
首先A和B使用自己的公钥发送给Certificate Authority,这个权威机构一般是政府或者金融部门的机构,并且发送过程严谨且安全。之后权威机构返回给他们各自的Certification = E(PRauth, [T || ID || PU])。这里是用权威机构的私钥去加密,里面包含了一个时间戳(作用是告知证书过期时间,如果过期了就说明这是个废的,哪怕有人盗取也无所谓),发送者的ID标识,发送者的PU。然后两方交互的时候使用权威机构的PU进行解密,因此安全性也很强。

Advantages

最大的优点就是可以通过使用权威机构的公钥来进行验证判断消息是否valid

X.509 Certificate

 Version

 Serial number

 Signature algorithm identifier

 Issuer name

 Period of validity

 Subject name

 Subject’s public- key information

 Issuer unique identifier

 Subject unique identifier

 Extensions

 Signature

The standard notation for a certificate of:

CA<< A >> = CA {V, SN, AI, CA, UCA, A, UA, Ap, TA}.

• with the meaning CA signs the certificate for user A with its private key.
[密码学复习]Cryptography_第37张图片

Week 9- ElGamal Signature

理解一下概念:素根

取一个数n,对于n来说所有跟他相对互质的数有一个集合S。假设存在一个数a,如果ax mod n(0 [密码学复习]Cryptography_第38张图片

An essential idea

• Idea:If x’= (x1+ x2) mod (q-1), (ax1) and (ax2) are given by a user, without revealing x1 and x2,

• then this can be verified by checking the following equation

• ax’ = (ax1) (ax2) mod (q)

• Note that , only the person who knows x1 and x2 could have
constructed this sequence: x’ , (ax1) and (ax2).

• Next, we give the ElGamal Signature idea.

ElGamal

注意本章主要内容是使用私钥进行加密,公钥进行解密,因为是签名。这一部应该是告知B,A收到了吧,不然B怎么会有m?

计算过程

  1. 根据题目选择q, α, m(m = H(M)),并随机选择1 < XA < q-1
  2. 计算YA = aXA mod q
  3. 公布public part {q, a, YA},private part为XA
  4. B方随机选择一个K,这个K需要relative prime to q-1,并且计算K-1K mod q-1 = 1
  5. 计算S1 = aK mod q, S2 = K-1(m - XAS1) mod q-1,现在就有了签名消息{S1, S2}
  6. Verification: V1 = am mod q
  7. V2 = (YA)S1 * (S1)S2 mod q
  8. V1=V1 valid
    [密码学复习]Cryptography_第39张图片

B传输信息给A:
[密码学复习]Cryptography_第40张图片

Week 11- User Authentication

知识点

  • Remote User-Authentication principles
  • Means of Authentication
  • Mutual Authentication Protocols
  • Replay Attacks. – Protocols Remote User Authentication
    • Needham-Schroeder (NS) Protocol
    • Denning’s modification
    • Neuman’s modifications

1. Remote User-Authentication principles

Authentication is a fundamental building block of a networkbased computer systems. And there are 2 important steps.

1.1 Identification step: Presenting an identifier to the security system.

(Identifiers should be assigned carefully, because authenticated
identities are the basis for other security services, such as access
control service.)

1.2 Verification step: Presenting or generating authentication

information that corroborates the binding between the entity and the
identifier.

• Note that user authentication is different from message authentication.

Example: user ID and password;

4 Means of Authentication

  • Something the individual knows: Examples:a password, a personal
    identification number (PIN), or answers to a prearranged set of questions.
    知道什么,如口令,PIN
  • Something the individual possesses: Examples: cryptographic keys,
    electronic keycards, smart cards, and physical keys. This type of
    authenticator is referred to as a token. 拥有什么:如私钥,电子密码卡
  • Something the individual is (static biometrics): Examples: Recognition
    by fingerprint, retina, and face. 静态生物特征:如指纹,视网膜,脸
  • Something the individual does (dynamic biometrics): Examples:
    recognition by voice pattern, handwriting characteristics, and typing
    rhythm. 动态生物特征:如声音,手写特征

2 types protocols: One-way/ Mutual

Main problem that these protocols solve is to address the two important issues:

  1. Confidentiality: the exchanged session keys are protected.
  2. Timeliness(合时): Ensure that the exchange is current and prevent replay attacks.

Mutual Authentication

Timeliness

  • Important because of the threat of message replays
  • Such replays could allow an opponent to:
    • compromise a session key
    • successfully impersonate another party
    • disrupt operations by presenting parties with messages that appear genuine but are not

Confidentiality

  • Essential identification and session-key information must be communicated in encrypted form
  • This requires the prior existence of secret or public keys that can be used for this purpose

Replay Attack

  1. copies a message and replays it later
  2. An opponent can replay a timestamped message within the valid time
    window
  3. An opponent can replay a timestamped message within the valid time
    window, but in addition, the opponent suppresses the original
    message; thus, the repetition cannot be detected
  4. Another attack involves a backward replay without modification and
    is possible if symmetric encryption is used and the sender cannot easily recognize the difference between messages sent and messages received on the basis of content

[密码学复习]Cryptography_第41张图片

Countermeasure

  1. Attach a sequence number to each message used in an authentication
    exchange

    – A new message is accepted only if its sequence number is in the proper order

    – Difficulty with this approach is that it requires each party to keep track of the last sequence number for each claimant it has dealt with

    Generally not used for authentication and key exchange because of overhead

  2. Timestamps

    – Requires that clocks among the various participants be synchronized

    – Party A accepts a message as fresh only if the message contains a timestamp that, in A’s
    judgment, is close enough to A’s knowledge of current time

  3. Challenge/response

    – Party A, expecting a fresh message from B, first sends B a nonce (challenge) and
    requires that the subsequent message (response) received from B contain the correct
    nonce value
    [密码学复习]Cryptography_第42张图片

One-way

  • Email application also uses encryption.
  • Email: Sender and Receiver need not be online at the same time.

    – The envelope or header must be in clear for the protocol to work over public networks.

    – Uses SMTP or X.400. Encryption should ensure that main handling systems cannot obtain decryption keys.

    – Recipient requires an authentication of the message source.

简单的复习- Needham-Schroeder(NS) Protocol of Key Distribution

[密码学复习]Cryptography_第43张图片

NS改进的方法

密钥Ka, Kb分别是 A、B与KDC所共享的主密钥,协议的目的是安全地将会话密钥K分发给A和B。步骤(2) A安全地收到会话密钥,步骤(3)的消息只能由B解密,步骤(4)反映了 B的收到的Ks,步骤(5)使B明确了自己与A拥有相同的会话密钥,且临时交互号N2保证B得到的消息是最新的。回顾第14章,步骤(4)和步骤(5)的目的是阻止特定类型的重放攻击。需要指出
的是敌手捕获步骤(3)的消息并重放它,将会在某些方式上打乱B的操作。
尽管有步骤(4)和步骤(5),该协议还是很容易受到一种形式的重放攻击。假设对手X已知之前的会话密钥,虽然这比对手简单地观察和记录步骤(3)更难发生,但这是一个安全隐患。除非B无限期地记得所有之前和A会话使用过的会话密钥,否则B就不能确定这是一个重放攻击。如果X能截获步骤(4)的握手消息,他就能伪造步骤(5) A的回复并将其发送给B, 而B却认为该消息来A于A且用已认证的会话密钥的加密。

Denning NS

[密码学复习]Cryptography_第44张图片
这种策略的最大的问题就是时间同步问题。如果时间不同步的情况下, A比B快一点,那么attacker截取了再发给B,刚好也满足时效性,这样的情况下的攻击就被称为抑制重放攻击(Suppress Replay Attack)

一种解决策略是强制A, B和KDC时钟同步,但是有的时候会难以做到,那么第二种方法就是Neuman 93 Modification

Neuman 93 Modification

[密码学复习]Cryptography_第45张图片

SSL

  • Secure Socket layer protocol uses Transport Later features of Modern Internet.
  • The main idea is to create a transport session between two nodes and then exchange a session key using a protocol similar to the Hybrid protocol.
  • Session key is used in the symmetric key encryption.
  • So, a Transport Layer Security (TLS) used two important concepts:
    • Connection between a client and a server
    • Session associated with the connection.
  • They use OSI layering model protocols for realizing the above concepts.

你可能感兴趣的:(密码学)