Docsity

Computer Security Midterm Exam Cheat Sheet, Quizzes of Cybersecurity

Toggle sidebar
bg1
CSc466/566 Computer Security
Midterm Exam Cheat-Sheet
Christian Collberg
Mon Mar 19, 2012
A Cheat-Sheet
A.1 Modular Arithmetic
(a+b) mod n= ((amod n) + (bmod n)) mod n
(a−b) mod n= ((amod n)−(bmod n)) mod n
(a∗b) mod n= ((amod n)∗(bmod n)) mod n
xymod n=
y
z}| {
x∗x∗ · ·· ∗ xmodn
A.2 Exponents/Powers
xaxb=x(a+b)
xaya= (xy)a
(xa)b=x(ab)
x(a
b)=b
√xa
x(a−b)=xa
xb
x−a=1
xa
A.3 Logarithms
y= logb(x) iff x=by
logb(1) = 0
logb(b) = 1
logb(xy) = logb(x) + logb(y)
logbx
y= logb(x)−logb(y)
logb(xn) = nlogb(x)
logb(x) = logb(c) logc(x) = logc(x)
logc(b)
A.4 Basic Theorems
Theorem 1 (Euler) Let xbe any positive in-
teger that’s relatively prime to the integer n > 0,
then xφ(n)mod n= 1.
Theorem 2 (Corollary to Euler’s theorem)
Let xbe any positive integer that’s relatively
prime to the integer n > 0, and let kbe any posi-
tive integer, then xkmod n=xkmod φ(n)mod n.
Theorem 3 (Bezout’s identity) Given any
integers aand b, not both zero, there exist in-
tegers iand jsuch that GCD(a, b) = ia +jb.
Theorem 4 (Corollary to Euler’s theorem)
Given two prime numbers pand q, integers
n=pq and 0< m < n, and an arbi-
trary integer k, then mkφ(n)+1 mod n=
mk(p−1)(q−1)+1 mod n=mmod n.
Theorem 5 (Fermat’s Little Theorem)
Let pbe a prime number and gany positive
integer g < p, then gp−1mod p= 1.
A.5 GCD
f un c g cd ( i n t a, i n t b) : ( i n t , i n t , i n t ) =
i f b= 0 th en
r e t u r n (a, 1,0)
q← ⌊a/b⌋
(d, k, l)←gcd(b, a mod b)
r e t u r n (d, l, k −lq)
•Use GCD to compute modular multiplica-
tive inverses. Given x < n, we want to
compute y=x−1mod n, i.e. yx mod n=
1
pf3

Partial preview of the text

Download Computer Security Midterm Exam Cheat Sheet and more Quizzes Cybersecurity in PDF only on Docsity!

CSc466/566 Computer Security

Midterm Exam Cheat-Sheet

Christian Collberg

Mon Mar 19, 2012

A Cheat-Sheet

A.1 Modular Arithmetic

(a + b) mod n = ((a mod n) + (b mod n)) mod n

(a − b) mod n = ((a mod n) − (b mod n)) mod n

(a ∗ b) mod n = ((a mod n) ∗ (b mod n)) mod n

xy^ mod n =

y ︷ ︸︸ ︷ x ∗ x ∗ · · · ∗ x modn

A.2 Exponents/Powers

xaxb^ = x(a+b) xaya^ = (xy)a (xa)b^ = x(ab) x(^

a b ) = b

xa

x(a−b)^ = xa xb x−a^ =

xa

A.3 Logarithms

y = logb (x) iffx = by logb (1) = 0 logb (b) = 1 logb (xy) = logb (x) + logb (y)

logb

x y

= logb (x) − logb (y)

logb (xn) = n logb (x)

logb (x) = logb (c) logc (x) =

logc (x) logc (b)

A.4 Basic Theorems

Theorem 1 (Euler) Let x be any positive in- teger that’s relatively prime to the integer n > 0 , then xφ(n)^ mod n = 1.

Theorem 2 (Corollary to Euler’s theorem) Let x be any positive integer that’s relatively prime to the integer n > 0 , and let k be any posi- tive integer, then xk^ mod n = xk^ mod^ φ(n)^ mod n.

Theorem 3 (Bezout’s identity) Given any integers a and b, not both zero, there exist in- tegers i and j such that GCD(a, b) = ia + jb.

Theorem 4 (Corollary to Euler’s theorem) Given two prime numbers p and q, integers n = pq and 0 < m < n, and an arbi- trary integer k, then mkφ(n)+1^ mod n = mk(p−1)(q−1)+1^ mod n = m mod n.

Theorem 5 (Fermat’s Little Theorem) Let p be a prime number and g any positive integer g < p, then gp−^1 mod p = 1.

A.5 GCD

f u n c gcd ( i n t a , i n t b ) : ( i n t , i n t , i n t ) = i f b = 0 then r e t u r n (a, 1 , 0) q ← ⌊a/b⌋ (d, k, l) ← gcd(b, a mod b) r e t u r n (d, l, k − lq)

  • Use GCD to compute modular multiplica- tive inverses. Given x < n, we want to compute y = x−^1 mod n, i.e. yx mod n =
  1. The inverse of x in Zn exists when GCD(n, x) = 1.
  • Calculate GCD(n, x) = (1, i, j) such that 1 = ix + jn. Then (ix + jn) mod n = ix mod n = 1 and i is x’s multiplicative in- verse in Zn.

A.6 RSA

  • Bob (Key generation):
    1. Generate two large random primes p and q.
    2. Compute n = pq.
    3. Select a small odd integer e relatively prime with φ(n).
    4. Compute φ(n) = (p − 1)(q − 1).
    5. Compute d = e−^1 mod φ(n).
      • PB = (e, n) is Bob’s RSA public key.
      • SB = (d, n) is Bob’ RSA private key.
  • Alice (encrypt and send a message M to Bob): 1. Get Bob’s public key PB = (e, n). 2. Compute C = M e^ mod n.
  • Bob (decrypt a message C received from Al- ice): 1. Compute M = Cd^ mod n.

A.7 Diffie-Hellman Key Exchange

  1. All parties (set-up): (a) Pick p, a prime number. (b) Pick g, a generator for Zp.
  2. Alice: (a) Pick a random x ∈ Zp, x > 0. (b) Compute X = gx^ mod p. (c) Send X to Bob.
  3. Bob: (a) Pick a random y ∈ Zp, x > 0. (b) Compute Y = gy^ mod p. (c) Send Y to Alice
  4. Alice computes the secret: K 1 = Y x^ mod p.
  5. Bob computes the secret: K 2 = Xy^ mod p.

A.8 Elgamal Encryption

  • Bob (Key generation):
    1. Pick a prime p.
    2. Find a generator g for Zp.
    3. Pick a random number x between 1 and p − 2.
    4. Compute y = gx^ mod p.
      • PB = (p, g, y) is Bob’s RSA public key.
      • SB = x is Bob’ RSA private key.
  • Alice (encrypt and send a message M to Bob): 1. Get Bob’s public key PB = (p, g, y). 2. Pick a random number k between 1 and p − 2. 3. Compute the ciphertext C = (a, b):

a = gk^ mod p b = M yk^ mod p

  • Bob (decrypt a message C = (a, b) received from Alice): 1. Compute M = b(ax)−^1 mod p.

A.9 RSA Signature Scheme

  • Bob (Key generation): As before.
    • PB = (e, n) is Bob’s RSA public key.
    • SB = (d, n) is Bob’ RSA private key.
  • Bob (sign a secret message M ):
    1. Compute S = M d^ mod n.
    2. Send M, S to Alice.
  • Alice (verify signature S received from Bob): 1. Receive M, S from Alice. 2. Verify that M =? Se^ mod n.

A.10 Elgamal Signature Scheme

  • Alice (Key generation): As before.
    1. Pick a prime p.
    2. Find a generator g for Zp.
    3. Pick a random number x between 1 and p − 2.