| 1 | ## AWS C Cal |
| 2 | |
| 3 | AWS Crypto Abstraction Layer: Cross-Platform, C99 wrapper for cryptography primitives. |
| 4 | |
| 5 | ## License |
| 6 | |
| 7 | This library is licensed under the Apache 2.0 License. |
| 8 | |
| 9 | ## Supported Platforms |
| 10 | * Windows (Vista and Later) |
| 11 | * Apple (MacOS 10.15+, IOS 11+) |
| 12 | * Unix (via OpenSSL compatible libcrypto) |
| 13 | |
| 14 | ## Build Instructions |
| 15 | |
| 16 | CMake 3.9+ is required to build. |
| 17 | |
| 18 | `<install-path>` must be an absolute path in the following instructions. |
| 19 | |
| 20 | #### Linux-Only Dependencies |
| 21 | |
| 22 | If you are building on Linux, there are several options for crypto libraries. |
| 23 | Preferred choice is aws-lc, that can be build as follows. |
| 24 | |
| 25 | ``` |
| 26 | git clone [email protected]:awslabs/aws-lc.git |
| 27 | cmake -S aws-lc -B aws-lc/build -DCMAKE_INSTALL_PREFIX=<install-path> |
| 28 | cmake --build aws-lc/build --target install |
| 29 | ``` |
| 30 | |
| 31 | Alternatively, OpenSSL versions 1.0.2 or 1.1.1 or BoringSSL at commit 9939e14 |
| 32 | (other commits are not tested and not guaranteed to work) can be used. To build |
| 33 | against OpenSSL or BoringSSL specify -DUSE_OPENSSL=ON. Typical OpenSSL flags can |
| 34 | be used to help project locate artifacts (-DLibCrypto_INCLUDE_DIR and -DLibCrypto_STATIC_LIBRARY) |
| 35 | |
| 36 | #### Building aws-c-cal and Remaining Dependencies |
| 37 | |
| 38 | ``` |
| 39 | git clone [email protected]:awslabs/aws-c-common.git |
| 40 | cmake -S aws-c-common -B aws-c-common/build -DCMAKE_INSTALL_PREFIX=<install-path> |
| 41 | cmake --build aws-c-common/build --target install |
| 42 | |
| 43 | git clone [email protected]:awslabs/aws-c-cal.git |
| 44 | cmake -S aws-c-cal -B aws-c-cal/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path> |
| 45 | cmake --build aws-c-cal/build --target install |
| 46 | ``` |
| 47 | |
| 48 | ## Currently provided algorithms |
| 49 | |
| 50 | ### Hashes |
| 51 | #### MD5 |
| 52 | ##### Streaming |
| 53 | ```` |
| 54 | struct aws_hash *hash = aws_md5_new(allocator); |
| 55 | aws_hash_update(hash, &your_buffer); |
| 56 | aws_hash_finalize(hash, &output_buffer, 0); |
| 57 | aws_hash_destroy(hash); |
| 58 | ```` |
| 59 | |
| 60 | ##### One-Shot |
| 61 | ```` |
| 62 | aws_md5_compute(allocator, &your_buffer, &output_buffer, 0); |
| 63 | ```` |
| 64 | |
| 65 | #### SHA256 |
| 66 | ##### Streaming |
| 67 | ```` |
| 68 | struct aws_hash *hash = aws_sha256_new(allocator); |
| 69 | aws_hash_update(hash, &your_buffer); |
| 70 | aws_hash_finalize(hash, &output_buffer, 0); |
| 71 | aws_hash_destroy(hash); |
| 72 | ```` |
| 73 | |
| 74 | ##### One-Shot |
| 75 | ```` |
| 76 | aws_sha256_compute(allocator, &your_buffer, &output_buffer, 0); |
| 77 | ```` |
| 78 | |
| 79 | ### HMAC |
| 80 | #### SHA256 HMAC |
| 81 | ##### Streaming |
| 82 | ```` |
| 83 | struct aws_hmac *hmac = aws_sha256_hmac_new(allocator, &secret_buf); |
| 84 | aws_hmac_update(hmac, &your_buffer); |
| 85 | aws_hmac_finalize(hmac, &output_buffer, 0); |
| 86 | aws_hmac_destroy(hmac); |
| 87 | ```` |
| 88 | |
| 89 | ##### One-Shot |
| 90 | ```` |
| 91 | aws_sha256_hmac_compute(allocator, &secret_buf, &your_buffer, &output_buffer, 0); |
| 92 | ```` |
| 93 | |
| 94 | ## FAQ |
| 95 | ### I want more algorithms, what do I do? |
| 96 | Great! So do we! At a minimum, file an issue letting us know. If you want to file a Pull Request, we'd be happy to review and merge it when it's ready. |
| 97 | ### Who should consume this package directly? |
| 98 | Are you writing C directly? Then you should. |
| 99 | Are you using any other programming language? This functionality will be exposed via that language specific crt packages. |
| 100 | ### I found a security vulnerability in this package. What do I do? |
| 101 | Due to the fact that this package is specifically performing cryptographic operations, please don't file a public issue. Instead, email [email protected], and we'll work with you directly. |
| 102 |