Trouble Setting IVs.

View: New views
2 Messages — Rating Filter:   Alert me  

Trouble Setting IVs.

by Darrell A. Sullivan, II :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am trying to decode a 48 byte transaction that has been encrypted with AES
using CBC.

When I get to the point of setting the IV parameter, I am receiving an error
of -11. The error locus is 1014 and the error type is 3.

I have verified that the IV I am sending is 16 bytes long.

Can anyone give me an idea of where I need to be looking to solve this?

The code is relatively straight forward:

    lRes = cryptInit()

    lRes = cryptCreateContext(cryptContext, CRYPT_UNUSED, CRYPT_ALGO_AES)

    lRes = cryptSetAttribute(cryptContext, CRYPT_CTXINFO_MODE,
CRYPT_MODE_CBC)

    lRes = cryptGetAttribute(cryptContext, CRYPT_CTXINFO_BLOCKSIZE,
lBlockSize)

    lRes = cryptSetAttribute(cryptContext, CRYPT_CTXINFO_KEYSIZE, 32)

    lRes = cryptSetAttributeString(cryptContext, CRYPT_CTXINFO_KEY, _
           password, Len(password))

    lRes = cryptGetAttributeString(cryptContext, CRYPT_CTXINFO_IV, iv,
ivSize)
    lRes = cryptGetAttribute(cryptContext, CRYPT_ATTRIBUTE_ERRORLOCUS, _
           errorLocus)
    lRes = cryptGetAttribute(cryptContext, CRYPT_ATTRIBUTE_ERRORTYPE, _
           errorType)

    lRes = cryptDecrypt(cryptContext, sBuffer, Len(sBuffer))

    lRes = cryptGetAttributeString(cryptContext, _
               CRYPT_ATTRIBUTE_INT_ERRORMESSAGE, errorString, _
               errorStringLength)

    lRes = cryptGetAttribute(cryptContext, CRYPT_ATTRIBUTE_ERRORLOCUS, _
           errorLocus)
    lRes = cryptGetAttribute(cryptContext, CRYPT_ATTRIBUTE_ERRORTYPE, _
           errorType)


    lRes = cryptGetAttribute(cryptContext, CRYPT_CTXINFO_MODE, DefaultMode)

    lRes = cryptDestroyContext(cryptContext)

    lRes = cryptEnd()



_______________________________________________
Cryptlib mailing list
Cryptlib@... via Mail: cryptlib-request@...
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.

Re: Trouble Setting IVs.

by Peter Gutmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"Darrell A. Sullivan, II" <darrell@...> writes:

>When I get to the point of setting the IV parameter, I am receiving an error
>of -11. The error locus is 1014 and the error type is 3.
>
>Can anyone give me an idea of where I need to be looking to solve this?
>
>lRes = cryptGetAttributeString(cryptContext, CRYPT_CTXINFO_IV, iv, ivSize)

That isn't setting the IV, it's trying to read it.  Since it hasn't been set
yet, cryptlib is returning CRYPT_ERROR_NOTINITED.

Peter.

_______________________________________________
Cryptlib mailing list
Cryptlib@... via Mail: cryptlib-request@...
Archive: ftp://ftp.franken.de/pub/crypt/cryptlib/archives/
http://news.gmane.org/gmane.comp.encryption.cryptlib
Posts from non-subscribed addresses are blocked to prevent spam, please
subscribe in order to post messages.