Imported Upstream version 4.6.0.125

Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-08-03 10:59:49 +00:00
parent a569aebcfd
commit e79aa3c0ed
17047 changed files with 3137615 additions and 392334 deletions

View File

@@ -0,0 +1,162 @@
namespace System.Security.Cryptography {
static class CAPI {
// OID key type.
internal const uint CRYPT_OID_INFO_OID_KEY = 1;
internal const uint CRYPT_OID_INFO_NAME_KEY = 2;
internal const uint CRYPT_OID_INFO_ALGID_KEY = 3;
internal const uint CRYPT_OID_INFO_SIGN_KEY = 4;
public static string CryptFindOIDInfoNameFromKey (string key, OidGroup oidGroup)
{
// TODO: incomplete
// TODO: oidGroup is ignored
switch (key) {
case "1.2.840.113549.1.1.5":
case "1.3.14.3.2.29":
case "1.3.14.3.2.15":
return "sha1RSA";
case "1.2.840.113549.1.1.4":
case "1.3.14.3.2.3":
return "md5RSA";
case "1.2.840.10040.4.3":
case "1.3.14.3.2.13":
return "sha1DSA";
case "1.2.840.113549.1.1.2":
case "1.3.14.7.2.3.1":
return "md2RSA";
case "1.2.840.113549.1.1.3":
return "md4RSA";
return "md4RSA";
return "md4RSA";
case "1.3.14.3.2.27":
return "dsaSHA1";
case "2.16.840.1.101.2.1.1.19":
return "mosaicUpdatedSig";
case "1.3.14.3.2.26":
return "sha1";
case "1.2.840.113549.2.5":
return "md5";
case "2.16.840.1.101.3.4.2.1":
return "sha256";
case "2.16.840.1.101.3.4.2.2":
return "sha384";
case "2.16.840.1.101.3.4.2.3":
return "sha512";
case "1.2.840.113549.1.1.11":
return "sha256RSA";
case "1.2.840.113549.1.1.12":
return "sha384RSA";
case "1.2.840.113549.1.1.13":
return "sha512RSA";
case "1.2.840.113549.1.1.10":
return "RSASSA-PSS";
case "1.2.840.10045.4.1":
return "sha1ECDSA";
case "1.2.840.10045.4.3.2":
return "sha256ECDSA";
case "1.2.840.10045.4.3.3":
return "sha384ECDSA";
case "1.2.840.10045.4.3.4":
return "sha512ECDSA";
case "1.2.840.10045.4.3":
return "specifiedECDSA";
case "1.2.840.113549.1.1.1":
return "RSA";
case "1.2.840.113549.1.7.1":
return "PKCS 7 Data";
case "1.2.840.113549.1.9.3":
return "Content Type";
case "1.2.840.113549.1.9.4":
return "Message Digest";
case "1.2.840.113549.1.9.5":
return "Signing Time";
case "1.2.840.113549.3.7":
return "3des";
case "2.5.29.17":
return "Subject Alternative Name";
case "2.16.840.1.101.3.4.1.2":
return "aes128";
case "2.16.840.1.101.3.4.1.42":
return "aes256";
case "2.16.840.1.113730.1.1":
return "Netscape Cert Type";
}
return null;
}
public static string CryptFindOIDInfoKeyFromName (string name, OidGroup oidGroup)
{
// TODO: incomplete
// TODO: oidGroup is ignored
switch(name) {
case "sha1RSA":
return "1.2.840.113549.1.1.5";
case "md5RSA":
return "1.2.840.113549.1.1.4";
case "sha1DSA":
return "1.2.840.10040.4.3";
case "shaRSA":
return "1.3.14.3.2.29";
case "md2RSA":
return "1.2.840.113549.1.1.2";
case "md4RSA":
return "1.2.840.113549.1.1.3";
case "dsaSHA1":
return "1.3.14.3.2.27";
case "mosaicUpdatedSig":
return "2.16.840.1.101.2.1.1.19";
case "sha1":
return "1.3.14.3.2.26";
case "md5":
return "1.2.840.113549.2.5";
case "sha256":
return "2.16.840.1.101.3.4.2.1";
case "sha384":
return "2.16.840.1.101.3.4.2.2";
case "sha512":
return "2.16.840.1.101.3.4.2.3";
case "sha256RSA":
return "1.2.840.113549.1.1.11";
case "sha384RSA":
return "1.2.840.113549.1.1.12";
case "sha512RSA":
return "1.2.840.113549.1.1.13";
case "RSASSA-PSS":
return "1.2.840.113549.1.1.10";
case "sha1ECDSA":
return "1.2.840.10045.4.1";
case "sha256ECDSA":
return "1.2.840.10045.4.3.2";
case "sha384ECDSA":
return "1.2.840.10045.4.3.3";
case "sha512ECDSA":
return "1.2.840.10045.4.3.4";
case "specifiedECDSA":
return "1.2.840.10045.4.3";
case "RSA":
return "1.2.840.113549.1.1.1";
case "PKCS 7 Data":
return "1.2.840.113549.1.7.1";
case "Content Type":
return "1.2.840.113549.1.9.3";
case "Message Digest":
return "1.2.840.113549.1.9.4";
case "Signing Time":
return "1.2.840.113549.1.9.5";
case "3des":
return "1.2.840.113549.3.7";
case "Subject Alternative Name":
return "2.5.29.17";
case "aes128":
return "2.16.840.1.101.3.4.1.2";
case "aes256":
return "2.16.840.1.101.3.4.1.42";
case "Netscape Cert Type":
return "2.16.840.1.113730.1.1";
}
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
namespace System
{
internal static class EnvironmentHelpers
{
internal static bool IsWindowsVistaOrAbove()
{
return true;
}
}
}

View File

@@ -0,0 +1,164 @@
using System.Collections;
namespace System.Net
{
static class UnsafeNclNativeMethods
{
internal static unsafe class HttpApi
{
const int HttpHeaderRequestMaximum = (int)HttpRequestHeader.UserAgent + 1;
const int HttpHeaderResponseMaximum = (int)HttpResponseHeader.WwwAuthenticate + 1;
internal static class HTTP_REQUEST_HEADER_ID {
internal static string ToString(int position) {
return m_Strings[position];
}
private static string[] m_Strings = {
"Cache-Control",
"Connection",
"Date",
"Keep-Alive",
"Pragma",
"Trailer",
"Transfer-Encoding",
"Upgrade",
"Via",
"Warning",
"Allow",
"Content-Length",
"Content-Type",
"Content-Encoding",
"Content-Language",
"Content-Location",
"Content-MD5",
"Content-Range",
"Expires",
"Last-Modified",
"Accept",
"Accept-Charset",
"Accept-Encoding",
"Accept-Language",
"Authorization",
"Cookie",
"Expect",
"From",
"Host",
"If-Match",
"If-Modified-Since",
"If-None-Match",
"If-Range",
"If-Unmodified-Since",
"Max-Forwards",
"Proxy-Authorization",
"Referer",
"Range",
"Te",
"Translate",
"User-Agent",
};
}
internal static class HTTP_RESPONSE_HEADER_ID {
private static Hashtable m_Hashtable;
static HTTP_RESPONSE_HEADER_ID() {
m_Hashtable = new Hashtable((int)Enum.HttpHeaderResponseMaximum);
for (int i = 0; i < (int)Enum.HttpHeaderResponseMaximum; i++) {
m_Hashtable.Add(m_Strings[i], i);
}
}
internal static int IndexOfKnownHeader(string HeaderName) {
object index = m_Hashtable[HeaderName];
return index==null ? -1 : (int)index;
}
internal static string ToString(int position) {
return m_Strings[position];
}
}
internal enum Enum {
HttpHeaderCacheControl = 0, // general-header [section 4.5]
HttpHeaderConnection = 1, // general-header [section 4.5]
HttpHeaderDate = 2, // general-header [section 4.5]
HttpHeaderKeepAlive = 3, // general-header [not in rfc]
HttpHeaderPragma = 4, // general-header [section 4.5]
HttpHeaderTrailer = 5, // general-header [section 4.5]
HttpHeaderTransferEncoding = 6, // general-header [section 4.5]
HttpHeaderUpgrade = 7, // general-header [section 4.5]
HttpHeaderVia = 8, // general-header [section 4.5]
HttpHeaderWarning = 9, // general-header [section 4.5]
HttpHeaderAllow = 10, // entity-header [section 7.1]
HttpHeaderContentLength = 11, // entity-header [section 7.1]
HttpHeaderContentType = 12, // entity-header [section 7.1]
HttpHeaderContentEncoding = 13, // entity-header [section 7.1]
HttpHeaderContentLanguage = 14, // entity-header [section 7.1]
HttpHeaderContentLocation = 15, // entity-header [section 7.1]
HttpHeaderContentMd5 = 16, // entity-header [section 7.1]
HttpHeaderContentRange = 17, // entity-header [section 7.1]
HttpHeaderExpires = 18, // entity-header [section 7.1]
HttpHeaderLastModified = 19, // entity-header [section 7.1]
// Response Headers
HttpHeaderAcceptRanges = 20, // response-header [section 6.2]
HttpHeaderAge = 21, // response-header [section 6.2]
HttpHeaderEtag = 22, // response-header [section 6.2]
HttpHeaderLocation = 23, // response-header [section 6.2]
HttpHeaderProxyAuthenticate = 24, // response-header [section 6.2]
HttpHeaderRetryAfter = 25, // response-header [section 6.2]
HttpHeaderServer = 26, // response-header [section 6.2]
HttpHeaderSetCookie = 27, // response-header [not in rfc]
HttpHeaderVary = 28, // response-header [section 6.2]
HttpHeaderWwwAuthenticate = 29, // response-header [section 6.2]
HttpHeaderResponseMaximum = 30,
HttpHeaderMaximum = 41
}
private static string[] m_Strings = {
"Cache-Control",
"Connection",
"Date",
"Keep-Alive",
"Pragma",
"Trailer",
"Transfer-Encoding",
"Upgrade",
"Via",
"Warning",
"Allow",
"Content-Length",
"Content-Type",
"Content-Encoding",
"Content-Language",
"Content-Location",
"Content-MD5",
"Content-Range",
"Expires",
"Last-Modified",
"Accept-Ranges",
"Age",
"ETag",
"Location",
"Proxy-Authenticate",
"Retry-After",
"Server",
"Set-Cookie",
"Vary",
"WWW-Authenticate",
};
}
}
}

View File

@@ -22,18 +22,28 @@ namespace System.Net {
}
[Conditional ("TRACE")]
internal static void Enter(TraceSource traceSource, object obj, string method, object paramObject) {
}
internal static void Enter(TraceSource traceSource, object obj, string method, object paramObject) {
}
[Conditional ("TRACE")]
internal static void Exception(TraceSource traceSource, object obj, string method, Exception e) {
}
[Conditional ("TRACE")]
internal static void Exit(TraceSource traceSource, object obj, string method, object retObject) {
}
[Conditional ("TRACE")]
internal static void PrintInfo(TraceSource traceSource, object obj, string method, string msg) {
}
[Conditional ("TRACE")]
internal static void PrintWarning(TraceSource traceSource, object obj, string method, string msg) {
}
[Conditional ("TRACE")]
internal static void PrintWarning(TraceSource traceSource, string msg) {
}
}
#if MOBILE

View File

@@ -1,15 +1,208 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
namespace Microsoft.Win32
{
static class NativeMethods
{
public const int E_ABORT = unchecked ((int)0x80004004);
static class NativeMethods
{
public const int E_ABORT = unchecked ((int)0x80004004);
public static bool CloseProcess (IntPtr handle)
{
// TODO:
return true;
}
}
public const int PROCESS_TERMINATE = 0x0001;
public const int PROCESS_CREATE_THREAD = 0x0002;
public const int PROCESS_SET_SESSIONID = 0x0004;
public const int PROCESS_VM_OPERATION = 0x0008;
public const int PROCESS_VM_READ = 0x0010;
public const int PROCESS_VM_WRITE = 0x0020;
public const int PROCESS_DUP_HANDLE = 0x0040;
public const int PROCESS_CREATE_PROCESS = 0x0080;
public const int PROCESS_SET_QUOTA = 0x0100;
public const int PROCESS_SET_INFORMATION = 0x0200;
public const int PROCESS_QUERY_INFORMATION = 0x0400;
public const int PROCESS_QUERY_LIMITED_INFORMATION = 0x1000;
public const int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
public const int SYNCHRONIZE = 0x00100000;
public const int PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF;
public const int DUPLICATE_CLOSE_SOURCE = 1;
public const int DUPLICATE_SAME_ACCESS = 2;
public const int STILL_ACTIVE = 0x00000103;
public const int WAIT_OBJECT_0 = 0x00000000;
public const int WAIT_FAILED = unchecked((int)0xFFFFFFFF);
public const int WAIT_TIMEOUT = 0x00000102;
public const int WAIT_ABANDONED = 0x00000080;
public const int WAIT_ABANDONED_0 = WAIT_ABANDONED;
public static bool DuplicateHandle(HandleRef hSourceProcessHandle, SafeHandle hSourceHandle, HandleRef hTargetProcess,
out SafeWaitHandle targetHandle, int dwDesiredAccess, bool bInheritHandle, int dwOptions)
{
bool release = false;
try {
hSourceHandle.DangerousAddRef (ref release);
MonoIOError error;
IntPtr nakedTargetHandle;
bool ret = MonoIO.DuplicateHandle (hSourceProcessHandle.Handle, hSourceHandle.DangerousGetHandle (), hTargetProcess.Handle,
out nakedTargetHandle, dwDesiredAccess, bInheritHandle ? 1 : 0, dwOptions, out error);
if (error != MonoIOError.ERROR_SUCCESS)
throw MonoIO.GetException (error);
targetHandle = new SafeWaitHandle (nakedTargetHandle, true);
return ret;
} finally {
if (release)
hSourceHandle.DangerousRelease ();
}
}
public static bool DuplicateHandle(HandleRef hSourceProcessHandle, HandleRef hSourceHandle, HandleRef hTargetProcess,
out SafeProcessHandle targetHandle, int dwDesiredAccess, bool bInheritHandle, int dwOptions)
{
MonoIOError error;
IntPtr nakedTargetHandle;
bool ret = MonoIO.DuplicateHandle (hSourceProcessHandle.Handle, hSourceHandle.Handle, hTargetProcess.Handle,
out nakedTargetHandle, dwDesiredAccess, bInheritHandle ? 1 : 0, dwOptions, out error);
if (error != MonoIOError.ERROR_SUCCESS)
throw MonoIO.GetException (error);
targetHandle = new SafeProcessHandle (nakedTargetHandle, true);
return ret;
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern IntPtr GetCurrentProcess();
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern bool GetExitCodeProcess (IntPtr processHandle, out int exitCode);
public static bool GetExitCodeProcess (SafeProcessHandle processHandle, out int exitCode)
{
bool release = false;
try {
processHandle.DangerousAddRef (ref release);
return GetExitCodeProcess (processHandle.DangerousGetHandle (), out exitCode);
} finally {
if (release)
processHandle.DangerousRelease ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern bool TerminateProcess (IntPtr processHandle, int exitCode);
public static bool TerminateProcess (SafeProcessHandle processHandle, int exitCode)
{
bool release = false;
try {
processHandle.DangerousAddRef (ref release);
return TerminateProcess (processHandle.DangerousGetHandle (), exitCode);
} finally {
if (release)
processHandle.DangerousRelease ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern int WaitForInputIdle (IntPtr handle, int milliseconds);
public static int WaitForInputIdle (SafeProcessHandle handle, int milliseconds)
{
bool release = false;
try {
handle.DangerousAddRef (ref release);
return WaitForInputIdle (handle.DangerousGetHandle (), milliseconds);
} finally {
if (release)
handle.DangerousRelease ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern bool GetProcessWorkingSetSize (IntPtr handle, out IntPtr min, out IntPtr max);
public static bool GetProcessWorkingSetSize (SafeProcessHandle handle, out IntPtr min, out IntPtr max)
{
bool release = false;
try {
handle.DangerousAddRef (ref release);
return GetProcessWorkingSetSize (handle.DangerousGetHandle (), out min, out max);
} finally {
if (release)
handle.DangerousRelease ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern bool SetProcessWorkingSetSize (IntPtr handle, IntPtr min, IntPtr max);
public static bool SetProcessWorkingSetSize (SafeProcessHandle handle, IntPtr min, IntPtr max)
{
bool release = false;
try {
handle.DangerousAddRef (ref release);
return SetProcessWorkingSetSize (handle.DangerousGetHandle (), min, max);
} finally {
if (release)
handle.DangerousRelease ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern bool GetProcessTimes (IntPtr handle, out long creation, out long exit, out long kernel, out long user);
public static bool GetProcessTimes (SafeProcessHandle handle, out long creation, out long exit, out long kernel, out long user)
{
bool release = false;
try {
handle.DangerousAddRef (ref release);
return GetProcessTimes (handle.DangerousGetHandle (), out creation, out exit, out kernel, out user);
} finally {
if (release)
handle.DangerousRelease ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern int GetCurrentProcessId ();
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern int GetPriorityClass (IntPtr handle);
public static int GetPriorityClass(SafeProcessHandle handle)
{
bool release = false;
try {
handle.DangerousAddRef (ref release);
return GetPriorityClass (handle.DangerousGetHandle ());
} finally {
if (release)
handle.DangerousRelease ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public static extern bool SetPriorityClass (IntPtr handle, int priorityClass);
public static bool SetPriorityClass(SafeProcessHandle handle, int priorityClass)
{
bool release = false;
try {
handle.DangerousAddRef (ref release);
return SetPriorityClass (handle.DangerousGetHandle (), priorityClass);
} finally {
if (release)
handle.DangerousRelease ();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static bool CloseProcess (IntPtr handle);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
171360d9052ed685b4dbe768b6b6e200a47c62b9

View File

@@ -28,9 +28,6 @@
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
#endif
#if MONO_X509_ALIAS
extern alias PrebuiltSystem;
#endif
#if MONO_SECURITY_ALIAS
using MX = MonoSecurity::Mono.Security.X509;
@@ -39,11 +36,6 @@ using MonoSecurity::Mono.Security.Interface;
using MX = Mono.Security.X509;
using Mono.Security.Interface;
#endif
#if MONO_X509_ALIAS
using XX509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
#else
using XX509CertificateCollection = System.Security.Cryptography.X509Certificates.X509CertificateCollection;
#endif
using System.Runtime.InteropServices;
using System.Security.Authentication.ExtendedProtection;
@@ -73,7 +65,7 @@ namespace System.Net.Security
internal static class GlobalSSPI
{
internal static SSPIInterface Create (string hostname, bool serverMode, SchProtocols protocolFlags, X509Certificate serverCertificate, XX509CertificateCollection clientCertificates,
internal static SSPIInterface Create (string hostname, bool serverMode, SchProtocols protocolFlags, X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
bool remoteCertRequired, bool checkCertName, bool checkCertRevocationStatus, EncryptionPolicy encryptionPolicy,
LocalCertSelectionCallback certSelectionDelegate, RemoteCertValidationCallback remoteValidationCallback, SSPIConfiguration userConfig)
{
@@ -226,7 +218,7 @@ namespace System.Net.Security
internal static X509Certificate2 GetRemoteCertificate (SafeDeleteContext safeContext, out X509Certificate2Collection remoteCertificateStore)
{
XX509CertificateCollection monoCollection;
X509CertificateCollection monoCollection;
if (safeContext == null || safeContext.IsInvalid) {
remoteCertificateStore = null;
return null;

View File

@@ -1,15 +0,0 @@
namespace System.Net {
internal enum WebHeaderCollectionType : ushort {
Unknown,
WebRequest,
WebResponse,
HttpWebRequest,
HttpWebResponse,
HttpListenerRequest,
HttpListenerResponse,
FtpWebRequest,
FtpWebResponse,
FileWebRequest,
FileWebResponse,
}
}