diff --git a/client.cpp b/client.cpp index 35a1050..d9fc88f 100644 --- a/client.cpp +++ b/client.cpp @@ -18,46 +18,6 @@ #include "helper.h" -// block cipher encryption function -int block_encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, unsigned char *iv, unsigned char *ciphertext) -{ - /* Declare cipher context */ - EVP_CIPHER_CTX *ctx; - - int len, ciphertext_len; - - /* Create and initialise the context */ - ctx = EVP_CIPHER_CTX_new(); - if (!ctx) - { - ERR_print_errors_fp(stderr); - } - - /* Initialise the encryption operation. */ - // choice for aes_256 ref: https://stackoverflow.com/questions/1220751/how-to-choose-an-aes-encryption-mode-cbc-ecb-ctr-ocb-cfb - if (EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv) != 1) - { - ERR_print_errors_fp(stderr); - } - - /* Provide the message to be encrypted, and obtain the encrypted output. EVP_EncryptUpdate can be called multiple times if necessary */ - if (EVP_EncryptUpdate(ctx, ciphertext, &len, plaintext, plaintext_len) != 1) - { - ERR_print_errors_fp(stderr); - } - - /* Finalize the encryption. Further cipher text bytes may be written at this stage. */ - if (EVP_EncryptFinal_ex(ctx, ciphertext + len, &ciphertext_len) != 1) - { - ERR_print_errors_fp(stderr); - } - - /* Clean up */ - EVP_CIPHER_CTX_free(ctx); - - return ciphertext_len + len; -} - int main(void) { load_env(".env"); diff --git a/latex/H3_CSE4303_ZheyuanWu.pdf b/latex/H3_CSE4303_ZheyuanWu.pdf index 420d004..8e84fb7 100644 Binary files a/latex/H3_CSE4303_ZheyuanWu.pdf and b/latex/H3_CSE4303_ZheyuanWu.pdf differ diff --git a/latex/H3_CSE4303_ZheyuanWu.tex b/latex/H3_CSE4303_ZheyuanWu.tex index c5709a7..7a11434 100644 --- a/latex/H3_CSE4303_ZheyuanWu.tex +++ b/latex/H3_CSE4303_ZheyuanWu.tex @@ -489,46 +489,6 @@ int main(void) #include "helper.h" -// block cipher encryption function -int block_encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, unsigned char *iv, unsigned char *ciphertext) -{ - /* Declare cipher context */ - EVP_CIPHER_CTX *ctx; - - int len, ciphertext_len; - - /* Create and initialise the context */ - ctx = EVP_CIPHER_CTX_new(); - if (!ctx) - { - ERR_print_errors_fp(stderr); - } - - /* Initialise the encryption operation. */ - // choice for aes_256 ref: https://stackoverflow.com/questions/1220751/how-to-choose-an-aes-encryption-mode-cbc-ecb-ctr-ocb-cfb - if (EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv) != 1) - { - ERR_print_errors_fp(stderr); - } - - /* Provide the message to be encrypted, and obtain the encrypted output. EVP_EncryptUpdate can be called multiple times if necessary */ - if (EVP_EncryptUpdate(ctx, ciphertext, &len, plaintext, plaintext_len) != 1) - { - ERR_print_errors_fp(stderr); - } - - /* Finalize the encryption. Further cipher text bytes may be written at this stage. */ - if (EVP_EncryptFinal_ex(ctx, ciphertext + len, &ciphertext_len) != 1) - { - ERR_print_errors_fp(stderr); - } - - /* Clean up */ - EVP_CIPHER_CTX_free(ctx); - - return ciphertext_len + len; -} - int main(void) { load_env(".env");