--- a/libidav/methods.c Sat Oct 03 20:10:54 2015 +0200 +++ b/libidav/methods.c Sun Oct 04 15:57:40 2015 +0200 @@ -87,6 +87,7 @@ int add_crypto_name = 1; int add_crypto_key = 1; + int add_crypto_hash = 1; char *crypto_ns = "idav"; UcxMap *namespaces = ucx_map_new(8); UCX_FOREACH(elm, properties) { @@ -104,6 +105,9 @@ } else if(!strcmp(p->name, "crypto-key")) { add_crypto_key = 0; crypto_ns = p->ns->prefix; + } else if(!strcmp(p->name, "crypto-hash")) { + add_crypto_hash = 0; + crypto_ns = p->ns->prefix; } } } @@ -166,6 +170,12 @@ s = S(":crypto-key />\n"); ucx_buffer_write(s.ptr, 1, s.length, buf); } + if(add_crypto_hash) { + ucx_buffer_putc(buf, '<'); + ucx_buffer_puts(buf, crypto_ns); + s = S(":crypto-hash />\n"); + ucx_buffer_write(s.ptr, 1, s.length, buf); + } } // extra properties @@ -214,6 +224,8 @@ ucx_buffer_write(s.ptr, 1, s.length, buf); s = S("<i:crypto-name />\n"); ucx_buffer_write(s.ptr, 1, s.length, buf); + s = S("<i:crypto-hash />\n"); + ucx_buffer_write(s.ptr, 1, s.length, buf); s = S("</D:prop>\n"); ucx_buffer_write(s.ptr, 1, s.length, buf); @@ -785,7 +797,7 @@ return buf; } -UcxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, char *name) { +UcxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, char *name, char *hash) { UcxBuffer *buf = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); sstr_t s; @@ -801,7 +813,7 @@ if(DAV_ENCRYPT_NAME(sn)) { s = S("<idav:crypto-name>"); ucx_buffer_write(s.ptr, 1, s.length, buf); - char *crname = aes_encrypt(name, key); + char *crname = aes_encrypt(name, strlen(name), key); ucx_buffer_puts(buf, crname); free(crname); s = S("</idav:crypto-name>\n"); @@ -814,6 +826,14 @@ s = S("</idav:crypto-key>\n"); ucx_buffer_write(s.ptr, 1, s.length, buf); + if(hash) { + s = S("<idav:crypto-hash>"); + ucx_buffer_write(s.ptr, 1, s.length, buf); + ucx_buffer_puts(buf, hash); + s = S("</idav:crypto-hash>\n"); + ucx_buffer_write(s.ptr, 1, s.length, buf); + } + s = S("</D:prop>\n</D:set>\n</D:propertyupdate>\n"); ucx_buffer_write(s.ptr, 1, s.length, buf);