Skip to content

Commit

Permalink
increased performance by about 30%
Browse files Browse the repository at this point in the history
  • Loading branch information
brainfoolong committed Mar 27, 2024
1 parent 334fde2 commit 81a230b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions dist/ascon.es6.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// js-ascon v1.0.2 @ https://github.com/brainfoolong/js-ascon
// js-ascon v1.0.3 @ https://github.com/brainfoolong/js-ascon
/**
* Javascript / Typescript implementation of Ascon v1.2
* Heavily inspired by the python implementation of https://github.com/meichlseder/pyascon
Expand Down Expand Up @@ -107,7 +107,9 @@ export default class JsAscon {
const ciphertextTag = ciphertextAndTag.slice(-16);
const plaintext = JsAscon.processCiphertext(data, permutationRoundsB, rate, ciphertext);
const tag = JsAscon.finalize(data, permutationRoundsA, rate, key);
return plaintext;
if (JsAscon.byteArrayToHex(tag) === JsAscon.byteArrayToHex(ciphertextTag)) {
return plaintext;
}
return null;
}
/**
Expand Down
6 changes: 4 additions & 2 deletions dist/ascon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// js-ascon v1.0.2 @ https://github.com/brainfoolong/js-ascon
// js-ascon v1.0.3 @ https://github.com/brainfoolong/js-ascon
/**
* Javascript / Typescript implementation of Ascon v1.2
* Heavily inspired by the python implementation of https://github.com/meichlseder/pyascon
Expand Down Expand Up @@ -107,7 +107,9 @@ class JsAscon {
const ciphertextTag = ciphertextAndTag.slice(-16);
const plaintext = JsAscon.processCiphertext(data, permutationRoundsB, rate, ciphertext);
const tag = JsAscon.finalize(data, permutationRoundsA, rate, key);
return plaintext;
if (JsAscon.byteArrayToHex(tag) === JsAscon.byteArrayToHex(ciphertextTag)) {
return plaintext;
}
return null;
}
/**
Expand Down

0 comments on commit 81a230b

Please sign in to comment.