Problems implementing Rijndael

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ignacio De Marco

    Problems implementing Rijndael

    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.

  • dbtid

    #2
    Re: Problems implementing Rijndael

    Ignacio De Marco wrote:
    [color=blue]
    > 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[/color]

    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

    Comment

    • Ivan Voras

      #3
      Re: Problems implementing Rijndael

      Ignacio De Marco wrote:
      [color=blue]
      > 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[/color]

      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?

      Comment

      • Stephen Sprunk

        #4
        Re: Problems implementing Rijndael

        "Ignacio De Marco" <ignaciodemarco @gmail.com> wrote in message
        news:c4857042.0 409021032.27704 bdc@posting.goo gle.com...[color=blue]
        > 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[/color]

        Take a look at OpenSSL's AES implementation.

        S

        --
        Stephen Sprunk "Those people who think they know everything
        CCIE #3723 are a great annoyance to those of us who do."
        K5SSS --Isaac Asimov

        Comment

        Working...