Question

COSC 359

User Authentication

Description

A widely used password security technique is the use of hashed passwords and a salt value. This scheme is found on virtually all UNIX variants as well as on a number of other operating systems as shown in Figure 3.1 bellow.

To load a new password into the system, the user selects or is assigned a password. This password is combined with a fixed-length salt value. In older implementations, this value is related to the time at which the password is assigned to the user. Newer implementations use a pseudorandom or random number. The password and salt serve as inputs to a hashing algorithm to produce a fixed-length hash code. The hash algorithm is designed to be slow to execute to thwart attacks. The hashed password is then stored, together with a plaintext copy of the salt, in the password file for the corresponding user ID. The hashed-password method has been shown to be secure against a variety of cryptanalytic attacks [WAGN00].

When a user attempts to log on to a UNIX system, the user provides an ID and a password. The operating system uses the ID to index into the password file and retrieve the plaintext salt and the encrypted password. The salt and user-supplied passwords are used as input to the encryption routine. If the result matches the stored value, the password is accepted.

// PART A: ID/PASSWORD CREATION

Write the necessary C++ code (or a language of your choice) for the following activities:

Create user ID and Password pair by asking users to input ID/Password. Check the input and help users to choose an acceptable ID/Password based on the company security policy.

Create a Salt value, add it to the Password and use a hash function to encrypt both Salt and Password.

Store user ID, Salt and hashed password in ID-PASSWORD.TXT

// PART B: USER AUTHENTICATION

Enhance your code from PART A for the following activities:

Ask users for ID/Password pair

Authenticate users using ID.txt and the ID-PASSWORD.TXT files.


Password Password File User ID Salt Hash code Salt slow hash function Load (a) Loading a new password Password File User id User ID Sa Hash code Salt Select Password slow hash function Hashed password Compare (b) Verifying a password Figure 3.1 UNIX Password Scheme

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

#include <fstream>

#include<string>

using namespace std;

class PasswordGeneration

{

private:

string userid;

string password;

int seed;

unsigned long hashValue;

public:

PasswordGeneration();

void setPassword();

unsigned int hash(string password);

void authenticateUser();

};

PasswordGeneration :: PasswordGeneration()

{

seed=2;

}

//Question 1

void PasswordGeneration ::setUserID()

{

cout<<"Enter UserID : ";

//getline(cin,userid);

cin >> userid;

}

void PasswordGeneration :: setPassword()

{

string error;

cout << "Enter Password : ";

cin >> password;

//getline(cin,password);

if(password.empty())

error = "Password shouldn't be empty";

else if(password.length() < 9)

error = "Password length must greater than 8";

else if(password.find_first_of("@#!*&_") ==string::npos)

error = "Password must contain any special character of these @,#,!,*,& and _";

else if(password.find_first_of("1234567890") == string::npos)

error = "Password must contain at least one digit";

else

{

error="Password is Accepted";

storeDatabase();

}

cout <<error << endl;

}

//Question 2

unsigned int PasswordGeneration ::hash(string password)

{

unsigned long hash = seed;

const char "pword=password.c_str();

while (*pword)

{

hash = hash * 101 + *pword++;

}

hashValue = hash;

}

//Question 3

void PasswordGeneration :: storeDatabase()

{

fstream uidfile("ID.txt",ios::app);

uidfile << userid;

uidfile.close();

fstream passwordfile("ID-PASSWORD.txt");

passwordfile << hash(password) ;

passwordfile.close();

}

//Part B: UserAuthentication

void PasswordGeneration :: authenticateUser()

{

string uid,pw;

cout << "User ID:";

cin >> uid;

cout << "User Password :";

cin >> pw;

unsigned long passhash=hash(pw);

string txtstr;

bool ustatus=false;

//reading id from the ID.txt file

ifstreamfile ("ID.txt");

while(getline(file,txtstr))

{

if(uid == txtstr)

ustatus =true;

}

file.close();

if(!ustatus)

{

cout <<"Invalid UserID"<<endl;

return;

}

txtstr="";

ustatus=false;

//reading password from the ID-PASSWORD.txt file

ifstream file2("ID-PASSWORD.txt");

while(getline(file2,txtstr))

{

if(passhash == hash(txtstr))

ustatus =true;

}

file2close();

if(!ustatus)

{

cout<<"Invalid Password"<<endl;

return;

}

}

cout<<"User Login Successfully...!"<<endl;

}

int main()

{

//PasswordGeneration obj("suresh","sure4has!urr");

PasswordGeneration obj;

// //Creation of User -> Part - A

obj.setUserID();

obj.setPassword();

//Authentication of User -> Part - B

obj.authenticateUser();

return 0;

}

Add a comment
Know the answer?
Add Answer to:
COSC 359 User Authentication Description A widely used password security technique is the use of hashed...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Netbeans code Option 1: Authentication System For security-minded professionals, it is important that only the...

    Java Netbeans code Option 1: Authentication System For security-minded professionals, it is important that only the appropriate people gain access to data in a computer system. This is called authentication. Once users gain entry, it is also important that they only see data related to their role in a computer system. This is called authorization. For the zoo, you will develop an authentication system that manages both authentication and authorization. You have been given a credentials file that contains credential...

  • C code: hash program (use the Fowler-Noll-Vo (FNV) hash algorithm) This is a simple program that...

    C code: hash program (use the Fowler-Noll-Vo (FNV) hash algorithm) This is a simple program that you will use in the second part of the assignment. Details of this program is as follows. A hashing algorithm is simply an algorithm that maps data of an arbitrary size into a hash value of a fixed size. On your VM, you should have a program called ”md5sum”, which computes the MD5 hash of a file (or bytes taken from standard input). One...

  • Chapter 06 Applied Cryptography 1. How is integrity provided? A. Using two-way hash functions and digital...

    Chapter 06 Applied Cryptography 1. How is integrity provided? A. Using two-way hash functions and digital signatures B. Using one-way hash functions and digital signatures C. By applying a digital certificate D. By using asymmetric encryption 2. Which term refers to the matching of a user to an account through previously shared credentials? A. Nonrepudiation B. Digital signing C. Authentication D. Obfuscation 3. Which term refers to an arranged group of algorithms? A. Crypto modules B. Cryptographic service providers (CSPs)...

  • Option 1: Authentication System For security-minded professionals, it is important that only the appropriate people gain...

    Option 1: Authentication System For security-minded professionals, it is important that only the appropriate people gain access to data in a computer system. This is called authentication. Once users gain entry, it is also important that they only see data related to their role in a computer system. This is called authorization. For the zoo, you will develop an authentication system that manages both authentication and authorization. You have been given a credentials file that contains credential information for authorized...

  • I need help ASAP on this, this is due at midnight PST. This is the current...

    I need help ASAP on this, this is due at midnight PST. This is the current code I have. How can I allow the user to quit. My counting while loop works fine, but I would like it to not keep outputting username if a file was successfully opened. This is what is required. Prompt You have assumed the role of managing the technology infrastructure at a zoo. You will develop a working program (either an authentication system or a...

  • TRUE/FALSE QUESTIONS:  Foundations of Information Security and Assurance 1. There is a problem anticipating and testing for...

    TRUE/FALSE QUESTIONS:  Foundations of Information Security and Assurance 1. There is a problem anticipating and testing for all potential types of non-standard inputs that might be exploited by an attacker to subvert a program. 2. Without suitable synchronization of accesses it is possible that values may be corrupted, or changes lost, due to over-lapping access, use, and replacement of shared values. 3. The biggest change of the nature in Windows XP SP2 was to change all anonymous remote procedure call (RPC)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT