Cryptography Libraries: OpenSSL, Crypto++, Java Crypto, Pycrypto
VerifiedAdded on 2023/05/30
|4
|887
|267
Homework Assignment
AI Summary
This assignment provides an investigation into several cryptographic libraries, including OpenSSL (C), Crypto++ (C++), Java Crypto (Java), and Pycrypto (Python). For each library, the assignment identifies the necessary requirements for usage, such as header files or package imports. It then names and documents functions for key generation, hash functions, block ciphers, and stream ciphers, describing their purpose, input variables, and expected output. The documentation includes specifics on initializing contexts, generating keys, creating digests, and performing encryption using different algorithms and modes. The analysis covers the functionalities and usage of these libraries in their respective programming languages.

INVESTIGATING CRYPTOGRAPHIC
LIBRARIES
1. Open – source cryptographic library:
a) C openSSL
Documentation Link: https://www.openssl.org/docs/
b) C++ crypto++
Documentation Link: https://www.cryptopp.com/docs/ref/
c) Java crpto
Documentation Link:
https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/
CryptoSpec.html
d) Python pycrypto
Documentation Link: https://pypi.org/project/pycrypto/
2. Requirements:
a) OpenSSL: There are several header files in openSSL for C programming
language. Every header file have its own purpose and implementation. However, 3
of the major header files along with the initialize functions required for it are
mentioned below:
# include "openssl/bio.h"
# include "openssl/ssl.h"
# include "openssl/err.h"
SSL_load_error_strings();
ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
b) Crypto++: To use crypto++ in C++. We need to include cryptlib.h file. There are
several other header files as well which perform a specific functions for crypto++.
All the other classes in header files are derived from the classes mentioned in the
crptyolib.h.
# include "cryptlib.h"
c) crypto: In java, we need to import the package javax.crypto.* before using any
Cipher methods. If we want to use any specific method only instead of using all of
them, we can mention the specified package instead of * in the import package.
Example - import javax.crypto.Cipher;
d) pycrypto: To use cryptography in Python, we need import crypto module before
using any of the methods.
Example: from Crypto.Hash import SHA256
LIBRARIES
1. Open – source cryptographic library:
a) C openSSL
Documentation Link: https://www.openssl.org/docs/
b) C++ crypto++
Documentation Link: https://www.cryptopp.com/docs/ref/
c) Java crpto
Documentation Link:
https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/
CryptoSpec.html
d) Python pycrypto
Documentation Link: https://pypi.org/project/pycrypto/
2. Requirements:
a) OpenSSL: There are several header files in openSSL for C programming
language. Every header file have its own purpose and implementation. However, 3
of the major header files along with the initialize functions required for it are
mentioned below:
# include "openssl/bio.h"
# include "openssl/ssl.h"
# include "openssl/err.h"
SSL_load_error_strings();
ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
b) Crypto++: To use crypto++ in C++. We need to include cryptlib.h file. There are
several other header files as well which perform a specific functions for crypto++.
All the other classes in header files are derived from the classes mentioned in the
crptyolib.h.
# include "cryptlib.h"
c) crypto: In java, we need to import the package javax.crypto.* before using any
Cipher methods. If we want to use any specific method only instead of using all of
them, we can mention the specified package instead of * in the import package.
Example - import javax.crypto.Cipher;
d) pycrypto: To use cryptography in Python, we need import crypto module before
using any of the methods.
Example: from Crypto.Hash import SHA256
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

3. Functions:
C C++
KeyGeneration #include <openssl/rsa.h>
EVP_PKEY_keygen_init(ctx)
EVP_PKEY_keygen(ctx,
&pkey)
XTR-
DH()
Hash
Functions
#include <openssl/evp.h>
EVP_MD_CTX_create()
RIPEMD-
320()
Block Ciphers #include <openssl/des.h>
DES_ecb_encrypt()
ECB ()
Stream
Ciphers
#include <openssl/rc4.h>
RC4_set_key()
Panama()
Java Python
KeyGeneration keyGenerator = KeyGenerator.getInstance("AES");
keyGenerator.init(keyBitSize, new SecureRandom());
keyGenerator.generateKey()
from Crypto.PublicKey
import RSA
from Crypto import
Random
key =
RSA.generate(1024,
Random.new().read)
Hash
Functions
digest = MessageDigest.getInstance("SHA-256");
digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
from Crypto.Hash
import SHA256
SHA256.new(message)
Block Ciphers cipher = Cipher.getInstance(“AES/GCM/NoPadding”); from Crypto.Cipher
import DES
des =
DES.new('01234567',
DES.MODE_ECB)
Stream
Ciphers
cipher = Cipher.getInstance(“DES”); from Crypto.Cipher
import ARC4
obj1 =
ARC4.new('01234567')
4. Documentation
C Description
KeyGeneration #include <openssl/rsa.h>
EVP_PKEY_keygen_init(ctx)
EVP_PKEY_keygen(ctx,
&pkey)
EVP_PKEY_keygen_init()
is to initialize a public key
algorithm context.
EVP_PKEY_keygen()
generates a public key and
the key is written to pkey
C C++
KeyGeneration #include <openssl/rsa.h>
EVP_PKEY_keygen_init(ctx)
EVP_PKEY_keygen(ctx,
&pkey)
XTR-
DH()
Hash
Functions
#include <openssl/evp.h>
EVP_MD_CTX_create()
RIPEMD-
320()
Block Ciphers #include <openssl/des.h>
DES_ecb_encrypt()
ECB ()
Stream
Ciphers
#include <openssl/rc4.h>
RC4_set_key()
Panama()
Java Python
KeyGeneration keyGenerator = KeyGenerator.getInstance("AES");
keyGenerator.init(keyBitSize, new SecureRandom());
keyGenerator.generateKey()
from Crypto.PublicKey
import RSA
from Crypto import
Random
key =
RSA.generate(1024,
Random.new().read)
Hash
Functions
digest = MessageDigest.getInstance("SHA-256");
digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
from Crypto.Hash
import SHA256
SHA256.new(message)
Block Ciphers cipher = Cipher.getInstance(“AES/GCM/NoPadding”); from Crypto.Cipher
import DES
des =
DES.new('01234567',
DES.MODE_ECB)
Stream
Ciphers
cipher = Cipher.getInstance(“DES”); from Crypto.Cipher
import ARC4
obj1 =
ARC4.new('01234567')
4. Documentation
C Description
KeyGeneration #include <openssl/rsa.h>
EVP_PKEY_keygen_init(ctx)
EVP_PKEY_keygen(ctx,
&pkey)
EVP_PKEY_keygen_init()
is to initialize a public key
algorithm context.
EVP_PKEY_keygen()
generates a public key and
the key is written to pkey

which is passed as
parameter.
Hash
Functions
#include <openssl/evp.h>
EVP_MD_CTX_init()
EVP_MD_CTX_create()
EVP_MD_CTX_init()
initializes digest context
and
EVP_MD_CTX_create()
returns the digest context
Block Ciphers #include <openssl/des.h>
DES_ecb_encrypt()
DES_ecb_encrypt()
encrypts a single 8-byte
block.
Stream
Ciphers
#include <openssl/rc4.h>
RC4_set_key()
sets up key using the
specified bytes long key at
data
C++ Description
KeyGeneration XTR-DH() XTR-DH() generates private
or public keys for encryption.
Hash
Functions
RIPEMD-320() RIPEMD-320() generates a
hash value for the message
passed as parameter and
returns the hash value
Block Ciphers ECB () It encrypts the block of text
passed as parameter.
Stream
Ciphers
Panama() Panama uses 256 bit key for
the encryption using stream
cipher
Java Description
KeyGeneration keyGenerator = KeyGenerator.getInstance("AES");
keyGenerator.init(keyBitSize, new SecureRandom());
keyGenerator.generateKey()
keyGenerator.init initializes the
algorithm to generate keys.
keyGenerator.generateKey
generates and returns the key
Hash
Functions
digest = MessageDigest.getInstance("SHA-256");
digest.digest(originalString.getBytes(StandardCharsets
.UTF_8));
MessageDigest.getInstance
creates a digest for the
parameter and digest.digest
provides a hash value for the
message.
Block Ciphers cipher = Cipher.getInstance(“AES/GCM/NoPadding”); Cipher.getInstance provides an
instance for AES algorithm for
block cipher and further
methods can be used
accordingly.
Stream
Ciphers
cipher = Cipher.getInstance(“DES”); Cipher.getInstance provides an
instance for DES algorithm for
block cipher and further
methods can be used
accordingly
parameter.
Hash
Functions
#include <openssl/evp.h>
EVP_MD_CTX_init()
EVP_MD_CTX_create()
EVP_MD_CTX_init()
initializes digest context
and
EVP_MD_CTX_create()
returns the digest context
Block Ciphers #include <openssl/des.h>
DES_ecb_encrypt()
DES_ecb_encrypt()
encrypts a single 8-byte
block.
Stream
Ciphers
#include <openssl/rc4.h>
RC4_set_key()
sets up key using the
specified bytes long key at
data
C++ Description
KeyGeneration XTR-DH() XTR-DH() generates private
or public keys for encryption.
Hash
Functions
RIPEMD-320() RIPEMD-320() generates a
hash value for the message
passed as parameter and
returns the hash value
Block Ciphers ECB () It encrypts the block of text
passed as parameter.
Stream
Ciphers
Panama() Panama uses 256 bit key for
the encryption using stream
cipher
Java Description
KeyGeneration keyGenerator = KeyGenerator.getInstance("AES");
keyGenerator.init(keyBitSize, new SecureRandom());
keyGenerator.generateKey()
keyGenerator.init initializes the
algorithm to generate keys.
keyGenerator.generateKey
generates and returns the key
Hash
Functions
digest = MessageDigest.getInstance("SHA-256");
digest.digest(originalString.getBytes(StandardCharsets
.UTF_8));
MessageDigest.getInstance
creates a digest for the
parameter and digest.digest
provides a hash value for the
message.
Block Ciphers cipher = Cipher.getInstance(“AES/GCM/NoPadding”); Cipher.getInstance provides an
instance for AES algorithm for
block cipher and further
methods can be used
accordingly.
Stream
Ciphers
cipher = Cipher.getInstance(“DES”); Cipher.getInstance provides an
instance for DES algorithm for
block cipher and further
methods can be used
accordingly
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

Python Description
KeyGeneration from Crypto.PublicKey
import RSA
from Crypto import
Random
key =
RSA.generate(1024,
Random.new().read)
RSA.generate generates a
random key of 1024 bits
long and returns
Hash
Functions
from Crypto.Hash import
SHA256
SHA256.new(message)
SHA256.new takes a
parameter message and
returns a hash value for
the message
Block Ciphers from Crypto.Cipher
import DES
des =
DES.new('01234567',
DES.MODE_ECB)
DES.new generates a
cihper text for the
message passed using
ECB mode
Stream
Ciphers
from Crypto.Cipher
import ARC4
obj1 =
ARC4.new('01234567')
ARC4.new generates a
cipher text for the
message using stream
cipher
KeyGeneration from Crypto.PublicKey
import RSA
from Crypto import
Random
key =
RSA.generate(1024,
Random.new().read)
RSA.generate generates a
random key of 1024 bits
long and returns
Hash
Functions
from Crypto.Hash import
SHA256
SHA256.new(message)
SHA256.new takes a
parameter message and
returns a hash value for
the message
Block Ciphers from Crypto.Cipher
import DES
des =
DES.new('01234567',
DES.MODE_ECB)
DES.new generates a
cihper text for the
message passed using
ECB mode
Stream
Ciphers
from Crypto.Cipher
import ARC4
obj1 =
ARC4.new('01234567')
ARC4.new generates a
cipher text for the
message using stream
cipher
1 out of 4
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.
