WIP: almost there

This commit is contained in:
Max Lv
2013-05-23 13:54:39 +08:00
parent 2d4940d3a2
commit 2f175d7028
5 changed files with 91 additions and 57 deletions
+8 -4
View File
@@ -16,7 +16,7 @@
#include <inttypes.h>
#endif
#define BUF_SIZE 4096
#define BUF_SIZE 512
#define BLOCK_SIZE 32
#define NONE -1
@@ -29,14 +29,18 @@
#define CAST5_CFB 6
#define DES_CFB 7
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
struct enc_ctx {
int method;
uint8_t key[EVP_MAX_KEY_LENGTH];
uint8_t iv[EVP_MAX_IV_LENGTH];
EVP_CIPHER_CTX *evp;
EVP_CIPHER_CTX evp;
};
char* encrypt(char *plaintext, int *len, struct enc_ctx *ctx);
char* decrypt(char *ciphertext, int *len, struct enc_ctx *ctx);
char* encrypt(char *plaintext, ssize_t *len, struct enc_ctx *ctx);
char* decrypt(char *ciphertext, ssize_t *len, struct enc_ctx *ctx);
void enc_ctx_init(int method, struct enc_ctx *ctx, int enc);
int enc_init(const char *pass, const char *method);