| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 180c150 commit d490b17
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -591,7 +591,9 @@ void ArrayBufferViewContents<T, S>::Read(v8::Local<v8::ArrayBufferView> abv) { | |||
| 591 | 591 | static_assert(sizeof(T) == 1, "Only supports one-byte data at the moment"); | |
| 592 | 592 | length_ = abv->ByteLength(); | |
| 593 | 593 | if (length_ > sizeof(stack_storage_) || abv->HasBuffer()) { | |
| 594 | - data_ = static_cast<T*>(abv->Buffer()->Data()) + abv->ByteOffset(); | ||
| 594 | + auto buf_data = abv->Buffer()->Data(); | ||
| 595 | + data_ = buf_data != nullptr ? static_cast<T*>(buf_data) + abv->ByteOffset() | ||
| 596 | + : stack_storage_; | ||
| 595 | 597 | } else { | |
| 596 | 598 | abv->CopyContents(stack_storage_, sizeof(stack_storage_)); | |
| 597 | 599 | data_ = stack_storage_; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -772,3 +772,26 @@ for (const test of TEST_CASES) { | |||
| 772 | 772 | decipher.final(); | |
| 773 | 773 | }, /Unsupported state or unable to authenticate data/); | |
| 774 | 774 | } | |
| 775 | + | ||
| 776 | + // Refs: https://github.com/nodejs/node/issues/62342 | ||
| 777 | + { | ||
| 778 | + const key = crypto.randomBytes(16); | ||
| 779 | + const nonce = crypto.randomBytes(13); | ||
| 780 | + | ||
| 781 | + const cipher = crypto.createCipheriv('aes-128-ccm', key, nonce, { | ||
| 782 | + authTagLength: 16, | ||
| 783 | + }); | ||
| 784 | + cipher.setAAD(Buffer.alloc(0), { plaintextLength: 0 }); | ||
| 785 | + cipher.update(new DataView(new ArrayBuffer(0))); | ||
| 786 | + cipher.final(); | ||
| 787 | + const tag = cipher.getAuthTag(); | ||
| 788 | + assert.strictEqual(tag.length, 16); | ||
| 789 | + | ||
| 790 | + const decipher = crypto.createDecipheriv('aes-128-ccm', key, nonce, { | ||
| 791 | + authTagLength: 16, | ||
| 792 | + }); | ||
| 793 | + decipher.setAuthTag(tag); | ||
| 794 | + decipher.setAAD(Buffer.alloc(0), { plaintextLength: 0 }); | ||
| 795 | + decipher.update(new DataView(new ArrayBuffer(0))); | ||
| 796 | + decipher.final(); | ||
| 797 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments