Problem Decrypting Data

P Burrows <[email protected]>
Newsgroups gmane.comp.encryption.cryptlib
Message-ID <[email protected]>
Hi,

I am a newbie to working with CryptLib and was wondering if someone could
help me figure out what I am doing wrong decrypting data. I've followed the
documentation very carefully and seem to be doing everything correct. But,
well, obviously I am not.

This is a simple password encryption using C# [1]. Pretty much the most
basic usage of the library, from what I can tell.

The one part I am not following to the letter is that I am calling the
cryptSetAttribute methods *before* I call cryptPushData.

But when I reverse those two calls, I get an error (and not the expected
error telling me I need a password, rather error -21 (No Permission to
Perform this Operation.))

Any help would be greatly appreciated. I've tried every variation of this
code that I can imagine. The full source of the entire (short, simple)
console application is here:
http://csharp.pastebin.com/m472c8e42


[1]
        static string DecryptData(string encodedData, string password)
        {
            byte[] envelopedData = StringToBytes(encodedData);
            int envelope = crypt.CreateEnvelope(crypt.UNUSED,
crypt.FORMAT_CRYPTLIB);
            crypt.SetAttribute(envelope, crypt.ENVINFO_DATASIZE,
envelopedData.Length);
            crypt.SetAttributeString(envelope, crypt.ENVINFO_PASSWORD,
password);
            int bytesCopied = 0;
            try
            {
                bytesCopied = crypt.PushData(envelope, envelopedData);
            }
            catch (CryptException cexc)
            {
                Console.WriteLine(cexc.ToString());
            }

            crypt.FlushData(envelope);
            byte[] messageBuffer = new byte[envelopedData.Length];
            bytesCopied = crypt.PopData(envelope, messageBuffer,
messageBuffer.Length);
            string unencryptedData =
ASCIIEncoding.ASCII.GetString(messageBuffer);
            crypt.DestroyEnvelope(envelope);
            return unencryptedData;
        }

--
Patrick Burrows

_______________________________________________
Cryptlib mailing list
[email protected] via Mail: [email protected]
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.