Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add argon2 and kyber #1291

Open
wants to merge 9 commits into
base: PB-2666-implement-pqc-on-drive
Choose a base branch
from

Conversation

TamaraFinogina
Copy link

@TamaraFinogina TamaraFinogina commented Sep 27, 2024

Update

  • Switching to Argon2. The idea is to re-compute all hashes in the database to Argon2 of the current PBKDF2 value and modify the login accordingly, then bit by bit change all users to just Argon2.
  • Add a post-quantum layer. The idea is always to send two encrypted values - 'secret' and 'secret XORed with the mnemonic'. The 'secret' is encrypted with KyberKEM (post-quantum) and 'secret XORed with mnemonic' with ECC from openpgp. This way, to get a mnemonic one must break both ECC and Kyber.

Related to PB-2666

Copy link

vercel bot commented Sep 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drive-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 30, 2024 10:48am

Copy link

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4689dfe
Status:⚡️  Build in progress...

View logs

Copy link

sonarcloud bot commented Sep 27, 2024

@sg-gs
Copy link
Member

sg-gs commented Sep 30, 2024

@TamaraFinogina Please provide a description

const messageHex = Buffer.from(message).toString('hex');

// message should be the same length as secret, which is 256 bits
const xoredMessage = XORhex(messageHex, secretHex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will they always be the same length?
Maybe we should check in case they are not, so that it throws an error.

try {
const publicKeyResponse = await userService.getPublicKeyByEmail(email);
publicKey = publicKeyResponse.publicKey;
publicKyberKey = publicKeyResponse.publicKyberKey;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the backend is already prepared to store this new key?

isThereAnyNewUser = true;
}
usersList.push({
email,
userRole,
isNewUser: !publicKey,
isNewUser: !publicKey || !publicKyberKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user will have both keys always?

});

expect(encryptedMessage).toBeDefined();
});

it('xor should work', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is too generic a test, separate it into different tests in which the description of what it has to achieve is a little more specific

Comment on lines +2 to +10
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.format": "explicit"
},
"svg.preview.background": "editor"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to be added to the gitignore, as it is part of the vs code configuration.

"preinstall": "node scripts/use-yarn.js",
"prepare": "husky install",
"dev": "craco start",
"start": "craco start",
"build": "craco build",
"vercel:install": "yarn run add:npmrc && yarn install",
"test:unit": "jest src/ && jest test/unit",
"test:unit": "vitest run test/unit && vitest run src/ ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting change, with Vitest the problems with global meta variable has gone?

};
}
export function XORhex(a: string, b: string): string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to add jsdoc for this function.

let res = '',
i = a.length,
j = b.length;
while (i-- > 0 && j-- > 0) res = (parseInt(a.charAt(i), 16) ^ parseInt(b.charAt(j), 16)).toString(16) + res;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the lengths of the chains are different, this will end before they have travelled the longest chain. Is this the desired behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants