text stringlengths 0 357 |
|---|
#ifdef DC_USE_RPGP |
int dc_pgp_symm_decrypt(dc_context_t* context, |
const char* passphrase, |
const void* ctext, size_t ctext_bytes, |
void** ret_plain_text, size_t* ret_plain_bytes) |
{ |
int success = 0; |
rpgp_message* encrypted = NULL; |
rpgp_message* decrypted = NULL; |
encrypted = rpgp_msg_from_bytes(ctext, ctext_bytes); |
if (dc_pgp_handle_rpgp_error(context)) { |
goto cleanup; |
} |
decrypted = rpgp_msg_decrypt_with_password(encrypted, passphrase); |
if (dc_pgp_handle_rpgp_error(context)) { |
goto cleanup; |
} |
rpgp_cvec* decrypted_bytes = rpgp_msg_to_bytes(decrypted); |
if (dc_pgp_handle_rpgp_error(context)) { |
goto cleanup; |
} |
*ret_plain_text = (void*)rpgp_cvec_data(decrypted_bytes); |
*ret_plain_bytes = rpgp_cvec_len(decrypted_bytes); |
// No drop as we only remove the struct |
free(decrypted_bytes); |
success = 1; |
cleanup: |
if (encrypted) { rpgp_msg_drop(encrypted); } |
if (decrypted) { rpgp_msg_drop(decrypted); } |
return success; |
} |
#else // !DC_USE_RPGP |
int dc_pgp_symm_decrypt(dc_context_t* context, |
const char* passphrase, |
const void* ctext, size_t ctext_bytes, |
void** ret_plain_text, size_t* ret_plain_bytes) |
{ |
int success = 0; |
pgp_io_t io; |
pgp_memory_t* outmem = NULL; |
memset(&io, 0, sizeof(pgp_io_t)); |
io.outs = stdout; |
io.errs = stderr; |
io.res = stderr; |
if ((outmem=pgp_decrypt_buf(&io, ctext, ctext_bytes, NULL, NULL, 0, 0, passphrase))==NULL) { |
goto cleanup; |
} |
*ret_plain_text = outmem->buf; |
*ret_plain_bytes = outmem->length; |
free(outmem); /* do not use pgp_memory_free() as we took ownership of the buffer */ |
outmem = NULL; |
success = 1; |
cleanup: |
if (outmem) { pgp_memory_free(outmem); } |
return success; |
} |
#endif // !DC_USE_RPGP |
``` |
Filename: dc_qr.c |
```c |
#include <stdarg.h> |
#include <unistd.h> |
#include "dc_context.h" |
#include "dc_apeerstate.h" |
#define MAILTO_SCHEME "mailto:" |
#define MATMSG_SCHEME "MATMSG:" |
#define VCARD_BEGIN "BEGIN:VCARD" |
#define SMTP_SCHEME "SMTP:" |
/** |
* Check a scanned QR code. |
* The function should be called after a QR code is scanned. |
* The function takes the raw text scanned and checks what can be done with it. |
* |
* The QR code state is returned in dc_lot_t::state as: |
* |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.