[Botan-devel] Converting pipe result to unsigned char*
the_logician at spray.se
Mon Dec 5 06:07:46 EST 2005
Thanks for taking the time to help me out with my problems.
The messages i have to encrypt/protect is less than one megabyte, so i don't think that memory shortage will be a problem.
I have one, hopefully last, question.
I receive an unsigned char* with a known length of the message it points to.
The problem is that the message contains a prepended tag that is 2-4 bytes long.
I need to remove these bytes before sending the message to the pipe.process_msg() method.
I tried to cast and set the startingpoint of the message by doing this below:
protPipe.process_msg((byte)operationCode_p_b[tagLen], operationLength_b - tagLen);
But the method does not accept unsigned char* as parameter and C++ forbids casting to Botan::byte.
Another attempt i did was to use memcpy to copy the array to a byte:
memcpy(input, operationCode_p_b[tagLen], operationLength_b - tagLen);
But compiler says "invalid conversion from 'unsigned char' to 'const void*' ".
Any suggestions on solution?
Thanks for all the help
> Från: Jack Lloyd <lloyd at randombit.net>
> Till: botan-devel at randombit.net
> Rubrik: Re: [Botan-devel] Converting pipe result to unsigned char*
> Datum: Fri, 2 Dec 2005 12:46:38 -0500
> However, be careful, since this method doubles up the amount of memory
> using for a brief time (during the copy, when the source and destination
> have to exist at once), which could be important if you're encrypting more
> a few megabytes of data at once. If you're planning on processing a lot of
> at once, and will be dumping it straight from the character array to a file
> socket, look at the DataSink class - you can use DataSink_Stream directly
> files, or subclass DataSink for sockets. Just inherit from DataSink,
> the write() member function, and build it into the pipeline.
> On Fri, Dec 02, 2005 at 12:12:20PM -0500, Jack Lloyd wrote:
> > If the output is binary, using Pipe's read() functions should work
> nicely; they
> > will write the output directly into a provided array of unsigned chars.
> > basic idiom is:
> > Pipe pipe(/* some filters */);
> > pipe.process_msg(/* blah */);
> > const u32bit expecting = pipe.remaining();
> > // byte == Botan's typedef for unsigned char
> > byte* output = new byte[expecting];
> > if(pipe.read(output, expecting) != expecting)
> > signal_error(); // this should never happen, but just to be safe...
> > -Jack
> > On Fri, Dec 02, 2005 at 04:55:57PM +0000, Kang Chung wrote:
> > > I need to convert the pipe encryption/decryption result to a unsigned
> char* somehow.
> > > I've tried the std::string to a unsigned char, but this does not seem
> to be a good solution.
> > >
> > > Does anyone have any good ideas? Please?
> > >
> > > /Kang Chung
> > > _______________________________________________
> > > botan-devel mailing list
> > > botan-devel at randombit.net
> > > <a
> > _______________________________________________
> > botan-devel mailing list
> > botan-devel at randombit.net
> > <a
> botan-devel mailing list
> botan-devel at randombit.net
More information about the botan-devel