{"id":13819346,"url":"https://github.com/stef/libsphinx","last_synced_at":"2025-03-27T05:30:41.784Z","repository":{"id":30221912,"uuid":"123976176","full_name":"stef/libsphinx","owner":"stef","description":"Sphinx-based Password Storage low-level library","archived":true,"fork":false,"pushed_at":"2025-01-31T12:42:37.000Z","size":2145,"stargazers_count":129,"open_issues_count":1,"forks_count":14,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-01-31T13:38:16.408Z","etag":null,"topics":["library","password-manager","password-storage","sphinx"],"latest_commit_sha":null,"homepage":"","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/stef.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":"2018-03-05T20:42:05.000Z","updated_at":"2025-01-31T12:43:12.000Z","dependencies_parsed_at":"2024-01-15T15:08:49.775Z","dependency_job_id":"d2237813-8557-42b0-9ec8-7bfcc92e91f1","html_url":"https://github.com/stef/libsphinx","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stef%2Flibsphinx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stef%2Flibsphinx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stef%2Flibsphinx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stef%2Flibsphinx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stef","download_url":"https://codeload.github.com/stef/libsphinx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791242,"owners_count":20672664,"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":["library","password-manager","password-storage","sphinx"],"created_at":"2024-08-04T08:00:45.580Z","updated_at":"2025-03-27T05:30:41.770Z","avatar_url":"https://github.com/stef.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# THIS PROJECT IS EOL\n\nlibsphinx has been replaced by liboprf https://github.com/stef/liboprf.\nit is here only for usage in the v1-legacy branch of pwdsphinx\nhttp://github.com/stef/pwdsphinx\n\n## About\n\nsphinx: a password **S**tore that **P**erfectly **H**ides from **I**tself\n(**N**o **X**aggeration)\n\nlibsphinx is a cryptographic password storage as described in\nhttps://eprint.iacr.org/2015/1099\n\nand as presented by the Levchin Prize winner 2018 Hugo Krawczyk on\nReal World Crypto https://www.youtube.com/watch?v=px8hiyf81iM\n\n## What is this thing?\n\nIt allows you to have only a few (at least one) passwords that you\nneed to remember, while at the same time provides unique 40 (ASCII)\ncharacter long very random passwords (256 bit entropy). Your master\npassword is encrypted (blinded) and sent to the password storage\nserver which (without decrypting) combines your encrypted password\nwith a big random number and sends this (still encrypted) back to you,\nwhere you can decrypt it (it's a kind of end-to-end encryption of\npasswords) and use the resulting unique, strong and very random\npassword to register/login to various services. The resulting strong\npasswords make offline password cracking attempts infeasible. If say\nyou use this with google and their password database is leaked your\npassword will still be safe.\n\nHow is this different from my password storage which stores the\npasswords in an encrypted database? Most importantly using an\nencrypted database is not \"end-to-end\" encrypted. Your master password\nis used to decrypt the database read out the password and send it back\nto you. This means whoever has your database can try to crack your\nmaster password on it, or can capture your master password while you\ntype or send it over the network. Then all your passwords are\ncompromised. If some attacker compromises your traditional password\nstore it's mostly game over for you. Using sphinx the attacker\ncontrolling your password store learns nothing about your master nor\nyour individual passwords. Also even if your strong password leaks,\nit's unique and cannot be used to login to other sites or services.\n\n## Installing\n\nInstall `libsodium`  and `libsodium-dev` using your operating system provided\npackage management. \n\nBuilding everything should (hopefully) be quite simple afterwards:\n\n```\ncd src\nmake\n```\n\n## Library\n\nlibsphinx builds a library, which you can use to build your\nown password manager either in C/C++ or any other language that can\nbind to this library.\n\n### The Sphinx API\nThe Library exposes the following 3 functions for the FK-PTR protocol\n(the password storage):\n\n```\nvoid sphinx_challenge(const uint8_t *pwd, const size_t p_len, uint8_t *bfac, uint8_t *chal);\n```\n * pwd, p_len: are input params, containing the master password and its length\n * bfac: is an output param, it's a pointer to an array of\n   `SPHINX_255_SCALAR_BYTES` (32) bytes - the blinding factor\n * chal: is an output param, it's a pointer to an array of\n   `SPHINX_255_SER_BYTES` (32) bytes - the challenge\n\n```\nint sphinx_respond(const uint8_t *chal, const uint8_t *secret, uint8_t *resp);\n```\n * chal: is an input param, it is the challenge from the challenge()\n   function, it has to be a `SPHINX_255_SER_BYTES` (32) bytes big array\n * secret: is an input param, it is the \"secret\" contribution from the\n   device, it is a `SPHINX_255_SCALAR_BYTES` (32) bytes long array\n * resp: is an output parameter, it is the result of this step, it\n   must be a `SPHINX_255_SER_BYTES` (32) byte sized array\n * the function returns 1 on error, 0 on success\n\n```\nint sphinx_finish(const uint8_t *pwd, const size_t p_len,\n                  const uint8_t *bfac, const uint8_t *resp,\n                  uint8_t *rwd);\n```\n\n * pwd: is an input param, it specifies the password again.\n * p_len: is an input param, it specifies the password length\n * bfac: is an input param, it is the bfac output from challenge(),\n   it is array of `SPHINX_255_SCALAR_BYTES` (32) bytes\n * resp: is an input parameter, it's the response from respond(), it\n   is a `SPHINX_255_SER_BYTES` (32) byte sized array\n * rwd: is an output param, the derived (binary) password, it is a\n   `SPHINX_255_SER_BYTES` (32) byte array\n * this function returns 1 on error, 0 on success\n\n## Standalone Binaries\n\nlibsphinx comes with very simple binaries implementing the sphinx\nprotocol, so you can build your own password storage even from shell\nscripts.  Each step in the SPHINX protocol is handled by one binary:\n\n### step 1 - challenge\nThe following creates a challenge for a device:\n```\necho -n \"shitty master password\" | ./challenge \u003ec 2\u003eb\n```\nThe master password is passed in through standard input.\n\nThe challenge is sent to standard output.\n\nA blinding factor is stored in a tempfile, the name of this file is output to\nstderr. This tempfile is needed in the last step again.\n\n### step 2 - device responds\nPass the challenge from step 1 on standard input like:\n```\n./respond secret \u003cc \u003er0\n```\nThe response is sent to standard output.\n\n### step 3 - derive password\nTo derive a (currently hex) password, pass the response from step 2 on standard\ninput and the filename of the tempfile and the challenge from step 1 like:\n\n```\nfname=$(cat b) ./derive $fname c \u003cr0 \u003epwd0\n```\n\nThe derived password is sent to standard output and currently is a 32\nbyte binary string. Please note that currently this only outputs the\nunblinded H(pwd)^k, for the full protocol this should be hashed again\nwith the password prepended.\n\n### step 4 - transform into ASCII password\n\nThe output from step 3 is a 32 byte binary string, most passwords have some\nlimitations to accept only printable - ASCII - chars. `bin2pass.py` is a python\nscript in the [pwdsphinx](https://github.com/stef/pwdsphinx) python module which takes a binary input on standard\ninput and transforms it into an ASCII password. It can have max two parameters\nthe classes of characters allowed ([**u**]pper-, [**l**]ower-case letters,\n[**d**]igits and [**s**]ymbols) and the size of the password. The following\nexamples should make this clear:\n\nFull ASCII, max size:\n```\n./bin2pass.py \u003cpwd0\n```\nno symbols, max size:\n```\n./bin2pass.py uld \u003cpwd0\n```\nno symbols, 8 chars:\n```\n./bin2pass.py uld 8 \u003cpwd0\n```\nonly digits, 4 chars:\n```\n./bin2pass.py d 4 \u003cpwd0\n```\nonly letters, 16 chars:\n```\n./bin2pass.py ul 16 \u003cpwd0\n```\n\n## Credits\n\nThis project was funded through the NGI0 PET Fund, a fund established\nby NLnet with financial support from the European Commission's Next\nGeneration Internet programme, under the aegis of DG Communications\nNetworks, Content and Technology under grant agreement No 825310.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstef%2Flibsphinx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstef%2Flibsphinx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstef%2Flibsphinx/lists"}