ExpectNonNull() public static method

public static ExpectNonNull ( IntPtr ptr ) : IntPtr
ptr IntPtr
return IntPtr
Example #1
0
        /// <summary>
        /// Factory method that calls BIO_new() with BIO_f_md()
        /// </summary>
        /// <param name="md"></param>
        /// <returns></returns>
        public static BIO MessageDigest(MessageDigest md)
        {
            IntPtr ptr = Native.ExpectNonNull(Native.BIO_new(Native.BIO_f_md()));

            Native.BIO_set_md(ptr, md.Handle);
            return(new BIO(ptr, true));
        }
Example #2
0
 /// <summary>
 /// Indexer that returns sk_value() or calls sk_insert()
 /// </summary>
 /// <param name="index"></param>
 /// <returns></returns>
 public T this[int index]
 {
     get
     {
         // Get the native pointer from the stack
         IntPtr ptr = Native.ExpectNonNull(Native.sk_value(this.ptr, index));
         // Create a new object
         T item = CreateInstance(ptr);
         // Addref the object
         item.AddRef();
         // Return the managed object
         return(item);
     }
     set
     {
         // Insert the item in the stack
         int ret = Native.sk_insert(this.ptr, value.Handle, index);
         if (ret < 0)
         {
             throw new OpenSslException();
         }
         // Addref the native pointer
         value.AddRef();
     }
 }
Example #3
0
 static Method()
 {
     original = Native.ExpectNonNull(Native.RAND_get_rand_method());
 }
Example #4
0
 /// <summary>
 /// Calls BN_new()
 /// </summary>
 public BigNumber()
     : base(Native.ExpectNonNull(Native.BN_new()), true)
 {
 }
Example #5
0
        /// <summary>
        /// Calls BN_bin2bn()
        /// </summary>
        /// <param name="buf"></param>
        /// <returns></returns>
        public static BigNumber FromArray(byte[] buf)
        {
            IntPtr ptr = Native.BN_bin2bn(buf, buf.Length, IntPtr.Zero);

            return(new BigNumber(Native.ExpectNonNull(ptr), true));
        }
Example #6
0
 /// <summary>
 /// Calls BN_CTX_new()
 /// </summary>
 public Context()
     : base(Native.ExpectNonNull(Native.BN_CTX_new()), true)
 {
 }
Example #7
0
        /// <summary>
        /// Factory method that calls BIO_new_file()
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static BIO File(string filename, string mode)
        {
            var ptr = Native.ExpectNonNull(Native.BIO_new_file(filename, mode));

            return(new BIO(ptr, true));
        }
Example #8
0
        /// <summary>
        /// Calls BIO_new(BIO_s_mem())
        /// </summary>
        /// <param name="takeOwnership"></param>
        /// <returns></returns>
        public static BIO MemoryBuffer(bool takeOwnership)
        {
            var ptr = Native.ExpectNonNull(Native.BIO_new(Native.BIO_s_mem()));

            return(new BIO(ptr, takeOwnership));
        }
Example #9
0
 /// <summary>
 /// Calls BIO_new(BIO_s_mem()) and then BIO_write() the buf
 /// </summary>
 /// <param name="buf"></param>
 public BIO(byte[] buf)
     : base(Native.ExpectNonNull(Native.BIO_new(Native.BIO_s_mem())), true)
 {
     Write(buf);
 }
Example #10
0
 /// <summary>
 /// Calls BIO_push()
 /// </summary>
 /// <param name="bio"></param>
 public void Push(BIO bio)
 {
     Native.ExpectNonNull(Native.BIO_push(ptr, bio.Handle));
 }
Example #11
0
 /// <summary>
 /// Calls BIO_new_mem_buf() from the specified buffer.
 /// </summary>
 /// <param name="buf"></param>
 public BIO(byte[] buf)
     : base(Native.ExpectNonNull(Native.BIO_new_mem_buf(buf, buf.Length)), true)
 {
 }
Example #12
0
 /// <summary>
 /// Calls sk_delete()
 /// </summary>
 /// <param name="index"></param>
 public void RemoveAt(int index)
 {
     Native.ExpectNonNull(Native.sk_delete(this.ptr, index));
 }
Example #13
0
 /// <summary>
 /// Calls sk_new_null()
 /// </summary>
 public Stack()
     : base(Native.ExpectNonNull(Native.sk_new_null()), true)
 {
 }