HMAC
HMAC
HMAC Concept
HMAC Algorithm
If length of K+ = b: In this case, we do not take any action, and proceed to step 2.
If length of K+ > b: we need to trim k, for this, we pass K through the message-
digest algorithm(H) selected for this particular instance of HMAC.
Equation, K+ ⊕ ipad = Si
Equation, K+ ⊕ opad = So
Step – 6: Append H to So
Append the message digest calculated in step 4 to the end of S o.
The selected message-digest algorithm (e.g., MD5, SHA-I, etc.) is applied to the
output of step 6 (i.e. to the concatenation of S o and H). Finally, we got MAC.
Pros:
HMAC is faster to compute and verify digital signatures because they use hash
functions rather than public key.
HMACs can be used in some cases where the use of public key cryptography is
prohibited.
Cons:
Key exchange is main issue, so can’t prevent against replay of message attack.
One of the most widely used MACs is referred to as the Data Authentication
Algorithm. The algorithm is designed using the Cipher Block Chaining mode of
operation of DES, as shown in figure. The data (e.g., message, record, file, or
program) to be authenticated are grouped into fixed size 64-bit blocks: D1, D2,
….., DN. If necessary, the final block is padded on the right with zeroes to make a
64-bit blocks. Using the DES encryption algorithm and a secret key, a data
authentication code (DAC) is calculated as follows:
The DAC consists of either the entire block ON or the leftmost M bits of the block,
with 16 ≤ M ≤ 64.
Data Authentication Algorithm (DAA), which is now obsolete. Then CMAC, which
is designed to overcome the deficiencies of DAA. Cipher-based Message
Authentication Code (CMAC) mode of operation for use with AES and triple DES.
First, let us define the operation of CMAC when the message is an integer
multiple n of the cipher block length b. For AES, b=128, and for triple DES, b=64.
The message is divided into n blocks (M1, M2,…, Mn ).
For AES, the key size is 128, 192, or 256 bits; for triple DES, the key size is 112 or
168 bits. CMAC is calculated as follows:
C1 = E(K, M1)
T = MSBTlen(Cn)
Hash Function
In hash function H accepts a variable length block of input data called as ‘M’ and
produces the fixed size hash value can be represented as h = M(H).
Figure: Block diagram of Hash Function
When hash function provides security, this is called cryptographic hash functions.
Hash function protects the integrity of the message. If encryption process is
applying on message with hash function, it is also providing authentication and
confidentiality.
A hash function provides a property that has function applied on variable amount
of data (M) and then it produces the fixed amount of output data. If any bit or
bits changes in the data, then whole hash function output data will also change.
Cryptographic has function is one-way function, which is practically infeasible to
invert. The most popular hashing algorithm is MD5 and SHA.
MAC
MAC = C (K, M)
Hash value of a message when encrypted with the private key of a user is, his
digital signature on that e-Document. Digital signature is an example of
asymmetric key cryptography which uses three different algorithms to complete
the process.
Step – 1: First step is key generation algorithm which generates private key and
a corresponding public key.
Step – 2: Next step signing algorithm which selects sending message and a
private key generated in step 1, to produce a signature.
1. It must verify the author and the date and time of the signature.
Advantage
Disadvantage
Expiry: In this era of fast technology, many of these tech products have a short
life.
Certificates: In order to effectively use of digital signatures, both senders and
receivers may have to buy digital certificates.
On the basis of the properties just discussed, we can formulate the following
requirements for a digital signature.
The signature must be a bit pattern that depends on the message being
signed.
The signature must use some unique information of the sender to prevent
both forgery and denial.
Security
Non-Repudiation: There are situation where a user sends a message and alter
on refuses that he had sent that message. That is known as non-repudiation
because the person who signed the document cannot repudiate the signature at
a later time.
Now a day’s digital signature techniques are used in many application areas like
sending confidential e-mails, during secure payment transfer and possibly all
software companies, universities, educational institutions those want to achieve
authentication and integrity of their confidential information.
Algorithm
Step-1: Generate a random integer XA, such that 1 < XA < q-1.
XA
Step-2: Compute YA = α mod q.
Step-3: A’s private key is XA; A’s pubic key is {q, α, YA}.
Signature Verification
The Schnorr signature scheme is also based on discrete logarithms. The Schnorr
scheme minimizes the message-dependent amount of computation required to
generate a signature. The main work for signature generation does not depend
on the message. The scheme is based on using a prime modulus p, with having a
(p-1) prime factor of q appropriate size; that is, p = 1 (mod q). Typically, we use
p = 21024 and q = 2160. Thus, p is a 1024-bit number, and q is a 160-bit number,
which is also the length of the SHA-1 hash value.
Algorithm
Step-3: Choose a random integer s with 0 < s < q. This is the user’s private key.
-s
Step-4: Calculate v = α mod p. This is the user’s public key.
Step-1: Choose a random integer r with 0 < r < q and compute x = αr mod p.
This computation is a pre-processing stage independent of the message M to be
signed.
Step-2: Concatenate the message with and hash the result to compute the
value:
e = H (M || x)
Step-3: Compute y = (r + se) mod q. The signature consists of the pair (e, y).
Signature Verification
Step-1: Compute x’
x’ = α y ve mod p
x’ = α y α -se
mod p (∵ v = α -s
mod p)
(y-se)
x’ = α mod p
x’ = α r mod p (∵ y = r + se)
x’ = x
So, here x’ = x.
The National Institute of Standards and Technology (NIST) has published Federal
Information Processing Standard FIPS 186, known as the Digital Signature
Standard (DSS). The DSS makes use of the SHA and presents a new digital
signature technique, the Digital Signature Algorithm (DSA). Latest version also
incorporates digital signature algorithms based on RSA and on elliptic curve
cryptography. Let us discuss RSA and DSS Approach….
In the RSA approach, the message to be signed is input to a hash function that
produces a secure hash code of fixed length. This hash code is then encrypted
using the sender’s private key to form the signature. Both the message and the
signature are then transmitted. The recipient takes the message and produces a
hash code. The recipient also decrypts the signature using the sender’s public
key. If the calculated hash code matches the decrypted signature, the signature
is accepted as valid.
The DSS approach also makes use of a hash function. The hash code is provided
as input to a signature function along with a random number k, generated for
this particular signature. The signature function also depends on the sender’s
private key (PRa), and a set of parameters known to a group of communicating
principle. We can consider this set to constitute a global public key (PUG). The
result is a signature consisting of two components, labelled s and r. At the
receiving end, the hash code of the incoming message is generated. The
signature is input to a verification function. The verification function also
depends on the global public key as well as the sender’s public key (PU a), which
is paired with the sender’s private key. The output of the verification function is a
value that is equal to the signature component r, if the signature is valid. The
signature function is such that only the sender, with knowledge of the private
key, could have produced the valid signature.
Digital Signature Algorithm
Signature Verification
Key Management and Key Distribution in network security
Key Management
The main aim of key management is to generate a secret key between two
parties and store it to prove the authenticity between communicating users. Key
management is the techniques which support key generation, storage and
maintenance of the key between authorized users.
User registration
User initialization
Key generation
Key installation
Key registration
Normal use
Key backup
Key update
Key recovery
Key Distribution
Introduction
When two parties share the same key (i.e. symmetric key) that protect from
access by others, the process between two parties that exchanges that key
called as symmetric key distribution. If two person wants to communicates with
each other via messages or exchange data without interference of other. Two
parties/person A and B achieved the key distribution in various ways:
2. A third party can select the key and physically deliver it to A and B.
3. If A and B have previously and recently used a key, one party can transmit the
new key to the other, encrypted using the old key.
Options 1 and 2 calls for manual delivery of a key to the users. In manual
delivery of key is difficult in a wide-area distributed system. Returning to our list,
option 3 is a possibility for either link encryption or end-to-end encryption, but if
an attacker ever succeeds in gaining access to one key, then all subsequent keys
will be revealed. For end-to-end encryption some variation on option 4 has been
widely adopted. In this scheme, a key distribution centre responsible for
distributing keys to pairs of users (hosts, processes, applications) as needed.
Each user must share a unique key with the distribution centre for purposes of
key distribution.
The use of a key distribution centre is based on the use of a hierarchy of keys. At
a minimum, two levels of keys are used (show in Figure). Communication
between end systems is encrypted using a temporary key, often referred to as a
session key. Typically, the session key is used for the duration of a logical
connection, such as a frame relay connection or transport connection, and then
discarded. Each session key is obtained from the key distribution centre over the
same networking facilities used for end-user communication. Accordingly,
session keys are transmitted in encrypted form, using a master key that is
shared by the key distribution centre and an end system or user.
The scenario assumes that each user shares a unique master key with the key
distribution centre (KDC). Let us assume that user A wishes to establish a logical
connection with B and requires a one-time session key to protect the data
transmitted over the connection. User A has a master key, Ka, known only to
itself and the KDC; similarly, User B shares the master key K b with the KDC. Let
us discuss all steps…
Step – 1: A issues a request to the KDC for a session key to protect a logical
connection to B.
IDA || IDB || N1
The message includes the identity of A and B and a unique identifier, N1, for this
transaction, which we refer to as a nonce. The nonce may be a timestamp, a
counter, or a random number; the minimum requirement is that it differs with
each request. Also, to prevent masquerade, it should be difficult for an opponent
to guess the nonce. Thus, a random number is a good choice for a nonce.
Step – 2: The KDC responds with a message encrypted using K a. Thus, A is the
only one who can successfully read the message, and A knows that it originated
at the KDC.
The message includes two items intended for A: The one-time session key, K s, to
be used for the session. The original request message, including the nonce, to
enable A to match this response with the appropriate request. Thus, A can verify
that its original request was not altered before reception by the KDC and,
because of the nonce. In addition, the message includes two items intended for
B: The one-time session key, Ks, to be used for the session. An identifier of A
(e.g., its network address), IDA These last two items are encrypted with K b(the
master key that the KDC shares with B).They are to be sent to B to establish the
connection and prove A’s identity.
Step – 3: A stores the session key for use in the upcoming session and forwards
to B the information that originated at the KDC for B, namely, E (K b, [Ks || IDA]).
Because this information is encrypted with Kb, it is protected from
eavesdropping. B now knows the session key (K s), knows that the other party is A
(from IDA), and knows that the information originated at the KDC (because it is
encrypted using Kb). At this point, a session key has been securely delivered to A
and B, and they may begin their protected exchange.
Step – 4: Using the newly minted session key for encryption, B sends a nonce,
N2, to A. E (Ks, N2).
Step – 5: Also, using Ks, A responds with f (N2), where f is a function that
performs some transformation on N2 (e.g., adding one). E (Ks, f (N2)).
For example, there can be local KDCs, each responsible for a small domain of the
overall internetwork, such as a single LAN or a single building. For
communication among entities within the same local domain, the local KDC is
responsible for key distribution. If two entities in different domains desire a
shared key, then the corresponding local KDCs can communicate through a
global KDC. In this case, any one of the three KDCs involved can actually select
the key. The hierarchical concept can be extended to three or even more layers,
depending on the size of the number of users and the geographic scope of the
internetwork.
The more frequently session keys are exchanged, the more secure they are,
because the attacker has to capture session key every time to decrypt cipher
text. Short session key life time à Key exchange frequently & more secure. Long
session key life time à Reduce Key exchange time & less network bandwidth
used. For connection-oriented protocols, new session key for each new
connection. Update key periodically, if the connection has long time. For
connection less protocols, not to use a new key for each session but use a given
session key for a fixed period of time.
A transparent key control scheme
The steps involved in establishing a connection are shown in figure. When one
host wants to set up a connection to another host, it transmits a connection -
request packet (step 1).
The SSM (Session security module) saves that packet and applies to the KDC for
permission to establish the connection (step 2). The communication between
the SSM and the KDC is encrypted using a master key shared only by this SSM
and the KDC. If the KDC approves the connection request, it generates the
session key and delivers it to the two appropriate SSMs, using a unique
permanent key for each SSM (step 3). The requesting SSM can now release the
connection request packet, and a connection is set up between the two end
systems (step 4). All user data exchanged between the two end systems are
encrypted by their respective SSMs using the onetime session key.
Decentralized Key Control
Decentralized key control is not practical for larger networks using symmetric
encryption only, it may be useful within a local context. A session key may be
established with the following sequence of steps:
Step – 2: B responds with a message that is encrypted using the shared master
key. The response includes the session key selected by B, an identifier of B, the
value f(N1), and another nonce, N2.
There are two approaches: Simple Secret Key Distribution and Secret key
Distribution with Confidentiality and Authentication.
Encryption of this message with B’s public key ensures that only B can read it;
encryption with A’s private key ensures that only A could have sent it. B decrypt
the message and get secret key Ks. The result is that this scheme ensures both
confidentiality and authentication in the exchange of a secret
There are four methods of public key distribution: Public announcement of Public
Keys, Publicly Available Directory, Public Key Authority and Public Key
Certificates.
In a public key cryptography, such as RSA, any user can send his/her key to any
other user or broadcast it to the group as shown in figure.
Figure: Public Announcement of Public Keys
This type of approach is having a biggest drawback. Any user can pretend to be
a user A and send a public to another user or broadcast it. Until user A has got
this thing and alerts to other user, a pretender is able to read all encrypted
message of other users.
A user can replace the existing key with a new one at any time for any particular
reason.
It is more secure than public announcement but still having some weakness. A
hacker can obtain the private key of directory or temper with the information
kept by directory.
Public-Key Authority
Step – 2: The authority responds with a message that is encrypted using the
authority’s private key, PRauth. Thus, A is able to decrypt the message using the
authority’s public key. Therefore, A is assured that the message originated with
the authority.
The message includes the following: B’s public key, PU b, which A can use to
encrypt messages destined for B. The original request used to enable A to match
this response with the corresponding earlier request and to verify that the
original request was not altered before reception by the authority. The original
timestamp given so A can determine that this is not an old message from the
authority containing a key other than B’s current public key.
Step – 3: A stores B’s public key and also uses it to encrypt a message to B
containing an identifier of A (IDA) and a nonce (N1), which is used to identify this
transaction uniquely.
Step – 4 & 5: B retrieves A’s public key from the authority in the same manner
as A retrieved B’s public key.
Step – 7: A returns N2, which is encrypted using B’s public key, to assure B that
its correspondent is A.
Public-Key Certificates
The directory of names and public keys maintained by the authority is vulnerable
to tampering. An alternative approach, first suggested by Kohn Felder, is to use
certificates. In essence, a certificate consists of a public key, an identifier of the
key owner, and the whole block signed by a trusted third party. Typically, the
third party is a certificate authority, such as a government agency or a financial
institution that is trusted by the user community. A user can present his or her
public key to the authority in a secure manner and obtain a certificate. The user
can then publish the certificate. Anyone needing this user’s public key can obtain
the certificate and verify that it is valid by way of the attached trusted signature.
A participant can also convey its key information to another by transmitting its
certificate. Other participants can verify that the certificate was created by the
authority. Below diagram shows the distribution of public keys using public key
certificates.
Figure: Public Key certificates
Step – 1: Any participant can read a certificate to determine the name and
public key of the certificate’s owner.
Step – 2: Any participant can verify that the certificate originated from the
certificate authority and is not counterfeit.
Step – 3: Only the certificate authority can create and update certificates.
Purpose of PKI
The purpose for developing a PKI is to enable secure, convenient, and efficient
obtain public keys.
PKIX
Public key infrastructure X.509 is called as PKIX. Figure shows the PKIX
Architectural Model.
PKIX Elements
Figure shows the interrelationship among the key elements of the PKIX model.
These elements are,
End entity: A generic term used to denote end users, devices (e.g., servers,
routers), or any other entity that can be identified in the subject field of a public
key certificate.
Repository: A generic term used to denote any method for storing certificates
and CRLs so that they can be retrieved by end entities.
Registration:
Registration begins the process of enrolling in a PKI. User first makes itself known
to a CA (directly or through an RA), prior to that CA issuing a certificate for that
user. Registration usually involves some offline or online procedure for mutual
authentication. Typically, the end entity is issued one or more shared secret keys
used for subsequent authentication.
Key Pair Recovery: Key pairs can be used to support digital signature creation
and verification, encryption and decryption, or both. When a key pair is used for
encryption/decryption, it is important to provide a mechanism to recover the
necessary decryption keys when normal access to the keying material is no
longer possible, otherwise it will not be possible to recover the encrypted data.
Key pair recovery allows end entities to restore their encryption/decryption key
pair from an authorized key backup facility (typically, the CA that issued the end
entity’s certificate).
Key Pair Update: All key pairs need to be updated regularly (i.e., replaced with
a new key pair) and new certificates issued. Update is required when the
certificate lifetime expires and as a result of certificate revocation.
The PKI working group has defines two alternative management protocols.
Where CMS refers to RFC 2630, and cryptographic message syntax (CMS).
CMS can encrypt, decrypt, sign and verify, compress and decompress CMS
documents.
Introduction
𝐴 → 𝐾𝐷𝐶: 𝐼𝐷𝐴||𝐼𝐷𝐵||𝑁1
𝐴 → 𝐵: 𝐸 (𝐾𝑏, [𝐾𝑠||𝐼𝐷𝐴])
𝐵 → 𝐴: 𝐸 (𝐾𝑠, 𝑁2)
𝐴 → 𝐵: 𝐸 (𝐾𝑠, 𝑓(𝑁2))
The protocol is still vulnerable to a form of replay attack. Suppose that an
opponent, X, has been able to compromise an old session key. X can impersonate
A and trick B into using the old key by simply replaying step 3. Unless B
remembers indefinitely all previous session keys used with A, B will be unable to
determine that this is a replay. If X can intercept the handshake message in step
4, then it can impersonate A’s response in step 5. From this point on, X can send
bogus messages to B that appear to B to come from A using an authenticated
session key. Denning proposes to overcome this weakness by a modification to
the Needham/Schroeder protocol that includes the addition of a timestamp to
steps 2 and 3.
Solution by Denning
Figure : Denning's
Solution
Her proposal assumes that the master keys, K a and Kb, are secure, and it consists
of the following steps.
𝐴 → 𝐾𝐷𝐶: 𝐼𝐷𝐴||𝐼𝐷𝐵
𝐴 → 𝐵: 𝐸 (𝐾𝑏, [𝐾𝑠||𝐼𝐷𝐴||𝑇])
𝐵 → 𝐴: 𝐸 (𝐾𝑠, 𝑁1)
𝐴 → 𝐵: 𝐸 (𝐾𝑠, 𝑓(𝑁1))
T is a timestamp that assures A and B that the session key has only just been
generated. Thus, both A and B know that the key distribution is a fresh
exchange.
A and B can verify time by checking that |𝐶𝑙𝑜𝑐𝑘 − 𝑇| < ∆𝑡1 + ∆𝑡2, where ∆𝑡1, is
the estimated normal difference between the KDC’s clock and the local clock (at
A or B) and ∆𝑡2 is the expected network delay time. A new concern is raised:
namely, that this new scheme requires rely on clocks that are synchronized
throughout the network points out a risk involved.
The risk is based on the fact that the distributed clocks can become
unsynchronized as a result of damage on or faults in the clocks or the
synchronization mechanism. The problem occurs when a sender’s clock is ahead
of the intended recipient’s clock.
In this case, an opponent can intercept a message from the sender and replay it
later when the timestamp in the message becomes current at the recipient’s
site. This replay could cause unexpected results. Gong refers to such attacks as
suppress-replay attacks. One way to counter suppress-replay attacks is to
enforce the requirement that parties regularly check their clocks against the
KDC’s clock.
The other alternative, which avoids the need for clock synchronization, is to rely
on handshaking protocols using nonces. This alternative is not vulnerable to a
suppress-replay attack, because the nonces the recipient will choose in the
future are unpredictable to the sender.
𝐴 → 𝐵: 𝐼𝐷𝐴 || 𝑁𝑎
𝐴 → 𝐵: 𝐸 (𝐾𝑏, [𝐼𝐷𝐴||𝐾𝑠||𝑇𝑏])||𝑁𝑎′
𝐴 → 𝐵: 𝐸 (𝐾𝑠, 𝑁𝑏′)
When B receives the message in step 1, it verifies that the ticket has not expired.
The newly generated nonces and assure each party that there is no replay
attack.
One-way Authentication
Figure : One way Authentication
With some refinement, the KDC strategy is a candidate for encrypted electronic
mail. Because we wish to avoid requiring that the recipient (B) be on line at the
same time as the sender (A), steps 4 and 5 must be eliminated. For a message
with content, the sequence is as follows:
This approach guarantees that only the intended recipient of a message will be
able to read it. It also provides a level of authentication that the sender is A. The
protocol does not protect against replay attack.
Kerberos Protocol
What is Kerberos?
1-User,
3-Services (servers).
Why Kerberos?
Characteristics of Kerberos
Secure: 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.
Authentication Server (AS): A server that issues tickets for a desired service
which are in turn given to users for access to the service.
Client: An entity on the network that can receive a ticket from Kerberos.
Credential cache or ticket file: A file which contains the keys for encrypting
communications between a user and various network services.
Key distribution centre (KDC): A service that issue Kerberos tickets and which
usually run on the same host as the ticket-granting server (TGS).
Realm: A network that uses Kerberos composed of one or more servers called
KDCs and a potentially large number of clients.
Ticket-granting server (TGS): A server that issues tickets for a desired service
which are in turn given to users for access to the service. The TGS usually runs
on the same host as the KDC.
Ticket-granting ticket (TGT): A special ticket that allows the client to obtain
additional tickets without applying for them from the KDC.
Working of Kerberos
Step 1: (Fig 1)
The AS, receives the request by the client and verifies that the client.
Step 2:
Upon verification, a timestamp is created with current time in a user session with
expiration date. The timestamp ensures that when 8 hours is up, the encryption
key is useless.
Step 3: (Fig 2)
Figure : Authentication Service issues
TGT
Step 4: (Fig 3)
Step 5: (Fig. 4)
Figure : TGS grants client the
service ticket
The TGS creates an encrypted key with a timestamp and grants the client a
service ticket.
Step 6:
Step 7 (Fig. 5)
Figure : Service server decrypt key and check
the time stamp
The server decrypts the key and check timestamp is still valid or not.
Step 8: (Fig. 6)
The client decrypts the ticket. If the keys are still valid, communication is
initiated between client and server. Now the client is authenticated until the
session expires.
Is Kerberos safe?
Kerberos is more secure than other authentication methods because it does not
send plain text pass- words over the network and instead of password uses
encrypted tickets.