Ignacio De Marco wrote:
I'm not very familiar with C, so I would like to ask you how can use
the algorithm Rijndael, suppousing that I want two simple functions (in C ANSI)
implementing the CBC or ECB Modes (is the same for me, because I have
both implementations in Delphi, but i need the same implementations in
C for an AS400) with an interface similiar to this (in Object Pascal):
function Encrypt(PlainTe xt: string; Key: string): string
function Decrypt(Encrypt edText: string; Key: string): string
Thanks in regard,
Ignacio De Marco.
Mercado Abierto Electrónico S.A.
www.mae.com.ar
This is close to topical, so...
Object Pascal implements Strings as a sort of record
type, in operation similar to this:
Type String = record
length: byte;
bytes: array of char;
end;
C doesn't implement strings this way, so you have two choices:
a) build a type of your own that does something similar
b) pass the length of PlainText, Key and EncryptedText to the
appropriate functions, and then provide a way to get the
length of the result. You might do such like this
int Encrypt (void *PlainText, unsigned long ptLength,
void *Key, unsigned long kLength,
void **EncryptedStri ng, unsigned long *esLength);
int Decrypt (void *EncryptedText, unsigned long etLength,
void *Key, unsigned long kLength,
void **DecryptedStri ng, unsigned long *dsLength);
The last two parameters in each case are for you to return
a value to the caller.
e.g. in Encrypt, you would do something like
*EncryptedStrin g = encrypted_buffe r;
*esLength = encrypted_buffe r_len;
HTH