Ejemplo n.º 1
0
        public virtual unsafe bool TryExportECPrivateKey(Span <byte> destination, out int bytesWritten)
        {
            ECParameters ecParameters = ExportParameters(true);

            fixed(byte *privPin = ecParameters.D)
            {
                try
                {
                    using (AsnWriter writer = ecParameters.WriteECPrivateKey())
                    {
                        return(writer.TryEncode(destination, out bytesWritten));
                    }
                }
                finally
                {
                    CryptographicOperations.ZeroMemory(ecParameters.D);
                }
            }
        }
Ejemplo n.º 2
0
        public virtual unsafe byte[] ExportECPrivateKey()
        {
            ECParameters ecParameters = ExportParameters(true);

            fixed(byte *privPin = ecParameters.D)
            {
                try
                {
                    using (AsnWriter writer = ecParameters.WriteECPrivateKey())
                    {
                        return(writer.Encode());
                    }
                }
                finally
                {
                    CryptographicOperations.ZeroMemory(ecParameters.D);
                }
            }
        }