C++ Program two functions seal/open that encrypt/decrypt data using Hybrid Encryption.

Kapalı İlan edilme: 9 ay önce Teslim sırasında ödenir
Kapalı Teslim sırasında ödenir

Function seal:

Declaration:

bool seal(const char * inFile, const char * outFile, const char * publicKeyFile, const char * symmetricCipher)

Description:

The function accepts four parameters, the first three parameters define the names of files. In the file inFile, you will find binary data intended for encryption, outFile is the output file where you save all the necessary data for decryption, and publicKeyFile is the public key that will be used to encrypt the symmetric key. The parameter symmetricCipher is the name of the symmetric cipher.

The function generates a symmetric (shared) key and an initialization vector (IV), which will be the input to the symmetric cipher symmetricCipher. You will encrypt the data in inFile with this cipher, key, and IV. Also, you encrypt the symmetric key with an asymmetric cipher (RSA) using the public key stored in publicKeyFile.

OpenSSL does most of the work for you:

PEM_read_PUBKEY reads the public key,

EVP_SealInit generates a shared key and IV (if necessary), encrypts the shared key, and sets the context,

EVP_SealUpdate and EVP_SealFinal work the same as in previous tasks.

Hybrid encryption is able to encrypt for multiple recipients. The data is encrypted only once with a shared key and IV, but the shared key can be encrypted with multiple public keys. Therefore, the function accepts an array of public keys.

Output file format:

The output file will have the following structure:

position in file length structure description

0 4 B int NID - A numerical identifier for an OpenSSL cipher. (used symmetric cipher)

4 4 B int EKlen - length of the encrypted key

8 EKlen B unsigned char array Encrypted key using RSA

8 + EKlen IVlen B unsigned char array Initialization vector (if needed)

8 + EKlen + IVlen --- unsigned char array Encrypted data

Expected function behavior:

Returns true in case of success, false otherwise.

In case the function returns false, the output file will not exist.

Function open:

Declaration:

bool open(const char * inFile, const char * outFile, const char * privateKeyFile )

Description:

In the file inFile, you will find an encrypted file in the same format as the output file from the seal function. Write the decrypted data to the output file outFile - binary identity with the input file to the seal function is expected. This time, the private key for decrypting the encrypted key can be found in privateKeyFile. The functions PEM_read_PrivateKey, EVP_OpenInit, EVP_OpenUpdate, and EVP_OpenFinal will play a key role in this function.

Sample data contents

[login to view URL] - public key (try to open it as a txt file),

[login to view URL] - private key,

[login to view URL] - file with declarations and a basic test,

[login to view URL] - encrypted file. You can use it to test decryption. It was encrypted using the attached private key. After decryption, you will find ASCII text in it. If you encrypt the same data, the file will not be the same as [login to view URL] - a different key and IV were used.

Final advice

There are many places in this task where functions may return an error. Check and consider automatically releasing resources using unique_ptr (applies to context, key, allocated arrays, and file closing).

The length of the encrypted key depends on the public key. You cannot count on a fixed length.

When compiling, do not forget to link the OpenSSL crypto library using -lcrypto.

The OpenSSL version on progtest is 1.1.1n.

All "notes" from the previous task apply.

C++ Programlama Yazılım Mimarisi Bilgisayar Güvenliği

Proje NO: #36522965

Proje hakkında

5 teklif Uzak proje Aktif 8 ay önce

Bu iş için 5 freelancer ortalamada $37 teklif veriyor

aravinda333

Hi, I have great experience in implementing cryptographic algorithms both public and private from scratch as well as using the OpenSSL libraries, the core APIs as well as EVP functions in C or C++. I have clearly Daha Fazla

$50 USD in 2 gün içinde
(55 Değerlendirme)
5.5
haciyevnicatdev

Hello Client! I am a senior expert with 10+ years of strong experience in C/C++ Programming and Cryptography. If you hire me, I will perfectly complete two functions seal/open that encrypt/decrypt data using hybrid enc Daha Fazla

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(1 Yorum)
1.0
kumaraayush33

******⭐⭐COMPETITVE PROGRAMMER ⭐⭐********* Hi. Very happy to bid your project because my skills are fitted in your project .I am a expert in C/C++, C#, Python, OOP, Java and have rich experiences for over 5 years. I can Daha Fazla

$30 USD in 7 gün içinde
(0 Değerlendirme)
0.0
Edindev

I am familiar with your topic. Kindly allow me to start working on it. I GUARANTEE you high quality, detailed, self-tailored paper to your specifications and within the stipulated time frame

$46 USD in 3 gün içinde
(0 Değerlendirme)
0.0
rpi5691949a84c8b

I'm a very experienced c/c++ developer. I think that I Will be able to solve your problem realy fast

$30 USD in 5 gün içinde
(0 Değerlendirme)
0.0