Пример #1
0
            public override void Write(byte[] buffer, int offset, int count)
            {
                IntPtr buf = Marshal.AllocHGlobal(count);

                Marshal.Copy(buffer, offset, buf, count);
                int writeCount;

                do
                {
                    writeCount = OpenSSL.BIO_write(bio, buf, count);
                } while (writeCount <= 0 && OpenSSL.BIO_should_retry(bio));
                OpenSSL.OpenSSLCheck(writeCount == count, "BIO_write");
                Marshal.FreeHGlobal(buf);
            }
Пример #2
0
            public override int Read(byte[] buffer, int offset, int count)
            {
                IntPtr buf = Marshal.AllocHGlobal(count);
                int    readCount;

                do
                {
                    readCount = OpenSSL.BIO_read(bio, buf, count);
                } while (readCount <= 0 && OpenSSL.BIO_should_retry(bio));
                OpenSSL.OpenSSLCheck(readCount > 0, "BIO_write");
                Marshal.Copy(buf, buffer, offset, readCount);
                Marshal.FreeHGlobal(buf);
                return(readCount);
            }