Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Move pal_random to System.Native from CoreRT #16652

Merged
merged 2 commits into from
Mar 3, 2017

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Mar 3, 2017

Move https://github.com/dotnet/corert/blob/master/src/Native/System.Private.CoreLib.Native/pal_random.cpp to System.Native so that it can be shared between CoreCLR and CoreRT CoreLibs

@stephentoub
Copy link
Member

We already have:

extern "C" int32_t CryptoNative_GetRandomBytes(uint8_t* buf, int32_t num)

and
extern "C" int AppleCryptoNative_GetRandomBytes(uint8_t* pBuf, uint32_t cbBuf, int32_t* pkCCStatus)

Can/should we avoid having another mechanism?
cc: @bartonjs

@jkotas
Copy link
Member Author

jkotas commented Mar 3, 2017

I am not going to add dependency from low-level runtime that just needs to generate a couple of good enough random numbers to the big crypto stack. Almost the same code is in CoreCLR PAL today. This is just to improve sharing between CoreCLR and CoreRT.

@stephentoub
Copy link
Member

stephentoub commented Mar 3, 2017

Fair enough. We should just make sure we don't inadvertently start using this in places we should be using the other ones. Or alternatively if there's no reason to be using the others, just use this one. My uber point is how many different "get random bytes" functions do we actually need.

@jkotas
Copy link
Member Author

jkotas commented Mar 3, 2017

@alexperovich This will let us move Unix GetRandomBytes to the shared corelib partition.

@jkotas
Copy link
Member Author

jkotas commented Mar 3, 2017

I have renamed the method to SystemNative_GetNonCryptographicallySecureRandomBytes to make it clear what it does.

@stephentoub
Copy link
Member

Great. Thanks.

@jkotas
Copy link
Member Author

jkotas commented Mar 3, 2017

@dotnet-bot test Innerloop OSX Debug Build and Test please

@stephentoub stephentoub merged commit 274d3c3 into dotnet:master Mar 3, 2017
@jkotas jkotas deleted the pal_random branch March 3, 2017 18:08
@karelz karelz modified the milestone: 2.0.0 Mar 6, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Move pal_random to System.Native from CoreRT

Commit migrated from dotnet/corefx@274d3c3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants