Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Helpers.cs
Go to the documentation of this file.
1using System;
4
6
7internal static class Helpers
8{
9 public static bool UsesIv(this CipherMode cipherMode)
10 {
11 return cipherMode != CipherMode.ECB;
12 }
13
14 public static byte[] GetCipherIv(this CipherMode cipherMode, byte[] iv)
15 {
16 if (cipherMode.UsesIv())
17 {
18 if (iv == null)
19 {
21 }
22 return iv;
23 }
24 return null;
25 }
26
27 public static byte[] TrimLargeIV(byte[] currentIV, int blockSizeInBits)
28 {
29 int num = checked(blockSizeInBits + 7) / 8;
30 if (currentIV != null && currentIV.Length > num)
31 {
32 byte[] array = new byte[num];
33 Buffer.BlockCopy(currentIV, 0, array, 0, array.Length);
34 return array;
35 }
36 return currentIV;
37 }
38
39 [return: NotNullIfNotNull("src")]
40 public static byte[] CloneByteArray(this byte[] src)
41 {
42 if (src == null)
43 {
44 return null;
45 }
46 return (byte[])src.Clone();
47 }
48
50 {
51 return ((mode == CipherMode.CFB) ? feedbackSizeInBits : algorithm.BlockSize) / 8;
52 }
53}
static byte[] TrimLargeIV(byte[] currentIV, int blockSizeInBits)
Definition Helpers.cs:27
static byte[] GetCipherIv(this CipherMode cipherMode, byte[] iv)
Definition Helpers.cs:14
static int GetPaddingSize(this SymmetricAlgorithm algorithm, CipherMode mode, int feedbackSizeInBits)
Definition Helpers.cs:49
static byte[] CloneByteArray(this byte[] src)
Definition Helpers.cs:40
static bool UsesIv(this CipherMode cipherMode)
Definition Helpers.cs:9
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
Definition Buffer.cs:102
static string Cryptography_MissingIV
Definition SR.cs:112
Definition SR.cs:7