NetTalk Central

Author Topic: Cryptonite question..  (Read 5531 times)

robirenz

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Cryptonite question..
« on: March 17, 2016, 06:44:44 AM »
Help please

Sorry if this is not nettalk related, although I will be using it with nettalk as a service..
Anyway.. I need to decode and decrypt a data string I'll be receiving on a URL.

similiar to this:

http://mytest.reddin.net/testa?data=+9PJM7jC8g1pdb0YnN19ZJl8eUgUfT8z5IOBGGq+4UPK8YSx1lT16Ghv9OsX+Kh6Q8+BCx2QgaePeLsHZn5xEAIKtkVOWM5xqqacEh3eMlaHDhQCWpETYz+lHWqMVXdY

Python code looks so easy

secret_key = '1234567890123456'
cipher = AES.new(secret_key,  AES.MODE_ECB)
encoded = '+9PJM7jC8g1pdb0YnN19ZJl8eUgUfT8z5IOBGGq+4UPK8YSx1lT16Ghv9OsX+Kh6Q8+BCx2QgaePeLsHZn5xEAIKtkVOWM5xqqacEh3eMlaHDhQCWpETYz+lHWqMVXdY'
decoded = cipher.decrypt(base64.b64decode(encoded))
data = json.loads(decoded)

so I took the encoded text and sent it to this web site

http://aesencryption.net/

works like a charm I get the data back..

so I try doing the same in clarion..

My current code.

inbase64 = '+9PJM7jC8g1pdb0YnN19ZJl8eUgUfT8z5IOBGGq+4UPK8YSx1lT16Ghv9OsX+Kh6Q8+BCx2QgaePeLsHZn5xEAIKtkVOWM5xqqacEh3eMlaHDhQCWpETYz+lHWqMVXdY'
stbase.SetValue(inbase64, true)
stbase.Base64decode()
dataLen = stbase.length()
Password = '1234567890123456'
ProviderType = cs:PROV_RSA_AES 
ProviderName = cs:MS_ENH_RSA_AES_PROV
Algorithm = cs:ALG_SID_AES_128
Crypto.DecryptString(stbase,datalen,Password,ProviderType,ProviderName,Algorithm)

but I get and error when I try to decrypt and frankly have no idea what it means..
http://screencast.com/t/tfK3UkaRJa
that error is followed by the following error..
http://screencast.com/t/O8hbJhK5Kb

and of course nothing gets decrypted.

can it really be more difficult, or am I doing to enormous booboo here..

Best Regards...

Roberto Renz


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Cryptonite question..
« Reply #1 on: March 18, 2016, 05:12:37 AM »
have you tried doing it in the example program?

Cheers
Bruce

robirenz

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Cryptonite question..
« Reply #2 on: March 18, 2016, 05:43:03 AM »
That's what I'm using..

that code is basicly from from the example program.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Cryptonite question..
« Reply #3 on: March 23, 2016, 04:23:54 AM »
Hi Robert,

ok, I think you misunderstood me.
I was not interested in your code, I was interested in your result _running_ the example and entering the values there.

There are a number of settings you can use for AES, including
Cipher Mode (CBC, EDC),
Padding
Initial Vector (if CBC)
and these need to be set correctly.

Do you know what these are set to for your Python code?

Bruce


robirenz

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Cryptonite question..
« Reply #4 on: March 24, 2016, 01:31:25 PM »
ok.. so any help would be appreciated..

what happened to Kevin's help here?   it's all gone..

Best Regards...

Roberto Renz

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Cryptonite question..
« Reply #5 on: March 29, 2016, 11:29:45 PM »
I removed Kevin's answers (and some of your posts) because if the thread gets too long it will be unreadable.
There was nothing useful in the removed posts.

I have posted a new Cryptonite build with some new settings in the example to show you what I had in mind.
the root of the problem seems to be covered in the docs here;

http://www.capesoft.com/docs/CryptoNite/CryptoNite.htm#Interoperability

Cheers
Bruce

robirenz

  • Jr. Member
  • **
  • Posts: 88
    • View Profile
    • Email
Re: Cryptonite question..
« Reply #6 on: March 30, 2016, 07:22:05 AM »
for those interested in what I did now with Bruce's newest update is the following.
st1 is a stringtheory object.

     outdata = 'ee8fkXvqWUhObN/B+9MbaiX5PH9cvkiyRBA/wOMaKqTs6W9j+LdwARS108cfqLfr'
     st1.SetValue(outdata)
     st1.Base64decode()
     datalen = st1.Length()
     outdata = st1.getvalue()
     Crypto.CipherMode = 2
     indata = outdata
     Password = '1234567890123456'
     ProviderType = cs:PROV_RSA_AES
     ProviderName = cs:MS_ENH_RSA_AES_PROV
     Algorithm = cs:CALG_AES_128
     KeyHashAlg = 0
     CipherMode = cs:CRYPT_MODE_ECB
     PaddingMode = 4
     initVector = ''                       
     Crypto.DecryptString(indata,datalen,Password,ProviderType,ProviderName,Algorithm,KeyHashAlg,CipherMode,PaddingMode,clip(initVector))   
     
    And that's the code I used to decrypt my stuff from AES 128 with ECB mode (AES is also know as Rijndael  in case somebody doesn't recognize the name)
    Hope that helps somebody else out.

    Best Regards..
    Roberto Renz