Skip to content

Commit

Permalink
finish aes
Browse files Browse the repository at this point in the history
  • Loading branch information
acagliano committed Sep 23, 2023
1 parent 6da4b70 commit d65e94a
Show file tree
Hide file tree
Showing 11 changed files with 497 additions and 437 deletions.
16 changes: 0 additions & 16 deletions cryptx.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ void cryptx_hmac_update(struct cryptx_hmac_ctx* context, const void* data, size_
* @brief Output digest for current HMAC-state (preserves state).
* @param context Pointer to an HMAC-state context.
* @param digest Pointer to a buffer to write digest to.
* @note @b digest must be at large enough to hold the hash digest.
* You can retrieve the necessary size by accessing the @b digest_len
* member of an initialized @b cryptx_hmac_ctx.
*/
void cryptx_hmac_digest(struct cryptx_hmac_ctx* context, void* digest);

Expand Down Expand Up @@ -341,10 +338,6 @@ aes_error_t cryptx_aes_init(struct cryptx_aes_ctx* context,
* @param len Length of data at @b plaintext to encrypt.
* @param ciphertext Pointer to buffer to write encrypted data to.
* @returns An @b aes_error_t indicating the status of the AES operation.
* @note @b ciphertext should large enough to hold the encrypted message.
* See the @b cryptx_aes_get_ciphertext_len macro for CBC mode.
* @note @b plaintext and @b ciphertext are aliasable.
* @note Encrypt is streamable, such that \f$ encrypt(msg1) + encrypt(msg2) \f$ is functionally identical to \f$ encrypt(msg1+msg2) \f$ with the exception of intervening padding in CBC mode.
*/
aes_error_t cryptx_aes_encrypt(const struct cryptx_aes_ctx* context,
const void* plaintext,
Expand All @@ -358,8 +351,6 @@ aes_error_t cryptx_aes_encrypt(const struct cryptx_aes_ctx* context,
* @param len Length of data at @b ciphertext to decrypt.
* @param plaintext Pointer to buffer to write decryped data to.
* @returns An @b aes_error_t indicating the status of the AES operation.
* @note @b plaintext and @b ciphertext are aliasable.
* @note Decrypt is streamable, such that \f$ decrypt(msg1) + decrypt(msg2) \f$ is functionally identical to \f$ decrypt(msg1+msg2) \f$ with the exception of intervening padding in CBC mode.
*/
aes_error_t cryptx_aes_decrypt(const struct cryptx_aes_ctx* context,
const void* ciphertext,
Expand All @@ -373,8 +364,6 @@ aes_error_t cryptx_aes_decrypt(const struct cryptx_aes_ctx* context,
* @param aad Pointer to additional authenticated data segment.
* @param aad_len Length of additional data segment.
* @returns An @b aes_error_t indicating the status of the AES operation.
* @note This function can only be called between cipher initialization and encryption/decryption. Attempting to
* call this function at any other time will return @b AES_INVALID_OPERATION.
*/
aes_error_t cryptx_aes_update_aad(struct cryptx_aes_ctx* context,
const void* aad, size_t aad_len);
Expand All @@ -384,10 +373,6 @@ aes_error_t cryptx_aes_update_aad(struct cryptx_aes_ctx* context,
* @param context Pointer to an AES context
* @param digest Pointer to a buffer to output digest to. Must be at least 16 bytes large.
* @returns An @b aes_error_t indicating the status of the AES operation.
* @warning <b>Nonce-misuse vulnerability/forbidden attack</b>: GCM is vulnerable to key discovery
* if the same nonce is reused to encrypt or decrypt multiple messages. Once you generate a digest for data processed
* by the cipher, cycle the nonce by generating a new one and calling @b cryptx_aes_init again with the new nonce.
* To ensure this is done properly, the context is marked invalid once this function is called.
*/
aes_error_t cryptx_aes_digest(struct cryptx_aes_ctx* context, uint8_t *digest);

Expand All @@ -401,7 +386,6 @@ aes_error_t cryptx_aes_digest(struct cryptx_aes_ctx* context, uint8_t *digest);
* @param ciphertext_len Length of ciphertext to authenticate.
* @param tag Pointer to expected auth tag to validate against.
* @returns TRUE if authentication tag matches expected, FALSE otherwise.
* @note If this function returns FALSE, do not decrypt the message.
*/

bool cryptx_aes_verify(const struct cryptx_aes_ctx* context,
Expand Down
648 changes: 315 additions & 333 deletions docs/doxygen/xml/cryptx_8h.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/doxygen/xml/structCipher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<para>for AES </para>
</sect3>
</detaileddescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="254" column="1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="251" column="1"/>
<listofallmembers>
</listofallmembers>
</compounddef>
Expand Down
14 changes: 7 additions & 7 deletions docs/doxygen/xml/structcryptx__aes__ctx.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="256" column="10" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="256" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="253" column="10" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="253" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__aes__ctx_1ab7564e0e5d2e1bd96b083f913eda1382" prot="public" static="no" mutable="no">
<type>uint32_t</type>
Expand All @@ -31,7 +31,7 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="257" column="10" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="257" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="254" column="10" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="254" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__aes__ctx_1a3cc495f40d5a578c335fd03fe2772e4a" prot="public" static="no" mutable="no">
<type>uint8_t</type>
Expand All @@ -46,7 +46,7 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="258" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="258" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="255" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="255" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__aes__ctx_1a46d05a8ea39c183bd6f09d5fa95bfe25" prot="public" static="no" mutable="no">
<type>uint8_t</type>
Expand All @@ -61,7 +61,7 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="259" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="259" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="256" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="256" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__aes__ctx_1af6a8c176ebacf1d1fc6a25b1ec2ec6d8" prot="public" static="no" mutable="no">
<type>uint8_t</type>
Expand All @@ -76,7 +76,7 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="260" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="260" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="257" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="257" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__aes__ctx_1a019c3bf1d587684ca720951dc0f390c3" prot="public" static="no" mutable="no">
<type><ref refid="unioncryptx__aes__private__h" kindref="compound">cryptx_aes_private_h</ref></type>
Expand All @@ -91,7 +91,7 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="261" column="22" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="261" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="258" column="22" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="258" bodyend="-1"/>
</memberdef>
</sectiondef>
<briefdescription>
Expand Down Expand Up @@ -131,7 +131,7 @@
</childnode>
</node>
</collaborationgraph>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="255" column="1" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="255" bodyend="262"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="252" column="1" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="252" bodyend="259"/>
<listofallmembers>
<member refid="structcryptx__aes__ctx_1a46d05a8ea39c183bd6f09d5fa95bfe25" prot="public" virt="non-virtual"><scope>cryptx_aes_ctx</scope><name>ciphermode</name></member>
<member refid="structcryptx__aes__ctx_1a3cc495f40d5a578c335fd03fe2772e4a" prot="public" virt="non-virtual"><scope>cryptx_aes_ctx</scope><name>iv</name></member>
Expand Down
6 changes: 3 additions & 3 deletions docs/doxygen/xml/structcryptx__ecc__point.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="681" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="681" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="665" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="665" bodyend="-1"/>
</memberdef>
<memberdef kind="variable" id="structcryptx__ecc__point_1ada79cb09d73636479cf469e6de935973" prot="public" static="no" mutable="no">
<type>uint8_t</type>
Expand All @@ -30,15 +30,15 @@
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="682" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="682" bodyend="-1"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="666" column="9" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="666" bodyend="-1"/>
</memberdef>
</sectiondef>
<briefdescription>
<para>Defines a point for use with elliptic curve arithmetic. </para>
</briefdescription>
<detaileddescription>
</detaileddescription>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="680" column="1" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="680" bodyend="683"/>
<location file="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" line="664" column="1" bodyfile="/Users/acagliano/Library/Mobile Documents/com~apple~CloudDocs/Repositories/toolchain/src/cryptx/cryptx.h" bodystart="664" bodyend="667"/>
<listofallmembers>
<member refid="structcryptx__ecc__point_1a7a6b80237baf8237385a5827601d1337" prot="public" virt="non-virtual"><scope>cryptx_ecc_point</scope><name>x</name></member>
<member refid="structcryptx__ecc__point_1ada79cb09d73636479cf469e6de935973" prot="public" virt="non-virtual"><scope>cryptx_ecc_point</scope><name>y</name></member>
Expand Down
Loading

0 comments on commit d65e94a

Please sign in to comment.