ACS Material 2
ACS Material 2
x and y are integers modulo q, but e is not less than q. So, this transcript is not correct.
x and y are integers modulo q, and e is less than q. This transcript satisfies the conditions and
could be a correctly performed execution.
So, the correct transcript is (15, 10, 27) if e is correctly calculated using the hash function, and it's
less than q.
State the ELGamal Digital signature scheme and find out the public and private key for the
given values and verify the signature
Prime field GF (19); XA =16, K=5, m=14, α = 10
Primitive roots {2, 3, 10, 13, 14, 15}
Interpret how is it possible to use a hash function to construct a block cipher with a
structure similar to DES. Because a hash function is one way and a block cipher must be
reversible to decrypt. Explain in detail.
Constructing a Block Cipher with Hash Functions
To build a block cipher using a hash function, we can employ a structure that uses the hash
function in a reversible scheme. Here's a detailed breakdown of how this can be conceptualized:
Illustrate how the operation for SHA would be carried out on a little-endian machine. SHA
is designed to work with a big-endian byte order. Explain in detail.
Steps to Carry Out SHA on a Little-Endian Machine
Step 1: Convert Input to Big-Endian Format
When data is read from a little-endian machine, it must be converted to big-endian format before
processing:
Byte Reordering: For every multi-byte integer in the input (e.g., 32-bit words), the bytes need to
be reversed. For example, if the data is stored as 0x12 0x34 0x56 0x78 in little-endian, it should
be interpreted as 0x78 0x56 0x34 0x12 in big-endian.
Step 2: Padding the Message
Add a '1' Bit: Append a single '1' bit to the end of the message.
Add '0' Bits: Fill the rest of the block with '0' bits until the total length is 448 bits (or 56 bytes).
Append Length: Finally, append the length of the original message (in bits) as a 64-bit big-endian
integer.
This length is represented in big-endian, so if the length in little-endian was 0xAABBCCDD, you
must store it as 0xDDCCBBAA.
Step 3: Process Each 512-bit Block
Divide into 32-bit Words: Split the 512 bits into sixteen 32-bit words. After the byte order
adjustment, ensure these words are treated as big-endian.
Expand to 64 Words: The SHA algorithm requires 64 words. Use the message schedule to expand
the original 16 words into 64 words by applying bitwise operations and rotations.
Step 4: Initialize Hash Values
The initial hash values must also be set in big-endian. If they are stored as 0x67452301 in little-
endian, it must be reversed to 0x01234567 for use.
Step 5: Execute the Main Loop
In the main processing loop:
Use the big-endian words directly for all operations. Ensure that any multi-byte operations (e.g.,
additions, logical operations) consider the values as big-endian. This might involve reinterpreting
data as needed.
Step 6: Finalize the Hash Value
Once all blocks are processed, the final hash value is obtained from the hash values maintained
throughout processing, which also must be represented in big-endian format.
In summary, when implementing SHA on a little-endian machine, you need to:
Convert the input data and the length representation to big-endian format.
Ensure all operations treat the data as big-endian throughout processing, particularly during the
expansion and the main loop.
Illustrate how arbitrated digital signatures schemes can be used to overcome the problem
associated with the direct digital signature.
Arbitrated Digital Signatures
The problem associated with the Direct digital signature can be overcome by using arbitrated
schemes.
In the arbitrated scheme, the entire signed message from the sender goes to the arbiter A. The
arbiter subjects the message and signature to a number of tests to check the origin and control.
The date and time is attached to the message. This indicates that the digital signature has been
verified and is satisfied. The message is then transmitted to the receiver.
Requirement of the arbiter:
As the arbiter plays a sensitive and crucial role, it should be a trusted third party.
Notation:X = Sender Y = Recipient A = Arbiter M=Message T=Timestamp
Scheme 1: Conventional encryption, Arbiter sees the message:
The sender X and arbiter A share the master key Kax the receiver y and the arbiter A share
the master key Kay
When X wants to send a message M to Y, construct a message computes the hash value
H(M). This hash is encrypted using symmetric encryption with the key Kax which acts as
signature. The message along with the signature is transmitted to A.
At A, it decrypts the signature and checks the hash value to validate the message. A
transmit the message to Y, encrypted with Kay. Y decrypt to extract the message and signature.
Disadvantage:
Eaves dropper can read the message as there is no confidentiality.
Scheme 2: Conventional encryption, Arbiter does not see the message:
Kax and Kay are the master keys.
Kxy is the key shared between the X and Y
When x wants to transmit a message to Y, the packet goes to arbiter.
The same procedure as that of I scheme is used X transmit an identifier, a copy of the message
encrypted with Kxy and a signature to A.
The signature is the hash of the message encrypted with Kxa
A decrypt the signature, and checks the hash value to validate the message.
A cannot read the message, A attaches to it the time stamps, encrypt with Kxa and transmit to Y.
Attack: The arbiter can join with an attacker and deny a message with sender’s signature.
Scheme 3: Public key encryption, Arbiter does not see the message:
This method uses the public key cryptography which gives authentication and digital signature.
The doubly encrypted message is concatenated with IDx and sent to arbiter.
A can decrypt the outer encryption to ensure that the message has come from X.
A then transmit the message with IDx and time stamp.
Advantages:
No information is shared among parties before communication, hence fraud is avoided.
No incorrectly dated message can be sent.
Disadvantages:
The complex public key algorithm is to be twice for encryption and twice for decryption.
Secure: A network eavesdropper should not be able to obtain the necessary information to
impersonate a user. More generally, Kerberos should be strong enough that a potential
opponent does not find it to be the weak link.
Reliable: For all services that rely on Kerberos for access control, lack of availability of
the Kerberos service means lack of availability of the supported services. Hence, Kerberos
should be highly reliable and should employ distributed server architecture, with one
system able to back up another.
Transparent: Ideally, the user should not be aware that authentication is taking place,
beyond the requirement to enter a password.
Scalable: The system should be capable of supporting large numbers of clients and servers.
This suggests a modular, distributed architecture.
To support these requirements, the overall scheme of Kerberos is that of a trusted third-party
authentication service that uses a protocol based on Needham and Schroeder.
It is trusted in the sense that clients and servers trust Kerberos to mediate their mutual
authentication. Assuming the Kerberos protocol is well designed, and then the authentication service is
secure if the Kerberos server itself is secure.
Two versions of Kerberos are in common use. Version 4 and Version 5
Kerberos Version 4
Version 4 of Kerberos makes use of DES, in a rather elaborate protocol, to provide the
authentication service
In an unprotected network environment, any client can apply to any server for service. The
obvious security risk is that of impersonation. To counter this threat, servers must be able to confirm
the identities of clients who request service. But in an open environment, this places a substantial burden
on each server.
An alternative is to use an authentication server (AS) that knows the passwords of all users and
stores these in a centralized database. In addition, the AS shares a unique secret key with each server.
The simple authentication dialogue is as follows:
1. C >> AS: IDc||Pc||IDv
2. AS >> C: Ticket
3. C >> V: IDc||Ticket
Ticket= EKv(IDc||ADc||IDv)
C : Client,
AS : Authentication Server,
V : Server, IDc : ID of the client,
Pc : Password of the client,
ADc : Address of client, IDv : ID of the server,
Kv : secret key shared by AS and V,
|| : concatenation.
4.2.2 A More Secure Authentication Dialogue
There are two major problems associated with the previous approach:
Plaintext transmission of the password.
Each time a user has to enter the password.
To solve these problems, we introduce a scheme for avoiding plaintext passwords, and a new
server, known as ticket granting server (TGS). The hypothetical scenario is as follows:
Once per user logon session:-
1. C >> AS: IDc||IDtgs
2. AS >> C: Ekc (Tickettgs)
The new service, TGS, issues tickets to users who have been authenticated to AS. Thus, the
user first requests a ticket-granting ticket (Tickettgs) from the AS. The client module in the user
workstation saves this ticket.
Each time the user requires access to a new service, the client applies to the TGS, using the
ticket to authenticate itself. The TGS then grants a ticket for the particular service. The client saves each
service-granting ticket and uses it to authenticate its user to a server each time a particular service is
requested.
Let us look at the details of this scheme:
1. The client requests a ticket-granting ticket on behalf of the user by sending its user's ID and
password to the AS, together with the TGS ID, indicating a request to use the TGS service
2. The AS responds with a ticket that is encrypted with a key that is derived from the user's
password.
When this response arrives at the client, the client prompts the user for his or her password,
generates the key, and attempts to decrypt the incoming message.
If the correct password is supplied, the ticket is successfully recovered.
Because only the correct user should know the password, only the correct user can recover the
ticket. Thus, we have used the password to obtain credentials from Kerberos without having to transmit
the password in plaintext. Now that the client has a ticket-granting ticket, access to any server can be
obtained with steps 3 and 4:
3. The client requests a service-granting ticket on behalf of the user. For this purpose, the client
transmits a message to the TGS containing the user's ID, the ID of the desired service, and the
ticket-granting ticket
4. The TGS decrypts the incoming ticket and verifies the success of the decryption by the presence
of its ID. It checks to make sure that the lifetime has not expired. Then it compares the user ID
and network address with the incoming information to authenticate the user. If the user is
permitted access to the server V, the TGS issues a ticket to grant access to the requested service.
The service-granting ticket has the same structure as the ticket-granting ticket. Indeed, because
the TGS is a server, we would expect that the same elements are needed to authenticate a client to the
TGS and to authenticate a client to an application server.
Again, the ticket contains a timestamp and lifetime. If the user wants access to the same service
at a later time, the client can simply use the previously acquired service-granting ticket and need not
bother the user for a password.
Note that the ticket is encrypted with a secret key (Kv) known only to the TGS and the server,
preventing alteration.
Finally, with a particular service-granting ticket, the client can gain access to the corresponding
service with step 5:
5. The client requests access to a service on behalf of the user. For this purpose, the client transmits
a message to the server containing the user's ID and the service-granting ticket. The server
authenticates by using the contents of the ticket.
This new scenario satisfies the two requirements of only one password query per user session
and protection of the user password.
Lifetime associated with the ticket granting ticket. If the lifetime is very short, then the
user will be repeatedly asked for a password. If the lifetime is long, then the opponent
has the greater opportunity for replay.
SHA
The algorithm takes as input a message with a maximum length of less than bits and produces
as output a 512-bit message digest. The input is processed in 1024-bit blocks. Figure 3.8 depicts the
overall processing of a message to produce a digest.
The message is padded so that its length is congruent to 896 modulo 1024. Padding is always
added, even if the message is already of the desired length. Thus, the number of padding bits is in the
range of 1 to 1024. The padding consists of a single 1 bit followed by the necessary number of 0 bits.
A block of 128 bits is appended to the message. This block is treated as an unsigned 128-bit
integer (most significant byte first) and contains the length of the original message (before the padding).
The outcome of the first two steps yields a message that is an integer multiple of 1024 bits in
length. In Figure 3,8 , the expanded message is represented as the sequence of 1024-bit blocks M1, M2,
……….. MN , so that the total length of the expanded message is NX1024 bits.
A 512-bit buffer is used to hold intermediate and final results of the hash function.The buffer
can be represented as eight 64-bit registers (a, b, c, d, e, f, g, h).These registers are initialized to the
following 64-bit integers (hexadecimal values):
a = 6A09E667F3BCC908 e = 510E527FADE682D1
b = BB67AE8584CAA73B f = 9B05688C2B3E6C1F
c = 3C6EF372FE94F82B g = 1F83D9ABFB41BD6B
d = A54FF53A5F1D36F1 h = 5BE0CD19137E2179
These values are stored in big-endian format, which is the most significant byte of a word in the low-
address (leftmost) byte position. These words were obtained by taking the first sixty-four bits of the
fractional parts of the square roots of the first eight prime numbers.
The heart of the algorithm (Fig 3.9) is a module that consists of 80 rounds; Each round takes as
input the 512-bit buffer value, abcdefgh, and updates the contents of the buffer. At input to the first
round, the buffer has the value of the intermediate hash value,Hi-1
Each round makes use of a 64-bit value Wt, derived from the current 1024-bit block (Mi) being
processed .These values are derived using a message schedule described subsequently.
Each round also makes use of an additive constant kt, where 0<=t<=79 indicates one of the 80
rounds.
The output of the eightieth round is added to the input to the first round (Hi-1) to produce Hi.The
addition is done independently for each of the eight words in the buffer with each of the corresponding
words in Hi-1, using addition modulo 264 .
Step 5: Output.
After all N 1024-bit blocks have been processed, the output from the Nth stage is the 512-bit message
digest.
H0 = IV
Hi = SUM64 (Hi-1, ABCDEFGHi)
MD = HN
Where
ABCDEq = the output of the last round of processing of the ith message block
SUM32 = Addition modulo 232 performed separately on each word of the pair
of inputs
T1 = h + Ch(e,f,g) + ( e) + Wt + Kt)
T2 = ( a) + Maj(a,b,c)
Where
T = Step number; 0 ≤ t ≤ 79
Ch(e,f,g) = (a AND f) (NOT e AND g)
The conditional function: If e then f else g (Fig 3.10)
Fig 3.10 Elementary SHA Operation(single step)
The functions can be summarized as follows:
For A0 ≤ t ≤ 59 the function is true if two or three of the argument are true.
The following diagram 3.11 illustrates how the 32bit word values wt are derived from the 512 bit
message.
Figure 3.11.Creation of 80-word Input Sequence for SHA-512 Processing of Single Block
The first 16 values of wt are taken directly from the 16 words of the current block.the remaining values
are defined as follows.
Thus in the first 16 steps of processing the values of wt is equal to the corresponding word in the
message block. For the remaining 64 steps the value of wt consists of the circular left shift by one bit
of the XOR of four of the processing values of wt.
Both MD5 and RIPEMD-160 uses one of the 16 words of a message block directly as input to each step
function only the order of the word is permuted from round to round.
SHA-1 expands the 16 block words to 80 words for use in the compression function.
Apply public key system using RSA, to intercept the cipher text C=11 sent to a user whose
public key is e=7, n=187. What is the plain text M?
The steps involved in RSA algorithm for generating the key are
The resulting keys are public key PU = {7, 187} and private key PR = {23, 187}.
The example shows the use of these keys for a plaintext input of M= 88. For encryption, we
need to calculate C = 887 mod 187.
887 mod 187 = [(884 mod 187) × (882 mod 187)× (881 mod 187)] mod 187
881 mod 187 = 88
882 mod 187 = 7744 mod 187 = 77
884 mod 187 = 59,969,536 mod 187 = 132
887 mod 187 = (88 × 77 × 132) mod 187 = 894,432 mod 187 = 11
1123 mod 187 = [(111 mod 187) × (112 mod 187) × (114 mod 187)× (118 mod 187) ×
8
(11 mod 187)] mod 187
111 mod 187 = 11
112 mod 187 = 121
114 mod 187 = 14,641 mod 187 = 55
118 mod 187 = 214,358,881 mod 187 = 33
1123 mod 187 = (11 × 121 × 55 × 33 × 33) mod 187 = 79,720,245 mod 187 = 88
Users Alice and Bob use the Diffie-Hellman key exchange technique with a common
prime q = 83 and a primitive root α = 5.
i) If Alice has a private key XA = 6, what is Alice’s public key YA? (5)
ii) If Bob has a private key XB = 10, what is Bob’s public key YB? (5)
YA = 69
YB = 55
Substituting in the values:
KB= 6910mod 83
The shared secret key calculated by both parties is:
𝐾=23
(Alice’s calculation)
K=23(Alice’s calculation)
𝐾=4
(Bob’s calculation)
K=4(Bob’s calculation)
Alice's public key
𝑌𝐴=69
Bob's public key
𝑌𝐵=55
Shared secret key
𝐾=23
Both the sender and receiver know the value of n. the sender knows the value of e and
only the receiver knows the value of d. thus, this is a public key encryption algorithm with a
public key of KU = {e, n} and a private key of KR = {d, n}. For this algorithm to be satisfactory
for public key encryption, the following requirements must be met:
1. It is possible to find values of e, d, n such that Med = M mod n for all M < n.
2. It is relatively easy to calculate Me and Cd for all values of M < n.
3. It is infeasible to determine d given e and n.
Let us focus on the first requirement. We need to find the relationship of the form:
Med = M mod n
Given two prime numbers p and q and two integers, n and m, such that n=pq and 0<m<n, and
arbitrary integer k, the following relationship holds
where Ф(n) – Euler totient function, which is the number of positive integers less than n and
relatively prime to n. we can achieve the desired relationship, if
ed = kФ(n)+1
This is equivalent to saying:
ed ≡ 1 mod Ф(n)
d = e-1 mod Ф(n)
That is, e and d are multiplicative inverses mod Ф(n). According to the rule of modular
arithmetic, this is true only if d (and therefore e) is relatively prime to Ф(n). Equivalently,
gcd(Ф(n), d) = 1.
We are now ready to state the RSA scheme. The ingredients are the following:
p, q, two prime numbers (private, chosen)
n = pq (public, calculated)
e, with gcd(Ф (n), e) = 1; 1 <e < Ф (n) (public, chosen)
d≡K e-1 (mod Ф (n)) (private, calculated)
The steps involved in RSA algorithm for generating the key are
The resulting keys are public key PU = {7, 187} and private key PR = {23, 187}.
The example shows the use of these keys for a plaintext input of M= 88. For encryption, we
need to calculate C = 887 mod 187.
887 mod 187 = [(884 mod 187) × (882 mod 187)× (881 mod 187)] mod 187
881 mod 187 = 88
882 mod 187 = 7744 mod 187 = 77
884 mod 187 = 59,969,536 mod 187 = 132
887 mod 187 = (88 × 77 × 132) mod 187 = 894,432 mod 187 = 11
1123 mod 187 = [(111 mod 187) × (112 mod 187) × (114 mod 187)× (118 mod 187) ×
8
(11 mod 187)] mod 187
111 mod 187 = 11
112 mod 187 = 121
114 mod 187 = 14,641 mod 187 = 55
118 mod 187 = 214,358,881 mod 187 = 33
1123 mod 187 = (11 × 121 × 55 × 33 × 33) mod 187 = 79,720,245 mod 187 = 88
Explain Diffie Hellman Key Exchange algorithm in detail.
First, we define a primitive root of a prime number p as one whose power generate all
the integers from 1 to (p-1) i.e., if ‘a’ is a primitive root of a prime number p, then the numbers
a mod p, a2 mod p, … ap-1 mod p
are distinct and consists of integers from 1 to (p-1) in some permutation.
For any integer ‘b’ and a primitive root ‘a’ of a prime number ‘p’, we can find a unique
exponent ‘i’ such that
b ≡ ai mod p where 0 ≤ i ≤ (p-1)
The exponent ‘i’ is referred to as discrete logarithm.
The Algorithm
Figure 2.37 summarizes the Diffie-Hellman key exchange algorithm.There are publicly
known numbers: a prime number ‘q’ and an integer α that is primitive root of q. suppose users
A and B wish to exchange a key. User A selects a random integer XA< q and computes YA = α
XA mod q.
Similarly, user B independently selects a random integer XB< q and computes YB = α
XB mod q. Each side keeps the X value private and makes the Y value available publicly to the
other side.
User A computes the key as
The protocol depicted in figure 2.38 is insecure against a man-in-the-middle attack. Suppose
Alice and Bob wish to exchange keys, and Darth is the adversary. The attack proceeds as
follows:
1. Darth prepares for the attack by generating two random private keys XD1 and XD2 and then
computing the corresponding public keys YD1 and YD2.
2. Alice transmits YA to Bob.
3. Darth intercepts YA and transmits YD1 to Bob. Darth also calculates K2 = (YA) XD2 mod q.
4. Bob receives YD1 and calculates K1 = (YD1) XB mod q.
5. Bob transmits XA to Alice.
6. Darth intercepts XA and transmits YD2 to Alice. Darth calculates K1 = (YB) XD1 mod q.
7. Alice receives YD2 and calculates K2 = (YD2) XA mod q.
At this point, Bob and Alice think that they share a secret key, but instead Bob and Darth share
secret key K1 and Alice and Darth share secret key K2. All future communication between Bob
and Alice is compromised in the following way:
1. Alice sends an encrypted message M: E(K2, M).
2. Darth intercepts the encrypted message and decrypts it, to recover M.
3. Darth sends Bob E(K1, M) or E(K1, M'), where M' is any message
Example:
Key exchange is based on the use of the prime number q = 353 and a primitive root of 353, in
this case α = 3. A and B select secret keys XA= 97 and XB= 233, respectively.
Each computes its public key:
A computes YA=397 mod 353 = 40.
B computes YB= 3233 mod 353 = 248.
After they exchange public keys, each can compute the common secret key:
A computes K = (YB)XAmod 353 = 24897 mod 353 = 160.
B computes K = (YA)XBmod 353 = 40 233 mod 353 = 160.
A special addition operation is defined over elliptic curves and with the inclusion of a point
“O” called point at infinity.
If three points are on a line intersecting an elliptic curve, then their sum is equal to this
point at infinity O (which acts as the identity element for this addition operation)
An elliptic group over the Galois Field Ep(a,b) is obtained by computing x3+ax+b mod
p for 0≤ x≤ p. The constants a&b are non-negative integers smaller than the prime number p
must satisfy the condition.
4a3 + 27b2 mod p ≠ 0
For each value of x, one needs to determine whether or not it is a quadratic residue.
If not then the point is not in the elliptic group Ep (a,b)
Let the points P = (x1,y1) and Q = (X2,Y2) be in the elliptic group Ep (a,b) and O be the point at
infinity.
The rules for addition over the elliptic group Ep (a,b) are:
1. P+O = O+P = P
2.If x2 = x1 and y2 = -y1, that is P = (x1,y1) and Q = (X2,Y2) = (x1,-y1) = -P Then P+Q = O
x3 2 x1 x2
and y3 ( x1 x3 ) y1
y2 y1
x x if PQ
2 1
2
3 x1 a if PQ
2 y1
Elliptic Curve Encryption:
Elliptic curve cryptography can be used to encrypt the plain text message M, into
ciphertext. The plain text message M is encoded into a point PM from the finite set of points in
the elliptic group, Ep(a,b).
The first step consists in choosing a generator point, G ε Ep(a, b) , such that the smallest value
of n for which nG = o is a very large prime number.
The elliptic group Ep(a,b) and the generator point G are made public.
Each user select a private key,nA< n and compute the public key PA as PA = nAG
After receiving the ciphertext pair of points, PC, Bob multiplies the firstpoint,(KG) with his
private key nB and then adds the result to the second point in the ciphertext pair of points (PM
+ KPB)
Only Bob knowing the private key nB, can remove nB(KG) from the second point of the
ciphertext pair of point, i.e (PM + KPB), and hence retrieve the plaintext information PM
Explain Public key-distribution with an example.
Advantages:
No keys exist before the start of the communication no key exist after the completion
of communication
Secure from eaves dropping
Disadvatages:
Replay attack
Meet in the middle attack
A generates a public/private key pair {PUa, PRa} and transmits a message intended
for B consisting of PUaand an identifier of A, IDA.
D intercepts the message, creates its own public/private key pair {PUd, PRd} and
transmits PUs 0 0 IDA to B.
B generates a secret key, Ks, and transmits E(PUs, Ks).
D intercepts the message and learns Ks by computing D(PRd, E(PUd, Ks)).
D transmits E(PUa, Ks) to A.