Skip to content

Commit

Permalink
Merge branch 'release/8.0-staging' into merge/release/8.0-to-release/…
Browse files Browse the repository at this point in the history
…8.0-staging
  • Loading branch information
carlossanlop authored Nov 15, 2023
2 parents a5e9bb7 + 5acd05e commit e9d858b
Show file tree
Hide file tree
Showing 24 changed files with 446 additions and 2,736 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
<NetFrameworkCurrent Condition="'$(DotNetBuildFromSource)' == 'true'" />

<!-- Important: Set this to the GA version (or a close approximation) during servicing and adjust the TFM property below. -->
<ApiCompatNetCoreAppBaselineVersion>7.0.0</ApiCompatNetCoreAppBaselineVersion>
<ApiCompatNetCoreAppBaselineTFM>net7.0</ApiCompatNetCoreAppBaselineTFM>
<ApiCompatNetCoreAppBaselineVersion>8.0.0</ApiCompatNetCoreAppBaselineVersion>
<ApiCompatNetCoreAppBaselineTFM>net8.0</ApiCompatNetCoreAppBaselineTFM>

<TargetFrameworkForNETFrameworkTasks>$(NetFrameworkToolCurrent)</TargetFrameworkForNETFrameworkTasks>
<!-- Don't build for NETFramework during source-build. -->
Expand Down
8 changes: 6 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,13 @@
<Uri>https://github.com/dotnet/roslyn-analyzers</Uri>
<Sha>b4d9a1334d5189172977ba8fddd00bda70161e4a</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.ApiCompat.Task" Version="8.0.100-rtm.23520.8">
<Dependency Name="Microsoft.DotNet.ApiCompat.Task" Version="8.0.100">
<Uri>https://github.com/dotnet/sdk</Uri>
<Sha>7e33fd449381b337c290a801057fdcd68c4b7220</Sha>
<Sha>e9d13cbe7e8c1d52ce276a8655f52a87e1017c46</Sha>
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.sdk" Version="8.0.100-rtm.23551.6">
<Uri>https://github.com/dotnet/sdk</Uri>
<Sha>e9d13cbe7e8c1d52ce276a8655f52a87e1017c46</Sha>
<SourceBuild RepoName="sdk" ManagedOnly="true" />
</Dependency>
<Dependency Name="optimization.windows_nt-arm64.MIBC.Runtime" Version="1.0.0-prerelease.23525.5">
Expand Down
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<MinorVersion>0</MinorVersion>
<PatchVersion>1</PatchVersion>
<SdkBandVersion>8.0.100</SdkBandVersion>
<PackageVersionNet7>7.0.14</PackageVersionNet7>
<PackageVersionNet7>7.0.$([MSBuild]::Add($(PatchVersion),14))</PackageVersionNet7>
<PackageVersionNet6>6.0.$([MSBuild]::Add($([System.Version]::Parse('$(PackageVersionNet7)').Build),11))</PackageVersionNet6>
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
<PreReleaseVersionIteration>
Expand Down Expand Up @@ -85,7 +85,7 @@
<PropertyGroup>
<StaticCsVersion>0.2.0</StaticCsVersion>
<!-- SDK dependencies -->
<MicrosoftDotNetApiCompatTaskVersion>8.0.100-rtm.23520.8</MicrosoftDotNetApiCompatTaskVersion>
<MicrosoftDotNetApiCompatTaskVersion>8.0.100</MicrosoftDotNetApiCompatTaskVersion>
<!-- Arcade dependencies -->
<MicrosoftDotNetBuildTasksFeedVersion>8.0.0-beta.23556.5</MicrosoftDotNetBuildTasksFeedVersion>
<MicrosoftDotNetCodeAnalysisVersion>8.0.0-beta.23556.5</MicrosoftDotNetCodeAnalysisVersion>
Expand Down Expand Up @@ -127,7 +127,7 @@
<SystemCollectionsImmutableVersion>7.0.0</SystemCollectionsImmutableVersion>
<SystemComponentModelAnnotationsVersion>5.0.0</SystemComponentModelAnnotationsVersion>
<SystemDataSqlClientVersion>4.8.5</SystemDataSqlClientVersion>
<SystemDrawingCommonVersion>7.0.0</SystemDrawingCommonVersion>
<SystemDrawingCommonVersion>8.0.0</SystemDrawingCommonVersion>
<SystemIOFileSystemAccessControlVersion>5.0.0</SystemIOFileSystemAccessControlVersion>
<SystemMemoryVersion>4.5.5</SystemMemoryVersion>
<SystemReflectionMetadataVersion>7.0.0</SystemReflectionMetadataVersion>
Expand Down
8 changes: 8 additions & 0 deletions eng/packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'$(SuppressFinalPackageVersion)' == 'true' or
'$(DotNetBuildFromSource)' == 'true'">true</DisablePackageBaselineValidation>
<PackageValidationBaselineVersion Condition="'$(PackageValidationBaselineVersion)' == ''">$(ApiCompatNetCoreAppBaselineVersion)</PackageValidationBaselineVersion>

<BeforePack>$(BeforePack);IncludeAnalyzersInPackage;AddNETStandardCompatErrorFileForPackaging</BeforePack>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);AddRuntimeSpecificFilesToPackage;IncludeProjectReferencesWithPackAttributeInPackage</TargetsForTfmSpecificContentInPackage>
<!-- Don't include target platform specific dependencies, since we use the target platform to represent RIDs instead -->
Expand All @@ -37,6 +38,13 @@
<BuildProjectReferences Condition="'$(NoBuild)' == 'true'">false</BuildProjectReferences>
</PropertyGroup>

<PropertyGroup Condition="'$(PreReleaseVersionLabel)' == 'servicing'">
<!-- In servicing, the live package is compared against the GA version in strict mode. -->
<EnableStrictModeForBaselineValidation>true</EnableStrictModeForBaselineValidation>
<!-- In servicing, disable the APICompat rule that validates that the assembly versions must match. -->
<NoWarn>$(NoWarn);CP0003</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(PreReleaseVersionLabel)' == 'servicing' and
'$(PackageUseIncrementalServicingVersion)' == 'true'">
<!-- If no servicing version is set we need to default to 0 in order for dependency versions to
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10069,7 +10069,6 @@ void gc_heap::update_ro_segment (heap_segment* seg, uint8_t* allocated, uint8_t*
{
enter_spin_lock (&gc_heap::gc_lock);

assert (use_frozen_segments_p);
assert (heap_segment_read_only_p (seg));
assert (allocated <= committed);
assert (committed <= heap_segment_reserved (seg));
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/nativeaot/Runtime/gcrhenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,10 +749,12 @@ void GCToEEInterface::DiagGCEnd(size_t index, int gen, int reason, bool fConcurr
UNREFERENCED_PARAMETER(gen);
UNREFERENCED_PARAMETER(reason);

#ifdef FEATURE_EVENT_TRACE
if (!fConcurrent)
{
ETW::GCLog::WalkHeap();
}
#endif // FEATURE_EVENT_TRACE
}

// Note on last parameter: when calling this for bgc, only ETW
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Runtime.InteropServices;
using Internal.Cryptography;

using Microsoft.Win32.SafeHandles;

Expand Down Expand Up @@ -30,7 +31,7 @@ internal static unsafe NTSTATUS BCryptSignHashPkcs1(
{
fixed (char* pHashAlgorithmName = hashAlgorithmName)
fixed (byte* pHash = &MemoryMarshal.GetReference(hash))
fixed (byte* pDest = &MemoryMarshal.GetReference(destination))
fixed (byte* pDest = &Helpers.GetNonNullPinnableReference(destination))
{
BCRYPT_PKCS1_PADDING_INFO paddingInfo = default;
paddingInfo.pszAlgId = (IntPtr)pHashAlgorithmName;
Expand All @@ -56,7 +57,7 @@ internal static unsafe NTSTATUS BCryptSignHashPss(
{
fixed (char* pHashAlgorithmName = hashAlgorithmName)
fixed (byte* pHash = &MemoryMarshal.GetReference(hash))
fixed (byte* pDest = &MemoryMarshal.GetReference(destination))
fixed (byte* pDest = &Helpers.GetNonNullPinnableReference(destination))
{
BCRYPT_PSS_PADDING_INFO paddingInfo = default;
paddingInfo.pszAlgId = (IntPtr)pHashAlgorithmName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@

using System;
using System.Runtime.InteropServices;
using Internal.Cryptography;
using Microsoft.Win32.SafeHandles;

internal static partial class Interop
{
internal static partial class NCrypt
{
[LibraryImport(Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial ErrorCode NCryptSignHash(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ReadOnlySpan<byte> pbHashValue, int cbHashValue, Span<byte> pbSignature, int cbSignature, out int pcbResult, AsymmetricPaddingMode dwFlags);
private static unsafe partial ErrorCode NCryptSignHash(SafeNCryptKeyHandle hKey, void* pPaddingInfo, byte* pbHashValue, int cbHashValue, byte* pbSignature, int cbSignature, out int pcbResult, AsymmetricPaddingMode dwFlags);

internal static unsafe ErrorCode NCryptSignHash(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ReadOnlySpan<byte> pbHashValue, Span<byte> pbSignature, out int pcbResult, AsymmetricPaddingMode dwFlags)
{
fixed (byte* pHash = &MemoryMarshal.GetReference(pbHashValue))
fixed (byte* pSignature = &Helpers.GetNonNullPinnableReference(pbSignature))
{
return NCryptSignHash(hKey, pPaddingInfo, pHash, pbHashValue.Length, pSignature, pbSignature.Length, out pcbResult, dwFlags);
}
}

[LibraryImport(Libraries.NCrypt, StringMarshalling = StringMarshalling.Utf16)]
internal static unsafe partial ErrorCode NCryptVerifySignature(SafeNCryptKeyHandle hKey, void* pPaddingInfo, ReadOnlySpan<byte> pbHashValue, int cbHashValue, ReadOnlySpan<byte> pbSignature, int cbSignature, AsymmetricPaddingMode dwFlags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,25 @@ public void Verify2048WithSha1()
}
}

[Fact]
public void SignData_NullSignature_Fails()
{
using (DSA dsa = DSAFactory.Create())
{
dsa.ImportParameters(DSATestData.GetDSA1024Params());

bool result = dsa.TrySignData(
"hello"u8,
(Span<byte>)null,
HashAlgorithmName.SHA1,
DSASignatureFormat.IeeeP1363FixedFieldConcatenation,
out int bytesWritten);

Assert.False(result);
Assert.Equal(0, bytesWritten);
}
}

private void SignAndVerify(byte[] data, string hashAlgorithmName, DSAParameters dsaParameters, int expectedSignatureLength)
{
using (DSA dsa = DSAFactory.Create())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,32 @@ public void VerifyHash_InvalidArguments_Throws(ECDsa ecdsa)
AssertExtensions.Throws<ArgumentNullException>("hash", () => ecdsa.VerifyHash(null, null));
AssertExtensions.Throws<ArgumentNullException>("signature", () => ecdsa.VerifyHash(new byte[0], null));
}

[Theory]
[MemberData(nameof(RealImplementations))]
public void SignHash_NullSignature_Fails(ECDsa ecdsa)
{
byte[] hash = RandomNumberGenerator.GetBytes(SHA256.HashSizeInBytes);

AssertExtensions.Throws<ArgumentException>("destination", () =>
ecdsa.SignHash(hash, (Span<byte>)null, DSASignatureFormat.IeeeP1363FixedFieldConcatenation));

bool result = ecdsa.TrySignHash(hash, (Span<byte>)null, DSASignatureFormat.IeeeP1363FixedFieldConcatenation, out int bytesWritten);
Assert.False(result);
Assert.Equal(0, bytesWritten);
}

[Theory]
[MemberData(nameof(RealImplementations))]
public void SignData_NullSignature_Fails(ECDsa ecdsa)
{
AssertExtensions.Throws<ArgumentException>("destination", () =>
ecdsa.SignData("hello"u8, (Span<byte>)null, HashAlgorithmName.SHA256, DSASignatureFormat.IeeeP1363FixedFieldConcatenation));

bool result = ecdsa.TrySignData("hello"u8, (Span<byte>)null, HashAlgorithmName.SHA256, DSASignatureFormat.IeeeP1363FixedFieldConcatenation, out int bytesWritten);
Assert.False(result);
Assert.Equal(0, bytesWritten);
}
}

[SkipOnPlatform(TestPlatforms.Browser, "Not supported on Browser")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,60 @@ public void PssSignature_WrongLength()
}
}

[ConditionalTheory]
[InlineData(true)]
[InlineData(false)]
public void SignHash_NullSignature_Fails(bool usePss)
{
if (!SupportsPss)
{
throw new SkipTestException("Platform does not support PSS");
}

RSASignaturePadding padding = usePss ? RSASignaturePadding.Pss : RSASignaturePadding.Pkcs1;

using (RSA rsa = RSA.Create())
{
byte[] hash = RandomNumberGenerator.GetBytes(SHA256.HashSizeInBytes);

AssertExtensions.Throws<ArgumentException>("destination", () =>
rsa.SignHash(hash, (Span<byte>)null, HashAlgorithmName.SHA256, padding));

bool result = rsa.TrySignHash(
hash,
(Span<byte>)null,
HashAlgorithmName.SHA256,
padding,
out int bytesWritten);

Assert.False(result);
Assert.Equal(0, bytesWritten);
}
}

[ConditionalTheory]
[InlineData(true)]
[InlineData(false)]
public void SignData_NullSignature_Fails(bool usePss)
{
if (!SupportsPss)
{
throw new SkipTestException("Platform does not support PSS");
}

RSASignaturePadding padding = usePss ? RSASignaturePadding.Pss : RSASignaturePadding.Pkcs1;

using (RSA rsa = RSA.Create())
{
AssertExtensions.Throws<ArgumentException>("destination", () =>
rsa.SignData("hello"u8, (Span<byte>)null, HashAlgorithmName.SHA256, padding));

bool result = rsa.TrySignData("hello"u8, (Span<byte>)null, HashAlgorithmName.SHA256, padding, out int bytesWritten);
Assert.False(result);
Assert.Equal(0, bytesWritten);
}
}

private void ExpectSignature(
byte[] expectedSignature,
byte[] data,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<NoWarn>$(NoWarn);NU5128;NU5131;PKV004</NoWarn>
<!-- Place assemblies in the nuget ref folder -->
<BuildOutputTargetFolder>ref</BuildOutputTargetFolder>
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static AnalysisResults Analyze(
AnalysisResults results;
if (minLength == 0 || !TryUseSubstring(uniqueStrings, ignoreCase, minLength, maxLength, out results))
{
results = CreateAnalysisResults(uniqueStrings, ignoreCase, minLength, maxLength, 0, 0, static (s, _, _) => s.AsSpan());
results = CreateAnalysisResults(uniqueStrings, ignoreCase, minLength, maxLength, 0, 0, isSubstring: false, static (s, _, _) => s.AsSpan());
}

return results;
Expand Down Expand Up @@ -71,7 +71,7 @@ private static bool TryUseSubstring(ReadOnlySpan<string> uniqueStrings, bool ign
if (HasSufficientUniquenessFactor(set, uniqueStrings))
{
results = CreateAnalysisResults(
uniqueStrings, ignoreCase, minLength, maxLength, index, count,
uniqueStrings, ignoreCase, minLength, maxLength, index, count, isSubstring: true,
static (string s, int index, int count) => s.AsSpan(index, count));
return true;
}
Expand All @@ -96,7 +96,7 @@ private static bool TryUseSubstring(ReadOnlySpan<string> uniqueStrings, bool ign
if (HasSufficientUniquenessFactor(set, uniqueStrings))
{
results = CreateAnalysisResults(
uniqueStrings, ignoreCase, minLength, maxLength, comparer.Index, count,
uniqueStrings, ignoreCase, minLength, maxLength, comparer.Index, count, isSubstring: true,
static (string s, int index, int count) => s.AsSpan(s.Length + index, count));
return true;
}
Expand All @@ -110,7 +110,7 @@ private static bool TryUseSubstring(ReadOnlySpan<string> uniqueStrings, bool ign
}

private static AnalysisResults CreateAnalysisResults(
ReadOnlySpan<string> uniqueStrings, bool ignoreCase, int minLength, int maxLength, int index, int count, GetSpan getSubstringSpan)
ReadOnlySpan<string> uniqueStrings, bool ignoreCase, int minLength, int maxLength, int index, int count, bool isSubstring, GetSpan getSubstringSpan)
{
// Start off by assuming all strings are ASCII
bool allAsciiIfIgnoreCase = true;
Expand All @@ -120,11 +120,11 @@ private static AnalysisResults CreateAnalysisResults(
// substrings are ASCII, so we check each.
if (ignoreCase)
{
// Further, if the ASCII substrings don't contain any letters, then we can
// Further, if the ASCII keys (in their entirety) don't contain any letters, then we can
// actually perform the comparison as case-sensitive even if case-insensitive
// was requested, as there's nothing that would compare equally to the substring
// other than the substring itself.
bool canSwitchIgnoreCaseToCaseSensitive = true;
bool canSwitchIgnoreCaseHashToCaseSensitive = !isSubstring;

foreach (string s in uniqueStrings)
{
Expand All @@ -135,20 +135,20 @@ private static AnalysisResults CreateAnalysisResults(
if (!IsAllAscii(substring))
{
allAsciiIfIgnoreCase = false;
canSwitchIgnoreCaseToCaseSensitive = false;
canSwitchIgnoreCaseHashToCaseSensitive = false;
break;
}

// All substrings so far are still ASCII only. If this one contains any ASCII
// letters, mark that we can't switch to case-sensitive.
if (canSwitchIgnoreCaseToCaseSensitive && ContainsAnyLetters(substring))
if (canSwitchIgnoreCaseHashToCaseSensitive && ContainsAnyLetters(substring))
{
canSwitchIgnoreCaseToCaseSensitive = false;
canSwitchIgnoreCaseHashToCaseSensitive = false;
}
}

// If we can switch to case-sensitive, do so.
if (canSwitchIgnoreCaseToCaseSensitive)
if (canSwitchIgnoreCaseHashToCaseSensitive)
{
ignoreCase = false;
}
Expand Down
Loading

0 comments on commit e9d858b

Please sign in to comment.