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

◆ RewritePkcs8ECPrivateKeyWithZeroPublicKey() [2/2]

static unsafe AsnWriter System.Security.Cryptography.CngPkcs8.RewritePkcs8ECPrivateKeyWithZeroPublicKey ( ReadOnlySpan< byte > source)
inlinestaticprivate

Definition at line 279 of file CngPkcs8.cs.

280 {
281 fixed (byte* pointer = &MemoryMarshal.GetReference(source))
282 {
283 using MemoryManager<byte> memoryManager = new System.Buffers.PointerMemoryManager<byte>(pointer, source.Length);
285 System.Security.Cryptography.Asn1.AlgorithmIdentifierAsn algId = privateKeyInfoAsn.PrivateKeyAlgorithm;
286 if (algId.Algorithm != "1.2.840.10045.2.1")
287 {
288 return null;
289 }
292 fixed (byte* ptr = ret.D)
293 {
294 try
295 {
296 if (!ret.Curve.IsExplicit || ret.Q.X != null || ret.Q.Y != null)
297 {
298 return null;
299 }
300 byte[] array = new byte[ret.D.Length];
301 ret.Q.Y = array;
302 ret.Q.X = array;
303 return System.Security.Cryptography.EccKeyFormatHelper.WritePkcs8PrivateKey(ret, privateKeyInfoAsn.Attributes);
304 }
305 finally
306 {
307 Array.Clear(ret.D);
308 }
309 }
310 }
311 }
static unsafe ECParameters FromECPrivateKey(ReadOnlySpan< byte > key, out int bytesRead)
static AsnWriter WritePkcs8PrivateKey(ECParameters ecParameters, AttributeAsn[] attributes=null)
static ECPrivateKey Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)
static PrivateKeyInfoAsn Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)

References System.Security.Cryptography.Asn1.AlgorithmIdentifierAsn.Algorithm, System.array, System.Array.Clear(), System.Security.Cryptography.Asn1.ECPrivateKey.Decode(), System.Security.Cryptography.Asn1.PrivateKeyInfoAsn.Decode(), System.Security.Cryptography.EccKeyFormatHelper.FromECPrivateKey(), System.key, System.pointer, System.source, and System.Security.Cryptography.EccKeyFormatHelper.WritePkcs8PrivateKey().