Ciphers and the RSA Encryption Algorithm:
Introduction to C-based memory management


Data Structures


Implementation of the Caeser Cypher and RSA encryption with the goal of exposing students to C memory management issues.

In this assignment students will implement both a simple caeser cypher, followed by an RSA encryption/decryption functions, using only constructs supported in C (malloc/free, C-style strings, and the C string.h functions; use of streams is still permitted). Given these restrictions, the students are forced to grapple with typical memory management issues (e.g. memory allocation, pointer-based parameter passing, segmentation faults) while implementing a tool many will find interesting.

Duration: 3 weeks

Background: Students are assumed to have 1-2 semesters of an imperative or objected oriented language (e.g. Java) and to have seen the basic syntax of C, but are not assumed to have worked with pointers. All required background on RSA and related number theory is explained within the lab (or hidden in provided code), but the student may need supplemental instruction on the basic C functions (e.g. malloc, strcat) and C bit-operators (by the instructor or through some written text).


John Karro


coding, short-answer prose

Assignment Duration

Several Weeks

Communication Skill

reading, writing

Technical Skill

Implementation, pointer and memory management

Workplace Scenario

You are a programmer for a tech. company who has been tasked with setting up a protocol for secure communications – allowing users to exchange emails without that cannot be read by outsiders. To do so you will implement RSA public-key encryption; because the speed of encryption/decryption is considered a priority, you will implement these in C (as opposed to C++ or Java).

From a pedagogical perspective, the point of this assignment is to give you exposure to C-style programming, helping you to understand memory manipulation. We will continue to use the C++ compiler (avoiding the hassle of installing a C compiler), but you will be restricted to using only C libraries. Hence you experience working with the C programming language, and have you think about issues that C++ frequently (and Java always) hides from the programmer. In the course of this project you will also look at both a common cipher algorithm and RSA, one of the core encryption algorithms. RSA was the first public-key encryption algorithm, and the mathematics on which it is built is similar to many more sophisticated encryption algorithms. You are not expected to understand the mathematical basis for RSA, but by the end of this project you should understand how public-private encryption key pairs are generated, how they are used, and why they are so useful in computer security.

Team Size




John Karro, “Ciphers and the RSA Encryption Algorithm: Introduction to C-based memory management ,” Incorporating Communication Outcomes into the Computer Science Curriculum, accessed September 25, 2017, http://cs-comm.lib.muohio.edu/items/show/41.


Creative Commons License


Allowed tags: <p>, <a>, <em>, <strong>, <ul>, <ol>, <li>