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

◆ PadBlock() [3/3]

int Internal.Cryptography.UniversalCryptoEncryptor.PadBlock ( ReadOnlySpan< byte > block,
Span< byte > destination )
inlineprivate

Definition at line 62 of file UniversalCryptoEncryptor.cs.

63 {
64 int length = block.Length;
65 int num = length % base.PaddingSizeBytes;
66 int num2 = base.PaddingSizeBytes - num;
67 switch (base.PaddingMode)
68 {
69 case PaddingMode.None:
70 if (num != 0)
71 {
73 }
74 if (destination.Length < length)
75 {
77 }
78 block.CopyTo(destination);
79 return length;
80 case PaddingMode.ANSIX923:
81 {
82 int num4 = length + num2;
83 if (destination.Length < num4)
84 {
86 }
87 block.CopyTo(destination);
88 destination.Slice(length, num2 - 1).Clear();
89 destination[length + num2 - 1] = (byte)num2;
90 return num4;
91 }
92 case PaddingMode.ISO10126:
93 {
94 int num6 = length + num2;
95 if (destination.Length < num6)
96 {
98 }
99 block.CopyTo(destination);
101 destination[length + num2 - 1] = (byte)num2;
102 return num6;
103 }
104 case PaddingMode.PKCS7:
105 {
106 int num5 = length + num2;
107 if (destination.Length < num5)
108 {
110 }
111 block.CopyTo(destination);
112 destination.Slice(length, num2).Fill((byte)num2);
113 return num5;
114 }
115 case PaddingMode.Zeros:
116 {
117 if (num2 == base.PaddingSizeBytes)
118 {
119 num2 = 0;
120 }
121 int num3 = length + num2;
122 if (destination.Length < num3)
123 {
125 }
126 block.CopyTo(destination);
127 destination.Slice(length, num2).Clear();
128 return num3;
129 }
130 default:
132 }
133 }
static string Argument_DestinationTooShort
Definition SR.cs:14
static string Cryptography_UnknownPaddingMode
Definition SR.cs:154
static string Cryptography_PartialBlock
Definition SR.cs:124
Definition SR.cs:7
void CopyTo(Span< T > destination)

References System.SR.Argument_DestinationTooShort, System.ReadOnlySpan< T >.CopyTo(), System.SR.Cryptography_PartialBlock, System.SR.Cryptography_UnknownPaddingMode, System.destination, System.Security.Cryptography.RandomNumberGenerator.Fill(), System.length, and System.ReadOnlySpan< T >.Length.