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

◆ ReadEncryptedPkcs8< TRet >() [3/5]

static void System.Security.Cryptography.KeyFormatHelper.ReadEncryptedPkcs8< TRet > ( string[] validOids,
ReadOnlyMemory< byte > source,
ReadOnlySpan< char > password,
ReadOnlySpan< byte > passwordBytes,
KeyReader< TRet > keyReader,
out int bytesRead,
out TRet ret )
inlinestaticprivate

Definition at line 159 of file KeyFormatHelper.cs.

160 {
161 int length;
163 try
164 {
166 length = reader.PeekEncodedValue().Length;
167 EncryptedPrivateKeyInfoAsn.Decode(ref reader, source, out decoded);
168 }
169 catch (AsnContentException inner)
170 {
171 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding, inner);
172 }
174 Memory<byte> memory = array;
175 try
176 {
177 memory = memory[..PasswordBasedEncryption.Decrypt(in decoded.EncryptionAlgorithm, password, passwordBytes, decoded.EncryptedData.Span, array)];
178 ReadPkcs8(validOids, memory, keyReader, out var bytesRead2, out ret);
179 if (bytesRead2 != memory.Length)
180 {
181 ret = default(TRet);
182 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
183 }
184 bytesRead = length;
185 }
186 catch (CryptographicException inner2)
187 {
188 throw new CryptographicException(System.SR.Cryptography_Pkcs8_EncryptedReadFailed, inner2);
189 }
190 finally
191 {
192 CryptographicOperations.ZeroMemory(memory.Span);
194 }
195 }
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
static string Cryptography_Pkcs8_EncryptedReadFailed
Definition SR.cs:126
Definition SR.cs:7
static void Return(byte[] array, int clearSize=-1)
Definition CryptoPool.cs:12
static byte[] Rent(int minimumLength)
Definition CryptoPool.cs:7
static ReadOnlyMemory< byte > ReadPkcs8(string[] validOids, ReadOnlyMemory< byte > source, out int bytesRead)
ReadOnlySpan< byte > PeekEncodedValue()
unsafe ReadOnlySpan< T > Span
static void Decode(ref AsnValueReader reader, ReadOnlyMemory< byte > rebind, out EncryptedPrivateKeyInfoAsn decoded)

References System.array, System.SR.Cryptography_Der_Invalid_Encoding, System.SR.Cryptography_Pkcs8_EncryptedReadFailed, System.Security.Cryptography.Asn1.EncryptedPrivateKeyInfoAsn.Decode(), System.Security.Cryptography.PasswordBasedEncryption.Decrypt(), System.Security.Cryptography.Asn1.EncryptedPrivateKeyInfoAsn.EncryptedData, System.Security.Cryptography.Asn1.EncryptedPrivateKeyInfoAsn.EncryptionAlgorithm, System.length, System.Memory< T >.Length, System.ReadOnlyMemory< T >.Length, System.ReadOnlySpan< T >.Length, System.Formats.Asn1.AsnValueReader.PeekEncodedValue(), System.Security.Cryptography.KeyFormatHelper.ReadPkcs8(), System.Security.Cryptography.CryptoPool.Rent(), System.Security.Cryptography.CryptoPool.Return(), System.source, System.Memory< T >.Span, System.ReadOnlyMemory< T >.Span, and System.Security.Cryptography.CryptographicOperations.ZeroMemory().