aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs46
1 files changed, 23 insertions, 23 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
index 3ed9172..1b3e70d 100644
--- a/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/CryptoGridAssetClient.cs
@@ -86,11 +86,11 @@ namespace OpenSim.Framework.Communications.Cache
86 86
87 #region Rjindael 87 #region Rjindael
88 /// <summary> 88 /// <summary>
89 /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and 89 /// This class uses a symmetric key algorithm (Rijndael/AES) to encrypt and
90 /// decrypt data. As long as encryption and decryption routines use the same 90 /// decrypt data. As long as encryption and decryption routines use the same
91 /// parameters to generate the keys, the keys are guaranteed to be the same. 91 /// parameters to generate the keys, the keys are guaranteed to be the same.
92 /// The class uses static functions with duplicate code to make it easier to 92 /// The class uses static functions with duplicate code to make it easier to
93 /// demonstrate encryption and decryption logic. In a real-life application, 93 /// demonstrate encryption and decryption logic. In a real-life application,
94 /// this may not be the most efficient way of handling encryption, so - as 94 /// this may not be the most efficient way of handling encryption, so - as
95 /// soon as you feel comfortable with it - you may want to redesign this class. 95 /// soon as you feel comfortable with it - you may want to redesign this class.
96 /// </summary> 96 /// </summary>
@@ -123,11 +123,11 @@ namespace OpenSim.Framework.Communications.Cache
123 /// </param> 123 /// </param>
124 /// <param name="initVector"> 124 /// <param name="initVector">
125 /// Initialization vector (or IV). This value is required to encrypt the 125 /// Initialization vector (or IV). This value is required to encrypt the
126 /// first block of plaintext data. For RijndaelManaged class IV must be 126 /// first block of plaintext data. For RijndaelManaged class IV must be
127 /// exactly 16 ASCII characters long. 127 /// exactly 16 ASCII characters long.
128 /// </param> 128 /// </param>
129 /// <param name="keySize"> 129 /// <param name="keySize">
130 /// Size of encryption key in bits. Allowed values are: 128, 192, and 256. 130 /// Size of encryption key in bits. Allowed values are: 128, 192, and 256.
131 /// Longer keys are more secure than shorter keys. 131 /// Longer keys are more secure than shorter keys.
132 /// </param> 132 /// </param>
133 /// <returns> 133 /// <returns>
@@ -143,7 +143,7 @@ namespace OpenSim.Framework.Communications.Cache
143 { 143 {
144 // Convert strings into byte arrays. 144 // Convert strings into byte arrays.
145 // Let us assume that strings only contain ASCII codes. 145 // Let us assume that strings only contain ASCII codes.
146 // If strings include Unicode characters, use Unicode, UTF7, or UTF8 146 // If strings include Unicode characters, use Unicode, UTF7, or UTF8
147 // encoding. 147 // encoding.
148 byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector); 148 byte[] initVectorBytes = Encoding.ASCII.GetBytes(initVector);
149 byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue); 149 byte[] saltValueBytes = Encoding.ASCII.GetBytes(saltValue);
@@ -153,8 +153,8 @@ namespace OpenSim.Framework.Communications.Cache
153 byte[] plainTextBytes = plainText; 153 byte[] plainTextBytes = plainText;
154 154
155 // First, we must create a password, from which the key will be derived. 155 // First, we must create a password, from which the key will be derived.
156 // This password will be generated from the specified passphrase and 156 // This password will be generated from the specified passphrase and
157 // salt value. The password will be created using the specified hash 157 // salt value. The password will be created using the specified hash
158 // algorithm. Password creation can be done in several iterations. 158 // algorithm. Password creation can be done in several iterations.
159 PasswordDeriveBytes password = new PasswordDeriveBytes( 159 PasswordDeriveBytes password = new PasswordDeriveBytes(
160 passPhrase, 160 passPhrase,
@@ -173,8 +173,8 @@ namespace OpenSim.Framework.Communications.Cache
173 // (CBC). Use default options for other symmetric key parameters. 173 // (CBC). Use default options for other symmetric key parameters.
174 symmetricKey.Mode = CipherMode.CBC; 174 symmetricKey.Mode = CipherMode.CBC;
175 175
176 // Generate encryptor from the existing key bytes and initialization 176 // Generate encryptor from the existing key bytes and initialization
177 // vector. Key size will be defined based on the number of the key 177 // vector. Key size will be defined based on the number of the key
178 // bytes. 178 // bytes.
179 ICryptoTransform encryptor = symmetricKey.CreateEncryptor( 179 ICryptoTransform encryptor = symmetricKey.CreateEncryptor(
180 keyBytes, 180 keyBytes,
@@ -265,8 +265,8 @@ namespace OpenSim.Framework.Communications.Cache
265 // Convert our ciphertext into a byte array. 265 // Convert our ciphertext into a byte array.
266 byte[] cipherTextBytes = cipherText; 266 byte[] cipherTextBytes = cipherText;
267 267
268 // First, we must create a password, from which the key will be 268 // First, we must create a password, from which the key will be
269 // derived. This password will be generated from the specified 269 // derived. This password will be generated from the specified
270 // passphrase and salt value. The password will be created using 270 // passphrase and salt value. The password will be created using
271 // the specified hash algorithm. Password creation can be done in 271 // the specified hash algorithm. Password creation can be done in
272 // several iterations. 272 // several iterations.
@@ -286,8 +286,8 @@ namespace OpenSim.Framework.Communications.Cache
286 // (CBC). Use default options for other symmetric key parameters. 286 // (CBC). Use default options for other symmetric key parameters.
287 symmetricKey.Mode = CipherMode.CBC; 287 symmetricKey.Mode = CipherMode.CBC;
288 288
289 // Generate decryptor from the existing key bytes and initialization 289 // Generate decryptor from the existing key bytes and initialization
290 // vector. Key size will be defined based on the number of the key 290 // vector. Key size will be defined based on the number of the key
291 // bytes. 291 // bytes.
292 ICryptoTransform decryptor = symmetricKey.CreateDecryptor( 292 ICryptoTransform decryptor = symmetricKey.CreateDecryptor(
293 keyBytes, 293 keyBytes,
@@ -320,7 +320,7 @@ namespace OpenSim.Framework.Communications.Cache
320 for (i = 0; i < decryptedByteCount; i++) 320 for (i = 0; i < decryptedByteCount; i++)
321 plainText[i] = plainTextBytes[i]; 321 plainText[i] = plainTextBytes[i];
322 322
323 // Return decrypted string. 323 // Return decrypted string.
324 return plainText; 324 return plainText;
325 } 325 }
326 } 326 }
@@ -403,17 +403,17 @@ namespace OpenSim.Framework.Communications.Cache
403 string salt = Convert.ToBase64String(rand); 403 string salt = Convert.ToBase64String(rand);
404 404
405 x.Data = UtilRijndael.Encrypt(x.Data, file.Secret, salt, "SHA1", 2, file.IVBytes, file.Keysize); 405 x.Data = UtilRijndael.Encrypt(x.Data, file.Secret, salt, "SHA1", 2, file.IVBytes, file.Keysize);
406 x.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}", 406 x.Metadata.Description = String.Format("ENCASS#:~:#{0}#:~:#{1}#:~:#{2}#:~:#{3}",
407 "OPENSIM_AES_AF1", 407 "OPENSIM_AES_AF1",
408 file.AlsoKnownAs, 408 file.AlsoKnownAs,
409 salt, 409 salt,
410 x.Description); 410 x.Metadata.Description);
411 } 411 }
412 412
413 private bool DecryptAssetBase(AssetBase x) 413 private bool DecryptAssetBase(AssetBase x)
414 { 414 {
415 // Check it's encrypted first. 415 // Check it's encrypted first.
416 if (!x.Description.Contains("ENCASS")) 416 if (!x.Metadata.Description.Contains("ENCASS"))
417 return true; 417 return true;
418 418
419 // ENCASS:ALG:AKA:SALT:Description 419 // ENCASS:ALG:AKA:SALT:Description
@@ -421,7 +421,7 @@ namespace OpenSim.Framework.Communications.Cache
421 string[] splitchars = new string[1]; 421 string[] splitchars = new string[1];
422 splitchars[0] = "#:~:#"; 422 splitchars[0] = "#:~:#";
423 423
424 string[] meta = x.Description.Split(splitchars, StringSplitOptions.None); 424 string[] meta = x.Metadata.Description.Split(splitchars, StringSplitOptions.None);
425 if (meta.Length < 5) 425 if (meta.Length < 5)
426 { 426 {
427 m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt"); 427 m_log.Warn("[ENCASSETS] Recieved Encrypted Asset, but header is corrupt");
@@ -432,7 +432,7 @@ namespace OpenSim.Framework.Communications.Cache
432 if (m_keyfiles.ContainsKey(meta[2])) 432 if (m_keyfiles.ContainsKey(meta[2]))
433 { 433 {
434 RjinKeyfile deckey = m_keyfiles[meta[2]]; 434 RjinKeyfile deckey = m_keyfiles[meta[2]];
435 x.Description = meta[4]; 435 x.Metadata.Description = meta[4];
436 switch (meta[1]) 436 switch (meta[1])
437 { 437 {
438 case "OPENSIM_AES_AF1": 438 case "OPENSIM_AES_AF1":
@@ -506,7 +506,7 @@ namespace OpenSim.Framework.Communications.Cache
506 { 506 {
507 string assetUrl = _assetServerUrl + "/assets/"; 507 string assetUrl = _assetServerUrl + "/assets/";
508 508
509 m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.FullID); 509 m_log.InfoFormat("[CRYPTO GRID ASSET CLIENT]: Sending store request for asset {0}", asset.Metadata.FullID);
510 510
511 RestObjectPoster.BeginPostObject<AssetBase>(assetUrl, asset); 511 RestObjectPoster.BeginPostObject<AssetBase>(assetUrl, asset);
512 } 512 }