BIO_gets() private method

private BIO_gets ( IntPtr b, byte buf, int len ) : int
b System.IntPtr
buf byte
len int
return int
Esempio n. 1
0
        /// <summary>
        /// Calls BIO_gets()
        /// </summary>
        /// <returns></returns>
        public string ReadString()
        {
            var       sb         = new StringBuilder();
            const int BLOCK_SIZE = 64;
            var       buf        = new byte[BLOCK_SIZE];
            var       ret        = 0;

            while (true)
            {
                ret = Native.BIO_gets(ptr, buf, buf.Length);
                if (ret == 0)
                {
                    break;
                }
                if (ret < 0)
                {
                    throw new OpenSslException();
                }

                sb.Append(Encoding.ASCII.GetString(buf, 0, ret));
            }

            return(sb.ToString());
        }