[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6575":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},6575,"tiny-AES-c","kokke\u002Ftiny-AES-c","kokke","Small portable AES128\u002F192\u002F256 in C","",null,"C",4965,1391,142,25,0,4,21,3,65.53,"The Unlicense",false,"master",true,[],"2026-06-12 04:00:29","![CI](https:\u002F\u002Fgithub.com\u002Fkokke\u002Ftiny-AES-c\u002Factions\u002Fworkflows\u002Fc-cpp.yml\u002Fbadge.svg)\n### Tiny AES in C\n\nThis is a small and portable implementation of the AES [ECB](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBlock_cipher_mode_of_operation#Electronic_Codebook_.28ECB.29), [CTR](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBlock_cipher_mode_of_operation#Counter_.28CTR.29) and [CBC](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBlock_cipher_mode_of_operation#Cipher_Block_Chaining_.28CBC.29) encryption algorithms written in C.\n\nYou can override the default key-size of 128 bit with 192 or 256 bit by defining the symbols AES192 or AES256 in [`aes.h`](https:\u002F\u002Fgithub.com\u002Fkokke\u002Ftiny-AES-c\u002Fblob\u002Fmaster\u002Faes.h).\n\nThe API is very simple and looks like this (I am using C99 `\u003Cstdint.h>`-style annotated types):\n\n```C\n\u002F* Initialize context calling one of: *\u002F\nvoid AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key);\nvoid AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv);\n\n\u002F* ... or reset IV at random point: *\u002F\nvoid AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv);\n\n\u002F* Then start encrypting and decrypting with the functions below: *\u002F\nvoid AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);\nvoid AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);\n\nvoid AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);\nvoid AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);\n\n\u002F* Same function for encrypting as for decrypting in CTR mode *\u002F\nvoid AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);\n```\n\nImportant notes: \n * No padding is provided so for CBC and ECB all buffers should be multiples of 16 bytes. For padding [PKCS7](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FPadding_(cryptography)#PKCS7) is recommendable.\n * ECB mode is considered unsafe for most uses and is not implemented in streaming mode. If you need this mode, call the function for every block of 16 bytes you need encrypted. See [wikipedia's article on ECB](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBlock_cipher_mode_of_operation#Electronic_Codebook_(ECB)) for more details.\n * This library is designed for small code size and simplicity, intended for cases where small binary size, low memory footprint and portability is more important than high performance. If speed is a concern, you can try more complex libraries, e.g. [Mbed TLS](https:\u002F\u002Ftls.mbed.org\u002F), [OpenSSL](https:\u002F\u002Fwww.openssl.org\u002F) etc.\n\nYou can choose to use any or all of the modes-of-operations, by defining the symbols CBC, CTR or ECB in [`aes.h`](https:\u002F\u002Fgithub.com\u002Fkokke\u002Ftiny-AES-c\u002Fblob\u002Fmaster\u002Faes.h) (read the comments for clarification).\n\nC++ users should `#include` [aes.hpp](https:\u002F\u002Fgithub.com\u002Fkokke\u002Ftiny-AES-c\u002Fblob\u002Fmaster\u002Faes.hpp) instead of [aes.h](https:\u002F\u002Fgithub.com\u002Fkokke\u002Ftiny-AES-c\u002Fblob\u002Fmaster\u002Faes.h)\n\nThere is no built-in error checking or protection from out-of-bounds memory access errors as a result of malicious input.\n\nThe module uses less than 200 bytes of RAM and 1-2K ROM when compiled for ARM, but YMMV depending on which modes are enabled.\n\nIt is one of the smallest implementations in C I've seen yet, but do contact me if you know of something smaller (or have improvements to the code here). \n\nI've successfully used the code on 64bit x86, 32bit ARM and 8 bit AVR platforms.\n\n\nGCC size output when only CTR mode is compiled for ARM:\n\n    $ arm-none-eabi-gcc -Os -DCBC=0 -DECB=0 -DCTR=1 -c aes.c\n    $ size aes.o\n       text    data     bss     dec     hex filename\n       1171       0       0    1171     493 aes.o\n\n.. and when compiling for the THUMB instruction set, we end up well below 1K in code size.\n\n    $ arm-none-eabi-gcc -Os -mthumb -DCBC=0 -DECB=0 -DCTR=1 -c aes.c\n    $ size aes.o\n       text    data     bss     dec     hex filename\n        903       0       0     903     387 aes.o\n\n\nI am using the Free Software Foundation, ARM GCC compiler:\n\n    $ arm-none-eabi-gcc --version\n    arm-none-eabi-gcc (4.8.4-1+11-1) 4.8.4 20141219 (release)\n    Copyright (C) 2013 Free Software Foundation, Inc.\n    This is free software; see the source for copying conditions.  There is NO\n    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n\n\n\nThis implementation is verified against the data in:\n\n[National Institute of Standards and Technology Special Publication 800-38A 2001 ED](http:\u002F\u002Fnvlpubs.nist.gov\u002Fnistpubs\u002FLegacy\u002FSP\u002Fnistspecialpublication800-38a.pdf) Appendix F: Example Vectors for Modes of Operation of the AES.\n\nThe other appendices in the document are valuable for implementation details on e.g. padding, generation of IVs and nonces in CTR-mode etc.\n\n\nA heartfelt thank-you to [all the nice people](https:\u002F\u002Fgithub.com\u002Fkokke\u002Ftiny-AES-c\u002Fgraphs\u002Fcontributors) out there who have contributed to this project.\n\n\nAll material in this repository is in the public domain.\n","kokke\u002Ftiny-AES-c 是一个用 C 语言编写的轻量级且可移植的 AES128\u002F192\u002F256 加密库。该项目支持 ECB、CTR 和 CBC 三种加密模式，并允许通过定义符号来选择不同的密钥长度（128、192 或 256 位）。其 API 设计简洁，易于集成到各种嵌入式系统或资源受限的环境中。适用于对代码体积和内存占用有严格要求但对性能要求不高的场景，如物联网设备、微控制器等。需要注意的是，该库未提供填充功能，因此在使用 CBC 和 ECB 模式时，所有数据块应为 16 字节的倍数。此外，ECB 模式因安全性较低而不推荐用于大多数实际应用中。",2,"2026-06-11 03:07:42","top_language"]