Professional Documents
Culture Documents
We will give a brief description of the merely built in functions you are
allowed to use.
You can find information on most of the built in functions we are using in the
sample source codes at http://www.openssl.org/docs/crypto/crypto.html
- des_encrypt1
You will use a built in function called des_encrypt1 to do the actual DES
encryption / decryption.
As a reference on how to use this function, you can view the file tempdes.c.
- des_set_key_checked
This function will check that the key passed is of odd parity and is not a week or
semi-weak key. If
the parity is wrong, then -1 is returned. If the key is a weak key, then -2 is
returned. If an error
is returned, the key schedule is not generated.
NOTE: On the Openssl web page, you might notice that the DES built in functions are
written different
than what we are showing here. For example, "des_encrypt1" is written as
"DES_encrypt1" on the web page.
This is because the server where we will test your code has an older Openssl
version installed, so it
does not accept the new format. Please keep using the format we are presenting
here.
- RSA_generate_key
This function will generate the public and private keys
- RSA_public_encrypt
This function will encrypt data using an RSA public key
RSA_public_encrypt(int flen, unsigned char *from, unsigned char *to, RSA *rsa, int
padding)
a. flen: number of bytes to encrypt
b. from: buffer with data to encrypt
c. to: buffer with data to decrypt
d. rsa: pointer to the key data structure
e. padding: Don't worry about this argument. Assign the following value to
it: RSA_PKCS1_PADDING
- RSA_private_decrypt
This function will decrypt data using an RSA private key
RSA_private_decrypt(int flen, unsigned char *from, unsigned char *to, RSA *rsa, int
padding)
a. flen: number of bytes to encrypt
b. from: buffer with data to encrypt
c. to: buffer with data to decrypt
d. rsa: pointer to the key data structure
e. padding: Don't worry about this argument. Assign the following value to
it: RSA_PKCS1_PADDING
- Sha1_Init
This function will initialize some data structures necessary for the generation of
the digest
Sha1_Init(SHA_CTX *c)
a. c: initialize the SHA_CTX structure
- Sha1_Update
This function will be called repeatedly using a block of certain size that have
been read from the input file,
to generate the digest
- Sha1_Final
This function will copy the resultant digest to an output buffer and will release
any memory space used for the
data structures created with SHA1_Init