Fix test with wrong buffer size
Problem: For some reason the test sets `c` to 147 + 16 bytes, when we only need 147 bytes. It's unclear to me why this is happening, but I can confirm that Sodium-Native throws an error if you try this. Solution: Use 147 bytes until I figure out what the problem is.
This commit is contained in:
parent
f710e35ed2
commit
a40b363726
@ -69,20 +69,18 @@ const m = new Uint8Array([
|
||||
])
|
||||
|
||||
// static unsigned char c[147 + crypto_box_MACBYTES];
|
||||
const c = new Uint8Array(147 + crypto_box_MACBYTES)
|
||||
// CHANGED: Neither Sodium-Native or Sodium-JavaScript handle when `c` is too big.
|
||||
// I don't know why the test makes it so big, but if Sodium-Native throws
|
||||
// then it seems like Sodium-JavaScript should throw too.
|
||||
const c = new Uint8Array(147)
|
||||
|
||||
//
|
||||
// int
|
||||
// main(void)
|
||||
// {
|
||||
// size_t i;
|
||||
// int ret;
|
||||
let i
|
||||
let ret
|
||||
//
|
||||
|
||||
// int ret;
|
||||
// ret = crypto_box_easy(c, m, 131, nonce, bobpk, alicesk);
|
||||
// assert(ret == 0);
|
||||
ret = crypto_box_easy(c, m, nonce, bobpk, alicesk)
|
||||
let ret = crypto_box_easy(c, m, nonce, bobpk, alicesk)
|
||||
|
||||
// for (i = 0; i < 131 + crypto_box_MACBYTES; ++i) {
|
||||
// printf(",0x%02x", (unsigned int) c[i]);
|
||||
@ -91,9 +89,10 @@ for (i = 0; i < 131 + crypto_box_MACBYTES; ++i) {
|
||||
const hex = c[i].toString(16).padStart(2, '0')
|
||||
process.stdout.write(`,0x${hex}`)
|
||||
}
|
||||
|
||||
// printf("\n");
|
||||
process.stdout.write('\n')
|
||||
//
|
||||
|
||||
// /* Null message */
|
||||
//
|
||||
// ret = crypto_box_easy(c, guard_page, 0, nonce, bobpk, alicesk);
|
||||
@ -115,6 +114,5 @@ process.stdout.write('\n')
|
||||
// assert(ret == -1);
|
||||
//
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
if (typeof window !== 'undefined') window.close()
|
||||
|
Loading…
Reference in New Issue
Block a user