S
s.seitz
hi gods and programmers!
i've got a weird problem with strlen() in C.
in a current project, i need to AES_decrypt() some string. By now, i'm
using the libssl (openssl) API.
To get this AES_decrypt() work, i needed to split the encoded input
into pieces of 16 byte. This works as expected.
Only problem is every LAST piece in a line, which is propably shorter
than 16 byte (as you already assumed, this differs between 1 and 15).
According to the manual, i'll need to pad the piece with zeros until it
reaches the length of 16 byte.
Well, this is my problem: I can't pad with \0 since C cuts this
'string' at the first occurency of \0.
I tried almost everything: strcat, membcpy, writing directly to the
address ... nothing... the last piece of encoded data stays as short as
before my trials.
Again, my problem is NOT the AES_decrypt(). My problem is padding the
input with trailing \0 bytes.
void AES_decrypt(const unsigned char *in, unsigned char *out,
^^^^ const AES_KEY
*key);
this needs to be strlen()=16 ---------'
Please, if someone knows an answer, let me know.
Thanks in advance.
Stephan Seitz
<[email protected]>
i've got a weird problem with strlen() in C.
in a current project, i need to AES_decrypt() some string. By now, i'm
using the libssl (openssl) API.
To get this AES_decrypt() work, i needed to split the encoded input
into pieces of 16 byte. This works as expected.
Only problem is every LAST piece in a line, which is propably shorter
than 16 byte (as you already assumed, this differs between 1 and 15).
According to the manual, i'll need to pad the piece with zeros until it
reaches the length of 16 byte.
Well, this is my problem: I can't pad with \0 since C cuts this
'string' at the first occurency of \0.
I tried almost everything: strcat, membcpy, writing directly to the
address ... nothing... the last piece of encoded data stays as short as
before my trials.
Again, my problem is NOT the AES_decrypt(). My problem is padding the
input with trailing \0 bytes.
void AES_decrypt(const unsigned char *in, unsigned char *out,
^^^^ const AES_KEY
*key);
this needs to be strlen()=16 ---------'
Please, if someone knows an answer, let me know.
Thanks in advance.
Stephan Seitz
<[email protected]>