{"id":18783570,"url":"https://github.com/sticknet/sticky-signal-protocol-c","last_synced_at":"2025-12-20T17:30:20.571Z","repository":{"id":139605286,"uuid":"349699685","full_name":"sticknet/sticky-signal-protocol-c","owner":"sticknet","description":"Customized Signal Protocol for the Stick Protocol","archived":false,"fork":false,"pushed_at":"2021-03-20T10:59:49.000Z","size":306,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T11:44:56.864Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sticknet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-20T10:59:34.000Z","updated_at":"2021-03-20T10:59:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed474ecc-774f-40eb-a2b0-5e13aa7cef3d","html_url":"https://github.com/sticknet/sticky-signal-protocol-c","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sticknet%2Fsticky-signal-protocol-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sticknet%2Fsticky-signal-protocol-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sticknet%2Fsticky-signal-protocol-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sticknet%2Fsticky-signal-protocol-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sticknet","download_url":"https://codeload.github.com/sticknet/sticky-signal-protocol-c/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239699579,"owners_count":19682574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T20:39:47.045Z","updated_at":"2025-12-20T17:30:20.516Z","avatar_url":"https://github.com/sticknet.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Customised Signal protocol for the Stick protocol | C.\n\n# Overview\n\nThis is a ratcheting forward secrecy protocol that works in synchronous and asynchronous messaging \nenvironments. See the [Java library](https://github.com/whispersystems/libsignal-protocol-java) for more details.\n\n# Building libsignal-protocol-c\n\n## Development host setup\n\n### Build dependencies\n\n* [CMake](https://cmake.org/) 2.8.4 or higher\n* [Check *1](https://libcheck.github.io/check/)\n* [OpenSSL *1](https://www.openssl.org/) 1.0 or higher\n * On MacOS X, [Common Crypto](https://developer.apple.com/library/content/documentation/Security/Conceptual/cryptoservices/GeneralPurposeCrypto/GeneralPurposeCrypto.html) is used instead of OpenSSL\n* [LCOV *2](http://ltp.sourceforge.net/coverage/lcov.php)\n\nMost of these dependencies are required just for the unit test suite and\ndevelopment of the library itself. When integrating into actual applications,\nyou should not need anything beyond CMake. Alternatively, you may integrate\nthe code using a build system of your choice.\nItems marked with *1 are required for tests, with *2 are additionally required for code coverage.\n\n### Setting up a fresh source tree\n\n    $ cd /path/to/libsignal-protocol-c\n    $ mkdir build\n    $ cd build\n    $ cmake -DCMAKE_BUILD_TYPE=Debug ..\n    $ make\n\n### Running the unit tests\n\n    $ cd /path/to/libsignal-protocol-c/build\n    $ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=1 ..\n    $ cd tests\n    $ make\n    $ cd ..\n    $ ctest\n\n### Creating the code coverage report\n\n    $ cd /path/to/libsignal-protocol-c/build\n    $ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=1 -DCOVERAGE=1 ..\n    $ make coverage\n\nThe generated code coverage report can be found in:\n`/path/to/libsignal-protocol-c/build/coverage`\n\n### Eclipse project setup\n\nCMake provides a tutorial on Eclipse project setup here:\nhttps://cmake.org/Wiki/CMake:Eclipse_UNIX_Tutorial\n\nIt is recommended to follow the more manual \"Option 2,\" since the Eclipse\nproject generator built into CMake tends to be outdated and leads you toward\na very awkward and occasionally broken project configuration.\n\n### Protocol Buffers compiler\n\nThis project uses serialization code based on [Protocol Buffers](https://github.com/google/protobuf).\nSince the official library does not support C, the [protobuf-c](https://github.com/protobuf-c/protobuf-c)\ngenerator is used instead. For the sake of convenience, the generated code and its dependencies are\nincluded in the source tree. The generated code can be regenerated at any time by installing the two\nmentioned packages and running \"make\" in the \"protobuf/\" subdirectory.\n\n## Target platforms\n\nCMake toolchain files have been included from the following sources:\n\n* [iOS](https://code.google.com/archive/p/ios-cmake)\n* [BlackBerry 10](https://github.com/blackberry/OGRE/blob/master/src/CMake/toolchain/blackberry.toolchain.cmake)\n\n# Using libsignal-protocol-c\n\n## Library initialization\n\nBefore using the library, a libsignal-protocol-c client needs to initialize a global\ncontext. This global context is used to provide callbacks for implementations\nof functions used across the library that need client-specific implementations.\nRefer to \"signal_protocol.h\" for detailed documentation on these functions, and the unit\ntests for example implementations.\n\n```c\nsignal_context *global_context;\nsignal_context_create(\u0026global_context, user_data);\nsignal_context_set_crypto_provider(global_context, \u0026provider);\nsignal_context_set_locking_functions(global_context, lock_function, unlock_function);\n```\n\n## Client install time\n\nAt install time, a libsignal-protocol-c client needs to generate its identity keys,\nregistration id, and prekeys.\n\n```c\nratchet_identity_key_pair *identity_key_pair;\nuint32_t registration_id;\nsignal_protocol_key_helper_pre_key_list_node *pre_keys_head;\nsession_signed_pre_key *signed_pre_key;\n\nsignal_protocol_key_helper_generate_identity_key_pair(\u0026identity_key_pair, global_context);\nsignal_protocol_key_helper_generate_registration_id(\u0026registration_id, 0, global_context);\nsignal_protocol_key_helper_generate_pre_keys(\u0026pre_keys_head, start_id, 100, global_context);\nsignal_protocol_key_helper_generate_signed_pre_key(\u0026signed_pre_key, identity_key_pair, 5, timestamp, global_context);\n\n/* Store identity_key_pair somewhere durable and safe. */\n/* Store registration_id somewhere durable and safe. */\n\n/* Store pre keys in the pre key store. */\n/* Store signed pre key in the signed pre key store. */\n```\n\nThe above example is simplified for the sake of clarity. All of these functions return errors\non failure, and those errors should be checked for in real usage.\n\nThere are also iteration and serialization methods for the above types that should\nbe used as appropriate.\n\n## Building a session\n\nA libsignal-protocol-c client needs to implement four data store callback interfaces:\n`signal_protocol_identity_key_store`, `signal_protocol_pre_key_store`,\n`signal_protocol_signed_pre_key_store`, and `signal_protocol_session_store`.\nThese will manage loading and storing of identity, prekeys, signed prekeys,\nand session state.\n\nThese callback interfaces are designed such that implementations should treat\nall data flowing through them as opaque binary blobs. Anything necessary for\nreferencing that data will be provided as separate function arguments to those\ncallbacks. If it is ever necessary for clients to directly access stored data\nin terms of library data structures, they should use the accessor functions\ndeclared in \"signal_protocol.h\" for these data stores.\n\nOnce the callbacks for these data stores are implemented, building a session\nis fairly straightforward:\n\n```c\n/* Create the data store context, and add all the callbacks to it */\nsignal_protocol_store_context *store_context;\nsignal_protocol_store_context_create(\u0026store_context, context);\nsignal_protocol_store_context_set_session_store(store_context, \u0026session_store);\nsignal_protocol_store_context_set_pre_key_store(store_context, \u0026pre_key_store);\nsignal_protocol_store_context_set_signed_pre_key_store(store_context, \u0026signed_pre_key_store);\nsignal_protocol_store_context_set_identity_key_store(store_context, \u0026identity_key_store);\n\n/* Instantiate a session_builder for a recipient address. */\nsignal_protocol_address address = {\n    \"+14159998888\", 12, 1\n};\nsession_builder *builder;\nsession_builder_create(\u0026builder, store_context, \u0026address, global_context);\n\n/* Build a session with a pre key retrieved from the server. */\nsession_builder_process_pre_key_bundle(builder, retrieved_pre_key);\n\n/* Create the session cipher and encrypt the message */\nsession_cipher *cipher;\nsession_cipher_create(\u0026cipher, store_context, \u0026address, global_context);\n\nciphertext_message *encrypted_message;\nsession_cipher_encrypt(cipher, message, message_len, \u0026encrypted_message);\n\n/* Get the serialized content and deliver it */\nsignal_buffer *serialized = ciphertext_message_get_serialized(encrypted_message);\n\ndeliver(signal_buffer_data(serialized), signal_buffer_len(serialized));\n\n/* Cleanup */\nSIGNAL_UNREF(encrypted_message);\nsession_cipher_free(cipher);\nsession_builder_free(builder);\nsignal_protocol_store_context_destroy(store_context);\n```\n\nThe above example is simplified for the sake of clarity. All of these functions return errors\non failure, and those errors should be checked for in real usage.\n\n## Memory management notes\n\nFor every custom data type that the libsignal-protocol-c library can allocate and\nreturn, a corresponding way of deallocating an instance of that data type\nis provided.\n\nThe more basic and higher level data types provide a type-specific free or\ndestroy function. These types include `signal_context`,\n`signal_protocol_store_context`, `signal_buffer`, `signal_buffer_list`,\n`signal_int_list`, `signal_protocol_key_helper_pre_key_list_node`, `session_builder`,\n`session_cipher`, `group_session_builder`, `group_cipher`, and\n`fingerprint_generator`.\n\nMost of the other data types, including everything internal, use a reference\ncounting mechanism. If you are going to hold onto a reference to one of these\ntypes, use the `SIGNAL_REF(x)` macro to increment its count. If you are done\nwith a reference, use `SIGNAL_UNREF(x)` to decrement its count. When the count\nreaches 0, the type's destructor function is called.\n\n# Legal things\n## Cryptography Notice\n\nThis distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software.\nBEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.\nSee \u003chttp://www.wassenaar.org/\u003e for more information.\n\nThe U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms.\nThe form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.\n\n## License\n\nCopyright 2015-2016 Open Whisper Systems\n\nLicensed under the GPLv3: http://www.gnu.org/licenses/gpl-3.0.html\n\nAdditional Permissions For Submission to Apple App Store: Provided that you are otherwise in compliance with the GPLv3 for each covered work you convey (including without limitation making the Corresponding Source available in compliance with Section 6 of the GPLv3), Open Whisper Systems also grants you the additional permission to convey through the Apple App Store non-source executable versions of the Program as incorporated into each applicable covered work as Executable Versions only under the Mozilla Public License version 2.0 (https://www.mozilla.org/en-US/MPL/2.0/).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsticknet%2Fsticky-signal-protocol-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsticknet%2Fsticky-signal-protocol-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsticknet%2Fsticky-signal-protocol-c/lists"}