Cryptography: Via DMS: Ankit
Cryptography: Via DMS: Ankit
Cryptography: Via DMS: Ankit
Ankit
:
Applications of functions
via DMS
in cryptography
(Mod/Hash)
Ankit Kumar Amarjeet Kumar
IT-24 IT-19
Ankit
Mod function
Definition,example,some formula,
Hash function
Definitions, key points, Example.
Cryptography
Overlook, caesar cipher,hashing as password
encryption
Conclusion
Mod function simply tell you the
Amarjeet remainder when a no is divided by
divisor so what is remainder.
Note that a remainder cannot be greater
The mighty mod than divisor.
This property is of greater importance
function For ex- 3 mod 2 =1
that helps to concise the outputwe would
see in further slides,
Mod
we define the modulo n function as follows:
If x = qn + r, 0 ≤ r < n, then x mod n = r.
In other words, x mod n is the nonnegative r
emainder (also called the residue of x modu
lo n) when x is divided by the positive integ
er n. This seemingly innocuous function tur
ns up in a surprising number of applications
, some of which will be explored in further s
ections
function
Amarjeet
Clock Arithmetic
Military time uses a 24-hour clock whereas, Standard time uses am
and pm
Mod
he modulo 12 function:
8:00 military time: Compute 8 mod 12 = 8 gives 8:00 am standard time
6:00 military time:Compute 16 mod 12 = 4 gives 4:00 pm standard time
The am or pm designation is determined by whether the quotient in the d
ivision is 0 (am) or 1 (pm). Counting modulo 12 begins at 0 and wraps ar
ound to 0 again when 12 is reached:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3,…
function
These are some of formulas which
would simplify our computations
Amarjeet when dealing with large input.
Some mod operations
(x+y) mod n = (x mod n + y mod n) mod n
(x * y) mod n = {(x mod n * y mod n) mod n}
By above result,
220 mod 6 = (22 mod 6 * 10 mod 6) mod 6
= (4 * 4) mod 6 = 16 mod
6=4
In addition, spreadsheet software usually co
ntains a mod function that speeds up compu
tations.
Hashing
A hash function is a function h: S→ T where the domain S is a set of text strings or in
teger values, and the codomain T is the set of integers {0, 1, …, t − 1
where t is some relatively small positive integer.
Key points
• The function h maps a potentially large set of integer values S into a relatively sm
all window of integer values T.
• Consequently h isn’t likely to be a one-to-one function.Whatever the function h(x)
does to x, the last step is almost always to apply the mod t function so the final val
ue of h(x) falls in the codomain {0, 1, …, t − 1}
Ques S is a set of positive integers, T is the
set of integers (0, … , t − 1)and the hash
function h(x) is given by
h(x) = x mod t
If t = 10, for example,
Sol Then values are computed modulo 10:
h(7) = 7 mod 10 = 0
h(23) = 23 mod 10 = 3
Hashing
h(59) = 59 mod 10 = 9
h(158) = 158 mod 10 = 8
h(48) = 48 mod 10 = 8
Here 158 and 48 hash to the same value
Amarjeet
Computer Security
Towards a safer world
Amarjeet
Computer security
Here, we can see how modulo is used in encrypting and decrypting caesar cipher.
Hashing as a password
encryption
Limitations
Data can be decrypted if you have the right key,
If two users have same passwords,encrypted text would look same.From which it can be concluded that t
hey share same password.
Hashing and Salting Alice's Passwo
Hashing and Salting Bob's
rd
Password
User: Alice User: Bob
Salt: f1nd1ngn3m0
Salt: f1nd1ngd0ry
//we have created 16 words from 512 bits with each word having 32-bit
Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array:
for i from 16 to 63
s0 := (w[i-15] rightrotate 7) xor (w[i-15] rightrotate 18) xor (w[i-15] rightshift 3)
s1 := (w[i- 2] rightrotate 17) xor (w[i- 2] rightrotate 19) xor (w[i- 2] rightshift 10)
w[i] := w[i-16] + s0 + w[i-7] + s1
Initialize working variables to current hash value: Compression function main loop:
for i from 0 to 63
a := h0
S1 := (e rightrotate 6) xor (e rightrotate
b := h1 11) xor (e rightrotate 25)
c := h2 ch := (e and f) xor ((not e) and g)
d := h3
temp1 := h + S1 + ch + k[i] + w[i]
S0 := (a rightrotate 2) xor (a rightrotate
e := h4 13) xor (a rightrotate 22)
f := h5 maj := (a and b) xor (a and c) xor (b
g := h6 and c)
temp2 := S0 + maj
h := h7
h := g
g := f
f := e
e := d + temp1
d := c
c := b
b := a
a := temp1 + temp2
Add the compressed chunk to the current hash value:
h0 := h0 + a
h1 := h1 + b
h2 := h2 + c
h3 := h3 + d
h4 := h4 + e
h5 := h5 + f
h6 := h6 + g
h7 := h7 + h