Imported Upstream version 5.18.0.142

Former-commit-id: 7467d4b717762eeaf652d77f1486dd11ffb1ff1f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-10-09 08:20:59 +00:00
parent e52655b4dc
commit 0abdbe5a7d
1547 changed files with 93792 additions and 47893 deletions

View File

@ -101,13 +101,22 @@ namespace Crimson.CommonCrypto {
// size_t was changed to IntPtr for 32/64 bits size difference - even if mono is (moslty) used in 32bits only on OSX today
[DllImport ("/System/Library/Frameworks/Security.framework/Security")]
extern internal static /* int */ int SecRandomCopyBytes (/* SecRandomRef */ IntPtr rnd, /* size_t */ IntPtr count, /* uint8_t* */ byte[] bytes);
unsafe extern internal static /* int */ int SecRandomCopyBytes (/* SecRandomRef */ IntPtr rnd, /* size_t */ IntPtr count, /* uint8_t* */ byte *data);
static internal void GetRandom (byte[] buffer)
unsafe static internal void GetRandom (byte[] buffer)
{
if (SecRandomCopyBytes (IntPtr.Zero, (IntPtr) buffer.Length, buffer) != 0)
fixed (byte* fixed_bytes = buffer) {
if (SecRandomCopyBytes (IntPtr.Zero, (IntPtr)buffer.Length, fixed_bytes) != 0)
throw new CryptographicException (Marshal.GetLastWin32Error ()); // errno
}
}
static internal unsafe void GetRandom (byte* data, IntPtr data_length)
{
if (SecRandomCopyBytes (IntPtr.Zero, data_length, data) != 0)
throw new CryptographicException (Marshal.GetLastWin32Error ()); // errno
}
}
#if !MONOTOUCH && !XAMMAC