Commit Graph
589 Commits
Author SHA1 Message Date
Viktor Hofer 24cabc6eb0 Update solution files to include missing deps (#68668) 2022-05-02 20:14:05 +02:00
Kevin Jones 0a2bc2f864 Condition S.S.Cryptography tests on SHA1 signature support 2022-04-28 19:23:40 -04:00
Viktor HoferandJeremy Barton ba055bd94e Minimize the build graph by deleting unnecessary references (#68603)
* Minimize the build graph by deleting references

Minimizing projects' dependency graph. There are tons of unnecessary
Reference and ProjectReference items which aren't required anymore as
the referenced projects became full facade assemblies. Removing those
from a leaf's graph makes the graph smaller and therefore the project's
evaluation and build faster.

* Update src/libraries/System.Net.Quic/ref/System.Net.Quic.csproj

Co-authored-by: Jeremy Barton <[email protected]>

* Update Versions.props

Co-authored-by: Jeremy Barton <[email protected]>
2022-04-28 15:04:26 +02:00
Eric Erhardt 18be907176 Change Nullable to default to enable in libraries src and ref projects (#68102)
* Change the default Nullable to enabled for src projects

* Set Nullable=enable as the default for ref projects

* Fixup merge conflicts

* Disable nullable on shim projects and EventLog.Messages

* Set Nullable to blank on EventLog.Messages

This way no CodeAnalysis attributes are emitted into the assembly.
2022-04-25 11:15:37 -05:00
Elinor Fung a0635832f1 Rename DllImportGenerator project to LibraryImportGenerator (#66029) 2022-03-03 22:17:23 -08:00
Viktor Hofer febaf76743 Fix slngen.proj and update solution files (#65711)
* Fix slngen.proj

The SolutionName property is defined by the SDK and hence the condition was always true. Also the star (*) didn't expand when using the ValurOrDefault msbuild function. Fixing this by using a different name `SolutionNameOverride` and avoiding the ValueOrDefault msbuild function.

* Update solution files

Updating the solution files as those changed because of
microsoft/slngen@cb57e28 and apparently the solution files never were
updated.
2022-02-22 17:18:54 +01:00
WraithandVlad Brezae ddb22ef2ac Remove S.R.CS.Unsafe and Intrinsify Unsafe (#64861)
* private assemblies moved from Internal to System Runtime.CompilerServices

* reformat existing unsafe vm intrinsics

* implement Copy, CopyBlock, CopyBlockUnaligned, InitBlock, InitBlockUnaligned, Unbox, Add, Subtract, SubtractByteOffset

* remove System.Runtime.CompilerServices.Unsafe il project and replace with forward only cs project

* change all ilproj references to csproj

* remove nativeaot Unsafe

* add conditional package reference for S.R.CS.Unsafe on netcoreapp 6.0

* regenerate solutions

* mono interp

* [mono][interp] Implement Copy and Unbox intrinsics

* [mono][jit] Implement Copy and Unbox intrinsics

Co-authored-by: Vlad Brezae <[email protected]>
2022-02-19 21:50:14 -08:00
Viktor Hofer 20e8f905d0 Don't use Targets* helper properties in libs (#64500)
* Don't use Targets* helper properties in libs projs

This change makes it possible to migrate 200+ (ref+src) projects to use
TargetFramework instead of TargetFrameworks which avoids the additional
outer build evaluation and invocation which ultimately makes the overall
build faster.

Targets* properties (i.e. TargetsWindows, TargetsAnyOS, TargetsUnix,
etc.) rely on the TargetFramework property which usually are set
inside a project. The TargetFramework property is only
available before a project specifies it if it's explicitly set in a props
file or if the project is cross-targeting and the outer-build dispatches
into the inner-build. During the dispatch, the TargetFramework property
is passed in as a global property.

Until now that behavior wasn't a problem because every libraries project
cross-targeted (by setting the TargetFrameworks property) even though
many only include a single TargetFramework (i.e. NetCoreAppCurrent).

To allow projects to use the TargetFramework property instead of
TargetFrameworks, the Targets* helper properties can't be calculated
anymore early in a props file as the TargetFramework property isn't set
at that time.

In general, the guidance by the SDK/msbuild team is to not read from the
TargetFramework property before the project sets it
(in a property group). That effectively means that the TargetFramework
property shouldn't be used in props files at all.

Therefore these helper properties can't be used anymore for property
conditions and I'm replacing their usage with TargetPlatformIdentifier
comparisons for both properties and items.
In nearly all cases, the Targets* helper properties can be replaced with
TargetPlatformIdentifier checks on items and in the few cases where
TargetsUnix or TargetsLinux marks multiple tfms as compatible, the exact
tfms must be used instead for the TargetPlatformIdentifier comparison.

Whenever a project needs to condition properties on the platform, I'm
first setting the TargetPlatformIdentifier the same way the SDK sets it
so that the SDK later doesn't need to set it again to avoid the
additional expensive msbuild function call.

* Use TargetFramework singular to avoid outer builds

Use TargetFramework instead of TargetFrameworks property whenever a
projects only targets a single target framework. This avoid unnecessary
outer builds and evaluations and makes the build faster.
2022-02-12 13:07:16 +01:00
Jeremy Barton c12bea880a Fold inbox crypto into one assembly (#64307)
* Fold S.S.C.Csp into System.Security.Cryptography

This change leaves the tests in System.Security.Cryptography.Csp.Tests.dll,
because the crypto test infrastructure has not yet been upgraded to allow
for two algorithm provider tests in the same assembly (e.g. not both
Aes.Create() and AesCryptoServiceProvider can be tested)

* Change CryptoConfig string lookups to typeof for CSP types

* Fold S.S.C.Cng into S.S.Cryptography

* Fold S.S.C.OpenSsl into S.S.Cryptography

* Fold S.S.C.X509Certificates into S.S.Cryptography

* Fix dependent projects

* Fix ApiCompat errors

* Self-feedback

* Use typeof where now possible in CryptoConfig

* Don't use CNG's PKCS8 export for default EC objects

* RSA should probably function on Unix

* Fix nullability state of ChainPal.BuildChain across OSes

* Remove bad assert

* Special case macOS ECC data keys in CopyWithPrivateKey

* Undo some of the string resurrections

* Add missing Obsolete attribute
2022-01-29 19:20:49 -07:00
Stephen Toub 91da4ac9fd Add/use ArgumentException.ThrowIfNullOrEmpty (#64357)
Adds ArgumentException.ThrowIfNullOrEmpty and then uses it in a bunch of places around the tree.  Most of the replaced places used a resource string for the message, and I used it in places where it didn't feel like we were losing any meaningful information by centralizing on the single shared string, but I didn't use it in places where the resource string message used in the empty case conveyed something that seemed useful, e.g. a recommendation on what to use instead of an empty string.

There are a few places where I allowed for order of exception throws to change in the case where there were multiple user errors and the validation for a single argument was split, e.g. I changed a few cases of:
    ```C#
        if (arg1 is null) throw new ArgumentNullException(...);
        if (arg2 is null) throw new ArgumentNullException(...);
        if (arg1.Length == 0) throw new ArgumentException(...);
        if (arg2.Length == 0) throw new ArgumentException(...);
    ```
to:
    ```C#
        ArgumentException.ThrowIfNullOrEmpty(arg1);
        ArgumentException.ThrowIfNullOrEmpty(arg2);
    ```
even though it'll produce a different exception for `M("", null)` than it would previously.  Technically a breaking change, but given this is a case of multiple usage errors and all the exceptions are ArgumentException-based, I think it's acceptable.

I wanted to get this in before we do the massive !! conversion, as I expect !! auto-fixes will make it a bit harder to roll this out.  I explicitly did not do anything to roll out use of ArgumentNullException.ThrowIfNull, except in cases where I was modifying a method to use ArgumentException.ThrowIfNullOrEmpty, in which case for consistency I changed anything else in the function that could have been using ThrowIfNull to do so.
2022-01-28 14:16:09 -05:00
Adam Sitnik 2074477643 Remove some of the unused resource strings (#64379) 2022-01-27 19:21:12 +01:00
Elinor Fung 3806e15595 Use GeneratedDllImport for blittable p/invokes in System.IO.Compression, System.IO.Compression.Brotli, System.Net.Http, System.Net.NameResolution (#61638) 2021-11-16 14:01:42 -07:00
Jeremy Barton df5b118c6f Seed the unified System.Security.Cryptography.dll
* All of System.Security.Cryptography.Primitives has been moved
* AsymmericKeyExchangeFormatter moved from S.S.C.Algorithms
* This just starts the process to keep the infrastructure pieces separate from code layout pieces.
2021-11-01 22:30:26 -07:00
Viktor Hofer 0964be0ae9 Update slngen and solution files (#60871)
Update slngen tooling to latest stable version and solution files since
a lot changed since the last time they were updated:
- NET7 (removal of older TFMs)
- Source Generators
2021-10-26 21:23:54 +02:00
Elinor Fung 39048dd5de Undo solution and config changes from DllImportGenerator (#60481)
* Remove dotnet-experimental feed from NuGet.config
* Revert changes to solution files and restore configs
2021-10-15 11:06:12 -07:00
Jeremy Koritzinsky 27034bc84b Run slngen to regenerate the solution files. 2021-09-22 17:02:14 -07:00
Jeremy Koritzinsky 81293bfc1e Merge branch 'main' of https://github.com/dotnet/runtime into merge-main 2021-09-14 16:29:42 -07:00
Jeremy Koritzinsky 5b8ce63f73 Update DllImportGenerator to the latest version (#59117) 2021-09-14 16:15:21 -07:00
Viktor Hofer 36b6247cc7 Update solution files for correct ordering of elements (#58655)
With the newest udpate of slngen, the order of elements (configuration, folders, etc.) is in sync with how Visual Studio arranges them.
Also the order is now deterministic.

Based on that, updating all solution files to have the correct ordering of elements. This change also unblocks adding CI protection for
making sure that solution files are up-to-date in regards to their dependencies as slngen is now generating the files deterministically.
2021-09-04 00:16:15 +02:00
Viktor Hofer 49c74eec15 Update changed solution files under src/libraries (#57483)
* Update slngen logic and remove unnecessary P2Ps

* Update changed soluion files under src/libraries

* Fix Platforms build

* Update comment in slngen.targets
2021-08-18 19:35:54 +02:00
Kevin Jones 214443193a Check for OpenSSL availability for OpenSsl asymmetric primitives
If you attempt to use any of the *OpenSsl primitives on macOS, this will currently abort the whole process.
This changes them to check for OpenSSL's presence and throw an appropriate exception instead of aborting.

When used as an internal implementation, the aborting behavior remains.
2021-08-16 16:52:08 -07:00
Viktor Hofer a6b9a63f35 Update libraries solution and NuGet.config files (#56430)
* Update slngen and invocation

* Update NuGet.config files

* Update solution files with slngen
2021-07-28 18:44:17 +02:00
Jeremy Barton 16eabee0b2 Disable S.S.C.OpenSSL tests on the platforms that are PNSE. 2021-07-16 14:34:07 -07:00
Jeremy Barton f94711de45 Finish migrating RSAOpenSsl from RSA* to EVP_PKEY*
This change moves the RSAOpenSsl class (and the RSA.Create() internal class on Linux) to use EVP_PKEY
for the import and export operations, making the interaction with the underlying library based on
PKCS#8 PrivateKeyInfo and X.509 SubjectPublicKeyInfo key blobs.

A large portion of the code is just from splitting the key helpers files to not need all of the encrypted PKCS#8 support
in the System.Security.Cryptography.OpenSsl library, as the encrypted PKCS#8 <-> unencrypted PKCS#8 work provided
by the base classes is sufficient.

Once PKCS#8 and SPKI became the primary modes of interaction the spanified import and export routines for those got
overridden in RSAOpenSsl to avoid SPKI->RSAParameters->SPKI-style conversions.

This change completely eliminates SafeRsaHandle, and the only time that an `RSA*` is used at all is in the legacy RSAOpenSsl(IntPtr) constructor.
2021-07-13 18:20:19 -07:00
Kevin Jones 847cc5645d Implement CBC one shots on SymmetricAlgorithm 2021-07-07 11:12:12 -07:00
Viktor Hofer 7b575d777b Dead end S.Security.Cryptography.OpenSsl package (#51854)
* Dead end S.Security.Cryptography.OpenSsl package

To reduce complexity of the cryptography OpenSsl library, dead ending
its package as most of the configurations are partial facades anyway and
adding OpenSsl to the targeting pack. It's already part of the runtime
and exposed in aspnetcore's targeting pack.

.NET Standard libraries can continue to use the latest available package
which harvests for .NET Standard configurations.

Contributes to https://github.com/dotnet/runtime/issues/47530
2021-04-26 20:52:37 +02:00
Jeremy Barton a0811a130d Use EVP_PKEY for RSA public key operations
Also change the storage model to SafeEvpPKeyHandle,
only import and export use legacy SafeRsaHandle.
2021-04-20 09:26:50 -07:00
Elinor Fung 9c9eb90fae Switch to ProjectExclusions for assembly-level ActiveIssue tests on browser (#50891) 2021-04-08 18:37:21 -07:00
Marek Safar 95201492e7 Update ref assemblies libraries unsupported on mobile (#50616)
* Update ref assemblies libraries unsupported on mobile

* Add tvOS to known platforms list
2021-04-05 09:08:50 +02:00
Jeremy Barton 6aa4d59ca2 Use EVP_PKEY for RSA Decrypt 2021-03-24 10:27:42 -07:00
Steve MacLean 34294fabcb [macOS-arm64] Disable failing libraries tests (#49400)
* Disable tests for XUnit crashes on Apple Silicon

* Apple Silicon Disable System.IO.MemoryMappedFiles.Tests

* Apple Silicon disable DirectoryServices.Protocols.Tests

* Apple Silicon disable Cryptography tests

M1 helix missing usable libssl

* Apple Silicon disable TestVirtualMemorySize64

* Apple Silicon disable ImportCollectionsFromContainerOnly

* Apple Silicon disable XmlWriterApi tests

* Fix whitespace
2021-03-10 12:02:50 -05:00
Jeremy Koritzinsky 3e21dfcc41 Fix EC key file import tests (#49253)
* Fix cofactor import and disable tests that require the ability to derive a new public key from a private key + curve + generator, order, and cofactor.

* Add missing member.

* Disable more tests against CanDeriveNewPublicKey.

* Use isSupported instead of ConditionalFact.

* Fix net47 build.
2021-03-08 23:29:15 -08:00
Elinor Fung 6513d35a0b [AndroidCrypto] Add certs that don't use RC2 in test data (#49312) 2021-03-08 19:46:36 -08:00
Jeremy Koritzinsky b72b007e9c Disable RC2 tests on Android. (#49024)
* Disable RC2 tests on Android. RC2 isn't supported by Android.

* Use PlatformSpecific attribute instead of SkipOnMono.

* Skip key file tests that use RC2 encryption on Android

* Use ConditionalFact instead of PlatformSpecific.

* Reorganize usings and fix build failure.

* Add RC2Provider.cs to OpenSSL tests to fill in the RC2Factory type.

* Fix windows build.
2021-03-03 21:06:36 +00:00
b121bcacec Build unsupported version of System.Security.Cryptography.OpenSsl for mobile targets (#48595)
Co-authored-by: Adeel Mujahid <[email protected]>
Co-authored-by: Jeremy Barton <[email protected]>
2021-02-23 09:09:59 +01:00
Jeremy Koritzinsky 3cbdf4c57e Update SafeHandle types to have public parameterless constructors and add InitHandle API (#47189)
* Update public SafeHandle types to have public parameterless constructors.

Remove now-unneeded ILLink trim files.

Make public abstract SafeHandle constructors protected.

Remove comment on SafeWaitHandle

* Make SafeHandle constructors public for internal types.

Make internal abstract SafeHandle default constructors protected. Make non-abstract internal SafeHandles sealed when possible.

More internal SafeHandle types.

* Add new Marshal.InitHandle API.

Fix SetHandle accessibility

Fix test.

Use Marshal.InitHandle.

* PR feedback.

* Remove trailing whitespace.
2021-01-20 22:01:09 +00:00
Vladimir Sadov 7b993282b4 Enable host tests on OSX (#46640)
* Enable host tests on OSX

* initialize Ssl shim on demand

* fix OpenSsl.Tests

* partial modifier

* fixed Cryptography.Algorithms

* first to dlopen libssl wins
2021-01-13 10:01:53 -08:00
Viktor Hofer ceaa8ae8f7 Inline package descriptions and remove descriptions.json files across the repo (#46306)
* Support runtime package descriptions

* Update arcade Packaging pkg

* Inline pkg descriptions for coreclr

* Inline pkg descriptions for mono

* Inline pkg descriptions for installer

* Inline pkg descriptions for libraries
2020-12-22 16:07:56 +01:00
Anirudh AgnihotryandViktor Hofer 659c5fbc7f disable restore in vs for projects targeting platform specific old frameworks (#44932)
* disable vs restore in vs for projects targeting platform specific older frameworks

* Add infra to auto-update solution files for restore

* Add NuGet.config files for solutions affected by restore issue

Co-authored-by: Viktor Hofer <[email protected]>
2020-12-02 23:18:52 +01:00
Viktor Hofer ed295782bf Add workflow to update solution files with SlnGen and update them initially (#44703)
* Add slngen infra

* Update all solution files
2020-11-17 18:23:30 +01:00
Anirudh Agnihotry a7278fd9ba Fix packaging for the browser (#40814)
* Fix packaging for the browser

* fix wasm leg

* remove unused resource
2020-08-18 13:36:55 -07:00
Anirudh Agnihotry d0efddd932 Use Roslyn apis to generate Platform Not Supported Assemblies (#40296)
* fixes on the runtime side

* address feedback

* update arcade version

* merge conflicts

* update the version
2020-08-17 17:01:27 -07:00
Maxim Lipnin 196fd1804d [browser] Mark APIs as unsupported on browser (#40612)
* Mark System.Security.Cryptography.OpenSsl as unsupported on browser

* Mark other System.Security.Cryptography APIs as unsupported on browser

* Mark System.Data.Odbc.* as unsupported on browser

* Mark System.DirectoryServices.Protocols APIs as unsupported on browser

* Mark System.Drawing.Common APIs as unsupported on browser

* Mark System.IO.Ports as unsupported on browser
2020-08-13 12:55:30 -04:00
Adam Sitnik 6e922b89ec Mark System.Security.Cryptography.OpenSsl as unsupported on Windows, fixes #40101 (#40377) 2020-08-05 18:25:25 +02:00
Viktor Hofer 809a06f451 Remove depprojs in favor of PackageReferences (#35606)
- Remove depprojs which currently binplace external references into the RefPath folders in favor of PackageReference and PackageDownload items.
- Build all configurations by default when building an individual project (either on the CLI or inside VS) same as with the official SDK. This enables .NETFramework Test Explorer support.
- Centrally define libraries that compose the shared framework instead of in each Directory.Build.props file to be able to build the targeting pack first and consume it in the OOB libraries.
- Use ProjectReferences to reference OOB projects. Compile against the reference assembly but use the implementation assembly app-local during runtime.
- Remove OOBs from the testhost and remove the testhost folder for .NETFramework as it isn't required anymore.
- Only binplace for $(NetCoreAppCurrent) to compose a) the targeting pack, b) the runtime pack, c) the testhost, d) a full closure for the shims.
- Use Targeting Packs for OOB projects (with their implicit assembly references) but still explicitly define granular references for .NETCoreApp configurations (DisableImplicitAssemblyReferences switch). Use the implicit targeting pack references in some Microsoft.Extensions.* cases.
- Remove placeholder configurations as they aren't needed anymore with explicit P2Ps vs Targeting Pack references.
- Remove implicit assembly references (ie for .NETFramework, mscorlib)
- Remove AssemblySearchPath hacks that were introduced with b7c4cb7 as the targeting pack is now used by default.
- Reduce unnecessary .NETFramework configurations that were added to run tests in favor of the already existing ref&src configurations.
- Stop hardcoding the paths for wasm assemblies and use the returned TargetPath of the ProjectReferences.
- Addressed formatting (ItemGroups, References at the bottom of the project file, ordering of references, use LibrariesProjectRoot instead of a relative path, unnecessary AssemblyName and RootNamespace properties which are identical to the project name, ordering of tfms)
- Revert "fix clean (#33758)"
2020-07-23 17:20:26 +02:00
Jose Perez RodriguezandEric StJohn b7c4cb71fe Add NetFramework Configurations to OOB packages (#39099)
* Porting new netfx configurations for packages

* Add Netfx configurations to Microsoft.Extensions and missing System packages

* Making sure net461 configurations build against targeting pack assembly versions

* Undo changes to add netfx configurations on reference projects that don't ship in their package

* Fix issue with M.E.FP.P package by removing NetStandard.Library metapackage dependency

* Fix issues with depending on higher version than the one available in net461

* Disable UTF8String verifyClosure on package

* Undo changes to Microsoft.XmlSerializer.Generator

* Update src/libraries/Microsoft.Extensions.FileProviders.Physical/src/Microsoft.Extensions.FileProviders.Physical.csproj

Co-authored-by: Eric StJohn <[email protected]>

Co-authored-by: Eric StJohn <[email protected]>
2020-07-14 21:59:55 -07:00
Santiago Fernandez Madero 6eff5848bf Add browser tfm to test projects that used to run when it derived from Unix (#38954)
* Add browser tfm to test projects that used to run when it derived from Unix

* Don't build System.Net.Mail.Unit.Tests as they are already PNSE
2020-07-09 13:12:19 +02:00
Stephen Toub 6072e4d3a7 Update license headers (#38793) 2020-07-08 09:23:11 -04:00
Anirudh Agnihotry 5ce04ccc9a Make browser peer for windows_nt and unix (#37944)
Fixes https://github.com/dotnet/runtime/issues/38559
2020-07-08 12:59:37 +02:00
Maxim Lipnin 522d73e64c Add throwing PNSE to System.Security.Cryptography on WASM (#38379)
Since the entire set of System.Security.Cryptography.* tests has been disabled on WASM recently in https://github.com/dotnet/runtime/pull/37723, we need to let everyone know that those areas are not quite supported on WASM at the moment. In that case System.Security.Cryptography classes could throw PlatformNotSupportedException until some solution comes (https://github.com/dotnet/runtime/issues/37669)
2020-06-29 20:55:43 +02:00