Let me preface this by saying: please do not respond to this thread if your response is going to be something like, "Why r u trying to do that in LSL?" "What is this for?" or "Just use an external server" etc. I am really only interested in answers to the actual question, not anyone questioning why I'm asking this question or criticizing me for asking it.
That said.
Here is the question that I have:
How can you make a raw unibyte string in LSL?
Let me explain. There is a thing called HMAC-SHA1 (RFC 2104: http://tools.ietf.org/html/rfc2104). It's an algorithm for creating secure signatures from a message using SHA1 hashes and a secret key. The algorithm would basically look like this:
string result = llSHA1String(Key-XOR-0x54 + hex_decode(llSHA1String(Key-XOR-0x36 + message))
The problem is when we write a function to hex_decode the output from llSHA1String (which is a 40-char hex string) it runs into this fatal flaw: unprintable chars. For example the hash might include the byte, 0x95. This is not a valid character in a unibyte UTF8 string. However I have been able to use the UnicodeIntegerToUTF8 and UTF8ToUnicodeInteger commands to verify that the characters that I was storing had Unicode values of 0000 through 0255. But when I pass them into llSHA1String() for the second time, then the function outputs faulty results.
I seem to have no way of determining what byte value is actually stored in a particular character of a string when it comes to bytes in the range 128-255. The problem is that a lot of the high bit values (128-255) escape to UTF8 representations such as %C3%95, a multibyte character when using llEscapeURL().
I've tried looking through the Indra code but I can't find anything where it shows the source code behind what llSHA1String() is actually doing -- it seems to be server-side. And what's more, there is no documentation on how this function treats incoming streams of data... what values does it assign to what characters etc? Who knows?
Well it needs to be known. I need to know it. I want to know it.
And YES I know that there is Strife's Base64_SHA1 function. I'm trying to find a way to use LL's built in one. Because I feel like there has to be a way to use llSHA1String to do this... but if there isn't... then LL needs to build a Base64 and/or Hex implementation of the SHA1 algorithm into LSL such as llSHA1Base64 or something. So it would TAKE Base64 input and also RETURN Base64 input (same as Strife's does).
Thanks in advance for any help. I mainly just want to know: HOW DO I MAKE A RAW BYTE STRING WHERE THE CHARACTERS REPRESENT 0-255 TO FEED INTO LLSHA1STRING()?
Thanks.
SCRIPT MODE