CryptDecrypt fails with NTE_BAD_DATA

Discussion in 'Security Software' started by yakov.b, Jun 3, 2006.

  1. yakov.b

    yakov.b Guest


    I use a RSA key of 1024 bits.
    The encrypter has only the public blob and the decrypter has the
    private blob.
    The 2 machines are win xp pro sp2.
    I encrypt the data in chunks of 117 bytes that become 128 bytes.

    When CryptDecrypt fails, it is always NTE_BAD_DATA and it happens in
    about 1% of all cases, but when it happens all the chunks of the data
    are NTE_BAD_DATA.

    I'm 100% sure that it is not some flaw in my program because all
    messages before and after the failed message are okay and I've ran it
    debug on good and bad messages and nothing changed.

    Furthermore, when this error occurs the data is re-encrypted and then
    it decrypts okay!
    Of course the encrypted data is now different - it encrypts it
    differently every time.

    Now, has anyone ever seen this phenomena?
    I've searched alot but could find only padding issues and such - this
    is not the case as I don't have to do anything like that.
    Another thing I just thought about right now - can I affect the
    encryption by setting something in the extra 11 bytes? - they are
    uninitialized now.. will zero them tommorow.

    Thanks in advance,
    yakov.b, Jun 3, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.