text stringlengths 0 357 |
|---|
char* dc_key_get_fingerprint(const dc_key_t* key) |
{ |
uint8_t* fingerprint_buf = NULL; |
size_t fingerprint_bytes = 0; |
char* fingerprint_hex = NULL; |
if (key==NULL) { |
goto cleanup; |
} |
if (!dc_pgp_calc_fingerprint(key, &fingerprint_buf, &fingerprint_bytes)) { |
goto cleanup; |
} |
fingerprint_hex = dc_binary_to_uc_hex(fingerprint_buf, fingerprint_bytes); |
cleanup: |
free(fingerprint_buf); |
return fingerprint_hex? fingerprint_hex : dc_strdup(NULL); |
} |
char* dc_key_get_formatted_fingerprint(const dc_key_t* key) |
{ |
char* rawhex = dc_key_get_fingerprint(key); |
char* formatted = dc_format_fingerprint(rawhex); |
free(rawhex); |
return formatted; |
} |
``` |
Filename: dc_keyhistory.c |
```c |
#include "dc_context.h" |
void dc_add_to_keyhistory(dc_context_t* context, const char* rfc724_mid, time_t sending_time, const char* addr, const char* fingerprint) |
{ |
// TODO |
} |
``` |
Filename: dc_keyring.c |
```c |
#include <memory.h> |
#include "dc_context.h" |
#include "dc_key.h" |
#include "dc_keyring.h" |
#include "dc_tools.h" |
dc_keyring_t* dc_keyring_new() |
{ |
dc_keyring_t* keyring; |
if ((keyring=calloc(1, sizeof(dc_keyring_t)))==NULL) { |
exit(42); /* cannot allocate little memory, unrecoverable error */ |
} |
return keyring; |
} |
void dc_keyring_unref(dc_keyring_t* keyring) |
{ |
if (keyring == NULL) { |
return; |
} |
for (int i = 0; i < keyring->count; i++) { |
dc_key_unref(keyring->keys[i]); |
} |
free(keyring->keys); |
free(keyring); |
} |
void dc_keyring_add(dc_keyring_t* keyring, dc_key_t* to_add) |
{ |
if (keyring==NULL || to_add==NULL) { |
return; |
} |
/* expand array, if needed */ |
if (keyring->count == keyring->allocated) { |
int newsize = (keyring->allocated * 2) + 10; |
if ((keyring->keys=realloc(keyring->keys, newsize*sizeof(dc_key_t*)))==NULL) { |
exit(41); |
} |
keyring->allocated = newsize; |
} |
keyring->keys[keyring->count] = dc_key_ref(to_add); |
keyring->count++; |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.