[erlang-questions] blowfish cbc mode decrypt

Sverker Eriksson sverker.eriksson@REDACTED
Mon Nov 9 16:21:48 CET 2015


The call crypto:block_decrypt(blowfish_cbc, ...

ends up in C-function bf_cbc_crypt() in

$ERL_TOP/lib/crypto/c_src/crypto.c

which in turn calls OpenSSL functions BF_set_key() and BF_cbc_encrypt().


If you know the exact plain text to expect, have you tried doing
the reverse with crypto:block_encrypt.

What about trying the same with an unsensitive key that you can share.

Still don't understand what role IvSpec plays in all this.


/Sverker, Erlang/OTP


On 11/09/2015 02:17 PM, Bogdan Andu wrote:
> I have DataToBeDecrypted
>
> and one-liner in erlang shell:
>
> crypto:block_decrypt(blowfish_cbc, hexstr2bin(Key), IV, Rest).
>
> where DataToBeDecrypted is formatted as follows:
>
> <<IvSpec:8/binary, IV:8/binary, Rest/binary>> = DataToBeDecrypted
>
> I can extract IvSpec = <<"RandomIV">>,
>
> Next 8 octets is IV,
>
> Rest should bet the actual quantity to be decrypted,
>
> and the function call above fails to produce the plain text expected,
> only garbage
>
> Unfortunately Key is sensitive and cannot disclose the value.
>
> On Mon, Nov 9, 2015 at 11:40 AM, Rad Gruchalski <radek@REDACTED 
> <mailto:radek@REDACTED>> wrote:
>
>     Bogdan,
>
>     I wonder if you can show us a minimum viable example.
>     How do you encrypt, how do you decrypt. Can you present such code?
>
>     Kind regards,

>     Radek Gruchalski
>     
radek@REDACTED <mailto:radek@REDACTED>

>     <mailto:radek@REDACTED>
>     de.linkedin.com/in/radgruchalski/
>     <http://de.linkedin.com/in/radgruchalski/>
>
>     *Confidentiality:
>     *This communication is intended for the above-named person and may
>     be confidential and/or legally privileged.
>     If it has come to you in error you must take no action based on
>     it, nor must you copy or show it to anyone; please delete/destroy
>     and inform the sender immediately.
>
>     On Monday, 9 November 2015 at 10:38, Bogdan Andu wrote:
>
>>
>>     hi,
>>
>>     I really need some pointers about this issue
>>
>>     as i tried all kinds of combinations of IV and body
>>     to be decrypted.
>>
>>     Am i missing something or there is a bug in cipher
>>     blowfish_cbc ?
>>
>>
>>
>>     On Thu, Nov 5, 2015 at 3:51 PM, Bogdan Andu <bog495@REDACTED
>>     <mailto:bog495@REDACTED>> wrote:
>>>      Data to be decrypted (arrived on socket, etc) is:
>>>     <<IvSpec:8/binary, IV:8/binary, Rest/binary>> = EncryptedData
>>>
>>>     IV is ectracted form the 8-byte prepanded value preceding
>>>     IvSpec which has the value RandomIV.
>>>
>>>     decryption of Rest should be initialized with IV.
>>>
>>>
>>>     On Thu, Nov 5, 2015 at 3:38 PM, Radoslaw Gruchalski
>>>     <radek@REDACTED <mailto:radek@REDACTED>> wrote:
>>>>     You say your data is:
>>>>
>>>>     <<IvSpec>> == <<RandomIv>>
>>>>
>>>>     But you read:
>>>>
>>>>     Is your data <<IvSpec:8/binary, IV:8/binary, Rest/binary>>
>>>>
>>>>     Should it not be just:
>>>>
>>>>     <<IV:8/binary, Rest/binary>>
>>>>
>>>>     ?
>>>>
>>>>     Sent from Outlook <http://aka.ms/Ox5hz3>
>>>>
>>>>     _____________________________
>>>>     From: Bogdan Andu <bog495@REDACTED <mailto:bog495@REDACTED>>
>>>>     Sent: Thursday, November 5, 2015 2:26 p.m.
>>>>     Subject: [erlang-questions] blowfish cbc mode decrypt
>>>>     To: Erlang <erlang-questions@REDACTED
>>>>     <mailto:erlang-questions@REDACTED>>
>>>>
>>>>
>>>>
>>>>     Hi,
>>>>
>>>>     I have a stream of data called EncryptedData (with randomiv
>>>>     header specification).
>>>>     I want to decrypt using:
>>>>     crypto:block_decrypt(blowfish_cbc, hexstr2bin(Key), IV, Rest).
>>>>
>>>>     where:
>>>>
>>>>     EncryptedData is formatted as follows:
>>>>     <<IvSpec:8/binary, IV:8/binary, Rest/binary>>
>>>>
>>>>     IvSpec == <<"RandomIV">>
>>>>
>>>>     However the decryption does not works and garbage is generated
>>>>     (the function  ) .
>>>>
>>>>     What could be done given the fact that IV is an 8-byte quantity
>>>>     the Key is formatted according to crypto test suites and is 16
>>>>     bytes long
>>>>
>>>>     Am I missing something?
>>>>
>>>>     Thanks,
>>>>
>>>>     Bogdan
>>>>
>>>>
>>>
>>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151109/3cfa7f72/attachment.htm>


More information about the erlang-questions mailing list