473,698 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
www.mae.com.ar
Nov 14 '05 #1
3 2418
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
Nov 14 '05 #2
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


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?

Nov 14 '05 #3
"Ignacio De Marco" <ig************ @gmail.com> wrote in message
news:c4******** *************** ***@posting.goo gle.com...
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


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

Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2066
by: Pneumatus® | last post by:
I have tried to follow the instructions in the PHP manual but have been unable to get things working properly myself. The following script works fine for me: <?php /* Open the cipher */ $td = mcrypt_module_open ('rijndael-256', '', 'ofb', ''); /* Create the IV and determine the keysize length */ $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_DEV_RANDOM);
7
9556
by: Stingray | last post by:
Are there any know problems with using a MemoryStream as a backing store for a CryptoStream? I'm trying to simply encrypt and decrypt text in memory. I'd like to create some simple methods to encrypt text before writing to a database and decrypt it when reading it back. I figured I'd use a MemoryStream that I can either store as a blob or convert to a string and store as a varchar. Anyway, I can't get the CryptoStream to write to the...
19
2976
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and provide an open TD with a DIV in it for the content of this formlet. (The DIV is for DHTML to hide and show the content) I've created a web page showing step by step the two problems I'm encountering. This problem is much easier to see than it...
5
4179
by: ~~~ .NET Ed ~~~ | last post by:
Anybody has any idea why this simple thing is not working? I pass a text file as input to encrypt it, then pass the encrypted version to the same function and get some garbled data not at all resembling the input file. Rijndael rijndaelAlg = Rijndael.Create(); rijndaelAlg.BlockSize = 128; // 128 bits to comply with AES rijndaelAlg.Padding = PaddingMode.PKCS7;
0
2094
by: Jens Müller | last post by:
Hello, I try to program a Rijndael encryption in Windows which has to be compatible with php. In php I use the code below to encrypt with a 256 Bit Key and a 256 Bit block cipher. My windows code has the same specs, but the outcome is different. So far I use no iv to facilitate.
1
1488
by: RJ | last post by:
The 2.0 Framework SDK only has examples where the Rijndael class instance provides the key. I've tried setting my own key value, making sure my key length matches the KeySize property of my Rijndael instance. I always get "invalid key". Am I misunderstanding the concept - if I don't set and keep my own key, how will I be able to decrypt later? Any ideas or example would be much appreciated. RJ
4
4794
by: Sylvie | last post by:
http://www.obviex.com/samples/Encryption.aspx According to this link, I am using Rijndael Encryption & Decryption Algorithms, But I want my encrypted strings just CAPS string and just alphanumeric values ABC...Z and 123...90, no other chars I want, what should I do ? or what other algos I must use, Thanks
10
7823
by: Iwan Budihalim | last post by:
Who can help? I'm trying to implement an encrypted (plain text) communication between a Delphi application and an ASP.NET. My choice is AES/rijndael-128. For both sides, i use standard modules: Delphi: TDCP_rijndael Component (DCPcrypt Cryptographic Component Library v2) from cityinthesky (www.cityinthesky.com) ASP.NET : Standard library of Rijndael both sides are working, BUT they do different! The results in encryption
3
2569
by: KBS Developer | last post by:
Hi, I can encrypt without any problem but while decrypting I got junk. I've read the other thread about getting junk but that is not my case. Here is the sample code: private Rijndael GetKBSAlgorithm() { Rijndael rijndaelAlgorithm = Rijndael.Create(); rijndaelAlgorithm.IV = Convert.FromBase64String(tbIV.Text);
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.