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

◆ ImportEncryptedPkcs8PrivateKey() [2/4]

static unsafe Pkcs8Response System.Security.Cryptography.CngPkcs8.ImportEncryptedPkcs8PrivateKey ( ReadOnlySpan< byte > passwordBytes,
ReadOnlySpan< byte > source,
out int bytesRead )
inlinestaticpackage

Definition at line 135 of file CngPkcs8.cs.

136 {
137 fixed (byte* pointer = &MemoryMarshal.GetReference(source))
138 {
139 using MemoryManager<byte> memoryManager = new System.Buffers.PointerMemoryManager<byte>(pointer, source.Length);
140 try
141 {
142 ArraySegment<byte> arraySegment = System.Security.Cryptography.KeyFormatHelper.DecryptPkcs8(passwordBytes, memoryManager.Memory, out bytesRead);
143 Span<byte> span = arraySegment;
144 try
145 {
146 return ImportPkcs8(span);
147 }
148 catch (CryptographicException inner)
149 {
151 if (asnWriter == null)
152 {
153 throw new CryptographicException(System.SR.Cryptography_Pkcs8_EncryptedReadFailed, inner);
154 }
155 try
156 {
157 return ImportPkcs8(asnWriter);
158 }
159 catch (CryptographicException)
160 {
161 throw new CryptographicException(System.SR.Cryptography_Pkcs8_EncryptedReadFailed, inner);
162 }
163 }
164 finally
165 {
167 }
168 }
169 catch (AsnContentException inner2)
170 {
171 throw new CryptographicException(System.SR.Cryptography_Pkcs8_EncryptedReadFailed, inner2);
172 }
173 }
174 }
static string Cryptography_Pkcs8_EncryptedReadFailed
Definition SR.cs:126
Definition SR.cs:7
static Pkcs8Response ImportPkcs8(ReadOnlySpan< byte > keyBlob)
Definition CngPkcs8.cs:28
static unsafe AsnWriter RewritePkcs8ECPrivateKeyWithZeroPublicKey(ReadOnlySpan< byte > source)
Definition CngPkcs8.cs:278
static void Return(byte[] array, int clearSize=-1)
Definition CryptoPool.cs:12
static ArraySegment< byte > DecryptPkcs8(ReadOnlySpan< char > inputPassword, ReadOnlyMemory< byte > source, out int bytesRead)

References System.SR.Cryptography_Pkcs8_EncryptedReadFailed, System.Security.Cryptography.KeyFormatHelper.DecryptPkcs8(), System.Security.Cryptography.CngPkcs8.ImportPkcs8(), System.pointer, System.Security.Cryptography.CryptoPool.Return(), System.Security.Cryptography.CngPkcs8.RewritePkcs8ECPrivateKeyWithZeroPublicKey(), and System.source.