{"id":16153864,"url":"https://github.com/roginvs/test_crypto","last_synced_at":"2025-07-20T15:33:03.854Z","repository":{"id":77829739,"uuid":"241708466","full_name":"roginvs/test_crypto","owner":"roginvs","description":"AES implementation","archived":false,"fork":false,"pushed_at":"2021-03-21T10:14:42.000Z","size":1886,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T23:42:39.497Z","etag":null,"topics":[],"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/roginvs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-19T19:37:36.000Z","updated_at":"2023-02-08T09:14:18.000Z","dependencies_parsed_at":"2023-02-23T21:00:32.388Z","dependency_job_id":null,"html_url":"https://github.com/roginvs/test_crypto","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/roginvs/test_crypto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roginvs%2Ftest_crypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roginvs%2Ftest_crypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roginvs%2Ftest_crypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roginvs%2Ftest_crypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roginvs","download_url":"https://codeload.github.com/roginvs/test_crypto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roginvs%2Ftest_crypto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266151524,"owners_count":23884436,"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-10-10T01:14:47.211Z","updated_at":"2025-07-20T15:33:03.824Z","avatar_url":"https://github.com/roginvs.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Implementing AES encryption in CBC mode\n\n## Building and testing\n\n![ci_test](https://github.com/roginvs/test_crypto/workflows/ci_test/badge.svg)\n\n```bash\n./build-and-test.sh\n```\n\n## Using in command-line mode\n\nOnly AES-256-CBC with PKCS5 padding is supported\n\n```bash\n./main.out \u003cmode\u003e \u003civ\u003e \u003ckey\u003e \u003cinput_file_name\u003e \u003coutput_file_name\u003e\n\n# mode = aes-256-cbc | aes-256-cbc-d\n# iv = initialization vector\n```\n\n### Encryption example\n\n```bash\n./main.out \\\n  aes-256-cbc \\\n  22332211aabb22aa889922aa99002200 \\\n  2b7e151628aed2a6abf7158809cf4f3c2b7e151628aed2a6abf7158809cf4f3c \\\n  in.txt \\\n  in.txt.encrypted\n\n# The same, but using openssl\nopenssl enc -aes-256-cbc \\\n  -iv 22332211aabb22aa889922aa99002200 \\\n  -K 2b7e151628aed2a6abf7158809cf4f3c2b7e151628aed2a6abf7158809cf4f3c \\\n  -in in.txt \\\n  -out in.txt.encrypted\n\n```\n\n### Decryption example\n\n```bash\n./main.out \\\n  aes-256-cbc-d \\\n  22332211aabb22aa889922aa99002200 \\\n  2b7e151628aed2a6abf7158809cf4f3c2b7e151628aed2a6abf7158809cf4f3c \\\n  in.txt.encrypted \\\n  in.txt.decrypted\n\n# The same, but using openssl\nopenssl enc -aes-256-cbc \\\n  -d \\\n  -iv 22332211aabb22aa889922aa99002200 \\\n  -K 2b7e151628aed2a6abf7158809cf4f3c2b7e151628aed2a6abf7158809cf4f3c \\\n  -in in.txt.encrypted \\\n  -out in.txt.decrypted\n\n```\n\n## Using as library\n\n```C\n\n#include \"./aes.c\"\n\n// First of all we need to initialize tables\ninit_tables();\n\n// Block to encrypt\nuint8_t block[BLOCK_SIZE] = {\n    0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,\n    0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};\n\n// Key. In this example it is 256 bits length\nuint8_t cipher_key_256[AES_256_KEY_SIZE] = {\n    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,\n    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,\n    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f};\n\n// We have to perform expansion for the key according to standard\nuint8_t expanded_key_256[AES_256_EXPANDED_KEY_SIZE];\nfill_key_expansion(cipher_key_256, AES_256_KEY_SIZE, expanded_key_256);\n\n// And thenn to encrypt the block\naes_encrypt_block(block, expanded_key_256, AES_256_KEY_SIZE);\n\n// Now block contains encrypted data\n```\n\n## What can be improved\n\n- Try to use x86/x64 operations for perfomance\n- Chech that file is opened using buffered write - no need to perform fsync after each block\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froginvs%2Ftest_crypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froginvs%2Ftest_crypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froginvs%2Ftest_crypto/lists"}