Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Refactoring. #15

Draft
wants to merge 58 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
1583c50
Fix name to prevent same name of function in read/write to socket fun…
Jakio815 Feb 1, 2025
869a59e
Add an internal buffer to the SST_session_ctx_t
Jakio815 Feb 12, 2025
fac8211
Merge branch 'master' into refactor-for-lf
Jakio815 Feb 12, 2025
c78c0d7
Fix GCM tag size. Default is 16. Nonce should be 12.
Jakio815 Feb 12, 2025
cb84975
Formatting.
Jakio815 Feb 13, 2025
0103e7e
Add MAX_SECURE_COMM_LENGTH, which will be the length
Jakio815 Feb 13, 2025
7aec52d
Add fix on sending secure_comm_message. It splits the message if the …
Jakio815 Feb 13, 2025
ef47603
Fix MAX_PAYLOAD_LENGTH to MAX_SECURE_COMM_LENGTH
Jakio815 Feb 13, 2025
249be71
Move MAX_PAYLOAD_LENGTH and MAX_SECURE_COMM_LENGTH to c_api.h
Jakio815 Feb 13, 2025
e9392f8
Add SST_read_exact but still need to merge with sst_read_from_socket
Jakio815 Feb 13, 2025
9388a6d
Add SST_read
Jakio815 Feb 13, 2025
6053b87
Add SST_read to c api.
Jakio815 Feb 13, 2025
4e24cd3
Add SST_read test.
Jakio815 Feb 13, 2025
7496154
Minor fix.
Jakio815 Feb 13, 2025
7181214
Change api name to SST_write
Jakio815 Feb 13, 2025
abf1eed
Fix parameter order.
Jakio815 Feb 13, 2025
528ab6b
Fix parameter order.
Jakio815 Feb 13, 2025
84139b7
Fix function name.
Jakio815 Feb 13, 2025
48ade21
Fix name and return logic.
Jakio815 Feb 14, 2025
1af2bd4
Formatting.
Jakio815 Feb 14, 2025
2ff2993
Add description on sst_read_from_socket_exact
Jakio815 Feb 14, 2025
61a7aed
Formatting.
Jakio815 Feb 14, 2025
8fd638c
Add sst log and debug messages.
Jakio815 Feb 14, 2025
b689cf0
Add print error.
Jakio815 Feb 14, 2025
ebf2984
Remove unnecessary mesage in CMAKE
Jakio815 Feb 14, 2025
77fc736
Fix logging.
Jakio815 Feb 14, 2025
1132115
Add sst log and debug messages.
Jakio815 Feb 14, 2025
58260f4
Add print error.
Jakio815 Feb 14, 2025
46ac1e2
Remove unnecessary mesage in CMAKE
Jakio815 Feb 14, 2025
9c679dd
Fix logging.
Jakio815 Feb 14, 2025
4608b58
Fix tests to use print_buf_log.
Jakio815 Feb 14, 2025
cb26e27
Fix on log examples.
Jakio815 Feb 14, 2025
0d2828c
Fix to SST_print_error_exit()
Jakio815 Feb 18, 2025
1946991
Fix descriptions.
Jakio815 Feb 19, 2025
a7abb17
Fix to SST_print_error_return_null
Jakio815 Feb 19, 2025
83fb3c4
Merge branch 'logging' of github.com:iotauth/sst-c-api into refactor-…
Jakio815 Feb 19, 2025
0bda650
Minor fix.
Jakio815 Feb 19, 2025
f3c4e60
Minor fix- just move function.
Jakio815 Feb 19, 2025
a6c99ba
Refactor read_var_length_int and formatting.
Jakio815 Feb 19, 2025
c6612cc
Remove internal buf at this point.
Jakio815 Feb 19, 2025
aee192f
Add functions to header files. May be removed, if defined as static.
Jakio815 Feb 19, 2025
d591329
Update SST_read_server.c test.
Jakio815 Feb 19, 2025
e8597ea
Change entity client and server example to just use the user implemen…
Jakio815 Feb 19, 2025
1d7d4fd
Add argument number check.
Jakio815 Feb 19, 2025
3f66575
Revert "Add argument number check."
Jakio815 Feb 19, 2025
440df51
Revert "Revert "Add argument number check.""
Jakio815 Feb 19, 2025
cd93c92
Fix to show all errors only on debug compile mode.
Jakio815 Feb 19, 2025
8b988bb
Minor fix
Jakio815 Feb 19, 2025
43bfc80
Minor fix...
Jakio815 Feb 19, 2025
8a94cf3
Add headers.
Jakio815 Feb 19, 2025
9276038
Minor fix.
Jakio815 Feb 20, 2025
3f5a69a
Minor fix.
Jakio815 Feb 20, 2025
89aa57a
Remove receive_message() and receive_thread() function.
Jakio815 Feb 21, 2025
a089017
Remove return_decrypted_buf.
Jakio815 Feb 21, 2025
acdfc8f
Minor fix.
Jakio815 Feb 21, 2025
8b465e4
Remove thread functions, and make user to implement it using the SST_…
Jakio815 Feb 24, 2025
52ae85a
Minor type fix.
Jakio815 Mar 17, 2025
f3f3c50
Fix types
Jakio815 Mar 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
cmake_minimum_required(VERSION 3.19)
project(sst-lib VERSION 1.0.0 LANGUAGES C)

# Check `openssl version -d` and copy the path to OPENSSL_ROOT_DIR
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(OPENSSL_ROOT_DIR "/usr/local/lib64")
endif()

find_package(OpenSSL REQUIRED)
find_package(Threads REQUIRED)

Expand All @@ -33,13 +28,19 @@ target_include_directories(sst-c-api PUBLIC
# Ensure OpenSSL is installed along with sst-c-api
install(FILES ${OPENSSL_LIBRARIES} DESTINATION lib)

# Compiler flags
if(MSVC)
target_compile_options(sst-c-api PUBLIC /W4 /WX)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Exclude errors, because some can use GNU-specific variadic arguments. This is done for only compiling the SST library.
else()
target_compile_options(sst-c-api PUBLIC -Wall -Wextra -Wpedantic -Werror)
# Set DEBUG flag for Debug builds
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG")
message(STATUS "Enabling DEBUG flag")
target_compile_definitions(sst-c-api PUBLIC DEBUG=1)

# Compiler flags
if(MSVC)
target_compile_options(sst-c-api PUBLIC /W4 /WX)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Exclude errors, because some can use GNU-specific variadic arguments. This is done for only compiling the SST library.
else()
target_compile_options(sst-c-api PUBLIC -Wall -Wextra -Wpedantic -Werror)
endif()
endif()

# Install the library
Expand Down
24 changes: 2 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,16 @@ c_common -> c_crypto -> c_secure_comm -> c_api -> entity_client, entity_server
- Input is the struct config.
- Returns struct SST_session_ctx_t

**void \*receive_thread()**

- Creates a receive_thread and prints the received messages.
- Usage:

```
pthread_t thread;
pthread_create(&thread, NULL, &receive_thread, (void \*)session_ctx);
```

**void receive_message()**

- Receives messages and print them.

**int read_secure_message(int socket, unsigned char *buf, unsigned int buf_length, unsigned char *plaintext, SST_session_ctx_t *session_ctx)**

- `read_secure_message` checks the message header if it is a `SECURE_COMM_MSG`, and fills the buffer with the received message.
- Input is the connected socket, pointer of the buffer, and the given buffer's length (not the received message)
- This function does not decrypt the message, returns the message as **not decrypted.**
- Returns the length of the not decrypted message.

**int SST_write()**

**unsigned char * return_decrypted_buf()**

- The user can
- Returns the decrypted buffer, and must free() after use.

**int send_secure_message()**

- `send_secure_message()` is a function that sends a message with secure communication to the server by encrypting it with the session key.
- `SST_write()` is a function that sends a message with secure communication to the server by encrypting it with the session key.
- It recursively `write()`s until it sends the total message length.
- Input includes message, length of message, and session_ctx struct.
- Returns the bytes written if success, and -1 if failure.
Expand Down
Loading