aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-07-02 02:04:56 +0200
committerMelanie2012-07-02 02:04:56 +0200
commit4f04ec5fc26892f3ddc72741e6b600cff19c27da (patch)
treef124b428136af4a437bae506e76b44b26dcd4b86 /OpenSim
parentBring casing of llSHA1String in line with SL (diff)
downloadopensim-SC_OLD-4f04ec5fc26892f3ddc72741e6b600cff19c27da.zip
opensim-SC_OLD-4f04ec5fc26892f3ddc72741e6b600cff19c27da.tar.gz
opensim-SC_OLD-4f04ec5fc26892f3ddc72741e6b600cff19c27da.tar.bz2
opensim-SC_OLD-4f04ec5fc26892f3ddc72741e6b600cff19c27da.tar.xz
Implement the buggy version of llXorBase64Strings() for compatibility's sake
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs87
1 files changed, 84 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index dd7563a..fd8e586 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -8676,10 +8676,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8676 8676
8677 public LSL_String llXorBase64Strings(string str1, string str2) 8677 public LSL_String llXorBase64Strings(string str1, string str2)
8678 { 8678 {
8679 m_host.AddScriptLPS(1); 8679 string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
8680 Deprecated("llXorBase64Strings"); 8680
8681 ScriptSleep(300); 8681 ScriptSleep(300);
8682 return String.Empty; 8682 m_host.AddScriptLPS(1);
8683
8684 if (str1 == String.Empty)
8685 return String.Empty;
8686 if (str2 == String.Empty)
8687 return str1;
8688
8689 int len = str2.Length;
8690 if ((len % 4) != 0) // LL is EVIL!!!!
8691 {
8692 while (str2.EndsWith("="))
8693 str2 = str2.Substring(0, str2.Length - 1);
8694
8695 len = str2.Length;
8696 int mod = len % 4;
8697
8698 if (mod == 1)
8699 str2 = str2.Substring(0, str2.Length - 1);
8700 else if (mod == 2)
8701 str2 += "==";
8702 else if (mod == 3)
8703 str2 += "=";
8704 }
8705
8706 byte[] data1;
8707 byte[] data2;
8708 try
8709 {
8710 data1 = Convert.FromBase64String(str1);
8711 data2 = Convert.FromBase64String(str2);
8712 }
8713 catch (Exception)
8714 {
8715 return new LSL_String(String.Empty);
8716 }
8717
8718 // For cases where the decoded length of s2 is greater
8719 // than the decoded length of s1, simply perform a normal
8720 // decode and XOR
8721 //
8722 if (data2.Length >= data1.Length)
8723 {
8724 for (int pos = 0 ; pos < data1.Length ; pos++ )
8725 data1[pos] ^= data2[pos];
8726
8727 return Convert.ToBase64String(data1);
8728 }
8729
8730 // Remove padding
8731 while (str1.EndsWith("="))
8732 str1 = str1.Substring(0, str1.Length - 1);
8733 while (str2.EndsWith("="))
8734 str2 = str2.Substring(0, str2.Length - 1);
8735
8736 byte[] d1 = new byte[str1.Length];
8737 byte[] d2 = new byte[str2.Length];
8738
8739 for (int i = 0 ; i < str1.Length ; i++)
8740 {
8741 int idx = b64.IndexOf(str1.Substring(i, 1));
8742 if (idx == -1)
8743 idx = 0;
8744 d1[i] = (byte)idx;
8745 }
8746
8747 for (int i = 0 ; i < str2.Length ; i++)
8748 {
8749 int idx = b64.IndexOf(str2.Substring(i, 1));
8750 if (idx == -1)
8751 idx = 0;
8752 d2[i] = (byte)idx;
8753 }
8754
8755 string output = String.Empty;
8756
8757 for (int pos = 0 ; pos < d1.Length ; pos++)
8758 output += b64[d1[pos] ^ d2[pos % d2.Length]];
8759
8760 while (output.Length % 3 > 0)
8761 output += "=";
8762
8763 return output;
8683 } 8764 }
8684 8765
8685 public void llRemoteDataSetRegion() 8766 public void llRemoteDataSetRegion()