0% found this document useful (0 votes)
2 views

File-encryption-and-decryption-system-based-on-RSA-algorithm

This paper presents a file encryption and decryption system based on the RSA algorithm, detailing its feasibility and implementation using C++ Class Library. The system allows for the generation of asymmetric keys, encryption of files, and restoration of original files, while ensuring message integrity and ease of operation. The project emphasizes efficiency, reusability, and open-source development, contributing to the broader application of RSA in electronic security.

Uploaded by

Phan Thắm
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

File-encryption-and-decryption-system-based-on-RSA-algorithm

This paper presents a file encryption and decryption system based on the RSA algorithm, detailing its feasibility and implementation using C++ Class Library. The system allows for the generation of asymmetric keys, encryption of files, and restoration of original files, while ensuring message integrity and ease of operation. The project emphasizes efficiency, reusability, and open-source development, contributing to the broader application of RSA in electronic security.

Uploaded by

Phan Thắm
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

2011 International Conference on Computational and Information Sciences

File encryption and decryption system based on RSA algorithm


Suli Wang Ganlai Liu
School of Information Engineering
Support Center
Jingdezhen Ceramic Institute
Jingdezhen Telecom
Jingdezhen, Jiangxi Province, China
Jingdezhen, Jiangxi Province, China
[email protected] [email protected]

Abstract-This paper describes a complete


z Taken an integers e which coprime with
set of practical solution to file encryption based
(p-1) × (q-1)
on RSA algorithm. With analysis of the present
z Solution of the variant d by the equation
situation of the application of RSA algorithm, we
d×e=1 (mod (p-1)×(q-1))
find the feasibility of using it for file encryption.
z Tuple (e, n) as a public key
On basis of the conventional RSA algorithm, we
z Tuple (d, n) as the private key
use C + + Class Library to develop RSA
z < Encryption and decryption >
encryption algorithm Class Library, and realize
e
Groupware encapsulation with 32-bit windows z b=a mod n ˈ a=bd mod n. ˄ A is
platform. With reference of this Groupware on
expressly, b is cipher text˅
Net platform, you can realize the window
RSA technology has formed a relatively
application of encryption operation on any files
complete international norm in all aspects of
with RSA algorithm.
electronic security field. On the hardware side, it is
Keywords- RSA algorithm; file encryption used in a variety of sophisticated consumer
and decryption;Portable Components electronics products with the mature IC technology.
In terms of software applications, mainly in the
I. INTRODUCTION
Internet, RSA is widely used in encrypted
RSA public key encryption algorithm is connection, digital signatures and digital
developed by Ron rivest, Adishamir and certificates core algorithms.
Leonard adleman in 1977, is the most influential
public-key encryption algorithm, and has been II. PROJECT DESIGN
recommended for ISO public key data encryption After detailed needs analysis, software
standard. RSA algorithm is an asymmetric requirements can be summarized as follows:
cryptographic algorithm, the asymmetric, meaning z Can generate the asymmetric keys with
that the algorithm requires a key pair, use one of required digits
the encryption, you need to be decrypted with z You can save and load the key, the key
another. is saved as plain text
RSA algorithm can be simply described as z Can use specified key to encrypt any file
follows˖ with RSA algorithm, encrypted data
z <Generate keys > generated as plain text
z Take the prime number p,q, make z Encrypted files can be loaded and
n=p×q decrypted with the specified key to
restore the original file

978-0-7695-4501-1/11 $26.00 © 2011 IEEE 797


DOI 10.1109/ICCIS.2011.150
z Message integrity, ease of operation, the B. Montgomery modulus algorithm
graphical interface decency Exponentiation modulus operation is the

III. THE SPECIFIC DESIGN largest proportion of RSA algorithm; it most


directly determines the RSA arithmetic
As the design process involves many classes
performance. In the code of this software, we
and programs, so the following list only a few key
directly scan vlong binary By-bits canning.
technical designs, the specific encryption and
To improve the speed of exponentiation
decryption processes are all standard RSA
modulus operation, the key is to improve the speed
algorithm, so it is skipped to mention.
of modular multiplication. This software is the
A. Storage of large number and arithmetic application of Montgomery algorithm.
operation Select a cardinal number R=2k which coprime
Large number storage is provided by the with modulus n, variable n satisfy 2k-1n<2k,
Flex_unit Class. Large numbers are stored in a variable n should be odd number.Select R-1 and n’,
linear group with unit named as Unsigned. In the Satisfy 0<R-1 <n, 0 <n '<n, making the RR-1-nn' =
method Void Reserve (unsigned x) by the C++ to 1. For 0  m <Rn for any integer, Montgomery
give a new open space for pointer variable a, When multiplication is given modulo mR-1 mod n Fast
Flex_unit instance is stored in a larger number than Algorithm M (m):
the current stored one, they will call the reserve to M (m)
increase storage space, but when Flex_unit {
instance is stored in a smaller number than the λ = (m mod R)n' mod R;0 ≤ λ ≤ R
current stored one, storage does not automatically
t = ( m + λ n) / R
tighten to improve the efficiency of computing.
With pointer variable a, there are two important if (tn) return (t-n);
unsigned integer to control the storage, which is else return t;
unsigned variable z and unsigned variable n. }
Variable z is the number of units assigned space,
Because λn ≡ mnn' ≡ − m mod R ˈ so
with the increasing number of larger, not their
crunch, and variable n is the share of large variable t is integer, At the same time
numbers currently stored in the number of units,
tR ≡ m mod n ,so t ≡ mR −1 mod n DŽ And
each composed of a large numbers of Unsigned
and read into the unit from the Set method, Get because 0 ≤ m + λn ≤ Rn + Rn ˈ variable t
method to complete, the variable n is read-only. results in the range 0  t <2n, return if variable t is
Based on the Flex_unit Class storage not less than variable n, should return t-nDŽ
capabilities, we may have new class of In this program, RSA's core operations by
Vlong_value, implement arithmetic functions, and using the modulus multiplication algorithm is
to achieve the cast operator unsigned, to facilitate M (A * B). Although M (A * B) is not really
the large number of each type and ordinary integer needed by the results of modulus multiplication,
assignment. When large number is cast to but as long as the power mode algorithm to be
Unsigned, it will be the lowest four-byte value. modified accordingly, you can call this modulus
multiplication algorithm to calculate.

798
Use above modulus multiplication algorithm constructs an array b [ ], size is a prime number
by combining the above described power modulus search range, the size of search range is minded
algorithm, it can constitute a standard power
variable SS. Array b [0] to b [SS] correspond to
module Montgomery algorithm, which is the
software used by the process described below: the large number Start to Start + SS. First of all

M(m) elements of b[ ] initialized to 1, corresponding to


{ the large number to determine if a composite
k = ( m * n’ ) mod R;
number, the corresponding element of b [] is set to
x = (m + k*n ) / R;
if (x>=n) x -= n; 0. Finally, only need to do the exact prime number

return x; test for those large number which elements with b


} [ ] is corresponding to value 1. As long as the
Exp(C,E,n)
number being tested is a prime number reaches a
{
D=R-n; certain threshold, this number is on the sub-prime.

P=C*R mod n; This not only ensures the implementation of this


i=0; program can be completed in a short time, and that
while(true)
makes it possible to obtain relatively high accuracy
{
if(Ei==1)D=M(D*P);// Ei is the prime number.

current binary bit of E Next, the number of possible prime number


i+=1; (tag array b [] in the value of 1 corresponds to the
If (i== binary digits of E) number of elements) for prime testing.
break; The software application of Fermat's little
 P=M(P*P); theorem directly, take integer variable A which
  } relatively prime with variable p, is for a large
  return D*R-1 (mod n); prime p should satisfy the AP-1mod p = 1, we put
} the large prime p into a large integer, the number

We can use the Mul method and Exp method does meet this relationship may not be a prime
number. Then we change variable A, for several
of class of Monty in the practical realization. The
tests, if several tests are passed, the probability that
global function Modexp can initialize the object of this number is prime number is relatively large. By
Monty and call it’s exp method, we can directly this principle, we write the following test functions

call Modexp when operation. of prime numbers.


Int is_probable_prime_san ( const vlong &p )
C. Eratosthenes to find primes and Fermat {
primes screening test const rep = 4; //Testing times
Screening integers in the range of integer const unsigned any[rep] = { 2,3,5,7 };
for ( unsigned i=0; i<rep; i+=1 )
filter to find prime numbers, with all known to be a
if(modexp(any[i], p-vlong(1), p ) != vlong(1) )
composite number of integer excluded. Program
return 0;

799
return 1; and text files under the environment which
} demand a high security, such as in public forums.
If testing passed, the number is a prime
REFERENCES
number and will pass to previous program to use.
And here may be also another problem which can’t [1] Montgomery PL, Modular multiplication
be neglected, it is to get a composite number which without trialdivision[J], Mathematics of
can pass this test. In this case, it is to validate it Computation, 1985
from mathematical point of view that if RSA [2] Oh JH,Moon S J, Modular multiplication
encryption can be realized or not. After get a large method˷J˹, IEE Proceedings˖Computers and
prime number, that is parameter p and q in the Digital Tech-niques, 1998
RSA algorithm, we can calculate the key, also the [3] Shi Xiangdong, Dong Ping, a new core
encryption operation. design based on the RSA encryption algorithm,
micro-computer information, period 2005 12-3
CONCLUSION [4] [AX931] ANSI X9.31-1998 Digital
RSA algorithm encryption used in file Signatures using Reversible Public Key
encryption for small files, any file with asymmetric Cryptography for the Financial Services Industry
key encryption into its text can be more convenient (rDSA), Appendix A, American National
to communicate and manage, and it has broad Standards Institute, 1998ˊ
development prospects. The project application [5] [COCK73] Clifford Cocks, A Note on
was designed to take the efficiency and reusability 'Non-Secret Encryption', CESG Research Reportˈ
into account. The whole project opens source code 20 November 1973
and a variety of development information; it is [6] [KALI93] Burton Kalinski, Some
convenient for the reference and continuous Examples of the PKCS Standards, RSA
development. Application of this procedure can Laboratories, November 1993
easily communicate data including arbitrary binary

800

You might also like