Problems implementing Rijndael

  • Thread starter Ignacio De Marco
  • Start date
I

Ignacio De Marco

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(PlainText: string; Key: string): string

function Decrypt(EncryptedText: string; Key: string): string


Thanks in regard,

Ignacio De Marco.
Mercado Abierto Electrónico S.A.
www.mae.com.ar
 
D

dbtid

Ignacio said:
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(PlainText: string; Key: string): string

function Decrypt(EncryptedText: 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 **EncryptedString, unsigned long *esLength);

int Decrypt (void *EncryptedText, unsigned long etLength,
void *Key, unsigned long kLength,
void **DecryptedString, 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
*EncryptedString = encrypted_buffer;
*esLength = encrypted_buffer_len;


HTH
 
I

Ivan Voras

Ignacio said:
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(PlainText: string; Key: string): string

function Decrypt(EncryptedText: string; Key: string): string

What do you mean? Do you:

a) have C implementation(s) and want to use them in Delphi?
b) have Delphi implementation(s) with above declaration(s) and want to
use them in C?
c) none of the above, you just want an Rijndael implementation in C, no
matter how and which?
 
S

Stephen Sprunk

Ignacio De Marco said:
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(PlainText: string; Key: string): string

function Decrypt(EncryptedText: string; Key: string): string

Take a look at OpenSSL's AES implementation.

S
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top