i have multiple Raspberries running with SSH server:
(OpenSSH_7.4p1 Raspbian-10+deb9u7, OpenSSL 1.0.2u 20 Dec 2019).
And if i try to connect via Renci SshNet, i get the following error message:
Renci.SshNet.Common.SshConnectionException: "The server response
contains a null character at position 0x0000002A:
00000000 53 53 48 2D 32 2E 30 2D 4F 70 65 6E 53 53 48 5F
SSH-2.0-OpenSSH_ 00000010 37 2E 34 70 31 20 52 61 73 70 62 69 61 6E
2D 31 7.4p1 Raspbian-1 00000020 30 2B 64 65 62 39 75 37 0A 00
0+deb9u7..
A server must not send a null character before the Protocol Version
Exchange is complete.
More information is available here:
https://www.rfc-editor.org/rfc/rfc4253#section-4.2"
SshClient scClient = new SshClient("123.123.123.123", "pi", "raspberry");
scClient.Connect();
is it possible to change the behavior of the ssh server,
or even better; can i tell renci ssh to ignore these protocol errors?
I think it's a problem of the latest SSH.NET NuGet Package. Currently the newest is 2020.0.0. And the one prior to that is 2020.0.0-beta1.
2020.0.0 gives me this problem, 2020.0.0-beta1 does not.
I will report this issue on https://github.com/sshnet/SSH.NET/issues
EDIT:
2020.0.1 just got published. That doesn't seem to have this problem. I recommend you to try that version.
AntiXssEncoder.HtmlEncode have support only for .Net framework.
Can I use WebUtility.HtmlEncode for Antixss as we have our application in .net core 2.1?
TL;DR:
AntiXssEncoder.HtmlEncode have support only for .Net framework. Can I use WebUtility.HtmlEncode for Antixss as we have our application in .net core 2.1?
Correct.
But I want to stress that there is no-such thing as an "anti-XSS HTML-encoder" because all correctly-implemented HTML-encoders will protect your website from XSS attacks when used correctly.
(I don't know why Microsoft named it AntiXssEncoder, but given that at-the-time the main HtmlEncode implentation was actually buggy and insecure probably might have something to do with it, but that's ancient-history now.)
In .NET Core 2.1, you only need to use System.Net.WebUtility.HtmlEncode.
In other .NET releases (especially historical versions), things are complicated, read on if you dare...
Why AntiXssEncoder (aka AntiXss and AntiXss.Encoder) exists - and why it's obsolete in 2021:
The AntiXssEncoder class from the AntiXss NuGet package (aka Microsoft.Security.Application.AntiXss) is obsolete (and has been since 2014) when it was moved to System.Web.Security.AntiXss.
The other classes: AntiXssEncoder, Encoder, and AntiXss are just alternative APIs for the same underlying implementation in Encoder btw.
The AntiXssEncoder in System.Web.Security.AntiXss is not available in .NET Core 2.1. However this is not a significant problem:
The original Microsoft.Security.Application.AntiXss was created because HttpUtility.HtmlEncode was considered insecure because it did not encode single-apostrophe characters, so XSS attacks were possible against ASP.NET 1.x and ASP.NET 2.x WebForms (.aspx) pages that used single-apostrophes to delimit HTML attributes that contained user-specified values.
For example:
String userProvidedValue = "bad.gif' onerror='alert()";
<img src='<%= this.Server.HtmlEncode( userProvidedValue ) %>' />
...which will be rendered as:
<img src='bad.gif' onerror='alert()' />
However this issue was fixed in ASP.NET 4.0 when HttpUtility.HtmlEncode was corrected to also HTML-encode those apostrophes. So the exact same code above will now be rendered as below, which won't show an alert():
<img src='bad.gif' onerror='alert()' />
AntiXssEncoder also supported specifying a list of excluded Unicode code-points or Char values, this was added because AntiXssEncoder defaulted to hex-encoding all Char values (not code-points!) above 0xFFFF, which unfortunately meant that even completely safe text in Arabic, Hebrew, Kanji, etc would be escaped, making the raw HTML almost unreadable and ballooning the output HTML length.
For example the (gibberish) string "لك أن كلا" would be rendered as "لك أن كلا" - which isn't good.
Fortunately AntiXssEncoder.MarkAsSafe can be used to exclude character ranges at the programmer's discretion.
By the time .NET Core 2.1 came out, the System.Net.WebUtility class (not to be confused with System.Web.HttpUtility, of course) was improved so that it does not unnecessarily hex-encode high Char values and it does also HTML-encode apostrophes, hence why AntiXssEncoder was no-longer needed.
In .NET Core 3.1 (and later, including .NET 5 and .NET 6) things improved further, but also got a bit confusing...
Things got better because System.Text.Encodings.Web.HtmlEncoder was added. This is a separate implementation (instead of simply wrapping WebUtility) which brings back AntiXssEncoder's ability to exclude ranges of characters from encoding just in case you need that functionality. But it's a bit of an edge-case, imo.
You can do this by calling HtmlEncoder.Create(TextEncoderSettings) with a configured TextEncoderSettings object with the required char ranges excluded.
In .NET Core 3.1, for the sake of back-compat, Microsoft brought back System.Web.HttpUtility, however this is just another wrapper over WebUtility.HtmlEncode.
It does also have HtmlAttributeEncode - which does not encode single-apostrophes. There is no good reason to use this method, imo. I'm surprised Microsoft hasn't annotated it with [Obsolete], actually.
However, in .NET Core (and .NET 5 and later) there isn't any way to HTML encode text such that named entities are used instead of hex-encoded entities (other than <, >l and &).
Previously, the AntiXssEncoder.HtmlEncode (both Microsoft.Security and System.Web.Security) method had a the useNamedEntities parameter which involved a large hard-coded table of known entity names, e.g. £ becomes £ instead of .
I imagine they removed this functionality because you cannot safely used named-entities unless all other software in your HTML-processing pipeline also supports it, and given it's a large table I expect that lots of people had issues with it breaking poorly-updated downstream code.
The HTML Living Standard (aka "HTML5") calls them character references instead of "entities" (a holdover from SGML DTDs) and defines the &#nnnn;-syntax as means of encoding Unicode code-points specifically as opposed to a character-value in some other encoding scheme, whereas previously in HTML4 the spec refers to ISO 10646 (aka UCS) characters which is not Unicode as we know it today. (and I suspect that browsers may have tried to map characters based on the document's encoding/code-page if the page wasn't encoded using Unicode (like Shift-JIS), but I might be wrong).
Finally, here's a table comparing the output from all of the different HtmlEncode methods found in .NET as of 2021:
HtmlEncode methods available in .NET Framework 4.8
Note that the following HtmlEncode methods are excluded because they're just wrappers over other implementations:
System.Web.HttpServerUtility (aka Server.HtmlEncode) just forwards to HttpUtility.HtmlEncode.
System.Web.UI.HtmlTextWriter.WriteEncodedText also forwards to HttpUtility.HtmlEncode.
System.Web.HttpUtility.HtmlEncode:
In ASP.NET 1.x and ASP.NET 2.0 (2001 and 2005 respectively) this is incorrectly implemented such that it does not escape apostrophes. I've included results from that implementation in the "System.Web.HttpUtility.HtmlEncode (ASP.NET 1.1 and 2.0)" column, for historical curiosity.
In ASP.NET 4.x, the HttpUtility.HtmlEncode method just forwards to System.Web.Util.HttpEncoder.Current.HtmlEncode(s)
Note that System.Web.Util.HttpEncoder.**Current** can be replaced at runtime, which is how an update to ASP.NET 4.x (I forget which) was able to make almost everyone use (the then far-better) AntiXssEncoder without people needing to change their existing application code. Neat.
Also note that System.Web.Util.HttpEncoder.**Current** can point to any compatible implementation, while System.Web.Util.HttpEncoder.**Default**`` is _always_ just a wrapper over WebUtility.HtmlEncode`.
System.Web.Util.HttpEncoder.Default - as mentioned above, this is just another System.Net.WebUtility wrapper.
#
Input
Code-point(s)
UTF-8 bytes
UTF-16 bytes
System.Net.WebUtility.HtmlEncode
System.Text.Encodings.Web.HtmlEncoder
System.Web.Security.AntiXss.AntiXssEncoder.HtmlEncode(false)
System.Web.Security.AntiXss.AntiXssEncoder.HtmlEncode(true)
0
abc
U+0061 U+0062 U+0063
61 62 63
61 00 62 00 63 00
abc
abc
abc
abc
1
<
U+003C
3C
3C 00
<
<
<
<
2
>
U+003E
3E
3E 00
>
>
>
>
3
&
U+0026
26
26 00
&
&
&
&
4
"
U+0022
22
22 00
"
"
"
"
5
'
U+0027
27
27 00
'
'
'
'
6
Ÿ
U+009F
C2 9F
9F 00
Ÿ
7
U+00A0
C2 A0
A0 00
8
ÿ
U+00FF
C3 BF
FF 00
ÿ
ÿ
ÿ
ÿ
9
ā
U+0101
C4 81
01 01
ā
ā
ā
ā
10
~
U+007E
7E
7E 00
~
~
~
~
11
| `U+007F` | `7F` | `7F 00` |
12
£
U+00A3
C2 A3
A3 00
£
£
£
£
13
ÿ
U+00FF
C3 BF
FF 00
ÿ
ÿ
ÿ
ÿ
14
Ḃ
U+1E02
E1 B8 82
02 1E
Ḃ
Ḃ
Ḃ
Ḃ
15
💩
U+1F4A9
F0 9F 92 A9
3D D8 A9 DC
💩
💩
💩
💩
16
𣎴
U+233B4
F0 A3 8E B4
4C D8 B4 DF
𣎴
𣎴
𣎴
𣎴
17
𣎴
U+233B4
F0 A3 8E B4
4C D8 B4 DF
𣎴
𣎴
𣎴
𣎴
18
لك أن كلا
U+0644 U+0643 U+0020 U+0623 U+0646 U+0020 U+0643 U+0644 U+0627
D9 84 D9 83 20 D8 A3 D9 86 20 D9 83 D9 84 D8 A7
44 06 43 06 20 00 23 06 46 06 20 00 43 06 44 06 27 06
لك أن كلا
لك أن كلا
لك أن كلا
لك أن كلا
Obsolete and historical HtmlEncode methods:
This table is included only for computer-archeological reasons. **It does not apply to .NET Framework 4.8, nor any versions of ASP.NET Core and ASP.NET-for-.NET 5 or later.
#
Input
Code-point(s)
UTF-8 bytes
UTF-16 bytes
System.Web.HttpUtility.HtmlEncode (ASP.NET 1.1 and 2.0)
Microsoft.Security.Application.Encoder.HtmlEncode(false)
Microsoft.Security.Application.Encoder.HtmlEncode(true)
0
abc
U+0061 U+0062 U+0063
61 62 63
61 00 62 00 63 00
abc
abc
abc
1
<
U+003C
3C
3C 00
<
<
<
2
>
U+003E
3E
3E 00
>
>
>
3
&
U+0026
26
26 00
&
&
&
4
"
U+0022
22
22 00
"
"
"
5
'
U+0027
27
27 00
'
'
'
6
Ÿ
U+009F
C2 9F
9F 00
Ÿ
7
U+00A0
C2 A0
A0 00
8
ÿ
U+00FF
C3 BF
FF 00
ÿ
ÿ
ÿ
9
ā
U+0101
C4 81
01 01
ā
ā
ā
10
~
U+007E
7E
7E 00
~
~
~
11
| `U+007F` | `7F` | `7F 00` |
12
£
U+00A3
C2 A3
A3 00
£
£
£
13
ÿ
U+00FF
C3 BF
FF 00
ÿ
ÿ
ÿ
14
Ḃ
U+1E02
E1 B8 82
02 1E
Ḃ
Ḃ
Ḃ
15
💩
U+1F4A9
F0 9F 92 A9
3D D8 A9 DC
💩
💩
💩
16
𣎴
U+233B4
F0 A3 8E B4
4C D8 B4 DF
𣎴
𣎴
𣎴
17
𣎴
U+233B4
F0 A3 8E B4
4C D8 B4 DF
𣎴
𣎴
𣎴
18
لك أن كلا
U+0644 U+0643 U+0020 U+0623 U+0646 U+0020 U+0643 U+0644 U+0627
D9 84 D9 83 20 D8 A3 D9 86 20 D9 83 D9 84 D8 A7
44 06 43 06 20 00 23 06 46 06 20 00 43 06 44 06 27 06
لك أن كلا
لك أن كلا
لك أن كلا
HtmlEncode methods in .NET 5
#
Input
Code-point / Runes
UTF-8 bytes
UTF-16 bytes
System.Net.WebUtility.HtmlEncode
System.Web.HttpUtility.HtmlEncode (.NET 5)
System.Text.Encodings.Web.HtmlEncoder
0
abc
97 98 99
61 62 63
61 00 62 00 63 00
abc
abc
abc
1
<
60
3C
3C 00
<
<
<
2
>
62
3E
3E 00
>
>
>
3
&
38
26
26 00
&
&
&
4
"
34
22
22 00
"
"
"
5
'
39
27
27 00
'
'
'
6
Ÿ
159
C2 9F
9F 00
Ÿ
Ÿ
7
160
C2 A0
A0 00
8
ÿ
255
C3 BF
FF 00
ÿ
ÿ
ÿ
9
ā
257
C4 81
01 01
ā
ā
ā
10
~
126
7E
7E 00
~
~
~
11
| `127` | `7F` | `7F 00` |
``
12
£
163
C2 A3
A3 00
£
£
£
13
ÿ
255
C3 BF
FF 00
ÿ
ÿ
ÿ
14
Ḃ
7682
E1 B8 82
02 1E
Ḃ
Ḃ
Ḃ
15
💩
128169
F0 9F 92 A9
3D D8 A9 DC
💩
💩
💩
16
𣎴
144308
F0 A3 8E B4
4C D8 B4 DF
𣎴
𣎴
𣎴
17
𣎴
144308
F0 A3 8E B4
4C D8 B4 DF
𣎴
𣎴
𣎴
18
لك أن كلا
1604 1603 32 1571 1606 32 1603 1604 1575
D9 84 D9 83 20 D8 A3 D9 86 20 D9 83 D9 84 D8 A7
44 06 43 06 20 00 23 06 46 06 20 00 43 06 44 06 27 06
لك أن كلا
لك أن كلا
لك أن كلا
Everytime I open a GPIO pin I get this exception:
WinRT information: Failed to open a handle to the device.
A resource required for this operation is disabled.
I can't seem to find much information for this on the internet. Probably because UAP is still in a preview. And I don't think something is wrong with my code, it is almost the same one from the Blink example:
GpioController gpio = GpioController.GetDefault();
if (gpio != null)
{
var ledpin = gpio.OpenPin(11);
ledpin.Write(_light ? GpioPinValue.High : GpioPinValue.Low);
ledpin.SetDriveMode(GpioPinDriveMode.Output);
}
Only a subset of pins are available to usermode. Most pins are reserved by the system and cannot be accessed from usermode.
As far as I know pin 11 is not available. Try pin 12 or 13.
List of available Pins:
GPIO# Power-on Pull Header Pin
4 PullUp 7
5 PullUp 29
6 PullUp 31
12 PullDown 32
13 PullDown 33
16 PullDown 36
17 PullDown 11
18 PullDown 12
19 PullDown 35
20 PullDown 38
21 PullDown 40
22 PullDown 15
23 PullDown 16
24 PullDown 18
25 PullDown 22
26 PullDown 37
27 PullDown 13
35 PullUp Red Power LED
47 PullUp Green Activity LED
Edit: Added missing GPIOs
Randomly I'm getting the crash below in the iOS5 Simulator with Monotouch 5.2.6 and SGen being enabled. This is a debug build.
It is happening after clicking a button. That click spins off a new thread that shows a little progress indicator. When it is done thinking, it will exchange two views with animation (running all this on the UI thread).
I would like to know where to start because I don't get a managed stack trace. Am I right that it is trying to layout a UITableViewCell that no longer exists?
Native stacktrace:
0 MobileApp 0x00094fbc mono_handle_native_sigsegv + 284
1 MobileApp 0x0000be72 mono_sigsegv_signal_handler + 178
2 libsystem_c.dylib 0x9c5ee59b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 QuartzCore 0x04176891 -[CALayer actionForKey:] + 89
5 QuartzCore 0x0417982d _ZL12actionForKeyP7CALayerPN2CA11TransactionEP8NSString + 82
6 QuartzCore 0x0417c9c3 _ZN2CA5Layer12begin_changeEPNS_11TransactionEjRP11objc_object + 131
7 QuartzCore 0x04181f82 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 388
8 QuartzCore 0x04178205 -[CALayer setPosition:] + 68
9 QuartzCore 0x04177cba -[CALayer setFrame:] + 675
10 UIKit 0x021d8590 -[UIView(Geometry) setFrame:] + 198
11 UIKit 0x022e1731 -[UILabel setFrame:] + 233
12 UIKit 0x02439731 -[UITableViewCellLayoutManager layoutSubviewsOfCell:] + 4511
13 UIKit 0x02390e34 -[UITableViewCell layoutSubviews] + 2650
14 UIKit 0x021e3322 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 178
15 CoreFoundation 0x011d6e72 -[NSObject performSelector:withObject:] + 66
16 QuartzCore 0x0417392d -[CALayer layoutSublayers] + 266
17 QuartzCore 0x0417d827 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 231
18 QuartzCore 0x04103fa7 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 377
19 QuartzCore 0x04105ea6 _ZN2CA11Transaction6commitEv + 374
20 QuartzCore 0x041059d3 _ZN2CA11Transaction14release_threadEPv + 65
21 libsystem_c.dylib 0x9c5dfe0c _pthread_tsd_cleanup + 85
22 libsystem_c.dylib 0x9c59864c _pthread_exit + 146
23 libsystem_c.dylib 0x9c5989a0 pthread_exit + 33
24 MobileApp 0x0020434e thread_exit + 30
25 MobileApp 0x00203d03 thread_start_routine + 163
26 MobileApp 0x001aeb20 gc_start_thread + 80
27 libsystem_c.dylib 0x9c596ed9 _pthread_start + 335
28 libsystem_c.dylib 0x9c59a6de thread_start + 34
Native code is trying to access something that has been freed.
This is the key line:
4 QuartzCore 0x04176891 -[CALayer actionForKey:] + 89
you need to figure out what [CALayer actionForKey:] is trying to do (and on which object) - have in mind that this can be a number of things (calling a delegate / event, calling a virtual method, fetching a property). It's however difficult to be specific without seeing your actual code.
I Currently perform a large amount of encryption/decryption of text in c# using AES.
With a pure software system it can take quite a processor hit for a decent amount of time for the lots of datasets required to be decrypted. I know Intel have came out with their AES-NI instruction set and AMD has come out with similar.
I'm using .NET 4.0, I know that the windows CNG framework makes use of these instruction sets, but it does not appear that AesManaged in the .NET world does the same.
There is a fantastic project "CLR Security" which makes a gateway from .NET 3.5 to the windows CNG, however it hasn't been maintained in a year and I'd rather not (if possible) jump on a dying project.
There is a CNGProvider class in .NET 4 but there doesn't appear to be adequate documentation to cobble together a working decryption from it for AES.
Does anyone have experience with the topic they could point me in the right direction on how to get AES-NI implemented in a pure .NET environment, using pre-made classes, without having to do a p/invoke directly from c#? (It'd be fine if there was a wrapper class doing it, as long as it was maintained).
What about AesCryptoServiceProvider? It says that uses CAPI, and so
hopefully CNG if available. – Rup
This comment has helped tremendously, after doing some digging it looks like AesCryptoServiceProvider will use AES-NI if available. I cannot find any 'official' documentation from Microsoft on this however. When running simple timing benchmarks the difference is ~15x faster so either the API itself is massively optimized (which for a 15x increase is pretty nice optimization) or it uses the AES-NI instruction set.
Unfortunately I don't have a non AES-NI box to test on, but if I ever get one I'll update this thread with results.
So I'm pretty confident this is the API to use for AES-NI but cannot guarantee without further testing.
How to use a CNG (or AES-NI enabled instruction set) in .NET?
I'm going to focus on the AES-NI instruction set question. I found it to be interesting since I wondered it myself (for use in C and C++).
Microsoft added AES-NI support to Visual Studio 2008 SP1 (_MSC_FULL_VER >= 150030729). The earliest you can observe AES-NI in Microsoft products is circa 2008 since earlier compilers did not support it. That means Server 2008 has it, and possibly Windows Vista via a Service Pack, and above.
According to Does MS Crypto API supports AES and AES-NI processor instructions?, both rsaenh.dll and bcryptprimitives.dll have it. The statements made by IvanP tested on Windows 7 and Windows 10.
However, testing on Windows 8.1 reveals...
# Using a Developer Command prompt so dumpbin is on-path:
> dumpbin /disasm c:\Windows\System32\rsaenh.dll > rsaenh.dll.txt
> dumpbin /disasm c:\Windows\System32\bcryptprimitives.dll > bcryptprimitives.dll.txt
Then:
# Using a GitBash terminal for grep
$ grep -i aes rsaenh.dll.txt
$
And:
$ grep -i aes bcryptprimitives.dll.txt
000000018000234A: 66 0F 3A DF C0 00 aeskeygenassist xmm0,xmm0,0
0000000180002363: 66 0F 38 DB C0 aesimc xmm0,xmm0
000000018000237E: 66 0F 38 DC 41 10 aesenc xmm0,xmmword ptr [rcx+10h]
0000000180002384: 66 0F 38 DC 41 20 aesenc xmm0,xmmword ptr [rcx+20h]
000000018000238A: 66 0F 38 DC 41 30 aesenc xmm0,xmmword ptr [rcx+30h]
0000000180002390: 66 0F 38 DC 41 40 aesenc xmm0,xmmword ptr [rcx+40h]
0000000180002396: 66 0F 38 DC 41 50 aesenc xmm0,xmmword ptr [rcx+50h]
000000018000239C: 66 0F 38 DC 41 60 aesenc xmm0,xmmword ptr [rcx+60h]
00000001800023A2: 66 0F 38 DC 41 70 aesenc xmm0,xmmword ptr [rcx+70h]
00000001800023AF: 66 0F 38 DC 01 aesenc xmm0,xmmword ptr [rcx]
00000001800023B4: 66 0F 38 DC 41 10 aesenc xmm0,xmmword ptr [rcx+10h]
00000001800023C3: 66 41 0F 38 DD 02 aesenclast xmm0,xmmword ptr [r10]
000000018001936E: 66 0F 38 DC 41 10 aesenc xmm0,xmmword ptr [rcx+10h]
0000000180019374: 66 0F 38 DC 41 20 aesenc xmm0,xmmword ptr [rcx+20h]
000000018001937A: 66 0F 38 DC 41 30 aesenc xmm0,xmmword ptr [rcx+30h]
0000000180019380: 66 0F 38 DC 41 40 aesenc xmm0,xmmword ptr [rcx+40h]
0000000180019386: 66 0F 38 DC 41 50 aesenc xmm0,xmmword ptr [rcx+50h]
000000018001938C: 66 0F 38 DC 41 60 aesenc xmm0,xmmword ptr [rcx+60h]
0000000180019392: 66 0F 38 DC 41 70 aesenc xmm0,xmmword ptr [rcx+70h]
000000018001939F: 66 0F 38 DC 01 aesenc xmm0,xmmword ptr [rcx]
00000001800193A4: 66 0F 38 DC 41 10 aesenc xmm0,xmmword ptr [rcx+10h]
00000001800193B3: 66 41 0F 38 DD 02 aesenclast xmm0,xmmword ptr [r10]
000000018001952E: 66 0F 38 DE C4 aesdec xmm0,xmm4
0000000180019533: 66 0F 38 DE CC aesdec xmm1,xmm4
0000000180019538: 66 0F 38 DE D4 aesdec xmm2,xmm4
000000018001953D: 66 0F 38 DE DC aesdec xmm3,xmm4
000000018001954B: 66 0F 38 DF C4 aesdeclast xmm0,xmm4
0000000180019550: 66 0F 38 DF CC aesdeclast xmm1,xmm4
0000000180019555: 66 0F 38 DF D4 aesdeclast xmm2,xmm4
000000018001955A: 66 0F 38 DF DC aesdeclast xmm3,xmm4
000000018002E8B5: 66 0F 38 DE 41 10 aesdec xmm0,xmmword ptr [rcx+10h]
000000018002E8BB: 66 0F 38 DE 41 20 aesdec xmm0,xmmword ptr [rcx+20h]
000000018002E8C1: 66 0F 38 DE 41 30 aesdec xmm0,xmmword ptr [rcx+30h]
000000018002E8C7: 66 0F 38 DE 41 40 aesdec xmm0,xmmword ptr [rcx+40h]
000000018002E8CD: 66 0F 38 DE 41 50 aesdec xmm0,xmmword ptr [rcx+50h]
000000018002E8D3: 66 0F 38 DE 41 60 aesdec xmm0,xmmword ptr [rcx+60h]
000000018002E8D9: 66 0F 38 DE 41 70 aesdec xmm0,xmmword ptr [rcx+70h]
000000018002E8E6: 66 0F 38 DE 01 aesdec xmm0,xmmword ptr [rcx]
000000018002E8EB: 66 0F 38 DE 41 10 aesdec xmm0,xmmword ptr [rcx+10h]
000000018002E8FA: 66 41 0F 38 DF 02 aesdeclast xmm0,xmmword ptr [r10]
000000018003F458: 66 0F 38 DC E8 aesenc xmm5,xmm0
000000018003F45D: 66 0F 38 DC D8 aesenc xmm3,xmm0
000000018003F462: 66 0F 38 DC E0 aesenc xmm4,xmm0
000000018003F467: 66 0F 38 DC F0 aesenc xmm6,xmm0
000000018003F475: 66 0F 38 DD EF aesenclast xmm5,xmm7
000000018003F47A: 66 0F 38 DD DF aesenclast xmm3,xmm7
000000018003F47F: 66 0F 38 DD E7 aesenclast xmm4,xmm7
000000018003F492: 66 0F 38 DD F7 aesenclast xmm6,xmm7
So, on modern Windows, you need to use something that depends on bcryptprimitives.dll. I don't know what .Net primitives enlist bcryptprimitives.dll.
I also checked the following DLLs on Windows 8.1, and there were no AES-NI instructions present:
advapi32.dll
bcrypt.dll
crypt32.dll
cryptbase.dll
cryptcatsvc.dll
cryptdlg.dll
cryptdll.dll
cryptext.dll
cryptnet.dll
cryptowinrt.dll
cryptsp.dll
cryptsvc.dll
There's not much information about the subject on Microsoft's site. I got two hits from csp "aes-ni" site:microsoft.com, and 0 hits for csp "aesni" site:microsoft.com. Whatever is going on, Microsoft is keeping it secret.
I had worked in the earliest of chipsets that had these features. At that time Windows 7 didn't have the ability to work with AES. I resorted to the then available Ubuntu and used the Intel doc and with some inline assembly did a cpuid. That served my purpose of a training. Nevertheless one thing I learned is "Intel secure key" was made available almost at the same time as "AES-NI". So if I found RDRAND instruction in the chipset that means I "probably" had AES-NI. So this way the simplest I can do (but not quite documented) is
//PF_RDRAND_INSTRUCTION_AVAILABLE is not documented yet as part of MSDN API as of //this writing
IsProcessorFeaturePresent(PF_RDRAND_INSTRUCTION_AVAILABLE);
We can also use the CPU intrinsics this way
https://learn.microsoft.com/en-us/cpp/intrinsics/cpuid-cpuidex?view=vs-2019
Also see below document for more "proof".
https://csrc.nist.gov/csrc/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp1894.pdf