You've already forked linux-packaging-mono
Imported Upstream version 6.4.0.137
Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
parent
e9207cf623
commit
ef583813eb
@@ -74,7 +74,7 @@ namespace System {
|
||||
throw new ArgumentNullException("type");
|
||||
Contract.EndContractBlock();
|
||||
#if !FULL_AOT_RUNTIME
|
||||
if (type is System.Reflection.Emit.TypeBuilder)
|
||||
if (RuntimeFeature.IsDynamicCodeSupported && type is System.Reflection.Emit.TypeBuilder)
|
||||
throw new NotSupportedException(Environment.GetResourceString("NotSupported_CreateInstanceWithTypeBuilder"));
|
||||
#endif
|
||||
// If they didn't specify a lookup, then we will provide the default lookup.
|
||||
@@ -699,7 +699,7 @@ namespace System {
|
||||
}
|
||||
#endif // FEATURE_COMINTEROP
|
||||
|
||||
#if FEATURE_REMOTING || MOBILE_LEGACY
|
||||
#if !DISABLE_REMOTING && (FEATURE_REMOTING || MOBILE_LEGACY)
|
||||
// This method is a helper method and delegates to the remoting
|
||||
// services to do the actual work.
|
||||
[System.Security.SecurityCritical] // auto-generated_required
|
||||
|
||||
@@ -151,7 +151,6 @@ namespace System {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public virtual String Message {
|
||||
get {
|
||||
if (_message == null) {
|
||||
|
||||
@@ -281,7 +281,7 @@ namespace System {
|
||||
|
||||
if ((mode < GCCollectionMode.Default) || (mode > GCCollectionMode.Optimized))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_Enum"));
|
||||
throw new ArgumentOutOfRangeException("mode", Environment.GetResourceString("ArgumentOutOfRange_Enum"));
|
||||
}
|
||||
|
||||
Contract.EndContractBlock();
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace System.Globalization
|
||||
InitializeAbbreviatedEraNames(localeName, calendarId);
|
||||
|
||||
// Abbreviated English Era Names are only used for the Japanese calendar.
|
||||
if (calendarId == (int)CalendarId.JAPAN)
|
||||
if (!GlobalizationMode.Invariant && calendarId == (int)CalendarId.JAPAN)
|
||||
{
|
||||
this.saAbbrevEnglishEraNames = JapaneseCalendar.EnglishEraNames();
|
||||
}
|
||||
@@ -268,6 +268,10 @@ namespace System.Globalization
|
||||
|
||||
case CalendarId.JAPAN:
|
||||
case CalendarId.JAPANESELUNISOLAR:
|
||||
if (GlobalizationMode.Invariant)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
this.saEraNames = JapaneseCalendar.EraNames();
|
||||
break;
|
||||
|
||||
@@ -306,7 +310,11 @@ namespace System.Globalization
|
||||
break;
|
||||
case CalendarId.JAPAN:
|
||||
case CalendarId.JAPANESELUNISOLAR:
|
||||
this.saAbbrevEraNames = JapaneseCalendar.AbbrevEraNames();
|
||||
if (GlobalizationMode.Invariant)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
this.saAbbrevEraNames = this.saEraNames;
|
||||
break;
|
||||
case CalendarId.HIJRI:
|
||||
case CalendarId.UMALQURA:
|
||||
|
||||
@@ -22,14 +22,14 @@ namespace System.Globalization {
|
||||
** year based on the era.
|
||||
**
|
||||
** This system is adopted by Emperor Meiji in 1868. The year value is counted based on the reign of an emperor,
|
||||
** and the era begins on the day an emperor ascends the throne and continues until his death.
|
||||
** and the era begins on the day an emperor ascends the throne and continues until his death or his abdication.
|
||||
** The era changes at 12:00AM.
|
||||
**
|
||||
** For example, the current era is Heisei. It started on 1989/1/8 A.D. Therefore, Gregorian year 1989 is also Heisei 1st.
|
||||
** 1989/1/8 A.D. is also Heisei 1st 1/8.
|
||||
** For example, the current era is Reiwa. It started on 2019/5/1 A.D. Therefore, Gregorian year 2019 is also Reiwa 1st.
|
||||
** 2019/5/1 A.D. is also Reiwa 1st 5/1.
|
||||
**
|
||||
** Any date in the year during which era is changed can be reckoned in either era. For example,
|
||||
** 1989/1/1 can be 1/1 Heisei 1st year or 1/1 Showa 64th year.
|
||||
** 2019/1/1 can be 1/1 Reiwa 1st year or 1/1 Heisei 31st year.
|
||||
**
|
||||
** Note:
|
||||
** The DateTime can be represented by the JapaneseCalendar are limited to two factors:
|
||||
@@ -40,7 +40,7 @@ namespace System.Globalization {
|
||||
** Calendar Minimum Maximum
|
||||
** ========== ========== ==========
|
||||
** Gregorian 1868/09/08 9999/12/31
|
||||
** Japanese Meiji 01/01 Heisei 8011/12/31
|
||||
** Japanese Meiji 01/01 Reiwa 7981/12/31
|
||||
============================================================================*/
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace System.Globalization {
|
||||
// should be the first element.
|
||||
// That is, m_EraInfo[0] contains the most recent era.
|
||||
//
|
||||
// We know about 4 built-in eras, however users may add additional era(s) from the
|
||||
// We know about 5 built-in eras, however users may add additional era(s) from the
|
||||
// registry, by adding values to HKLM\SYSTEM\CurrentControlSet\Control\Nls\Calendars\Japanese\Eras
|
||||
//
|
||||
// Registry values look like:
|
||||
@@ -124,14 +124,16 @@ namespace System.Globalization {
|
||||
if (japaneseEraInfo == null)
|
||||
{
|
||||
// We know about some built-in ranges
|
||||
EraInfo[] defaultEraRanges = new EraInfo[4];
|
||||
defaultEraRanges[0] = new EraInfo( 4, 1989, 1, 8, 1988, 1, GregorianCalendar.MaxYear - 1988,
|
||||
EraInfo[] defaultEraRanges = new EraInfo[5];
|
||||
defaultEraRanges[0] = new EraInfo( 5, 2019, 5, 1, 2018, 1, GregorianCalendar.MaxYear - 2018,
|
||||
"\x4ee4\x548c", "\x4ee4", "R"); // era #5 start year/month/day, yearOffset, minEraYear
|
||||
defaultEraRanges[1] = new EraInfo( 4, 1989, 1, 8, 1988, 1, 2019-1988,
|
||||
"\x5e73\x6210", "\x5e73", "H"); // era #4 start year/month/day, yearOffset, minEraYear
|
||||
defaultEraRanges[1] = new EraInfo( 3, 1926, 12, 25, 1925, 1, 1989-1925,
|
||||
defaultEraRanges[2] = new EraInfo( 3, 1926, 12, 25, 1925, 1, 1989-1925,
|
||||
"\x662d\x548c", "\x662d", "S"); // era #3,start year/month/day, yearOffset, minEraYear
|
||||
defaultEraRanges[2] = new EraInfo( 2, 1912, 7, 30, 1911, 1, 1926-1911,
|
||||
defaultEraRanges[3] = new EraInfo( 2, 1912, 7, 30, 1911, 1, 1926-1911,
|
||||
"\x5927\x6b63", "\x5927", "T"); // era #2,start year/month/day, yearOffset, minEraYear
|
||||
defaultEraRanges[3] = new EraInfo( 1, 1868, 1, 1, 1867, 1, 1912-1867,
|
||||
defaultEraRanges[4] = new EraInfo( 1, 1868, 1, 1, 1867, 1, 1912-1867,
|
||||
"\x660e\x6cbb", "\x660e", "M"); // era #1,start year/month/day, yearOffset, minEraYear
|
||||
|
||||
// Remember the ranges we built
|
||||
@@ -221,9 +223,9 @@ namespace System.Globalization {
|
||||
|
||||
//
|
||||
// If we didn't have valid eras, then fail
|
||||
// should have at least 4 eras
|
||||
// should have at least 5 eras
|
||||
//
|
||||
if (iFoundEras < 4) return null;
|
||||
if (iFoundEras < 5) return null;
|
||||
|
||||
//
|
||||
// Now we have eras, clean them up.
|
||||
|
||||
@@ -511,6 +511,20 @@ namespace System.IO {
|
||||
return chars;
|
||||
}
|
||||
|
||||
#if MONO
|
||||
public virtual int Read(Span<char> buffer)
|
||||
{
|
||||
char[] bufferBytes = buffer.ToArray();
|
||||
return Read(bufferBytes, 0, bufferBytes.Length);
|
||||
}
|
||||
|
||||
public virtual int Read(Span<byte> buffer)
|
||||
{
|
||||
byte[] bufferBytes = buffer.ToArray();
|
||||
return Read(bufferBytes, 0, bufferBytes.Length);
|
||||
}
|
||||
#endif
|
||||
|
||||
public virtual int Read(byte[] buffer, int index, int count) {
|
||||
if (buffer==null)
|
||||
throw new ArgumentNullException("buffer", Environment.GetResourceString("ArgumentNull_Buffer"));
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Runtime;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace System.IO {
|
||||
// This abstract base class represents a writer that can write
|
||||
@@ -28,7 +29,7 @@ namespace System.IO {
|
||||
//
|
||||
[Serializable]
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
public class BinaryWriter : IDisposable
|
||||
public class BinaryWriter : IDisposable, IAsyncDisposable
|
||||
{
|
||||
public static readonly BinaryWriter Null = new BinaryWriter();
|
||||
|
||||
@@ -135,6 +136,45 @@ namespace System.IO {
|
||||
{
|
||||
return OutStream.Seek(offset, origin);
|
||||
}
|
||||
|
||||
#if MONO
|
||||
public virtual void Write(ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
Write(buffer.ToArray());
|
||||
}
|
||||
|
||||
public virtual void Write(ReadOnlySpan<char> buffer)
|
||||
{
|
||||
Write(buffer.ToArray());
|
||||
}
|
||||
|
||||
public virtual ValueTask DisposeAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetType() == typeof(BinaryWriter))
|
||||
{
|
||||
if (_leaveOpen)
|
||||
{
|
||||
return new ValueTask(OutStream.FlushAsync());
|
||||
}
|
||||
|
||||
OutStream.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Since this is a derived BinaryWriter, delegate to whatever logic
|
||||
// the derived implementation already has in Dispose.
|
||||
Dispose();
|
||||
}
|
||||
return default;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
return new ValueTask(Task.FromException(exc));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Writes a boolean to this stream. A single byte is written to the stream
|
||||
// with the value 0 representing false or the value 1 representing true.
|
||||
|
||||
@@ -1403,7 +1403,7 @@ namespace System.Reflection.Emit
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[ComVisible(false)]
|
||||
public struct ExceptionHandler : IEquatable<ExceptionHandler>
|
||||
public readonly struct ExceptionHandler : IEquatable<ExceptionHandler>
|
||||
{
|
||||
// Keep in sync with unmanged structure.
|
||||
internal readonly int m_exceptionClass;
|
||||
|
||||
@@ -62,6 +62,43 @@ namespace System.Reflection
|
||||
Modifier = 0x40,
|
||||
Sentinel = 0x41,
|
||||
Pinned = 0x45,
|
||||
|
||||
ELEMENT_TYPE_END = 0x00,
|
||||
ELEMENT_TYPE_VOID = 0x01,
|
||||
ELEMENT_TYPE_BOOLEAN = 0x02,
|
||||
ELEMENT_TYPE_CHAR = 0x03,
|
||||
ELEMENT_TYPE_I1 = 0x04,
|
||||
ELEMENT_TYPE_U1 = 0x05,
|
||||
ELEMENT_TYPE_I2 = 0x06,
|
||||
ELEMENT_TYPE_U2 = 0x07,
|
||||
ELEMENT_TYPE_I4 = 0x08,
|
||||
ELEMENT_TYPE_U4 = 0x09,
|
||||
ELEMENT_TYPE_I8 = 0x0A,
|
||||
ELEMENT_TYPE_U8 = 0x0B,
|
||||
ELEMENT_TYPE_R4 = 0x0C,
|
||||
ELEMENT_TYPE_R8 = 0x0D,
|
||||
ELEMENT_TYPE_STRING = 0x0E,
|
||||
ELEMENT_TYPE_PTR = 0x0F,
|
||||
ELEMENT_TYPE_BYREF = 0x10,
|
||||
ELEMENT_TYPE_VALUETYPE = 0x11,
|
||||
ELEMENT_TYPE_CLASS = 0x12,
|
||||
ELEMENT_TYPE_VAR = 0x13,
|
||||
ELEMENT_TYPE_ARRAY = 0x14,
|
||||
ELEMENT_TYPE_GENERICINST = 0x15,
|
||||
ELEMENT_TYPE_TYPEDBYREF = 0x16,
|
||||
ELEMENT_TYPE_I = 0x18,
|
||||
ELEMENT_TYPE_U = 0x19,
|
||||
ELEMENT_TYPE_FNPTR = 0x1B,
|
||||
ELEMENT_TYPE_OBJECT = 0x1C,
|
||||
ELEMENT_TYPE_SZARRAY = 0x1D,
|
||||
ELEMENT_TYPE_MVAR = 0x1E,
|
||||
ELEMENT_TYPE_CMOD_REQD = 0x1F,
|
||||
ELEMENT_TYPE_CMOD_OPT = 0x20,
|
||||
ELEMENT_TYPE_INTERNAL = 0x21,
|
||||
ELEMENT_TYPE_MAX = 0x22,
|
||||
ELEMENT_TYPE_MODIFIER = 0x40,
|
||||
ELEMENT_TYPE_SENTINEL = 0x41,
|
||||
ELEMENT_TYPE_PINNED = 0x45,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -1 +1 @@
|
||||
14e9c98271b7092feb7ff984bdddbdc5a9f1acdd
|
||||
a7122e56661c75df2dbf71b01e091405baf129e0
|
||||
@@ -1148,7 +1148,7 @@ namespace System.Runtime.InteropServices{
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited=false)]
|
||||
[System.Runtime.InteropServices.ComVisible(false)]
|
||||
public sealed class ManagedToNativeComInteropStubAttribute : Attribute
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
sealed public class BinaryFormatter :
|
||||
#if !FEATURE_REMOTING && !MONO
|
||||
#if DISABLE_REMOTING || (!FEATURE_REMOTING && !MONO)
|
||||
IFormatter
|
||||
#else
|
||||
IRemotingFormatter
|
||||
@@ -149,7 +149,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
return Deserialize(serializationStream, handler, true);
|
||||
}
|
||||
|
||||
#if FEATURE_REMOTING || MOBILE_LEGACY
|
||||
#if FEATURE_REMOTING || (MOBILE_LEGACY && !DISABLE_REMOTING)
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
public Object DeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage) {
|
||||
return Deserialize(serializationStream, handler, true, methodCallMessage);
|
||||
@@ -161,7 +161,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
return Deserialize(serializationStream, handler, false);
|
||||
}
|
||||
|
||||
#if FEATURE_REMOTING || MOBILE_LEGACY
|
||||
#if FEATURE_REMOTING || (MOBILE_LEGACY && !DISABLE_REMOTING)
|
||||
[System.Security.SecurityCritical] // auto-generated_required
|
||||
[System.Runtime.InteropServices.ComVisible(false)]
|
||||
public Object UnsafeDeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage) {
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
|
||||
//MethodCall and MethodReturn are handled special for perf reasons
|
||||
private bool bFullDeserialization;
|
||||
#if FEATURE_REMOTING
|
||||
#if FEATURE_REMOTING
|
||||
private bool bMethodCall;
|
||||
private bool bMethodReturn;
|
||||
private BinaryMethodCall binaryMethodCall;
|
||||
@@ -95,7 +95,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
m_objectManager.TopObject = value;
|
||||
}
|
||||
}
|
||||
#if FEATURE_REMOTING
|
||||
#if FEATURE_REMOTING
|
||||
internal void SetMethodCall(BinaryMethodCall binaryMethodCall)
|
||||
{
|
||||
bMethodCall = true;
|
||||
@@ -141,7 +141,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
|
||||
}
|
||||
|
||||
#if FEATURE_REMOTING || MOBILE_LEGACY
|
||||
#if FEATURE_REMOTING || (MOBILE_LEGACY && !DISABLE_REMOTING)
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
internal Object Deserialize(HeaderHandler handler, __BinaryParser serParser, bool fCheck, bool isCrossAppDomain, IMethodCallMessage methodCallMessage) {
|
||||
if (serParser == null)
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace System.Runtime.Serialization {
|
||||
using System;
|
||||
[Serializable]
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
public struct StreamingContext {
|
||||
internal Object m_additionalContext;
|
||||
internal StreamingContextStates m_state;
|
||||
public readonly struct StreamingContext {
|
||||
internal readonly Object m_additionalContext;
|
||||
internal readonly StreamingContextStates m_state;
|
||||
|
||||
public StreamingContext(StreamingContextStates state)
|
||||
: this (state, null) {
|
||||
|
||||
@@ -117,6 +117,7 @@ namespace System.Security.Claims
|
||||
return selectedClaimsIdentity;
|
||||
}
|
||||
|
||||
#if !DISABLE_SECURITY
|
||||
/// <summary>
|
||||
/// Used to set a custom claims principal.
|
||||
/// </summary>
|
||||
@@ -131,6 +132,7 @@ namespace System.Security.Claims
|
||||
|
||||
return new ClaimsPrincipal(Thread.CurrentPrincipal);
|
||||
}
|
||||
#endif
|
||||
|
||||
public static Func<IEnumerable<ClaimsIdentity>, ClaimsIdentity> PrimaryIdentitySelector
|
||||
{
|
||||
@@ -519,6 +521,7 @@ namespace System.Security.Claims
|
||||
}
|
||||
}
|
||||
|
||||
#if !DISABLE_SECURITY
|
||||
/// <summary>
|
||||
/// Returns the Current Principal by calling a delegate. Users may specify the delegate.
|
||||
/// </summary>
|
||||
@@ -537,6 +540,9 @@ namespace System.Security.Claims
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
public static ClaimsPrincipal Current => throw new PlatformNotSupportedException ();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a <see cref="IEnumerable{Claim}"/> where each claim is matched by <param name="match"/>.
|
||||
|
||||
@@ -113,5 +113,31 @@ namespace System.Security.Cryptography {
|
||||
public virtual String ToXmlString(bool includePrivateParameters) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#if MONO
|
||||
public virtual byte[] ExportEncryptedPkcs8PrivateKey (System.ReadOnlySpan<byte> passwordBytes, System.Security.Cryptography.PbeParameters pbeParameters) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual byte[] ExportEncryptedPkcs8PrivateKey (System.ReadOnlySpan<char> password, System.Security.Cryptography.PbeParameters pbeParameters) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual byte[] ExportPkcs8PrivateKey () => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual byte[] ExportSubjectPublicKeyInfo () => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual void ImportEncryptedPkcs8PrivateKey (System.ReadOnlySpan<byte> passwordBytes, System.ReadOnlySpan<byte> source, out int bytesRead) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual void ImportEncryptedPkcs8PrivateKey (System.ReadOnlySpan<char> password, System.ReadOnlySpan<byte> source, out int bytesRead) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual void ImportPkcs8PrivateKey (System.ReadOnlySpan<byte> source, out int bytesRead) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual void ImportSubjectPublicKeyInfo (System.ReadOnlySpan<byte> source, out int bytesRead) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual bool TryExportEncryptedPkcs8PrivateKey (System.ReadOnlySpan<byte> passwordBytes, System.Security.Cryptography.PbeParameters pbeParameters, System.Span<byte> destination, out int bytesWritten) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual bool TryExportEncryptedPkcs8PrivateKey (System.ReadOnlySpan<char> password, System.Security.Cryptography.PbeParameters pbeParameters, System.Span<byte> destination, out int bytesWritten) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual bool TryExportPkcs8PrivateKey (System.Span<byte> destination, out int bytesWritten) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual bool TryExportSubjectPublicKeyInfo (System.Span<byte> destination, out int bytesWritten) => throw new PlatformNotSupportedException ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace System.Security.Cryptography {
|
||||
using System.Security.Util;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
#if MONO
|
||||
using System.Buffers;
|
||||
#endif
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
// DSAParameters is serializable so that one could pass the public parameters
|
||||
@@ -266,5 +269,128 @@ namespace System.Security.Cryptography {
|
||||
{
|
||||
return new ArgumentException(Environment.GetResourceString("Cryptography_HashAlgorithmNameNullOrEmpty"), "hashAlgorithm");
|
||||
}
|
||||
|
||||
#if MONO
|
||||
// these methods were copied from CoreFX for NS2.1 support
|
||||
public static DSA Create(int keySizeInBits)
|
||||
{
|
||||
DSA dsa = Create();
|
||||
|
||||
try
|
||||
{
|
||||
dsa.KeySize = keySizeInBits;
|
||||
return dsa;
|
||||
}
|
||||
catch
|
||||
{
|
||||
dsa.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static DSA Create(DSAParameters parameters)
|
||||
{
|
||||
DSA dsa = Create();
|
||||
|
||||
try
|
||||
{
|
||||
dsa.ImportParameters(parameters);
|
||||
return dsa;
|
||||
}
|
||||
catch
|
||||
{
|
||||
dsa.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool TryCreateSignature(ReadOnlySpan<byte> hash, Span<byte> destination, out int bytesWritten)
|
||||
{
|
||||
byte[] sig = CreateSignature(hash.ToArray());
|
||||
if (sig.Length <= destination.Length)
|
||||
{
|
||||
new ReadOnlySpan<byte>(sig).CopyTo(destination);
|
||||
bytesWritten = sig.Length;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytesWritten = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
|
||||
{
|
||||
byte[] array = ArrayPool<byte>.Shared.Rent(data.Length);
|
||||
try
|
||||
{
|
||||
data.CopyTo(array);
|
||||
byte[] hash = HashData(array, 0, data.Length, hashAlgorithm);
|
||||
if (destination.Length >= hash.Length)
|
||||
{
|
||||
new ReadOnlySpan<byte>(hash).CopyTo(destination);
|
||||
bytesWritten = hash.Length;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytesWritten = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Array.Clear(array, 0, data.Length);
|
||||
ArrayPool<byte>.Shared.Return(array);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool TrySignData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
|
||||
{
|
||||
if (string.IsNullOrEmpty(hashAlgorithm.Name))
|
||||
{
|
||||
throw HashAlgorithmNameNullOrEmpty();
|
||||
}
|
||||
|
||||
if (TryHashData(data, destination, hashAlgorithm, out int hashLength) &&
|
||||
TryCreateSignature(destination.Slice(0, hashLength), destination, out bytesWritten))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bytesWritten = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool VerifyData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> signature, HashAlgorithmName hashAlgorithm)
|
||||
{
|
||||
if (string.IsNullOrEmpty(hashAlgorithm.Name))
|
||||
{
|
||||
throw HashAlgorithmNameNullOrEmpty();
|
||||
}
|
||||
|
||||
for (int i = 256; ; i = checked(i * 2))
|
||||
{
|
||||
int hashLength = 0;
|
||||
byte[] hash = ArrayPool<byte>.Shared.Rent(i);
|
||||
try
|
||||
{
|
||||
if (TryHashData(data, hash, hashAlgorithm, out hashLength))
|
||||
{
|
||||
return VerifySignature(new ReadOnlySpan<byte>(hash, 0, hashLength), signature);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Array.Clear(hash, 0, hashLength);
|
||||
ArrayPool<byte>.Shared.Return(hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool VerifySignature(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature) =>
|
||||
VerifySignature(hash.ToArray(), signature.ToArray());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace System.Security.Cryptography {
|
||||
using System.Security.Util;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics.Contracts;
|
||||
#if MONO
|
||||
using System.Buffers;
|
||||
#endif
|
||||
|
||||
// We allow only the public components of an RSAParameters object, the Modulus and Exponent
|
||||
// to be serializable.
|
||||
@@ -338,5 +341,176 @@ namespace System.Security.Cryptography {
|
||||
abstract public RSAParameters ExportParameters(bool includePrivateParameters);
|
||||
|
||||
abstract public void ImportParameters(RSAParameters parameters);
|
||||
|
||||
#if MONO // these methods were copied from CoreFX for NS2.1 support
|
||||
public static RSA Create(int keySizeInBits)
|
||||
{
|
||||
RSA rsa = Create();
|
||||
|
||||
try
|
||||
{
|
||||
rsa.KeySize = keySizeInBits;
|
||||
return rsa;
|
||||
}
|
||||
catch
|
||||
{
|
||||
rsa.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static RSA Create(RSAParameters parameters)
|
||||
{
|
||||
RSA rsa = Create();
|
||||
|
||||
try
|
||||
{
|
||||
rsa.ImportParameters(parameters);
|
||||
return rsa;
|
||||
}
|
||||
catch
|
||||
{
|
||||
rsa.Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool TryDecrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding, out int bytesWritten)
|
||||
{
|
||||
byte[] result = Decrypt(data.ToArray(), padding);
|
||||
|
||||
if (destination.Length >= result.Length)
|
||||
{
|
||||
new ReadOnlySpan<byte>(result).CopyTo(destination);
|
||||
bytesWritten = result.Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
bytesWritten = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool TryEncrypt(ReadOnlySpan<byte> data, Span<byte> destination, RSAEncryptionPadding padding, out int bytesWritten)
|
||||
{
|
||||
byte[] result = Encrypt(data.ToArray(), padding);
|
||||
|
||||
if (destination.Length >= result.Length)
|
||||
{
|
||||
new ReadOnlySpan<byte>(result).CopyTo(destination);
|
||||
bytesWritten = result.Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
bytesWritten = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual bool TryHashData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
|
||||
{
|
||||
byte[] result;
|
||||
byte[] array = ArrayPool<byte>.Shared.Rent(data.Length);
|
||||
try
|
||||
{
|
||||
data.CopyTo(array);
|
||||
result = HashData(array, 0, data.Length, hashAlgorithm);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Array.Clear(array, 0, data.Length);
|
||||
ArrayPool<byte>.Shared.Return(array);
|
||||
}
|
||||
|
||||
if (destination.Length >= result.Length)
|
||||
{
|
||||
new ReadOnlySpan<byte>(result).CopyTo(destination);
|
||||
bytesWritten = result.Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
bytesWritten = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool TrySignHash(ReadOnlySpan<byte> hash, Span<byte> destination, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding, out int bytesWritten)
|
||||
{
|
||||
byte[] result = SignHash(hash.ToArray(), hashAlgorithm, padding);
|
||||
|
||||
if (destination.Length >= result.Length)
|
||||
{
|
||||
new ReadOnlySpan<byte>(result).CopyTo(destination);
|
||||
bytesWritten = result.Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
bytesWritten = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool TrySignData(ReadOnlySpan<byte> data, Span<byte> destination, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding, out int bytesWritten)
|
||||
{
|
||||
if (string.IsNullOrEmpty(hashAlgorithm.Name))
|
||||
{
|
||||
throw HashAlgorithmNameNullOrEmpty();
|
||||
}
|
||||
if (padding == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(padding));
|
||||
}
|
||||
|
||||
if (TryHashData(data, destination, hashAlgorithm, out int hashLength) &&
|
||||
TrySignHash(destination.Slice(0, hashLength), destination, hashAlgorithm, padding, out bytesWritten))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bytesWritten = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool VerifyData(ReadOnlySpan<byte> data, ReadOnlySpan<byte> signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
|
||||
{
|
||||
if (string.IsNullOrEmpty(hashAlgorithm.Name))
|
||||
{
|
||||
throw HashAlgorithmNameNullOrEmpty();
|
||||
}
|
||||
if (padding == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(padding));
|
||||
}
|
||||
|
||||
for (int i = 256; ; i = checked(i * 2))
|
||||
{
|
||||
int hashLength = 0;
|
||||
byte[] hash = ArrayPool<byte>.Shared.Rent(i);
|
||||
try
|
||||
{
|
||||
if (TryHashData(data, hash, hashAlgorithm, out hashLength))
|
||||
{
|
||||
return VerifyHash(new ReadOnlySpan<byte>(hash, 0, hashLength), signature, hashAlgorithm, padding);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Array.Clear(hash, 0, hashLength);
|
||||
ArrayPool<byte>.Shared.Return(hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool VerifyHash(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding) =>
|
||||
VerifyHash(hash.ToArray(), signature.ToArray(), hashAlgorithm, padding);
|
||||
|
||||
public virtual byte[] ExportRSAPrivateKey () => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual byte[] ExportRSAPublicKey () => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual void ImportRSAPrivateKey (System.ReadOnlySpan<byte> source, out int bytesRead) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual void ImportRSAPublicKey (System.ReadOnlySpan<byte> source, out int bytesRead) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual bool TryExportRSAPrivateKey (System.Span<byte> destination, out int bytesWritten) => throw new PlatformNotSupportedException ();
|
||||
|
||||
public virtual bool TryExportRSAPublicKey (System.Span<byte> destination, out int bytesWritten) => throw new PlatformNotSupportedException ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#if MOBILE_LEGACY
|
||||
#if MOBILE_LEGACY && !DISABLE_REMOTING
|
||||
#define FEATURE_REMOTING
|
||||
#endif
|
||||
// ==++==
|
||||
|
||||
@@ -1932,8 +1932,7 @@ namespace System.Threading
|
||||
throw new NotSupportedException(Environment.GetResourceString("Arg_NotSupportedException"));
|
||||
Contract.EndContractBlock();
|
||||
#endif
|
||||
|
||||
return PostQueuedCompletionStatus(overlapped);
|
||||
throw new NotImplementedException("");
|
||||
}
|
||||
|
||||
[SecurityCritical]
|
||||
@@ -1986,8 +1985,7 @@ namespace System.Threading
|
||||
[System.Security.SecuritySafeCritical]
|
||||
internal static void NotifyWorkItemProgress()
|
||||
{
|
||||
if (!ThreadPoolGlobals.vmTpInitialized)
|
||||
ThreadPool.InitializeVMTp(ref ThreadPoolGlobals.enableWorkerTracking);
|
||||
EnsureVMInitialized();
|
||||
NotifyWorkItemProgressNative();
|
||||
}
|
||||
|
||||
@@ -2005,8 +2003,10 @@ namespace System.Threading
|
||||
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
// [ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
internal static extern bool IsThreadPoolHosted();
|
||||
internal static bool IsThreadPoolHosted()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
// [ResourceExposure(ResourceScope.None)]
|
||||
@@ -2075,8 +2075,10 @@ namespace System.Threading
|
||||
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
// [ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
private static extern bool BindIOCompletionCallbackNative(IntPtr fileHandle);
|
||||
private static bool BindIOCompletionCallbackNative(IntPtr fileHandle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user