[netcore] Implement Thread.GetCurrentProcessorId (#18450)
[mono-project.git] / mono / metadata / rand.c
blob8ce627ea4d9f8cfd92f9165b0a6e2435c5b3f390
1 /**
2 * \file
3 * System.Security.Cryptography.RNGCryptoServiceProvider support
5 * Authors:
6 * Mark Crichton (crichton@gimp.org)
7 * Patrik Torstensson (p@rxc.se)
8 * Sebastien Pouliot (sebastien@ximian.com)
10 * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
11 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
12 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
15 #include <config.h>
16 #include <glib.h>
18 #include "object.h"
19 #include "object-internals.h"
20 #include "rand.h"
21 #include "utils/mono-rand.h"
22 #include "icall-decl.h"
24 #ifndef ENABLE_NETCORE
26 MonoBoolean
27 ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngOpen (MonoError *error)
29 return (MonoBoolean) mono_rand_open ();
32 gpointer
33 ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngInitialize (const guchar *seed, gssize seed_length, MonoError *error)
35 return mono_rand_init (seed, seed_length);
38 gpointer
39 ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngGetBytes (gpointer handle, guchar *array, gssize array_length, MonoError *error)
41 g_assert (array || !array_length);
42 mono_rand_try_get_bytes (&handle, array, array_length, error);
43 return handle;
46 void
47 ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngClose (gpointer handle, MonoError *error)
49 mono_rand_close (handle);
52 #else
54 MONO_EMPTY_SOURCE_FILE (rand);
56 #endif /* ENABLE_NETCORE */