mirror of
https://gitlab.kit.edu/kit/scc/sys/mail/exim-encrypt-dlfunc.git
synced 2025-12-06 12:03:55 +01:00
…
This commit is contained in:
34
src/genkey.c
34
src/genkey.c
@ -32,11 +32,15 @@ void
|
||||
dump_key_as_exim_config(FILE * f, const char *name, unsigned char *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
fprintf(f, "%s = \"", name);
|
||||
for (int i = 0; i < keylen; i++) {
|
||||
fprintf(f, "\\x%02x", key[i]);
|
||||
}
|
||||
fprintf(f, "\"\n");
|
||||
// encode with base64
|
||||
unsigned int b64len = sodium_base64_ENCODED_LEN(keylen, sodium_base64_VARIANT_ORIGINAL);
|
||||
unsigned char *b64string = malloc(b64len);
|
||||
sodium_bin2base64((char *const) b64string, b64len,
|
||||
key, keylen,
|
||||
sodium_base64_VARIANT_ORIGINAL);
|
||||
fprintf(f, "%s = \"%s\"\n", name, b64string);
|
||||
|
||||
free(b64string);
|
||||
}
|
||||
|
||||
void
|
||||
@ -52,21 +56,6 @@ write_key_files(const char *filebase, const char *varname,
|
||||
sprintf(exim_filename, "%s_exim.conf", filebase);
|
||||
sprintf(raw_filename, "%s.raw", filebase);
|
||||
|
||||
/*
|
||||
// open header file
|
||||
f = fopen(header_filename, "w+");
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "Unable to open %s for writing",
|
||||
header_filename);
|
||||
exit(129);
|
||||
}
|
||||
// write key as C header
|
||||
dump_key_as_c_code(f, varname, key, keylen);
|
||||
|
||||
// close header file
|
||||
fclose(f);
|
||||
*/
|
||||
|
||||
// open exim config snippet file
|
||||
f = fopen(exim_filename, "w+");
|
||||
if (f == NULL) {
|
||||
@ -100,11 +89,6 @@ void create_cryptobox_keys(const char *filebase, const char *varname)
|
||||
unsigned char recipient_pk[crypto_box_PUBLICKEYBYTES];
|
||||
unsigned char recipient_sk[crypto_box_SECRETKEYBYTES];
|
||||
|
||||
while (key_contains_zero(recipient_pk, crypto_box_PUBLICKEYBYTES) &
|
||||
key_contains_zero(recipient_sk, crypto_box_SECRETKEYBYTES)) {
|
||||
crypto_box_keypair(recipient_pk, recipient_sk);
|
||||
}
|
||||
|
||||
char pk_filename[4096];
|
||||
char pk_varname[4096];
|
||||
char sk_filename[4096];
|
||||
|
||||
Reference in New Issue
Block a user