Loading...
Bangladesh Bank

Post: Assistant Programmer,
Exam Date: 03.02.2023, Exam Taker: BIBM
1. Consider strong entries with integer keys. Suppose the hash function is h (k) = k mod 13. Insert in the given order entries with keys 10, 3, 6, 16, 17, 19 in to the hash table using linear probing to resolve collisions. Show all the work.

The hash function is given as h(k)=k mod 13. The table size is 13, meaning we have indices from 0 to 12.

Step-by-Step Insertion Process Key: 10 Hash value: h(10) = 10 mod 13 = 10. Insert 10 at index 10. Key: 3 Hash value: h(3) = 3 mod 13 = 3. Insert 3 at index 3. Key: 6 Hash value: h(6) = 6 mod 13 = 6. Insert 6 at index 6. Key: 16 Hash value: h(16) = 16 mod 13 = 3. Index 3 is occupied. Use linear probing and insert 16 at index 4. Key: 17 Hash value: h(17) = 17 mod 13 = 4. Index 4 is occupied. Use linear probing and insert 17 at index 5. Key: 19 Hash value: h(19) = 19 mod 13 = 6. Index 6 is occupied. Use linear probing and insert 19 at index 7. Final Hash Table
IndexValue
0
1
2
33
416
517
66
719
8
9
1010
11
12

Summary The final hash table after inserting all keys using linear probing is as follows:

[ – , – , – , 3 , 16 , 17 , 6 , 19 , – , – , 10 , – , – ]
2. Describe a man-in the middle attack on the Diffie-Hellman key exchange protocol in which the adversary generates two public key pairs for the attack.

Man-in-the-Middle (MITM) Attack on Diffie–Hellman Key Exchange

In a MITM attack on Diffie–Hellman (DH), an attacker (Mallory) sits between Alice and Bob, intercepts their public keys, and replaces them with her own. Since basic DH provides no authentication, Alice and Bob cannot verify the real sender of the public key.

Normal DH (No Attack)

  • Public parameters: prime p, generator g
  • Alice selects private key a, sends public key A = ga mod p
  • Bob selects private key b, sends public key B = gb mod p
  • Shared key: K = gab mod p

MITM Attack (Attacker Generates Two Key Pairs)

Step 1: Interception
Mallory intercepts Alice’s public key A and Bob’s public key B.

Step 2: Mallory Creates Two Private Keys
Mallory chooses two private keys: m1 (for Bob) and m2 (for Alice).

Step 3: Mallory Generates Two Public Keys
Mallory computes:
M1 = gm1 mod p
M2 = gm2 mod p

Step 4: Key Replacement (Fake Public Keys)
Mallory sends M1 to Bob pretending it is from Alice.
Mallory sends M2 to Alice pretending it is from Bob.

Step 5: Two Different Shared Keys are Formed

  • Alice computes: K1 = (M2)a mod p (Alice–Mallory key)
  • Bob computes: K2 = (M1)b mod p (Bob–Mallory key)
  • Mallory can compute both keys:
    K1 = (A)m2 mod p and K2 = (B)m1 mod p

Result

  • Alice and Bob do not share the same secret key.
  • Mallory shares one key with Alice and another key with Bob.
  • Mallory can read, modify, and re-encrypt messages between them.

Why It Works

Because basic Diffie–Hellman does not provide authentication, public keys can be replaced without detection.

Prevention

  • Use Authenticated Diffie–Hellman
  • Use Digital Signatures / Certificates (PKI)
  • Use TLS (DHE/ECDHE + certificates)

Diffie–Hellman Key Exchange-এ Man-in-the-Middle (MITM) Attack

MITM attack-এ attacker (Mallory) Alice এবং Bob-এর মাঝখানে বসে public key গুলো intercept করে এবং নিজের public key বসিয়ে দেয়। Basic Diffie–Hellman-এ authentication নেই, তাই Alice/Bob বুঝতে পারে না public key আসলেই কার কাছ থেকে এসেছে।

Normal DH (Attack নেই)

  • Public parameter: prime p, generator g
  • Alice private key a নেয়, public key পাঠায় A = ga mod p
  • Bob private key b নেয়, public key পাঠায় B = gb mod p
  • Shared key: K = gab mod p

MITM Attack (Attacker দুইটি Key Pair তৈরি করে)

Step 1: Interception
Mallory Alice-এর public key A এবং Bob-এর public key B intercept করে।

Step 2: Mallory দুইটি Private Key নেয়
Mallory দুইটি private key বেছে নেয়: m1 (Bob-এর জন্য) এবং m2 (Alice-এর জন্য)।

Step 3: Mallory দুইটি Public Key তৈরি করে
Mallory হিসাব করে:
M1 = gm1 mod p
M2 = gm2 mod p

Step 4: Public Key Replace করে
Mallory Bob-কে M1 পাঠায় (যেন Alice পাঠিয়েছে)।
Mallory Alice-কে M2 পাঠায় (যেন Bob পাঠিয়েছে)।

Step 5: দুইটা আলাদা Shared Key তৈরি হয়

  • Alice হিসাব করে: K1 = (M2)a mod p (Alice–Mallory key)
  • Bob হিসাব করে: K2 = (M1)b mod p (Bob–Mallory key)
  • Mallory দুইটাই বের করতে পারে:
    K1 = (A)m2 mod p এবং K2 = (B)m1 mod p

Result

  • Alice এবং Bob-এর মধ্যে একই secret key তৈরি হয় না।
  • Mallory Alice-এর সাথে একটি key এবং Bob-এর সাথে আরেকটি key share করে।
  • Mallory মাঝখান থেকে message পড়তে, পরিবর্তন করতে, এবং পুনরায় encrypt করে পাঠাতে পারে।

কেন Attack কাজ করে

Basic Diffie–Hellman-এ authentication নেই, তাই public key সহজে replace করা যায়।

Prevention

  • Authenticated Diffie–Hellman ব্যবহার
  • Digital Signature / Certificate (PKI) ব্যবহার
  • TLS (DHE/ECDHE + certificate) ব্যবহার
3. Preserving confidentiality integrity and availability of data is a restatement of the concern over falsification, interception, masquerade and denial of service. Explain how the first three concepts relate to the last four.

The concepts of confidentiality, integrity, and availability (CIA triad) directly address the security concerns of falsification, interception, masquerade, and denial of service.

Confidentiality ensures that sensitive information is accessible only to authorized users, protecting against interception, where data could be accessed or stolen by unauthorized parties.

Integrity guarantees that data remains accurate and unaltered, defending against falsification, which involves malicious modification of data, and masquerade, where attackers assume false identities to tamper with information.

Availability ensures that information and resources are accessible when needed, countering denial of service (DoS) attacks that aim to make systems or data unavailable to legitimate users.

By maintaining confidentiality, integrity, and availability, organizations can effectively mitigate these four major security threats and enhance overall data protection.

Confidentiality, Integrity, Availability (CIA triad)-এর ধারণাগুলো মূলত চারটি security threat-এর সাথে সম্পর্কিত: falsification, interception, masquerade, এবং denial of service।

Confidentiality (গোপনীয়তা): সংবেদনশীল তথ্যকে শুধুমাত্র authorized users-এর জন্য accessible রাখে। এটি interception থেকে রক্ষা করে, অর্থাৎ unauthorized ব্যক্তি তথ্য access বা steal করতে পারবে না।

Integrity (অখণ্ডতা): নিশ্চিত করে যে তথ্য correct এবং unaltered আছে। এটি falsification থেকে রক্ষা করে, যেখানে data maliciously modify করা হয়, এবং masquerade থেকে, যেখানে attacker false identity ব্যবহার করে information manipulate করতে পারে।

Availability (উপলব্ধতা): তথ্য এবং resources ব্যবহারকারীদের প্রয়োজন অনুযায়ী accessible রাখে। এটি denial of service (DoS) attack থেকে রক্ষা করে, যা legitimate users-এর জন্য system বা data কে unavailable করতে চায়।

সারসংক্ষেপে, maintaining the CIA triad এই চারটি security threat mitigate করতে সাহায্য করে এবং overall data protection ensure করে।

4. Given two integers A and B as input write a program to compute the least common multiple of A and B.
#include <stdio.h>
int main () {
int n1, n2, max;
printf ("Enter two positive integers: ");
scanf ("%d %d", &n1, &n2);
// maximum number between n1 and n2 is stored in max

max = (n1> n2) ? n1: n2;
while (1) {
// Check if max is divisible by both n1 and n2
if ((max% n1 == 0)&& (max % n2 ==0)) {
 // If true, max is the LCM of n1 and n2
printf("The LCM of %d and %d is %d.", n1,n2,max);
break;
}
++max;
}
return 0;
}
    
Sample I/O:
Enter two positive integers: 14 8
The LCM of 14 and 8 is 56.
=== Code Execution Successful ===


🔗 Run Online: LCM of two integer

5.Given the adjacency list representation of a complete binary tree with 7 vertices, write the equivalent adjacency matrix representation. Assume that the vertices are numbered from 1 to 7 as in a binary heap.
Complete Binary TreeAdjacency List Representation
VertexConnected Vertices
12, 3
24, 5
36, 7
4
5
6
7
Adjacency Matrix Representation
1234567
10110000
20001100
30000011
40000000
50000000
60000000
70000000

You must subscribe & Login to view more.

Don’t have an account? Register

Or your subscription is under review by admin. Please message on WhatsApp / Telegram.

Leave a Comment

Latest Post
Field Based Job Question & Solution
Bank IT Job Solution

MCQ + Written from Bangladesh Bank, Sonali, Combined Bank IT recruitment.

BPSC IT Job Solution

BPSC Computer/IT cadre & non-cadre post Question papers with full solutions.

Gas Field IT Job Solution

Gas field like TGTDCL, BGDCL, JGTDSL, KGDCL, SGCL, RPGCL, GTCL etc. question solution

Power Sector IT Job Solution

Power sector such as NESCO, DESCO, DPDC, WZPDCL, BPDB, PGCB, BREB etc

Other IT Job Solution

Other Govt. Semi govt. organization like BCC, BTCL, CAAB, NSI etc.

NTRCA IT Job Solution (upcoming)

NTRCA ICT-related posts such as Assistant Teacher, Demonstrator, Lecturer.

IT MCQ Job Solution

Collected MCQ Job solution of BANK, BPSC, POWER SECTOR, GAS Field and Others.

Topic Based Q&S
WhatsApp Telegram Messenger