From 3659e64274fd601d43cbabd249476f65111974e6 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Fri, 27 Apr 2007 02:16:57 +0000
Subject: Added challenge generation function to generate cryptographic
strength challenges.
---
OpenSim.Framework/Remoting.cs | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
(limited to 'OpenSim.Framework')
diff --git a/OpenSim.Framework/Remoting.cs b/OpenSim.Framework/Remoting.cs
index 88f5598..12208fa 100644
--- a/OpenSim.Framework/Remoting.cs
+++ b/OpenSim.Framework/Remoting.cs
@@ -73,8 +73,27 @@ namespace OpenSim.Framework
}
///
+ /// Generates a new challenge string to be issued to a foreign host. Challenges are 1024-bit messages generated using the Crytographic Random Number Generator.
+ ///
+ /// A 128-character hexadecimal string containing the challenge.
+ public static string GenerateChallenge()
+ {
+ RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider();
+ byte[] bytes = new byte[64];
+ RNG.GetBytes(bytes);
+
+ StringBuilder sb = new StringBuilder(bytes.Length * 2);
+ foreach (byte b in bytes)
+ {
+ sb.AppendFormat("{0:x2}", b);
+ }
+ return sb.ToString();
+ }
+
+ ///
/// Helper function, merges two byte arrays
///
+ /// Sourced from MSDN Forum
/// A
/// B
/// C
--
cgit v1.1