{"id":18745443,"url":"https://github.com/gioblu/cape","last_synced_at":"2025-04-12T21:32:51.012Z","repository":{"id":24823716,"uuid":"28238232","full_name":"gioblu/Cape","owner":"gioblu","description":"String encryption for Arduino, limited microcontrollers and other embedded systems.","archived":false,"fork":false,"pushed_at":"2020-04-04T21:50:55.000Z","size":93,"stargazers_count":69,"open_issues_count":4,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-26T16:00:40.622Z","etag":null,"topics":["arduino","c-plus-plus","cipher","encrypted-data","encryption","encryption-key","encryptor","hash","string"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gioblu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-19T17:04:35.000Z","updated_at":"2025-02-01T10:39:33.000Z","dependencies_parsed_at":"2022-07-25T14:32:32.945Z","dependency_job_id":null,"html_url":"https://github.com/gioblu/Cape","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/gioblu%2FCape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gioblu%2FCape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gioblu%2FCape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gioblu%2FCape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gioblu","download_url":"https://codeload.github.com/gioblu/Cape/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248636328,"owners_count":21137428,"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":["arduino","c-plus-plus","cipher","encrypted-data","encryption","encryption-key","encryptor","hash","string"],"created_at":"2024-11-07T16:18:07.535Z","updated_at":"2025-04-12T21:32:50.663Z","avatar_url":"https://github.com/gioblu.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Cape 3.0\n====\nCape implements private key, public salt, xor based symmetric stream cipher developed to offer encryption on limited microcontrollers.\n\nCape is an experimental project, should be used for research and educational purposes and should not be applied in production. Cape 3.0 has been posted on reddit/r/crypto to obtain feedback about its algorithm and great minds broke it in a matter of hours:\n- rspencer01 exposed a full break of the algorithm using brute force and some hints about its plaintext\n- silkeh exposed a known plaintext attack and poor performance of salt\n\nSee the extremely educational related [issue](https://github.com/gioblu/Cape/issues/17), [KnownPlainTextVulnerability](https://github.com/gioblu/Cape/blob/master/examples/KnownPlainTextVulnerability/KnownPlainTextVulnerability.ino) and [ArduinoBruteForceKey](https://github.com/gioblu/Cape/blob/master/examples/ArduinoBruteForceKey/ArduinoBruteForceKey.ino) examples.\n\nCape algorithm is weak because has been engineered not taking in consideration enough the [Kerckhoff's principle](https://en.wikipedia.org/wiki/Kerckhoffs%27s_principle) or \"one ought to design systems under the assumption that the enemy will immediately gain full familiarity with them\" in contrast to the \"security through obscurity\" principle that is obviously not applicable to open-source software. Furthermore, has not been considered the possibility that an attacker could constrain the necessary time to brute force the key used having partial hints about its plain text content (known plain text vulnerability). Further study will be done to determine the feasibility of a new, more secure encryption algorithm to be applied in this library.\n\n### How to use Cape\nInstantiate Cape passing the encryption key, its length and optionally the salt. The longer is the key the higher is the encryption strength. Encryption key must be kept secret and never transmitted, generated salt instead can be exchanged only if encrypted.\n```cpp  \n  // Instance name - Private key - Length\n  Cape cape(\"YOUR-ENCRYPTION-KEY\", 19);\n  // Optional Public salt (to be shared encrypted)\n  cape.salt = \"S\";                      \n```\nAdding salt higher data security, supporting the same private key usage for a longer time, exchanging a new salt once in a while if necessary.\nTo hash data call `hash` passing the data source buffer, the destination buffer and the data length:\n```cpp  \n  char source[] = \"CRYPTMEPLEASE\";\n  char destination[13];\n  // Light symmetric stream cipher -\u003e \"I1C_8K)*8G}dB\"\n  cape.hash(source, destination, 13);    \n  // Hash again to get back        -\u003e \"CRYPTMEPLEASE\"\n  cape.hash(destination, source, 13);   \n```\nTo encrypt a string call `encrypt` passing the data source buffer, the destination buffer, the data length and a pseudo-random 8-bit integer used as initialization vector:\n```cpp  \n  char source[] =\"CRYPTMEPLEASE\";\n  char destination[14];\n  // Strong asymmetric encryption  -\u003e \"09)*\u0026{!@#*)I)\"\n  cape.encrypt(source, destination, 13, random(0, 255));\n  // Call decrypt to get back      -\u003e \"CRYPTMEPLEASE\"\n  cape.decrypt(destination, source, 14);\n```\nIn the destination buffer it is saved the encrypted data along with a one byte initialization vector at the end, be sure to define your destination buffer always 1 byte longer and not to exceed 65534 data length.\n\nIf you need to change the encryption key after instantiation call `set_key` passing the new key and its length:\n```cpp  \n  cape.set_key(\"YOUR-ENCRYPTION-KEY\", 19);\n```\n### Encryption strength\nAfter the support of expert cryptologists from [reddit/r/crypto](reddit/r/crypto), has been practically demonstrated that Cape v3.0 algorithm is weak and a full break is already publicly available.\n\n### Ports developed by contributors\n- [cape-js](https://github.com/eldisniper/cape-js) javascript port by eldisniper\n- [Cape.py](https://github.com/colinta/Cape.py) python port by by colinta\n- [CapeDotNet](https://github.com/Pharap/CapeDotNet) C# port by Pharap\n- [CapeHaskell](https://github.com/Pharap/CapeHaskell) Haskell port by Pharap\n\n### Contribute\nFeel free to open an issue or to send a pull request, changes affecting both algorithm and implementation can be proposed and are evaluated. If you have detected a vulnerability, act ethically and share **immediately** your discovery with the community. Thank you for your support.\n\n### License\n\n```cpp  \n/*  _____  _____   _____   _____\n   |      |_____| |_____| |_____\n   |_____ |     | |       |_____  version 3.0\n\nCape Copyright © 2012-2018, Giovanni Blu Mitolo All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License. */\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgioblu%2Fcape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgioblu%2Fcape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgioblu%2Fcape/lists"}