diff options
author | Adam Frisby | 2007-04-27 02:16:57 +0000 |
---|---|---|
committer | Adam Frisby | 2007-04-27 02:16:57 +0000 |
commit | 3659e64274fd601d43cbabd249476f65111974e6 (patch) | |
tree | 8aaa9a3ddbdbdae10916940f2d4efbf3ae5095a5 /OpenSim.Framework/Remoting.cs | |
parent | Cryptographic framework for authenticating and verifying remoting messages. M... (diff) | |
download | opensim-SC-3659e64274fd601d43cbabd249476f65111974e6.zip opensim-SC-3659e64274fd601d43cbabd249476f65111974e6.tar.gz opensim-SC-3659e64274fd601d43cbabd249476f65111974e6.tar.bz2 opensim-SC-3659e64274fd601d43cbabd249476f65111974e6.tar.xz |
Added challenge generation function to generate cryptographic strength challenges.
Diffstat (limited to 'OpenSim.Framework/Remoting.cs')
-rw-r--r-- | OpenSim.Framework/Remoting.cs | 19 |
1 files changed, 19 insertions, 0 deletions
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 | |||
73 | } | 73 | } |
74 | 74 | ||
75 | /// <summary> | 75 | /// <summary> |
76 | /// Generates a new challenge string to be issued to a foreign host. Challenges are 1024-bit messages generated using the Crytographic Random Number Generator. | ||
77 | /// </summary> | ||
78 | /// <returns>A 128-character hexadecimal string containing the challenge.</returns> | ||
79 | public static string GenerateChallenge() | ||
80 | { | ||
81 | RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider(); | ||
82 | byte[] bytes = new byte[64]; | ||
83 | RNG.GetBytes(bytes); | ||
84 | |||
85 | StringBuilder sb = new StringBuilder(bytes.Length * 2); | ||
86 | foreach (byte b in bytes) | ||
87 | { | ||
88 | sb.AppendFormat("{0:x2}", b); | ||
89 | } | ||
90 | return sb.ToString(); | ||
91 | } | ||
92 | |||
93 | /// <summary> | ||
76 | /// Helper function, merges two byte arrays | 94 | /// Helper function, merges two byte arrays |
77 | /// </summary> | 95 | /// </summary> |
96 | /// <remarks>Sourced from MSDN Forum</remarks> | ||
78 | /// <param name="a">A</param> | 97 | /// <param name="a">A</param> |
79 | /// <param name="b">B</param> | 98 | /// <param name="b">B</param> |
80 | /// <returns>C</returns> | 99 | /// <returns>C</returns> |