Problem in decryption using python which cipher text is encrypted in c++

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem in decryption using python which cipher text is encrypted in c++

Sugumar
Hi,

I have encrypted a free text in C++ using a EVP calls with CFB mode and 32 bytes of IV (Hex String).
Then i am passing this cipher text to my another end which is using a python(PyCrypto library) code to decrypt a cipher text using same Key and IV.
But i am getting error "IV must be of 16 bytes" in python.
I tried to convert 32 bytes of Hex string to 16 bytes ascii string but nothing works.

Please help me to resolve this.
Reply | Threaded
Open this post in threaded view
|

Re: Problem in decryption using python which cipher text is encrypted in c++

Salz, Rich
> Then i am passing this cipher text to my another end which is using a
> python(PyCrypto library) code to decrypt a cipher text using same Key and
> IV.

The IV, key, and ciphertext are all binary arrays of bytes.  Not C (or ASCII or UTF8 or anything) strings.  You will have to convert back/and forth.
--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Problem in decryption using python which cipher text is encrypted in c++

Sugumar
Thanks for your reply.

Correct me if i am wrong.
What i have understood from your point is, i have to read the first 2 char of 32 char IV and convert into a byte array right?
For example: my IV "12345678901234567890123456789012"
I have read first 2 char i.e "12" then i have to convert it into byte array.

Please give me some more clear idea about this.
If u have any example for this please post it for our better understanding.
Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Problem in decryption using python which cipher text is encrypted in c++

Michel
Hi Sugumar,

I might misunderstand your need but 'Hex' (as 'Base64') is just an encoding
method to ease use of characters that are not printable.
Your example hex string IV : "12345678901234567890123456789012" should be
converted to :

unsigned char IV[16] = { 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56,
0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12 };
in other words       = { 18,   52,   86,   120,  144,  18,   52,   86,
120,  144,  18,   52,   86,   120,  144,  18   }; (decimal values)

-----Message d'origine-----
De : openssl-users [mailto:[hidden email]] De la part de
Sugumar
Envoyé : lundi 22 février 2016 06:10
À : [hidden email]
Objet : Re: [openssl-users] Problem in decryption using python which cipher
text is encrypted in c++

Thanks for your reply.

Correct me if i am wrong.
What i have understood from your point is, i have to read the first 2 char
of 32 char IV and convert into a byte array right?
For example: my IV "12345678901234567890123456789012"
I have read first 2 char i.e "12" then i have to convert it into byte array.

Please give me some more clear idea about this.
If u have any example for this please post it for our better understanding.
Thanks.


--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users