takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cmac_stub.c Source File

cmac_stub.c

00001 /*
00002  * Copyright (c) , Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #if !defined(MBEDTLS_CONFIG_FILE)
00019 #include "mbedtls/config.h"
00020 #else
00021 #include MBEDTLS_CONFIG_FILE
00022 #endif
00023 
00024 
00025 #include "mbedtls/cmac.h"
00026 #include "mbedtls/platform_util.h"
00027 #include <string.h>
00028 
00029 #include "cmac_stub.h"
00030 
00031 cmac_stub_def cmac_stub;
00032 
00033 int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx,
00034                                 const unsigned char *key, size_t keybits )
00035 {
00036     if (cmac_stub.int_zero_counter) {
00037         cmac_stub.int_zero_counter--;
00038         return 0;
00039     }
00040     return cmac_stub.int_value;
00041 }
00042 
00043 int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
00044                                 const unsigned char *input, size_t ilen )
00045 {
00046     if (cmac_stub.int_zero_counter) {
00047         cmac_stub.int_zero_counter--;
00048         return 0;
00049     }
00050     return cmac_stub.int_value;
00051 }
00052 
00053 int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
00054                                 unsigned char *output )
00055 {
00056     if (cmac_stub.int_zero_counter) {
00057         cmac_stub.int_zero_counter--;
00058         return 0;
00059     }
00060     return cmac_stub.int_value;
00061 }
00062 
00063 int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx )
00064 {
00065     if (cmac_stub.int_zero_counter) {
00066         cmac_stub.int_zero_counter--;
00067         return 0;
00068     }
00069     return cmac_stub.int_value;
00070 }
00071 
00072 int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info,
00073                          const unsigned char *key, size_t keylen,
00074                          const unsigned char *input, size_t ilen,
00075                          unsigned char *output )
00076 {
00077     if (cmac_stub.int_zero_counter) {
00078         cmac_stub.int_zero_counter--;
00079         return 0;
00080     }
00081     return cmac_stub.int_value;
00082 }
00083 
00084 int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_length,
00085                               const unsigned char *input, size_t in_len,
00086                               unsigned char *output )
00087 {
00088     if (cmac_stub.int_zero_counter) {
00089         cmac_stub.int_zero_counter--;
00090         return 0;
00091     }
00092     return cmac_stub.int_value;
00093 }
00094