mbed TLS library

Dependents:   HTTPClient-SSL WS_SERVER

Embed: (wiki syntax)

« Back to documentation index

ccm.h File Reference

ccm.h File Reference

Counter with CBC-MAC (CCM) for 128-bit block ciphers. More...

Go to the source code of this file.

Data Structures

struct  ccm_context
 CCM context structure. More...

Functions

int ccm_init (ccm_context *ctx, cipher_id_t cipher, const unsigned char *key, unsigned int keysize)
 CCM initialization (encryption and decryption)
void ccm_free (ccm_context *ctx)
 Free a CCM context and underlying cipher sub-context.
int ccm_encrypt_and_tag (ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len)
 CCM buffer encryption.
int ccm_auth_decrypt (ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len)
 CCM buffer authenticated decryption.
int ccm_self_test (int verbose)
 Checkup routine.

Detailed Description

Counter with CBC-MAC (CCM) for 128-bit block ciphers.

Copyright (C) 2014, ARM Limited, All Rights Reserved

This file is part of mbed TLS (https://tls.mbed.org)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Definition in file ccm.h.


Function Documentation

int ccm_auth_decrypt ( ccm_context ctx,
size_t  length,
const unsigned char *  iv,
size_t  iv_len,
const unsigned char *  add,
size_t  add_len,
const unsigned char *  input,
unsigned char *  output,
const unsigned char *  tag,
size_t  tag_len 
)

CCM buffer authenticated decryption.

Parameters:
ctxCCM context
lengthlength of the input data
ivinitialization vector
iv_lenlength of IV
addadditional data
add_lenlength of additional data
inputbuffer holding the input data
outputbuffer for holding the output data
tagbuffer holding the tag
tag_lenlength of the tag
Returns:
0 if successful and authenticated, POLARSSL_ERR_CCM_AUTH_FAILED if tag does not match

Definition at line 316 of file ccm.c.

int ccm_encrypt_and_tag ( ccm_context ctx,
size_t  length,
const unsigned char *  iv,
size_t  iv_len,
const unsigned char *  add,
size_t  add_len,
const unsigned char *  input,
unsigned char *  output,
unsigned char *  tag,
size_t  tag_len 
)

CCM buffer encryption.

Parameters:
ctxCCM context
lengthlength of the input data in bytes
ivnonce (initialization vector)
iv_lenlength of IV in bytes must be 2, 3, 4, 5, 6, 7 or 8
addadditional data
add_lenlength of additional data in bytes must be less than 2^16 - 2^8
inputbuffer holding the input data
outputbuffer for holding the output data must be at least 'length' bytes wide
tagbuffer for holding the tag
tag_lenlength of the tag to generate in bytes must be 4, 6, 8, 10, 14 or 16
Note:
The tag is written to a separate buffer. To get the tag concatenated with the output as in the CCM spec, use tag = output + length and make sure the output buffer is at least length + tag_len wide.
Returns:
0 if successful

Definition at line 303 of file ccm.c.

void ccm_free ( ccm_context ctx )

Free a CCM context and underlying cipher sub-context.

Parameters:
ctxCCM context to free

Definition at line 98 of file ccm.c.

int ccm_init ( ccm_context ctx,
cipher_id_t  cipher,
const unsigned char *  key,
unsigned int  keysize 
)

CCM initialization (encryption and decryption)

Parameters:
ctxCCM context to be initialized
ciphercipher to use (a 128-bit block cipher)
keyencryption key
keysizekey size in bits (must be acceptable by the cipher)
Returns:
0 if successful, or a cipher specific error code

Definition at line 64 of file ccm.c.

int ccm_self_test ( int  verbose )

Checkup routine.

Returns:
0 if successful, or 1 if the test failed

Definition at line 396 of file ccm.c.