Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetCiphertextLengthBlockAligned()

int System.Security.Cryptography.SymmetricAlgorithm.GetCiphertextLengthBlockAligned ( int plaintextLength,
PaddingMode paddingMode )
inlineprivateinherited

Definition at line 252 of file SymmetricAlgorithm.cs.

253 {
254 if (plaintextLength < 0)
255 {
256 throw new ArgumentOutOfRangeException("plaintextLength", System.SR.ArgumentOutOfRange_NeedNonNegNum);
257 }
258 int blockSize = BlockSize;
259 if (blockSize <= 0 || ((uint)blockSize & 7u) != 0)
260 {
262 }
263 int num = blockSize >> 3;
264 int result;
265 int num2 = Math.DivRem(plaintextLength, num, out result) * num;
266 switch (paddingMode)
267 {
268 case PaddingMode.None:
269 if (result != 0)
270 {
271 throw new ArgumentException(System.SR.Cryptography_MatchBlockSize, "plaintextLength");
272 }
273 goto IL_0077;
274 case PaddingMode.Zeros:
275 if (result == 0)
276 {
277 goto IL_0077;
278 }
279 goto case PaddingMode.PKCS7;
280 case PaddingMode.PKCS7:
281 case PaddingMode.ANSIX923:
282 case PaddingMode.ISO10126:
283 if (int.MaxValue - num2 < num)
284 {
285 throw new ArgumentOutOfRangeException("plaintextLength", System.SR.Cryptography_PlaintextTooLarge);
286 }
287 return num2 + num;
288 default:
289 {
290 throw new ArgumentOutOfRangeException("paddingMode", System.SR.Cryptography_InvalidPaddingMode);
291 }
292 IL_0077:
293 return plaintextLength;
294 }
295 }
static string InvalidOperation_UnsupportedBlockSize
Definition SR.cs:74
static string Cryptography_MatchBlockSize
Definition SR.cs:52
static string Cryptography_PlaintextTooLarge
Definition SR.cs:56
static string Cryptography_InvalidPaddingMode
Definition SR.cs:46
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
Definition SR.cs:7

References System.SR.ArgumentOutOfRange_NeedNonNegNum, System.Security.Cryptography.SymmetricAlgorithm.BlockSize, System.SR.Cryptography_InvalidPaddingMode, System.SR.Cryptography_MatchBlockSize, System.SR.Cryptography_PlaintextTooLarge, System.Math.DivRem(), and System.SR.InvalidOperation_UnsupportedBlockSize.

Referenced by System.Security.Cryptography.SymmetricAlgorithm.GetCiphertextLengthCbc(), and System.Security.Cryptography.SymmetricAlgorithm.GetCiphertextLengthEcb().