Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose native "utilities" like CRC32 calculation, SHA-1, SHA-256 #648

Open
nfbot opened this issue Sep 25, 2020 · 19 comments
Open

Expose native "utilities" like CRC32 calculation, SHA-1, SHA-256 #648

nfbot opened this issue Sep 25, 2020 · 19 comments

Comments

@nfbot
Copy link
Member

nfbot commented Sep 25, 2020

Create a new C# class library that "taps" into the existing native methods and makes them available to managed apps.

@stale
Copy link

stale bot commented Nov 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale The issue/PR hasn't seen any activity from the past 60 days. label Nov 24, 2020
@networkfusion
Copy link
Member

Not stale!

@networkfusion networkfusion removed the stale The issue/PR hasn't seen any activity from the past 60 days. label Nov 30, 2020
@stale
Copy link

stale bot commented Feb 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale The issue/PR hasn't seen any activity from the past 60 days. label Feb 2, 2021
@networkfusion
Copy link
Member

Still Valid

@stale stale bot removed the stale The issue/PR hasn't seen any activity from the past 60 days. label Feb 5, 2021
@SandorDobos
Copy link

I found SUPPORT_ComputeCRC and lots of crypto in mbedtls.
Those are the existing native methods?
Do you mean to wire them out to lib-CoreLibrary level, right?
Any suggestions of c# level namespaces, class names?
System.Security.Cryptography and related classes below?

@networkfusion
Copy link
Member

They are (I think) existing methods in the native RTOS for most (if not all) boards, so they need exposing to the managed layer. I guess the question is, whether that is in corlib, or another "helper" lib... In all cases, it needs exposed in the managed layer to be truly useful...

BTW, this could be extended (and utility libs exist on the managed layer for things like generating them for connection to Azure when using AMQP).

@networkfusion
Copy link
Member

networkfusion commented Feb 28, 2021

I guess this is an example... https://github.com/networkfusion/NetMfMqttClient/blob/master/src/Gadgeteermqtt/SHA.cs
so would be a new lib called System.Security.Cryptography

@josesimoes
Copy link
Member

As the description above tried to explain: the goal is to expose the various utilities that are already available in the native part of the code to C#, thus saving the trouble to added them in their C# form. Not to mention the incurred penalty duplicating code that's already there and with an implementation with less performance.

Worth noting that this is NOT an excuse to add new stuff on the native code, rather expose what's already there. The most basic crypto functions, along with CRC32 are available has hardware implementations in most of mid-high level MCUs, so this becomes available with a minimum cost in code size.

Suggest that we continue this conversation in Discord, class-libraries-general channel, perhaps...

@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale The issue/PR hasn't seen any activity from the past 60 days. label Jun 2, 2021
@josesimoes
Copy link
Member

still active

@stale stale bot removed the stale The issue/PR hasn't seen any activity from the past 60 days. label Jun 2, 2021
@stale
Copy link

stale bot commented Aug 18, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale The issue/PR hasn't seen any activity from the past 60 days. label Aug 18, 2021
@josesimoes josesimoes removed the stale The issue/PR hasn't seen any activity from the past 60 days. label Aug 18, 2021
@stale
Copy link

stale bot commented Jan 7, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale The issue/PR hasn't seen any activity from the past 60 days. label Jan 7, 2022
@networkfusion networkfusion removed the stale The issue/PR hasn't seen any activity from the past 60 days. label Jan 8, 2022
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale The issue/PR hasn't seen any activity from the past 60 days. label Apr 16, 2022
@stale stale bot closed this as completed Apr 28, 2022
@networkfusion networkfusion reopened this Apr 29, 2022
@stale stale bot removed the stale The issue/PR hasn't seen any activity from the past 60 days. label Apr 29, 2022
@josesimoes josesimoes added up-for-grabs Hacktoberfest Related to hacktoberfest and removed Hacktoberfest labels Sep 29, 2023
@josesimoes
Copy link
Member

Was looking at this and on a quick search on .NET docs, found System.Runtime.Intrinsics

It has CRC32, SHA1, SHA256, etc pretty much what we're looking into exposing with this.
To me it feels like it better captures our intention and not so much providing hardcore cryptography stuff which we're unlikely to offer and (possibly) doesn't even make sense on embedded systems context.

@Ellerbach
Copy link
Member

I'm all in favor of moving some elements to native. We also have to check that those are present in all the native platforms. Otherwise for libs like Azure or AWS which are using those won't be able to work properly. And there is bunch of IoT devices using CRC16, CRC32, etc.

@josesimoes
Copy link
Member

Those are available yes. Actually, that's what prompted all this in the 1st place.
It's always there. All the rest are provided by Mbed Tls, which is available in all builds that have network.

@josesimoes
Copy link
Member

I'm taking back what I've wrote above... 😊 It seems that most of what we need to have exposed (despite several are in the Intrinsics namespace) is better fitted in Cryptography namespace. The "alien" class there will be CRC32 which doesn't exist on the full framework. But we've done it in the past with other APIs and we'll do it again: extend it with what we have. 😉

@josesimoes
Copy link
Member

Turns out that there is a .NET API for CRC32! System.IO.Hashing.
I'm thinking that we're better releasing two NuGets: one for this and another for the Cryptography namespace.

@Ellerbach
Copy link
Member

Turns out that there is a .NET API for CRC32! System.IO.Hashing.

That's a discovery for me! And a great news. It means we definitely can do all this then. Quite some work ahead but it will bring robustness in all this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Development

No branches or pull requests

5 participants