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

make MAC check robust against unpadded vs padded base64 differences #1378

Merged
merged 1 commit into from
May 20, 2020

Conversation

uhoreg
Copy link
Member

@uhoreg uhoreg commented May 15, 2020

No description provided.

@uhoreg uhoreg requested a review from a team May 15, 2020 20:55
@@ -167,7 +167,7 @@ export class SecretStorage extends EventEmitter {
if (info.algorithm === SECRET_STORAGE_ALGORITHM_V1_AES) {
if (info.mac) {
const {mac} = await SecretStorage._calculateKeyCheck(key, info.iv);
return info.mac === mac;
return info.mac.replace(/=+$/g, '') === mac.replace(/=+$/g, '');
Copy link
Member

Choose a reason for hiding this comment

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

is info mac one mac or multiple, one per line? just wondering about the point of the g modifier

Copy link
Member Author

Choose a reason for hiding this comment

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

Just one. The g probably isn't needed (but shouldn't be harmful either). It was just copied from encodeUnpaddedBase64 in src/crypto/olmlib.js

@uhoreg uhoreg requested a review from a team May 16, 2020 03:17
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

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

lgtm, might be nice to have it as a utility function

@uhoreg uhoreg merged commit 048d7a9 into develop May 20, 2020
@t3chguy t3chguy deleted the uhoreg/fix_mac_check branch May 10, 2022 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants