255 } |
255 } |
256 return CURL_SEEKFUNC_OK; |
256 return CURL_SEEKFUNC_OK; |
257 } |
257 } |
258 |
258 |
259 |
259 |
260 char* aes_encrypt(char *in, size_t len, DavKey *key) { |
260 char* aes_encrypt(const char *in, size_t len, DavKey *key) { |
261 unsigned char iv[16]; |
261 unsigned char iv[16]; |
262 if(!RAND_bytes(iv, 16)) { |
262 if(!RAND_bytes(iv, 16)) { |
263 return NULL; |
263 return NULL; |
264 } |
264 } |
265 |
265 |
302 //EVP_CIPHER_CTX_cleanup(&ctx); |
302 //EVP_CIPHER_CTX_cleanup(&ctx); |
303 |
303 |
304 return out; |
304 return out; |
305 } |
305 } |
306 |
306 |
307 char* aes_decrypt(char *in, size_t *length, DavKey *key) { |
307 char* aes_decrypt(const char *in, size_t *length, DavKey *key) { |
308 int len; |
308 int len; |
309 unsigned char *buf = (unsigned char*)util_base64decode_len(in, &len); |
309 unsigned char *buf = (unsigned char*)util_base64decode_len(in, &len); |
310 |
310 |
311 //EVP_CIPHER_CTX ctx; |
311 //EVP_CIPHER_CTX ctx; |
312 //EVP_CIPHER_CTX_init(&ctx); |
312 //EVP_CIPHER_CTX_init(&ctx); |
658 } |
658 } |
659 // TODO: cleanup cryptor |
659 // TODO: cleanup cryptor |
660 free(enc); |
660 free(enc); |
661 } |
661 } |
662 |
662 |
663 char* aes_encrypt(char *in, size_t len, DavKey *key) { |
663 char* aes_encrypt(const char *in, size_t len, DavKey *key) { |
664 unsigned char iv[16]; |
664 unsigned char iv[16]; |
665 if(dav_rand_bytes(iv, 16)) { |
665 if(dav_rand_bytes(iv, 16)) { |
666 return NULL; |
666 return NULL; |
667 } |
667 } |
668 |
668 |
713 free(buf); |
713 free(buf); |
714 |
714 |
715 return b64enc; |
715 return b64enc; |
716 } |
716 } |
717 |
717 |
718 char* aes_decrypt(char *in, size_t *len, DavKey *key) { |
718 char* aes_decrypt(const char *in, size_t *len, DavKey *key) { |
719 int inlen; |
719 int inlen; |
720 unsigned char *buf = (unsigned char*)util_base64decode_len(in, &inlen); |
720 unsigned char *buf = (unsigned char*)util_base64decode_len(in, &inlen); |
721 |
721 |
722 CCCryptorRef cryptor; |
722 CCCryptorRef cryptor; |
723 CCCryptorStatus status; |
723 CCCryptorStatus status; |