From 467b0f9adb842e82d385415837753f09ad1b34d4 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 22 Nov 2023 18:16:07 +0700 Subject: Consistent exception messages --- crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs | 2 +- crypto/src/crypto/agreement/kdf/DHKekGenerator.cs | 2 +- crypto/src/crypto/agreement/kdf/ECDHKekGenerator.cs | 2 +- crypto/src/crypto/digests/AsconDigest.cs | 4 ++-- crypto/src/crypto/digests/ISAPDigest.cs | 4 ++-- crypto/src/crypto/digests/PhotonBeetleDigest.cs | 2 +- crypto/src/crypto/digests/XoodyakDigest.cs | 2 +- crypto/src/crypto/generators/BaseKdfBytesGenerator.cs | 2 +- crypto/src/crypto/generators/Mgf1BytesGenerator.cs | 2 +- crypto/src/crypto/macs/Poly1305.cs | 4 ++-- crypto/src/crypto/modes/CcmBlockCipher.cs | 4 ++-- crypto/src/crypto/modes/EAXBlockCipher.cs | 2 +- crypto/src/crypto/modes/KCtrBlockCipher.cs | 2 +- crypto/src/crypto/modes/OCBBlockCipher.cs | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) (limited to 'crypto') diff --git a/crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs b/crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs index 8467460b4..9b08f3c04 100644 --- a/crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs +++ b/crypto/src/crypto/agreement/kdf/ConcatenationKdfGenerator.cs @@ -44,7 +44,7 @@ namespace Org.BouncyCastle.Crypto.Agreement.Kdf /// public int GenerateBytes(byte[] output, int outOff, int length) { - Check.OutputLength(output, outOff, length, "output buffer too small"); + Check.OutputLength(output, outOff, length, "output buffer too short"); #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER return GenerateBytes(output.AsSpan(outOff, length)); diff --git a/crypto/src/crypto/agreement/kdf/DHKekGenerator.cs b/crypto/src/crypto/agreement/kdf/DHKekGenerator.cs index 2dabe9d1f..a6cda5061 100644 --- a/crypto/src/crypto/agreement/kdf/DHKekGenerator.cs +++ b/crypto/src/crypto/agreement/kdf/DHKekGenerator.cs @@ -39,7 +39,7 @@ namespace Org.BouncyCastle.Crypto.Agreement.Kdf public int GenerateBytes(byte[] outBytes, int outOff, int length) { - Check.OutputLength(outBytes, outOff, length, "output buffer too small"); + Check.OutputLength(outBytes, outOff, length, "output buffer too short"); #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER return GenerateBytes(outBytes.AsSpan(outOff, length)); diff --git a/crypto/src/crypto/agreement/kdf/ECDHKekGenerator.cs b/crypto/src/crypto/agreement/kdf/ECDHKekGenerator.cs index dbb7ad535..faf0715e2 100644 --- a/crypto/src/crypto/agreement/kdf/ECDHKekGenerator.cs +++ b/crypto/src/crypto/agreement/kdf/ECDHKekGenerator.cs @@ -38,7 +38,7 @@ namespace Org.BouncyCastle.Crypto.Agreement.Kdf public int GenerateBytes(byte[] outBytes, int outOff, int length) { - Check.OutputLength(outBytes, outOff, length, "output buffer too small"); + Check.OutputLength(outBytes, outOff, length, "output buffer too short"); #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER return GenerateBytes(outBytes.AsSpan(outOff, length)); diff --git a/crypto/src/crypto/digests/AsconDigest.cs b/crypto/src/crypto/digests/AsconDigest.cs index 84c9299d3..42b576d52 100644 --- a/crypto/src/crypto/digests/AsconDigest.cs +++ b/crypto/src/crypto/digests/AsconDigest.cs @@ -155,7 +155,7 @@ namespace Org.BouncyCastle.Crypto.Digests #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER return DoFinal(output.AsSpan(outOff)); #else - Check.OutputLength(output, outOff, 32, "output buffer is too short"); + Check.OutputLength(output, outOff, 32, "output buffer too short"); FinishAbsorbing(); @@ -177,7 +177,7 @@ namespace Org.BouncyCastle.Crypto.Digests #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER public int DoFinal(Span output) { - Check.OutputLength(output, 32, "output buffer is too short"); + Check.OutputLength(output, 32, "output buffer too short"); FinishAbsorbing(); diff --git a/crypto/src/crypto/digests/ISAPDigest.cs b/crypto/src/crypto/digests/ISAPDigest.cs index 83214fe6b..4844a36ef 100644 --- a/crypto/src/crypto/digests/ISAPDigest.cs +++ b/crypto/src/crypto/digests/ISAPDigest.cs @@ -45,7 +45,7 @@ namespace Org.BouncyCastle.Crypto.Digests #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER return DoFinal(output.AsSpan(outOff)); #else - Check.OutputLength(output, outOff, 32, "output buffer is too short"); + Check.OutputLength(output, outOff, 32, "output buffer too short"); /* init state */ x0 = 17191252062196199485UL; @@ -84,7 +84,7 @@ namespace Org.BouncyCastle.Crypto.Digests #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER public int DoFinal(Span output) { - Check.OutputLength(output, 32, "output buffer is too short"); + Check.OutputLength(output, 32, "output buffer too short"); /* init state */ x0 = 17191252062196199485UL; diff --git a/crypto/src/crypto/digests/PhotonBeetleDigest.cs b/crypto/src/crypto/digests/PhotonBeetleDigest.cs index c7cbfdfca..1617fd1fa 100644 --- a/crypto/src/crypto/digests/PhotonBeetleDigest.cs +++ b/crypto/src/crypto/digests/PhotonBeetleDigest.cs @@ -95,7 +95,7 @@ namespace Org.BouncyCastle.Crypto.Digests public int DoFinal(byte[] output, int outOff) { - Check.OutputLength(output, outOff, 32, "output buffer is too short"); + Check.OutputLength(output, outOff, 32, "output buffer too short"); byte[] input = buffer.GetBuffer(); int inlen = (int)buffer.Length; diff --git a/crypto/src/crypto/digests/XoodyakDigest.cs b/crypto/src/crypto/digests/XoodyakDigest.cs index 4836f4d2b..defb60b04 100644 --- a/crypto/src/crypto/digests/XoodyakDigest.cs +++ b/crypto/src/crypto/digests/XoodyakDigest.cs @@ -69,7 +69,7 @@ namespace Org.BouncyCastle.Crypto.Digests public int DoFinal(byte[] output, int outOff) { - Check.OutputLength(output, outOff, 32, "output buffer is too short"); + Check.OutputLength(output, outOff, 32, "output buffer too short"); byte[] input = buffer.GetBuffer(); int inLen = (int)buffer.Length; diff --git a/crypto/src/crypto/generators/BaseKdfBytesGenerator.cs b/crypto/src/crypto/generators/BaseKdfBytesGenerator.cs index a1839dc33..01e655c20 100644 --- a/crypto/src/crypto/generators/BaseKdfBytesGenerator.cs +++ b/crypto/src/crypto/generators/BaseKdfBytesGenerator.cs @@ -63,7 +63,7 @@ namespace Org.BouncyCastle.Crypto.Generators */ public int GenerateBytes(byte[] output, int outOff, int length) { - Check.OutputLength(output, outOff, length, "output buffer too small"); + Check.OutputLength(output, outOff, length, "output buffer too short"); #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER return GenerateBytes(output.AsSpan(outOff, length)); diff --git a/crypto/src/crypto/generators/Mgf1BytesGenerator.cs b/crypto/src/crypto/generators/Mgf1BytesGenerator.cs index 7b4bb3c0b..161ce9ef3 100644 --- a/crypto/src/crypto/generators/Mgf1BytesGenerator.cs +++ b/crypto/src/crypto/generators/Mgf1BytesGenerator.cs @@ -37,7 +37,7 @@ namespace Org.BouncyCastle.Crypto.Generators /// public int GenerateBytes(byte[] output, int outOff, int length) { - Check.OutputLength(output, outOff, length, "output buffer too small"); + Check.OutputLength(output, outOff, length, "output buffer too short"); #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER return GenerateBytes(output.AsSpan(outOff, length)); diff --git a/crypto/src/crypto/macs/Poly1305.cs b/crypto/src/crypto/macs/Poly1305.cs index 61f13a972..5695f86b3 100644 --- a/crypto/src/crypto/macs/Poly1305.cs +++ b/crypto/src/crypto/macs/Poly1305.cs @@ -292,7 +292,7 @@ namespace Org.BouncyCastle.Crypto.Macs #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER return DoFinal(output.AsSpan(outOff)); #else - Check.OutputLength(output, outOff, BlockSize, "output buffer is too short."); + Check.OutputLength(output, outOff, BlockSize, "output buffer too short"); if (currentBlockOffset > 0) { @@ -338,7 +338,7 @@ namespace Org.BouncyCastle.Crypto.Macs #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER public int DoFinal(Span output) { - Check.OutputLength(output, BlockSize, "output buffer is too short."); + Check.OutputLength(output, BlockSize, "output buffer too short."); if (currentBlockOffset > 0) { diff --git a/crypto/src/crypto/modes/CcmBlockCipher.cs b/crypto/src/crypto/modes/CcmBlockCipher.cs index b7d90298a..fa583fdef 100644 --- a/crypto/src/crypto/modes/CcmBlockCipher.cs +++ b/crypto/src/crypto/modes/CcmBlockCipher.cs @@ -292,7 +292,7 @@ namespace Org.BouncyCastle.Crypto.Modes if (forEncryption) { outputLen = inLen + macSize; - Check.OutputLength(output, outOff, outputLen, "Output buffer too short."); + Check.OutputLength(output, outOff, outputLen, "output buffer too short"); CalculateMac(input, inOff, inLen, macBlock); @@ -322,7 +322,7 @@ namespace Org.BouncyCastle.Crypto.Modes throw new InvalidCipherTextException("data too short"); outputLen = inLen - macSize; - Check.OutputLength(output, outOff, outputLen, "Output buffer too short."); + Check.OutputLength(output, outOff, outputLen, "output buffer too short"); Array.Copy(input, inOff + outputLen, macBlock, 0, macSize); diff --git a/crypto/src/crypto/modes/EAXBlockCipher.cs b/crypto/src/crypto/modes/EAXBlockCipher.cs index 858786d10..bf0d14938 100644 --- a/crypto/src/crypto/modes/EAXBlockCipher.cs +++ b/crypto/src/crypto/modes/EAXBlockCipher.cs @@ -464,7 +464,7 @@ namespace Org.BouncyCastle.Crypto.Modes if (bufOff == bufBlock.Length) { - Check.OutputLength(outBytes, outOff, blockSize, "Output buffer is too short"); + Check.OutputLength(outBytes, outOff, blockSize, "output buffer too short"); // TODO Could move the ProcessByte(s) calls to here // InitCipher(); diff --git a/crypto/src/crypto/modes/KCtrBlockCipher.cs b/crypto/src/crypto/modes/KCtrBlockCipher.cs index b0c4054e0..032c75e25 100644 --- a/crypto/src/crypto/modes/KCtrBlockCipher.cs +++ b/crypto/src/crypto/modes/KCtrBlockCipher.cs @@ -117,7 +117,7 @@ namespace Org.BouncyCastle.Crypto.Modes public void ProcessBytes(byte[] input, int inOff, int len, byte[] output, int outOff) { - Check.DataLength(input, inOff, len, "input buffer too small"); + Check.DataLength(input, inOff, len, "input buffer too short"); Check.OutputLength(output, outOff, len, "output buffer too short"); int inStart = inOff; diff --git a/crypto/src/crypto/modes/OCBBlockCipher.cs b/crypto/src/crypto/modes/OCBBlockCipher.cs index a7facaa04..6dbaa09f6 100644 --- a/crypto/src/crypto/modes/OCBBlockCipher.cs +++ b/crypto/src/crypto/modes/OCBBlockCipher.cs @@ -613,7 +613,7 @@ namespace Org.BouncyCastle.Crypto.Modes protected virtual void ProcessMainBlock(byte[] output, int outOff) { - Check.DataLength(output, outOff, BLOCK_SIZE, "Output buffer too short"); + Check.OutputLength(output, outOff, BLOCK_SIZE, "output buffer too short"); /* * OCB-ENCRYPT/OCB-DECRYPT: Process any whole blocks -- cgit 1.4.1