mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-03 20:22:59 -05:00 
			
		
		
		
	Merge remote-tracking branch 'upstream-public/pr/1505' into development-proposed
This commit is contained in:
		
						commit
						ebfd3cad58
					
				@ -1,8 +1,11 @@
 | 
			
		||||
/**
 | 
			
		||||
 * \file ccm.h
 | 
			
		||||
 *
 | 
			
		||||
 * \brief CCM combines Counter mode encryption with CBC-MAC authentication
 | 
			
		||||
 *        for 128-bit block ciphers.
 | 
			
		||||
 * \brief This file provides an API for the CCM authenticated encryption
 | 
			
		||||
 *        mode for block ciphers.
 | 
			
		||||
 *
 | 
			
		||||
 * CCM combines Counter mode encryption with CBC-MAC authentication
 | 
			
		||||
 * for 128-bit block ciphers.
 | 
			
		||||
 *
 | 
			
		||||
 * Input to CCM includes the following elements:
 | 
			
		||||
 * <ul><li>Payload - data that is both authenticated and encrypted.</li>
 | 
			
		||||
@ -75,7 +78,8 @@ void mbedtls_ccm_init( mbedtls_ccm_context *ctx );
 | 
			
		||||
 * \param key       The encryption key.
 | 
			
		||||
 * \param keybits   The key size in bits. This must be acceptable by the cipher.
 | 
			
		||||
 *
 | 
			
		||||
 * \return          \c 0 on success, or a cipher-specific error code.
 | 
			
		||||
 * \return          \c 0 on success.
 | 
			
		||||
 * \return          A CCM or cipher-specific error code on failure.
 | 
			
		||||
 */
 | 
			
		||||
int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx,
 | 
			
		||||
                        mbedtls_cipher_id_t cipher,
 | 
			
		||||
@ -93,6 +97,13 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx );
 | 
			
		||||
/**
 | 
			
		||||
 * \brief           This function encrypts a buffer using CCM.
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * \note            The tag is written to a separate buffer. To concatenate
 | 
			
		||||
 *                  the \p tag with the \p output, as done in <em>RFC-3610:
 | 
			
		||||
 *                  Counter with CBC-MAC (CCM)</em>, use
 | 
			
		||||
 *                  \p tag = \p output + \p length, and make sure that the
 | 
			
		||||
 *                  output buffer is at least \p length + \p tag_len wide.
 | 
			
		||||
 *
 | 
			
		||||
 * \param ctx       The CCM context to use for encryption.
 | 
			
		||||
 * \param length    The length of the input data in Bytes.
 | 
			
		||||
 * \param iv        Initialization vector (nonce).
 | 
			
		||||
@ -107,13 +118,8 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx );
 | 
			
		||||
 * \param tag_len   The length of the tag to generate in Bytes:
 | 
			
		||||
 *                  4, 6, 8, 10, 12, 14 or 16.
 | 
			
		||||
 *
 | 
			
		||||
 * \note            The tag is written to a separate buffer. To concatenate
 | 
			
		||||
 *                  the \p tag with the \p output, as done in <em>RFC-3610:
 | 
			
		||||
 *                  Counter with CBC-MAC (CCM)</em>, use
 | 
			
		||||
 *                  \p tag = \p output + \p length, and make sure that the
 | 
			
		||||
 *                  output buffer is at least \p length + \p tag_len wide.
 | 
			
		||||
 *
 | 
			
		||||
 * \return          \c 0 on success.
 | 
			
		||||
 * \return          A CCM or cipher-specific error code on failure.
 | 
			
		||||
 */
 | 
			
		||||
int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
 | 
			
		||||
                         const unsigned char *iv, size_t iv_len,
 | 
			
		||||
@ -139,8 +145,9 @@ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
 | 
			
		||||
 * \param tag_len   The length of the tag in Bytes.
 | 
			
		||||
 *                  4, 6, 8, 10, 12, 14 or 16.
 | 
			
		||||
 *
 | 
			
		||||
 * \return          0 if successful and authenticated, or
 | 
			
		||||
 *                  #MBEDTLS_ERR_CCM_AUTH_FAILED if the tag does not match.
 | 
			
		||||
 * \return          \c 0 on success. This indicates that the message is authentic.
 | 
			
		||||
 * \return          #MBEDTLS_ERR_CCM_AUTH_FAILED if the tag does not match.
 | 
			
		||||
 * \return          A cipher-specific error code on calculation failure.
 | 
			
		||||
 */
 | 
			
		||||
int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
 | 
			
		||||
                      const unsigned char *iv, size_t iv_len,
 | 
			
		||||
@ -164,7 +171,8 @@ extern "C" {
 | 
			
		||||
/**
 | 
			
		||||
 * \brief          The CCM checkup routine.
 | 
			
		||||
 *
 | 
			
		||||
 * \return         \c 0 on success, or \c 1 on failure.
 | 
			
		||||
 * \return         \c 0 on success.
 | 
			
		||||
 * \return         \c 1 on failure.
 | 
			
		||||
 */
 | 
			
		||||
int mbedtls_ccm_self_test( int verbose );
 | 
			
		||||
#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user