Skip to content

Commit e08f238

Browse files
committed
src: Throw ObjectDisposedException.
Otherwise, _disposed is pointless. However, these are internal APIs, so this should never throw.
1 parent 69972f7 commit e08f238

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/HiAEDotNet/HiAEArm.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ internal HiAEArm(ReadOnlySpan<byte> key, ReadOnlySpan<byte> nonce)
5454

5555
internal void Encrypt(Span<byte> ciphertext, ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> associatedData = default)
5656
{
57+
if (_disposed) { throw new ObjectDisposedException(nameof(HiAEArm)); }
5758
int remainder = associatedData.Length & HiAE.BlockMask;
5859
Span<byte> padded = stackalloc byte[HiAE.BlockSize];
5960
if (associatedData.Length >= HiAE.BlockSize) {
@@ -92,6 +93,7 @@ internal void Encrypt(Span<byte> ciphertext, ReadOnlySpan<byte> plaintext, ReadO
9293

9394
internal void Decrypt(Span<byte> plaintext, ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> associatedData = default)
9495
{
96+
if (_disposed) { throw new ObjectDisposedException(nameof(HiAEArm)); }
9597
int remainder = associatedData.Length & HiAE.BlockMask;
9698
Span<byte> padded = stackalloc byte[HiAE.BlockSize];
9799
if (associatedData.Length >= HiAE.BlockSize) {

src/HiAEDotNet/HiAEx86.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ internal HiAEx86(ReadOnlySpan<byte> key, ReadOnlySpan<byte> nonce)
5454

5555
internal void Encrypt(Span<byte> ciphertext, ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> associatedData = default)
5656
{
57+
if (_disposed) { throw new ObjectDisposedException(nameof(HiAEx86)); }
5758
int remainder = associatedData.Length & HiAE.BlockMask;
5859
Span<byte> padded = stackalloc byte[HiAE.BlockSize];
5960
if (associatedData.Length >= HiAE.BlockSize) {
@@ -92,6 +93,7 @@ internal void Encrypt(Span<byte> ciphertext, ReadOnlySpan<byte> plaintext, ReadO
9293

9394
internal void Decrypt(Span<byte> plaintext, ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> associatedData = default)
9495
{
96+
if (_disposed) { throw new ObjectDisposedException(nameof(HiAEx86)); }
9597
int remainder = associatedData.Length & HiAE.BlockMask;
9698
Span<byte> padded = stackalloc byte[HiAE.BlockSize];
9799
if (associatedData.Length >= HiAE.BlockSize) {

0 commit comments

Comments
 (0)