예제 #1
0
        /// <summary>
        /// Calls EC_get_builtin_curves()
        /// </summary>
        /// <returns></returns>
        public static BuiltinCurve[] Get()
        {
            var count  = Native.EC_get_builtin_curves(IntPtr.Zero, 0);
            var curves = new BuiltinCurve[count];
            var ptr    = Native.OPENSSL_malloc(Marshal.SizeOf(typeof(EC_builtin_curve)) * count);

            try
            {
                Native.ExpectSuccess(Native.EC_get_builtin_curves(ptr, count));
                var pItem = ptr;

                for (var i = 0; i < count; i++)
                {
                    var raw = (EC_builtin_curve)Marshal.PtrToStructure(pItem, typeof(EC_builtin_curve));
                    curves[i] = new BuiltinCurve(raw.nid, raw.comment);
                    pItem     = new IntPtr(pItem.ToInt64() + Marshal.SizeOf(typeof(EC_builtin_curve)));
                }
            }
            finally
            {
                Native.OPENSSL_free(ptr);
            }

            return(curves);
        }
예제 #2
0
		/// <summary>
		/// Calls EC_get_builtin_curves()
		/// </summary>
		/// <returns></returns>
		public static BuiltinCurve[] Get()
		{
			var count = Native.EC_get_builtin_curves(IntPtr.Zero, 0);
			var curves = new BuiltinCurve[count];
			var ptr = Native.OPENSSL_malloc(Marshal.SizeOf(typeof(EC_builtin_curve)) * count);

			try
			{
				Native.ExpectSuccess(Native.EC_get_builtin_curves(ptr, count));
				var pItem = ptr;

				for (var i = 0; i < count; i++)
				{
					var raw = (EC_builtin_curve)Marshal.PtrToStructure(pItem, typeof(EC_builtin_curve));
					curves[i] = new BuiltinCurve(raw.nid, raw.comment);
					pItem = new IntPtr(pItem.ToInt64() + Marshal.SizeOf(typeof(EC_builtin_curve)));
				}
			}
			finally
			{
				Native.OPENSSL_free(ptr);
			}

			return curves;
		}