Well I have almost everything working. But i cant still figure
how this part (The REMarked one) is translated into PowerBASIC:
I have received lots of help already, but If someone can help me ill appreciate it very much. The part that is not translated is REMarked.
Here is a reference in PYTON:
Here is snippet in Java:
Same code in C For Linux:
And here is a reference in VB .NET (I think):
More Info Here:
All the rest of the code is already working, and i will make it available
when finished.
I dont know what commands like "TripleDESCryptoServiceProvider" do, Ill investigate it.
Feel free to help in any possible way, i will appreciate it very much.
how this part (The REMarked one) is translated into PowerBASIC:
Code:
FUNCTION Derive_key(Key AS STRING, Magic AS STRING) AS STRING LOCAL hash1, hash2, hash3, hash4 AS STRING hash1 = HMac_Sha1(Key, Magic) hash2 = HMac_Sha1(Key, Hash1 & Magic) hash3 = HMac_Sha1(Key, hash1) hash4 = HMac_Sha1(Key, Hash3 & Magic) FUNCTION = Hash2 & MID$(Hash4, 1, 4) END FUNCTION FUNCTION MBI_Encrypt(Key AS STRING, nonce AS STRING) AS STRING LOCAL key1, key2, key3, IV, hHash, Gg AS STRING key1 = DecodeStr64(key) key2 = derive_key(key1, "WS-SecureConversationSESSION KEY HASH") key3 = derive_key(key1, "WS-SecureConversationSESSION KEY ENCRYPTION") hHash = HMac_Sha1(Key2, nonce) RANDOMIZE TIMER IV = "aT7gJlKz" ' alg3 = TripleDESCryptoServiceProvider.Create ' alg3.Key = Encoding.Default.GetBytes(key3) ' alg3.Mode = CipherMode.CBC ' alg3.IV = iv ' akm = alg3.CreateEncryptor Gg = (nonce & CHR$(8,8,8,8,8,8,8,8)) FUNCTION = EncodeStr64(MKDWD$(28) & MKDWD$(1) & MKDWD$(26115) & MKDWD$(32772) & MKDWD$(8) & MKDWD$(LEN(hHash)) & MKDWD$(LEN(Gg)) & IV & hHash & Gg) END FUNCTION
Here is a reference in PYTON:
Here is snippet in Java:
Code:
//generate key's byte key1[] = Base64Coder.decode(secret); byte key2[] = derive_key(key1, "WS-SecureConversationSESSION KEY HASH".getBytes()); byte key3[] = derive_key(key1, "WS-SecureConversationSESSION KEY ENCRYPTION".getBytes()); //create hash byte hash[] = HMAC(key2, nonce.getBytes()); //add 8 bytes to the nonce byte nonceFillup[] = new byte[8]; for(int i = 0; i < 8; i++){ nonceFillup[i] = 0x08; } //create des3 thingy byte des[] = DES3(key3, byteCombine(nonce.getBytes(),nonceFillup), iv); //fill struct byte struct[] = byteCombine(byteCombine(byteCombine(start, iv ), hash ), des); //return stuff return ticket +" "+ new String(Base64Coder.encode(struct));
And here is a reference in VB .NET (I think):
More Info Here:
All the rest of the code is already working, and i will make it available
when finished.
I dont know what commands like "TripleDESCryptoServiceProvider" do, Ill investigate it.
Feel free to help in any possible way, i will appreciate it very much.
Comment