From b1912d799c3ed651e525b636160216849d8f4732 Mon Sep 17 00:00:00 2001 From: harshgMSFT Date: Wed, 23 Jul 2014 16:25:17 -0700 Subject: [PATCH] Moving to RandomNumberGenerator as CryptRandom is not supported in Mono --- src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs index 6b737bb733..2e960d9c37 100644 --- a/src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs +++ b/src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs @@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Globalization; using System.Runtime.CompilerServices; +using System.Security.Cryptography; using System.Text; using Microsoft.AspNet.Security.DataProtection; @@ -17,6 +18,7 @@ namespace Microsoft.AspNet.Mvc [DebuggerDisplay("{DebuggerString}")] internal sealed class BinaryBlob : IEquatable { + private static readonly RandomNumberGenerator _randomNumberGenerator = RandomNumberGenerator.Create(); private readonly byte[] _data; // Generates a new token using a specified bit length. @@ -93,7 +95,7 @@ namespace Microsoft.AspNet.Mvc private static byte[] GenerateNewToken(int bitLength) { var data = new byte[bitLength / 8]; - CryptRand.FillBuffer(new ArraySegment(data)); + _randomNumberGenerator.GetBytes(data); return data; }