1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-19 05:43:14 +03:00

Add (placeholder) CCM module

This commit is contained in:
Manuel Pégourié-Gonnard
2014-05-02 15:17:29 +02:00
parent 47431b6d31
commit a6916fada8
16 changed files with 192 additions and 4 deletions

View File

@ -11,6 +11,7 @@ set(src
bignum.c
blowfish.c
camellia.c
ccm.c
certs.c
cipher.c
cipher_wrap.c

View File

@ -37,7 +37,7 @@ endif
OBJS= aes.o aesni.o arc4.o \
asn1parse.o \
asn1write.o base64.o bignum.o \
blowfish.o camellia.o \
blowfish.o camellia.o ccm.o \
certs.o cipher.o cipher_wrap.o \
ctr_drbg.o debug.o des.o \
dhm.o ecdh.o ecdsa.o \

67
library/ccm.c Normal file
View File

@ -0,0 +1,67 @@
/*
* NIST SP800-38C compliant CCM implementation
*
* Copyright (C) 2014, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
*
* All rights reserved.
*
* 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 of CCM:
* http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf
* RFC 3610 "Counter with CBC-MAC (CCM)"
*
* Related:
* RFC 5116 "An Interface and Algorithms for Authenticated Encryption"
*/
#if !defined(POLARSSL_CONFIG_FILE)
#include "polarssl/config.h"
#else
#include POLARSSL_CONFIG_FILE
#endif
#if defined(POLARSSL_CCM_C)
#include "polarssl/ccm.h"
#if defined(POLARSSL_SELF_TEST) && defined(POLARSSL_AES_C)
#if defined(POLARSSL_PLATFORM_C)
#include "polarssl/platform.h"
#else
#define polarssl_printf printf
#endif
int ccm_self_test( int verbose )
{
if( verbose != 0 )
polarssl_printf( " CCM: skip\n" );
if( verbose != 0 )
polarssl_printf( "\n" );
return( 0 );
}
#endif /* POLARSSL_SELF_TEST && POLARSSL_AES_C */
#endif /* POLARSSL_CCM_C */

View File

@ -53,6 +53,10 @@
#include "polarssl/camellia.h"
#endif
#if defined(POLARSSL_CCM_C)
#include "polarssl/ccm.h"
#endif
#if defined(POLARSSL_CIPHER_C)
#include "polarssl/cipher.h"
#endif
@ -575,6 +579,13 @@ void polarssl_strerror( int ret, char *buf, size_t buflen )
snprintf( buf, buflen, "CAMELLIA - Invalid data input length" );
#endif /* POLARSSL_CAMELLIA_C */
#if defined(POLARSSL_CCM_C)
if( use_ret == -(POLARSSL_ERR_CCM_BAD_INPUT) )
snprintf( buf, buflen, "CCM - Bad input parameters to function" );
if( use_ret == -(POLARSSL_ERR_CCM_AUTH_FAILED) )
snprintf( buf, buflen, "CCM - Authenticated decryption failed" );
#endif /* POLARSSL_CCM_C */
#if defined(POLARSSL_CTR_DRBG_C)
if( use_ret == -(POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) )
snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" );

View File

@ -366,6 +366,9 @@ const char *features[] = {
#if defined(POLARSSL_CAMELLIA_C)
"POLARSSL_CAMELLIA_C",
#endif /* POLARSSL_CAMELLIA_C */
#if defined(POLARSSL_CCM_C)
"POLARSSL_CCM_C",
#endif /* POLARSSL_CCM_C */
#if defined(POLARSSL_CERTS_C)
"POLARSSL_CERTS_C",
#endif /* POLARSSL_CERTS_C */