libidav/crypto.c

changeset 261
f60d742a62a0
parent 260
26f5f817429e
child 267
171498cb2137
equal deleted inserted replaced
260:26f5f817429e 261:f60d742a62a0
31 #include <string.h> 31 #include <string.h>
32 #include <openssl/rand.h> 32 #include <openssl/rand.h>
33 33
34 #include <libidav/utils.h> 34 #include <libidav/utils.h>
35 #include "crypto.h" 35 #include "crypto.h"
36
37 #if OPENSSL_VERSION_NUMBER < 10000000
38
39 static EVP_CIPHER_CTX* create_evp_cipher_ctx() {
40 EVP_CIPHER_CTX *ctx = malloc(sizeof(EVP_CIPHER_CTX));
41 EVP_CIPHER_CTX_init(ctx);
42 return ctx;
43 }
44
45 static void free_evp_cipher_ctx(EVP_CIPHER_CTX *ctx) {
46 EVP_CIPHER_CTX_cleanup(ctx);
47 free(ctx);
48 }
49
50 #define EVP_CIPHER_CTX_new() create_evp_cipher_ctx()
51 #define EVP_CIPHER_CTX_free(ctx) free_evp_cipher_ctx(ctx)
52
53 #endif
36 54
37 AESDecrypter* aes_decrypter_new(DavKey *key, void *stream, dav_write_func write_func) { 55 AESDecrypter* aes_decrypter_new(DavKey *key, void *stream, dav_write_func write_func) {
38 AESDecrypter *dec = calloc(1, sizeof(AESDecrypter)); 56 AESDecrypter *dec = calloc(1, sizeof(AESDecrypter));
39 SHA256_Init(&dec->sha256); 57 SHA256_Init(&dec->sha256);
40 dec->stream = stream; 58 dec->stream = stream;

mercurial