451 free(buf); // only free the UcxBuffer struct |
451 free(buf); // only free the UcxBuffer struct |
452 return str; |
452 return str; |
453 } |
453 } |
454 |
454 |
455 void util_generate_key(DavKey *key, char *password) { |
455 void util_generate_key(DavKey *key, char *password) { |
456 key->data = malloc(SHA256_DIGEST_LENGTH); |
456 //key->data = malloc(SHA256_DIGEST_LENGTH); |
457 key->length = SHA256_DIGEST_LENGTH; |
457 //key->length = SHA256_DIGEST_LENGTH; |
458 key->type = DAV_KEY_AES256; |
458 key->type = DAV_KEY_AES256; |
459 |
459 |
460 SHA256_CTX sha256; |
460 //SHA256_CTX sha256; |
461 SHA256_Init(&sha256); |
461 //SHA256_Init(&sha256); |
462 SHA256_Update(&sha256, password, strlen(password)); |
462 //SHA256_Update(&sha256, password, strlen(password)); |
463 SHA256_Final(key->data, &sha256); |
463 //SHA256_Final(key->data, &sha256); |
464 } |
464 } |
465 |
465 |
466 char* util_key_input(DavContext *ctx, DavKey *key) { |
466 char* util_key_input(DavContext *ctx, DavKey *key) { |
467 sstr_t prompt = ucx_sprintf("Enter password for key (%s): ", key->name); |
467 sstr_t prompt = ucx_sprintf("Enter password for key (%s): ", key->name); |
468 char *password = util_password_input(prompt.ptr); |
468 char *password = util_password_input(prompt.ptr); |