{"id":31847944,"url":"https://github.com/wireapp/cryptobox-c","last_synced_at":"2025-10-12T09:58:43.880Z","repository":{"id":5623403,"uuid":"47832811","full_name":"wireapp/cryptobox-c","owner":"wireapp","description":"C-FFI to cryptobox","archived":false,"fork":false,"pushed_at":"2023-01-18T14:37:24.000Z","size":209,"stargazers_count":29,"open_issues_count":6,"forks_count":18,"subscribers_count":38,"default_branch":"develop","last_synced_at":"2024-05-09T16:41:51.884Z","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/wireapp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-11T15:02:09.000Z","updated_at":"2024-05-09T16:41:51.885Z","dependencies_parsed_at":"2023-02-10T15:31:41.685Z","dependency_job_id":null,"html_url":"https://github.com/wireapp/cryptobox-c","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/wireapp/cryptobox-c","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fcryptobox-c","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fcryptobox-c/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fcryptobox-c/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fcryptobox-c/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wireapp","download_url":"https://codeload.github.com/wireapp/cryptobox-c/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fcryptobox-c/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010951,"owners_count":26084841,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-10-12T09:58:40.369Z","updated_at":"2025-10-12T09:58:43.873Z","avatar_url":"https://github.com/wireapp.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wire\n\nThis repository is part of the source code of Wire. You can find more information at [wire.com](https://wire.com) or by contacting opensource@wire.com.\n\nYou can find the published source code at [github.com/wireapp](https://github.com/wireapp). \n\nFor licensing information, see the attached LICENSE file and the list of third-party licenses at [wire.com/legal/licenses/](https://wire.com/legal/licenses/).\n\n# Cryptobox - C API\n\n`cryptobox-c` provides a high-level C API for the `cryptobox` library.\n\n**Disclaimer: This project is an early work-in-progress.**\n\n## Dependencies\n\n  * [Rust](https://www.rust-lang.org/): 1.6 stable or later\n  * [Sodium](https://github.com/jedisct1/libsodium): 1.0 or later\n\n## Building\n\n### Compile\n\n    make\n\n### Test\n\n[Valgrind](http://valgrind.org/) must be installed, then\n\n    make test\n\n### Package\n\nThe current build can produce a basic Debian package. [Makedeb](https://github.com/wireapp/wire-server/tree/develop/tools/makedeb) must be installed, then\n\n    make dist\n\nwill place the package into `target/release/`. These debian packages are usually attached to every release and can be downloaded via github.\n\n## Language Bindings\n\n  * Java / Android: A Java API through JNI with support for cross-compilation to Android is provided by [cryptobox-jni](https://github.com/wireapp/cryptobox-jni).\n  * Objective-C / iOS: Cross-compiled binaries for iOS as well as an Objective-C API is provided by [cryptobox-ios](https://github.com/wireapp/cryptobox-ios).\n  * Haskell: Haskell FFI bindings are available through [cryptobox-haskell](https://github.com/wireapp/cryptobox-haskell).\n\n## API Overview\n\nThe following is an API overview. For detailed function signatures, refer to the [cbox.h](cbox.h) header file.\n\n### CBox\n\nA `CBox` is an opaque container for all the necessary key material of a single client (e.g. a single device of a user).\nA `CBox` is allocated with a call to `cbox_file_open`. It takes a `path` as an argument which must be a valid file path\npointing to an existing directory. That directory becomes the root directory for all data stored by that `CBox` or any of the `CBoxSession`s\nobtained from it.\n\n\u003e Note: Do not create multiple `CBox`es that operate on the same or overlapping directories.\n\nOpened `CBox`es should typically be used for an extended period of time to obtain sessions and in turn\nencrypt and decrypt messages.\n\n\u003e Note: Every call to `cbox_file_open` must be paired with a `cbox_close` to properly deallocate the `CBox`.\n\n### CBoxSession\n\nA `CBoxSession` represents a cryptographic session between two endpoints (e.g. devices).\nSessions are identified through a session ID, which is an opaque C string for\nthe `CryptoBox` API. A session ID should uniquely identify a remote client or device.\n\n#### Obtaining an existing session\n\nBefore deciding to initialise a new session, a client typically tries to obtain an existing session\nusing `cbox_session_get`. If no session is found, the `CBOX_NO_SESSION` error code is returned.\n\n#### Initialising a new session\n\nIf no session for a given session ID exists, a new session can be initialised either through\n`cbox_session_init_from_prekey` or `cbox_session_init_from_message`.\n\nA client who wants to send a message to another client with whom no session exists obtains a prekey from its peer\n(directly or indirectly) and uses `cbox_session_init_from_prekey`.\n\nA client who receives an encrypted message from another client with whom he has no existing session\nuses `cbox_session_init_from_message`.\n\n#### Encrypting and decrypting messages\n\nOnce a session is obtained it can be used to encrypt and decrypt messages via `cbox_encrypt`\nand `cbox_decrypt`, respectively.\n\nThe encrypt and decrypt operations fill `CBoxVec` structures which provide access to the encrypted or decrypted\ndata via `cbox_vec_data` as well as its length through `cbox_vec_len`. Once the data has been consumed and is\nno longer needed, a `CBoxVec` must be freed using `cbox_vec_free`.\n\n\u003e Note: Every call to `cbox_session_get`, `cbox_session_init_from_prekey` or `cbox_session_init_from_message`\nmust be paired with a `cbox_session_close` to properly deallocate the `CBoxSession`.\n\n#### Saving a session\n\nAfter successfully encrypting and/or decrypting one or more messages, a session can be saved\nthrough `cbox_session_save`. Once a session is saved, the changes to the key material are\npermanent, e.g. a decrypt operation cannot be repeated. It can therefore be advisable to\nsave a session only once the decrypted plaintext has been safely stored.\n\n### Prekeys\n\nIn order to establish sessions, one client must be able to obtain a prekey from another.\nTo generate a prekey, `cbox_new_prekey` is used, which fills a `CBoxVec` with the public\nkey meterial of the newly generated prekey which can then be sent directly to another\nclient or uploaded to a server for others to download.\n\n### Fingerprints\n\nPublic key fingerprints can be compared out-of-band to protect against MITM attacks.\nThe functions `cbox_fingerprint_local` and `cbox_fingerprint_remote` are provided for\nthat purpose.\n\n## Thread-safety\n\nThe API is not thread-safe. However, distinct `CBox`es and `CBoxSession`s can be used\nindependently (and concurrently). It is up to client code or higher-level language bindings\nto provide thread-safety as necessary for the desired usage pattern.\n\n\u003e Note: When sessions are used concurrently, it is important to make sure not to have\n\u003e two or more sessions with the same session ID in use at the same time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwireapp%2Fcryptobox-c","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwireapp%2Fcryptobox-c","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwireapp%2Fcryptobox-c/lists"}