mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 14:03:11 -07:00
Implement bright_ambassador
This commit is contained in:
parent
35c320d53d
commit
1162b26759
7 changed files with 155 additions and 4 deletions
|
@ -6,7 +6,8 @@ set(HEADER_FILES
|
|||
include/chiaki/base64.h
|
||||
include/chiaki/http.h
|
||||
include/chiaki/log.h
|
||||
include/chiaki/ctrl.h)
|
||||
include/chiaki/ctrl.h
|
||||
include/chiaki/rpcrypt.h)
|
||||
|
||||
set(SOURCE_FILES
|
||||
src/common.c
|
||||
|
@ -15,7 +16,9 @@ set(SOURCE_FILES
|
|||
src/base64.c
|
||||
src/http.c
|
||||
src/log.c
|
||||
src/ctrl.c)
|
||||
src/ctrl.c
|
||||
src/rpcrypt.c)
|
||||
|
||||
|
||||
add_library(chiaki-lib ${HEADER_FILES} ${SOURCE_FILES})
|
||||
set_target_properties(chiaki-lib PROPERTIES OUTPUT_NAME chiaki)
|
||||
|
@ -24,3 +27,6 @@ target_include_directories(chiaki-lib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/includ
|
|||
|
||||
find_package(Threads)
|
||||
target_link_libraries(chiaki-lib Threads::Threads)
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(chiaki-lib OpenSSL::Crypto)
|
42
lib/include/chiaki/rpcrypt.h
Normal file
42
lib/include/chiaki/rpcrypt.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* This file is part of Chiaki.
|
||||
*
|
||||
* Chiaki is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Chiaki is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CHIAKI_RPCRYPT_H
|
||||
#define CHIAKI_RPCRYPT_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CHIAKI_KEY_BYTES 0x10
|
||||
|
||||
typedef struct chiaki_rpcrypt_t
|
||||
{
|
||||
|
||||
} ChiakiRPCrypt;
|
||||
|
||||
CHIAKI_EXPORT void chiaki_rpcrypt_bright_ambassador(uint8_t *bright, uint8_t *ambassador, const uint8_t *nonce, const uint8_t *morning);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CHIAKI_RPCRYPT_H
|
|
@ -22,6 +22,7 @@
|
|||
#include "thread.h"
|
||||
#include "log.h"
|
||||
#include "ctrl.h"
|
||||
#include "rpcrypt.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <netdb.h>
|
||||
|
@ -70,7 +71,6 @@ typedef struct chiaki_event_t
|
|||
typedef void (*ChiakiEventCallback)(ChiakiEvent *event, void *user);
|
||||
|
||||
|
||||
#define CHIAKI_KEY_BYTES 0x10
|
||||
|
||||
typedef struct chiaki_session_t
|
||||
{
|
||||
|
|
45
lib/src/rpcrypt.c
Normal file
45
lib/src/rpcrypt.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* This file is part of Chiaki.
|
||||
*
|
||||
* Chiaki is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Chiaki is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <chiaki/rpcrypt.h>
|
||||
|
||||
|
||||
|
||||
CHIAKI_EXPORT void chiaki_rpcrypt_bright_ambassador(uint8_t *bright, uint8_t *ambassador, const uint8_t *nonce, const uint8_t *morning)
|
||||
{
|
||||
static const uint8_t echo_a[] = { 0x01, 0x49, 0x87, 0x9b, 0x65, 0x39, 0x8b, 0x39, 0x4b, 0x3a, 0x8d, 0x48, 0xc3, 0x0a, 0xef, 0x51 };
|
||||
static const uint8_t echo_b[] = { 0xe1, 0xec, 0x9c, 0x3a, 0xdd, 0xbd, 0x08, 0x85, 0xfc, 0x0e, 0x1d, 0x78, 0x90, 0x32, 0xc0, 0x04 };
|
||||
|
||||
for(uint8_t i=0; i<CHIAKI_KEY_BYTES; i++)
|
||||
{
|
||||
uint8_t v = nonce[i];
|
||||
v -= i;
|
||||
v -= 0x27;
|
||||
v ^= echo_a[i];
|
||||
ambassador[i] = v;
|
||||
}
|
||||
|
||||
for(uint8_t i=0; i<CHIAKI_KEY_BYTES; i++)
|
||||
{
|
||||
uint8_t v = morning[i];
|
||||
v -= i;
|
||||
v += 0x34;
|
||||
v ^= echo_b[i];
|
||||
v ^= nonce[i];
|
||||
bright[i] = v;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue