Comprehensive Report on Open Source Cryptographic Libraries and Usage

Verified

Added on  2023/06/03

|10
|1454
|163
Report
AI Summary
This report provides a comprehensive overview of several open-source cryptographic libraries available in different programming languages, including C (OpenSSL), C++ (Crypto++), Java (crypto), and Python (Pycrypto). It identifies each library and provides links to their respective documentation pages. The report details the necessary supporting libraries required for each, along with examples of functions for key generation, hash functions, block ciphers, and stream ciphers. Short documentation and code snippets are included to illustrate the usage of key functions within each library, offering practical insights into implementing cryptographic operations in various programming environments.
Document Page
Running head: CRYPTOGRAPHIC LIBRARIES
Cryptographic libraries
Name of the Student
Name of the University
Authors note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1CRYPTOGRAPHIC LIBRARIES
Identification and name of the open source cryptographic library
C: OpenSSL is one of the wide spread cryptographic libraries in C language. The
link to the library doc page is provided below;
https://www.openssl.org/
C++: In C++, one of the best open source cryptographic libraries is Crypto++. The
web link to the library page is provide below;
https://www.cryptopp.com/
JAVA: In java, an open source cryptographic library is “crypto” for developing the
cryptographic functions. Concerned link to the library is given by
https://docs.oracle.com/javase/7/docs/api/javax/crypto/package-summary.html
Python: One of the widely used cryptographic library in python is “Pycrypto”. Link
to the documentation is given below;
https://pypi.org/project/pycrypto/
list and explain all requirements for using the libraries
In order to use openSSL the following supported libraries are required, #include
<sys/socket.h>
#include <resolv.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
Document Page
2CRYPTOGRAPHIC LIBRARIES
#include <string.h>
For crypto++, the required support libraries are listed below;
#include <cstdio>
#include <iostream>
#include <osrng.h>
For java, in order to use crypto, the required supporting libraries are
Javax.*;
java.io.*;
java.security.*;
java.util.Arrays;
java. util. Base64;
for pycrypto; as this python library is bundled with the different other libraries the
only library that needs to be imported is “OS” library which provides the easy of interaction
with the different functions using the CPU.
Function for different categories
For pycrypto;
Key Generation: Crypto.PublicKey.RSA.generate().
Hash Functions: SHA256.new()
Block Ciphers: DES.new()
Stream Ciphers: ARC4()
Document Page
3CRYPTOGRAPHIC LIBRARIES
For C (OpenSSL);
Key Generation: openssl_pkey_new() This function generates a pair of new public
and private key.
Hash Functions: SHA256(ibuf, strlen(ibuf), obuf);
Block Ciphers: EVP_add_cipher()
Stream Ciphers: RC4_set_key();
For Crypto++;
Key Generation: LUCDIF(), XTR-DH ()s
Hash Functions: RIPEMD-320(), WHIRLPOOL ()
Block Ciphers: ECB (), CBC ()
Stream Ciphers: Panama (),
For crypto (Java);
Key Generation: keyGenerator.generateKey();
Hash Functions: MessageDigest.getInstance()
Block Ciphers : Cipher.getInstance("AES");
Stream Ciphers: CipherInputStream(),
Short documentation for every library
For Pycrypto();
Crypto.PublicKey.RSA.generate():
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4CRYPTOGRAPHIC LIBRARIES
keygen = RSA.generate(512, random_generator) # specifying the key in bits: here 512
bits
keygen
<RSAobj @0x7d12cf1b57e8 n(512),e,d,p,q,u,private>
SHA256.new()
Following is the depiction of the mentioned method;
from Crypto.Hash import SHA256
>>> SHA256.new('cde').hexdigest()
# in the above line the new(), contains the test to be hashed using the SHA256
algorithm
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
# the above is the hash value of cde.
DES.new()
del = DES.new('012345', DES.MODE_ECB)
tex = 'abcdef'
>>> cipherv = del.encrypt(tex)
>>> cipherv
'\xec\xc2\x9e\xd9] a\xd0'
# Output cipher value of ‘abcdef’
Document Page
5CRYPTOGRAPHIC LIBRARIES
ARC4()
obj = ARC4.new('01234') # this is the key to use getting the cipher value.
te = 'abcdefghi'
ciphered = obj.encrypt(te)
ciphered
'\xf0\xb7\x90{#ABXY9\xd06\x9f\xc0\x8c ' #Output value
For Crypto
Key Generation: keyGenerator.generateKey();
Using the KeyGenerator instance it needs to be initialized. Following is the example
of initializing a KeyGenerator to get a key using bit size of 256 bits:
SecureRandom secureRandom = new SecureRandom();
int keyBitSize = 256;
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
cipher.init(cipher.ENCRYPT_MODE, key);
String msg = new String(" how are you");
byte[] bytes = cipher.doFinal(msg.getBytes());
output: [B@2ac1fdc4
Hash Functions: MessageDigest.getInstance()
essageDigest md = MessageDigest.getInstance("SHA-256");
md.update(message.getBytes());
Document Page
6CRYPTOGRAPHIC LIBRARIES
System.out.println(digest);
byte[] digest = md.digest();
//changing to HexString
StringBuffer hexString = new StringBuffer();
for (int i = 0;i<digest.length;i++) { g
hexString.append(Integer.toHexString(0xFF & digest[i]));
Block Ciphers : Cipher.getInstance("AES");
public BlockCipher(int BlockLength,
int KeyLength)
Stream Ciphers: CipheroutStream()
keysa = keyGenerator.generateKey();
ciphertext = Cipher.getInstance();
cipher.init(Cipher.ENCRYPT_MODE, key);
try (OutputStream outputStream = new BufferedOutputStream(
new CipherOutputStream(new FileOutputStream(file), cipher))) {
for (int i = 0; i < 20; i++) {
outputStream.write(new String("New cipher text\n").getBytes());
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7CRYPTOGRAPHIC LIBRARIES
For Crypto++
Key Generation: LUCDIF(), XTR-DH () important in Generation of private and
public for encryption and decryption. The function has the following signature;
XTR_DH (const Integer &p, const Integer &q, const GFP2Element &g)
Hash Functions: WHIRLPOOL () in order to get the hash function for conversion
of the provided text.
Block Ciphers: ECB ();
cout << "Enter text to cipher: " << text << endl;
ECB_Mode< AES >::Encryption e;
e.SetKey( key, key.size() );
StringSource ss1( plain, true,
new StreamTransformationFilter( e,
new StringSink( cipher ) ) );
Stream Ciphers: Panama ()This function is helpful in generating hash function
and stream cipher while using this library. Example is given below;
#include "secblock.h"
#include "panama.h"
#include "files.h"
#include "hex.h"
#include "osrng.h"
Document Page
8CRYPTOGRAPHIC LIBRARIES
cipher.resize(text.size());
enc.ProcessData((byte*)&cipher[0], (const byte*)text.data(), text.size());
std::cout << "user provided text: " << text
std::cout << "Cipher converted text: ";
encoder.Put((const byte*)ciphered.data(), ciphered.size());
encoder.MessageEnd();
std::cout << std::endl;
PanamaCipher<LittleEndian>::Decryption dec;
OpenSSL:
Key Generation: openssl_pkey_new() This function generates a pair of new public
and private key.
Code segment:
resd = openssl_pkey_new();
openssl_pkey_export(resd, priv_key);
pub_key = openssl_pkey_get_details(res);
publ_key = publ_key['key']
Hash Functions: SHA256(ibuf, strlen(ibuf), obuf);
std::string src_str = "The box is full of candies";
Document Page
9CRYPTOGRAPHIC LIBRARIES
std::vector<unsigned char> hash(picosha2::k_digest_size);
picosha2::hash256(src_str.begin(), src_str.end(), hash.begin(), hash.end());
std::string hex_str = picosha2::bytes_to_hex_string(hash.begin(), hash.end());
Block Ciphers: EVP_add_cipher() fi
EVP_add_cipher(EVP_des_cbc());
Stream Ciphers: RC4_set_key ();
RC4_KEY key;
int i;
memset(bufPlaintxt,0,BUF_SIZE);
memset(bufCiphertxt,0,BUF_SIZE);
strncpy ((char *)bufPlain ,
" secret text", BUF_SIZE);
RC4_set_key(&key, strlen((char *)key_pass) ,key_pass);
RC4(&key, BUF_SIZE,(unsigned char *) bufPlaintxt, (unsigned char
*)bufCipher);
chevron_up_icon
1 out of 10
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]