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

CCM: Tag not computed correctly on initial call to decrypt (latest Canary) #280

Closed
MaKleSoft opened this issue Apr 4, 2016 · 2 comments
Closed

Comments

@MaKleSoft
Copy link

A weird bug has popped up when using sjcl in the latest version of Google Chrome Canary (Version 51.0.2698.0 canary (64-bit)). For some reason when calling sjcl.mode.ccm.decrypt() for the first time after loading the script, the tag is not computed correctly and the decryption fails. On every subsequent call everything works fine. Here is an example:

function testDecrypt() {
  var key = '984LZT0tcqQQjPWr6RL/3Xd2Ftu7J6cOggTzri0Pb60=';
  var iv = '5mdFbbnTJbHSp11Ee/u9nQ==';
  var ct = 'fXSdX+OO+YnKhfzKfb0DT7CIOQ==';
  var adata = '1gJqY1uowoD1YRWKH/qS9A==';
  var toBits = sjcl.codec.base64.toBits;
  var aes = new sjcl.cipher.aes(toBits(key));
  var pt = sjcl.mode.ccm.decrypt(aes, toBits(ct), toBits(iv), adata, 64);
  console.log(sjcl.codec.utf8String.fromBits(pt));
}

try {
  testDecrypt()
} catch(e) {
  console.error(e.toString());
  testDecrypt();
}

Output:

"CORRUPT: ccm: tag doesn't match"
"hello world"

And a live demo (It uses v1.0.0 but the problem persists in the latest version): https://jsbin.com/wiworadeja/edit?js,console

@Nilos
Copy link
Collaborator

Nilos commented May 31, 2016

Is this till a problem? Sounds more like a Chrome Bug to me.

@MaKleSoft
Copy link
Author

Hm, the issue seems to have disappeared in both Chrome Version 51.0.2704.79 (64-bit) and Canary Version 53.0.2753.0 (64-bit). I agree that this looks like a temporary bug in one of the Chromium builds. Anyway, there is no way to reproduce this now so might as well close this issue.

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

No branches or pull requests

2 participants