Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Add validation to decrypt passphrase - Closes #688 #709

Merged
merged 1 commit into from
Jul 16, 2018

Conversation

willclarktech
Copy link
Contributor

Closes #688

What was the problem?

We had no validation when decrypting passphrases, with unhelpful error messages.

How did I fix it?

Added validation and helpful error messages.

How to test it?

Try to decrypt a passphrase with some missing parameters.

Review checklist

shuse2
shuse2 previously requested changes Jul 10, 2018

requiredProperties.forEach(([property, propertyName]) => {
try {
hexToBuffer(property);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it weird to have partial validation named validateEncryptedPassphrase.
For example, getTagBuffer still validates if the length is 16, which is still used in encrypted passphrase, but not validated here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. How would you suggest doing it instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

oops sorry, forgot to put the suggestion.
Since we have method for each one with separate logic, maybe we should put the validation logic with meaningful message on each method?

@willclarktech willclarktech changed the base branch from 1.0.0 to 1.1.0 July 10, 2018 16:04
yatki
yatki previously requested changes Jul 11, 2018
Copy link
Contributor

@yatki yatki left a comment

Choose a reason for hiding this comment

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

just one minor comment

[iv, 'IV'],
[salt, 'Salt'],
[tag, 'Tag'],
];
Copy link
Contributor

@yatki yatki Jul 11, 2018

Choose a reason for hiding this comment

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

I would prefer to use Map instead of nested array. It'd save some memory. see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map Iterating Maps with for..of section

@willclarktech willclarktech force-pushed the 688-decrypt_passphrase_errors branch 2 times, most recently from 018b4de to 95bf5b8 Compare July 13, 2018 15:17
@willclarktech willclarktech dismissed stale reviews from shuse2 and yatki July 13, 2018 15:18

Addressed

yatki
yatki previously approved these changes Jul 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants