mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-14 00:04:13 +09:00
provide notice that new public key has been created and stored
This commit is contained in:
@@ -352,7 +352,7 @@ struct ed25519_key_s {
|
||||
EVP_PKEY *pkey;
|
||||
};
|
||||
|
||||
ed25519_key_t *ed25519_key_generate(const char *keyfile) {
|
||||
ed25519_key_t *ed25519_key_generate(const char *keyfile, int *result) {
|
||||
ed25519_key_t *key;
|
||||
EVP_PKEY_CTX *pctx;
|
||||
BIO *bp;
|
||||
@@ -360,9 +360,11 @@ ed25519_key_t *ed25519_key_generate(const char *keyfile) {
|
||||
bool new_pk = false;
|
||||
bool use_keyfile = strlen(keyfile);
|
||||
|
||||
*result = 0;
|
||||
|
||||
key = calloc(1, sizeof(ed25519_key_t));
|
||||
assert(key);
|
||||
|
||||
|
||||
if (use_keyfile) {
|
||||
file = fopen(keyfile, "r");
|
||||
if (file) {
|
||||
@@ -399,6 +401,7 @@ ed25519_key_t *ed25519_key_generate(const char *keyfile) {
|
||||
PEM_write_bio_PrivateKey(bp, key->pkey, NULL, NULL, 0, NULL, NULL);
|
||||
BIO_free(bp);
|
||||
fclose(file);
|
||||
*result = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ int gcm_decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *pl
|
||||
|
||||
typedef struct ed25519_key_s ed25519_key_t;
|
||||
|
||||
ed25519_key_t *ed25519_key_generate(const char * keyfile);
|
||||
ed25519_key_t *ed25519_key_generate(const char * keyfile, int * result);
|
||||
ed25519_key_t *ed25519_key_from_raw(const unsigned char data[ED25519_KEY_SIZE]);
|
||||
void ed25519_key_get_raw(unsigned char data[ED25519_KEY_SIZE], const ed25519_key_t *key);
|
||||
/*
|
||||
|
||||
@@ -84,16 +84,16 @@ derive_key_internal(pairing_session_t *session, const unsigned char *salt, unsig
|
||||
}
|
||||
|
||||
pairing_t *
|
||||
pairing_init_generate(const char * keyfile)
|
||||
pairing_init_generate(const char * keyfile, int *result)
|
||||
{
|
||||
pairing_t *pairing;
|
||||
|
||||
*result = 0;
|
||||
pairing = calloc(1, sizeof(pairing_t));
|
||||
if (!pairing) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pairing->ed = ed25519_key_generate(keyfile);
|
||||
pairing->ed = ed25519_key_generate(keyfile, result);
|
||||
|
||||
return pairing;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
typedef struct pairing_s pairing_t;
|
||||
typedef struct pairing_session_s pairing_session_t;
|
||||
|
||||
pairing_t *pairing_init_generate(const char * keyfile);
|
||||
pairing_t *pairing_init_generate(const char * keyfile, int *result);
|
||||
void pairing_get_public_key(pairing_t *pairing, unsigned char public_key[ED25519_KEY_SIZE]);
|
||||
|
||||
pairing_session_t *pairing_session_init(pairing_t *pairing);
|
||||
|
||||
10
lib/raop.c
10
lib/raop.c
@@ -442,12 +442,12 @@ raop_init(int max_clients, raop_callbacks_t *callbacks, const char* keyfile) {
|
||||
raop->logger = logger_init();
|
||||
|
||||
/* create a new public key for pairing */
|
||||
pairing = pairing_init_generate(keyfile);
|
||||
int new_key;
|
||||
pairing = pairing_init_generate(keyfile, &new_key);
|
||||
if (!pairing) {
|
||||
free(raop);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* store PK as a string in raop->pk_str */
|
||||
memset(raop->pk_str, 0, sizeof(raop->pk_str));
|
||||
#ifdef PK
|
||||
@@ -459,7 +459,10 @@ raop_init(int max_clients, raop_callbacks_t *callbacks, const char* keyfile) {
|
||||
strncpy(raop->pk_str, (const char *) pk_str, 2*ED25519_KEY_SIZE);
|
||||
free(pk_str);
|
||||
#endif
|
||||
|
||||
if (new_key) {
|
||||
printf("*** A new Public Key has been created and stored in %s\n", keyfile);
|
||||
}
|
||||
|
||||
/* Set HTTP callbacks to our handlers */
|
||||
memset(&httpd_cbs, 0, sizeof(httpd_cbs));
|
||||
httpd_cbs.opaque = raop;
|
||||
@@ -626,7 +629,6 @@ int
|
||||
raop_start(raop_t *raop, unsigned short *port) {
|
||||
assert(raop);
|
||||
assert(port);
|
||||
logger_log(raop->logger, LOGGER_DEBUG, "using Public Key:\n%s", raop->pk_str);
|
||||
return httpd_start(raop->httpd, port);
|
||||
}
|
||||
|
||||
|
||||
@@ -1224,9 +1224,9 @@ static int register_dnssd() {
|
||||
LOGE("No DNS-SD Server found (DNSServiceRegister call returned kDNSServiceErr_Unknown)");
|
||||
} else if (dnssd_error == -65548) {
|
||||
LOGE("DNSServiceRegister call returned kDNSServiceErr_NameConflict");
|
||||
LOGE("Is another instance of %s running with the same DeviceID (MAC address) or using same network ports?",
|
||||
LOGI("Is another instance of %s running with the same DeviceID (MAC address) or using same network ports?",
|
||||
DEFAULT_NAME);
|
||||
LOGI("\nUse options -m ... and -p ... to allow multiple instances of %s to run concurrently", DEFAULT_NAME);
|
||||
LOGI("Use options -m ... and -p ... to allow multiple instances of %s to run concurrently", DEFAULT_NAME);
|
||||
} else {
|
||||
LOGE("dnssd_register_raop failed with error code %d\n"
|
||||
"mDNS Error codes are in range FFFE FF00 (-65792) to FFFE FFFF (-65537) "
|
||||
|
||||
Reference in New Issue
Block a user