[Mono-dev] Help Finding this Function?

Rafael Teixeira monoman at gmail.com
Fri Jun 27 14:41:33 UTC 2014


Oops, looking more attentively at the code rand.c has lines like:

#if defined (HOST_WIN32)



*So you need to see what part of it is actually being compiled for the
platform you are targeting.*
When targeting Windows header files windows.h and wincrypt.h (from the
Windows SDK, which is a building dependency) are included and then probably
there you will find the definition for CryptAcquireContext but as with most
APIs from Windows it will actually be implemented by two entry-points
CryptAcquireContextA (for ANSI strings in parameters/returns) and
CryptAcquireContextW (for Unicode [UTF-16] strings) in some Microsoft
provided native dll.


In Unix we have:


gpointer
ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngInitialize
(MonoArray *seed)
{
	/* if required exception will be thrown in managed code */
	return ((!egd && (file < 0)) ? NULL : GINT_TO_POINTER (file));
}

and random bytes are obtained from the /dev/urandom device.


And the "Native" version simply short-circuits it as it simply uses an
internal rand() function for any call to
ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngGetBytes()
:



gpointer
ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngInitialize
(MonoArray *seed)
{
	return -1;
}


Rafael Teixeira
O..:.)oooo


On Fri, Jun 27, 2014 at 11:17 AM, Rafael Teixeira <monoman at gmail.com> wrote:

> You are looking at the wrong rand.c. They are switched on compilation
> depending on the target platform.
>
> Hope it helps,
>
> Rafael Teixeira
> O..:.)oooo
>
>
> On Fri, Jun 27, 2014 at 10:34 AM, Edward Ned Harvey (mono) <
> edward.harvey.mono at clevertrove.com> wrote:
>
>> > From: Miguel de Icaza [mailto:miguel at xamarin.com]
>> >
>> > rand.c has several implementations, the CryptAcquireContext is part of
>> the
>> > Win32 support, and is a Win32 API call.
>> >
>> > There is also a Native client implementation and a Unix one.
>>
>> Thanks - But - What am I missing?  I don't have any "wincrypt.h" file
>> anywhere in my mono source tree.  So I guess wincrypt.h exists in windows
>> and not unix/linux...  I guess if you build on windows, it probably calls
>> the Win32 API directly, and otherwise, some other functionally equivalent
>> implementation takes its place...
>>
>> I'm confused about the meaning of a "native" implementation versus a
>> "unix" one.  If I build on mac or linux, does that imply it uses the unix
>> one?  Are you saying non-windows platforms (mac/linux) implement this call
>> in a native library that's included in the OS?
>>
>> Sorry, I'm just still confused about how that gets hooked in, where it
>> comes from....
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20140627/c146f42c/attachment.html>


More information about the Mono-devel-list mailing list