Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions aws/src/lambdas/genPass/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ const handler = async (event: APIGatewayProxyEventV2): Promise<APIGatewayProxyRe

const body = typeof event.body === "string" ? JSON.parse(event.body) : event.body;

const dataToHash: string = body.dataToHash;
const salt: string = body.salt;

const strong_password = await calculatePassword(dataToHash, salt);
const strong_password = await calculatePassword(salt);

/*const hashValue = await argon2.hash(dataToHash, {
salt: slt,
Expand Down
19 changes: 11 additions & 8 deletions aws/src/lambdas/genPass/src/password_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@ const securityAnswers: string[] = [
];


export async function calculatePassword(inputValue: string, argon2_salt:string) : Promise<string>{
//if (!inputValue) return;
export async function calculatePassword(argon2_salt:string) : Promise<string>{

const db_val = "test_db_val" // FETCH THIS FROM DB. THIS IS WHAT WILL BE USED FOR CALCULATING CUSTOM SALT INDICIES

const enc_name = "Name";
const enc_email = "name@gmail.com"
const enc_phone = "5555555555"
const site_domain = "amazon.com"

const prepped_salt = db_val + "-" + argon2_salt;

const hashed_name = await extractHash((await hashText(enc_name, argon2_salt)).body);
const hashed_email = await extractHash((await hashText(enc_email, argon2_salt)).body);
const hashed_phone = await extractHash((await hashText(enc_phone, argon2_salt)).body);
const hashed_domain = await extractHash((await hashText(site_domain, argon2_salt)).body);
const hashed_name = await extractHash((await hashText(enc_name, prepped_salt)).body);
const hashed_email = await extractHash((await hashText(enc_email, prepped_salt)).body);
const hashed_phone = await extractHash((await hashText(enc_phone, prepped_salt)).body);
const hashed_domain = await extractHash((await hashText(site_domain, prepped_salt)).body);

const salt_indicies = await CalculateSalts(inputValue); // For now input value will go into calculating salt indicies for testing. Will change to an internal db value
const salt_indicies = await CalculateSalts(db_val);

/*const salt1 = await hashText(securityAnswers[salt_indicies[0]])
const salt2 = await hashText(securityAnswers[salt_indicies[1]])
Expand All @@ -41,7 +44,7 @@ export async function calculatePassword(inputValue: string, argon2_salt:string)
console.log(salt_indicies)

const arranged_string = hashed_name+salt2+hashed_phone+salt1+hashed_domain+salt3+hashed_email;
const fullHash = await hashText(arranged_string, argon2_salt);
const fullHash = await hashText(arranged_string, prepped_salt);
const extractedHash = extractHash(fullHash.body);
console.log(fullHash)
console.log(extractedHash)
Expand Down
6 changes: 6 additions & 0 deletions extension/src/hashpass/app/popup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ export default function Home() {
<>
<section className="mt-4 text-lg">Welcome to HashPass</section>
</>
<button>
Open Sign Up Window
</button>
<button>
Open Log In Window
</button>

</main>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use client';

import React, { useState } from 'react';
import { CalculateSalts } from './salt_calculator';
import { hashText, extractHash } from '../tools/hashing_tool';
//import { CalculateSalts } from './salt_calculator';
//import { hashText, extractHash } from '../tools/hashing_tool';


const securityAnswers: string[] = [
/*const securityAnswers: string[] = [
"Fluffy", // Answer to: "What was the name of your first pet?"
"Maple Street", // Answer to: "What street did you grow up on?"
"Blue", // Answer to: "What is your favorite color?"
Expand All @@ -16,40 +16,24 @@ const securityAnswers: string[] = [
"Hawaii", // Answer to: "Where did you go on your honeymoon?"
"Superman", // Answer to: "Who is your childhood hero?"
"Beethoven", // Answer to: "What is your favorite composer or musician?"
];


export async function calculatePassword(inputValue: string) : Promise<string>{
//if (!inputValue) return;

const enc_name = "Name";
const enc_email = "name@gmail.com"
const enc_phone = "5555555555"
const site_domain = "amazon.com"

const hashed_name = await hashText(enc_name);
const hashed_email = await hashText(enc_email);
const hashed_phone = await hashText(enc_phone);
const hashed_domain = await hashText(site_domain);

const salt_indicies = await CalculateSalts(inputValue); // For now input value will go into calculating salt indicies for testing. Will change to an internal db value

/*const salt1 = await hashText(securityAnswers[salt_indicies[0]])
const salt2 = await hashText(securityAnswers[salt_indicies[1]])
const salt3 = await hashText(securityAnswers[salt_indicies[2]])*/
const salt1 = securityAnswers[salt_indicies[0]];
const salt2 = securityAnswers[salt_indicies[1]];
const salt3 = securityAnswers[salt_indicies[2]];

console.log(salt_indicies)

const arranged_string = hashed_name+salt2+hashed_phone+salt1+hashed_domain+salt3+hashed_email;
const fullHash = await hashText(arranged_string)
const extractedHash = extractHash(fullHash);
console.log(fullHash)
console.log(extractedHash)

return extractedHash;
];*/


export const calculatePassword = async (salt: string): Promise<string> => {
try {
const response = await fetch('https://a5yz9onkp8.execute-api.us-east-1.amazonaws.com/default/gen_password', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
salt: salt,
}),
});
const data = await response.json();
return data.hash || '';
} catch (error) {
console.error('Hash error:', error);
return ''; // Return empty string in case of an error.
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { decrypt } from "../security_components/tools/AES_tool"
import {calculatePassword} from '../security_components/components/password_generator';

export default function Site_LogIn() {
const userId = "testuserid2" // This value will be the user's id in plaintext (retrieved from DB)
const userIdEncrypted = "HCxyVsfCvxXKyw/rMRpuTJv99PHUrIZhJHICv4zgkMTHXBtgHJi2" // This value will be the user's id in ciphertext (retrieved from DB)
const userId = "testuserid" // This value will be the user's id in plaintext (retrieved from DB)
const userIdEncrypted = "8gb2BSJbvxtRs53WGHs6jBoVBztcA03gIFv8t8Bm/CLt6fGKkEY=" // This value will be the user's id in ciphertext (retrieved from DB)
//valid simple pass for testing is testkey

const [keyString, setKeyString] = useState("");
Expand All @@ -20,6 +20,7 @@ export default function Site_LogIn() {
const decryptedText = await decrypt(userIdEncrypted, keyString);
console.log("Decrypted Data: " + decryptedText);


if(decryptedText === userId){
console.log("Valid Simple passphrase: User Authenticated")
const password = await calculatePassword(keyString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { parse } from "tldts";

export default function Site_SignUp() {
const UUID = "f98699a0-d010-4a68-833e-fc9cbbcdf800"
const userIdEncrypted = "DSvanR4myji5VmzC06OutTH+nsVUbcOc0pqP7iLPgePsrNj5obsMXkZd+yI9m6MRzf/Xeq921dzq73rvTi/zEQ=="
const userIdEncrypted = "W3CeGzefGlIYyBS5RjiZnFmBI0RdTc8EJDQmwLM1LyUw3zTfGa6botvDVJvE2JlMM5/P8FZOjPRPC7TXJ/B02A=="
// valid simple pass for testing is Passpass@1

const [keyString, setKeyString] = useState("");
Expand Down
Loading
Loading