/* TODO: Implement as appropriate to grow the flexibility of the library... * private static Curve25519Provider constructNativeProvider(SecureRandomProvider random) * { * return constructClass("NativeCurve25519Provider", random); * } */ private static Curve25519Provider constructClass(Type curve25519Impl, object[] ctorParams) { if (ctorParams == null) { ctorParams = new object[] { }; } Curve25519Provider provider = null; TypeInfo curve25519TypeInfo = curve25519Impl.GetTypeInfo(); #region Validation: Class must implement Curve25519Provider base class Type baseType = curve25519TypeInfo.BaseType; bool basedOnCurve25519Provider = false; while (baseType != typeof(System.Object)) { if (baseType == typeof(Curve25519Provider)) { basedOnCurve25519Provider = true; break; } baseType = baseType.GetTypeInfo().BaseType; } if (!basedOnCurve25519Provider) { throw new ArgumentException("Class must be a subclass of " + typeof(Curve25519Provider).Name); } #endregion IEnumerator <ConstructorInfo> ctorEnum = curve25519TypeInfo.DeclaredConstructors.GetEnumerator(); while (ctorEnum.MoveNext()) { ConstructorInfo currCtor = ctorEnum.Current; ParameterInfo [] paramsInfo = currCtor.GetParameters(); if (paramsInfo.Length == ctorParams.Length) { provider = (Curve25519Provider)currCtor.Invoke(ctorParams); break; } } return(provider); }
private Curve25519(Curve25519Provider provider) { this.provider = provider; }