/// <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)); }
/// <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(); } }
static Method() { original = Native.ExpectNonNull(Native.RAND_get_rand_method()); }
/// <summary> /// Calls BN_new() /// </summary> public BigNumber() : base(Native.ExpectNonNull(Native.BN_new()), true) { }
/// <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)); }
/// <summary> /// Calls BN_CTX_new() /// </summary> public Context() : base(Native.ExpectNonNull(Native.BN_CTX_new()), true) { }
/// <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)); }
/// <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)); }
/// <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); }
/// <summary> /// Calls BIO_push() /// </summary> /// <param name="bio"></param> public void Push(BIO bio) { Native.ExpectNonNull(Native.BIO_push(ptr, bio.Handle)); }
/// <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) { }
/// <summary> /// Calls sk_delete() /// </summary> /// <param name="index"></param> public void RemoveAt(int index) { Native.ExpectNonNull(Native.sk_delete(this.ptr, index)); }
/// <summary> /// Calls sk_new_null() /// </summary> public Stack() : base(Native.ExpectNonNull(Native.sk_new_null()), true) { }