2016-06-04 10:28:03

by Gadre Nayan

[permalink] [raw]
Subject: Unable to decrypt message

Hi,

I am trying to encrypt decrypt data over the wire. On the receiver
side I have a pre-routing hook where I get reference to my encrypted
data and apply decryption using the skcipher api's, however I am
unable to get the same data back.

My algo is same on both ends "cbc(aes)" and using CRYPTO_ALG_ASYNC ,
key is also same (content and size).

Should the Initialization vector also be the same. Since I am
generating iv random bytes on both ends.

Thanks


2016-06-04 10:38:01

by Gadre Nayan

[permalink] [raw]
Subject: Re: Unable to decrypt message

Additional information: My Key length is 32 bytes and iv length is 16
bytes but randomly generated. Data length is 20 bytes.
AFAIK IV data would be used in the 1st iteration of cbc mode (since
its chaining). So any Initialization vector should have worked. But
it doesn't. How ?



On Sat, Jun 4, 2016 at 3:51 PM, Gadre Nayan <[email protected]> wrote:
> Hi,
>
> I am trying to encrypt decrypt data over the wire. On the receiver
> side I have a pre-routing hook where I get reference to my encrypted
> data and apply decryption using the skcipher api's, however I am
> unable to get the same data back.
>
> My algo is same on both ends "cbc(aes)" and using CRYPTO_ALG_ASYNC ,
> key is also same (content and size).
>
> Should the Initialization vector also be the same. Since I am
> generating iv random bytes on both ends.
>
> Thanks

2016-06-04 20:59:09

by Jeffrey Walton

[permalink] [raw]
Subject: Re: Unable to decrypt message

> I am trying to encrypt decrypt data over the wire. On the receiver
> side I have a pre-routing hook where I get reference to my encrypted
> data and apply decryption using the skcipher api's, however I am
> unable to get the same data back.
>
> My algo is same on both ends "cbc(aes)" and using CRYPTO_ALG_ASYNC ,
> key is also same (content and size).

Depends on a number of things... But in general, the first thing to do
is find the self tests and run them. Finding the self tests may not be
that easy For example, afalg async tests are at
http://github.com/tstruk/afalg_async_test.

Jeff

2016-06-06 04:17:40

by Herbert Xu

[permalink] [raw]
Subject: Re: Unable to decrypt message

Gadre Nayan <[email protected]> wrote:
>
> Should the Initialization vector also be the same. Since I am
> generating iv random bytes on both ends.

Yes the IV must be the same at both ends.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt