Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
cipher_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 #include "mbedtls/cipher.h" 00025 #include "mbedtls/cipher_internal.h" 00026 #include "mbedtls/platform_util.h" 00027 00028 #include <stdlib.h> 00029 #include <string.h> 00030 00031 #if defined(MBEDTLS_GCM_C) 00032 #include "mbedtls/gcm.h" 00033 #endif 00034 00035 #if defined(MBEDTLS_CCM_C) 00036 #include "mbedtls/ccm.h" 00037 #endif 00038 00039 #if defined(MBEDTLS_CMAC_C) 00040 #include "mbedtls/cmac.h" 00041 #endif 00042 00043 #include "cipher_stub.h" 00044 00045 cipher_stub_def cipher_stub; 00046 00047 const int *mbedtls_cipher_list( void ) 00048 { 00049 return cipher_stub.int_ptr; 00050 } 00051 00052 const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type ) 00053 { 00054 return cipher_stub.info_value; 00055 } 00056 00057 const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name ) 00058 { 00059 return cipher_stub.info_value; 00060 } 00061 00062 const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id, 00063 int key_bitlen, 00064 const mbedtls_cipher_mode_t mode ) 00065 { 00066 return cipher_stub.info_value; 00067 } 00068 00069 void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx ) 00070 { 00071 } 00072 00073 void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx ) 00074 { 00075 } 00076 00077 int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info ) 00078 { 00079 if (cipher_stub.int_zero_counter) { 00080 cipher_stub.int_zero_counter--; 00081 return 0; 00082 } 00083 return cipher_stub.int_value; 00084 } 00085 00086 int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key, 00087 int key_bitlen, const mbedtls_operation_t operation ) 00088 { 00089 if (cipher_stub.int_zero_counter) { 00090 cipher_stub.int_zero_counter--; 00091 return 0; 00092 } 00093 return cipher_stub.int_value; 00094 } 00095 00096 int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, 00097 const unsigned char *iv, size_t iv_len ) 00098 { 00099 if (cipher_stub.int_zero_counter) { 00100 cipher_stub.int_zero_counter--; 00101 return 0; 00102 } 00103 return cipher_stub.int_value; 00104 } 00105 00106 int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx ) 00107 { 00108 if (cipher_stub.int_zero_counter) { 00109 cipher_stub.int_zero_counter--; 00110 return 0; 00111 } 00112 return cipher_stub.int_value; 00113 } 00114 00115 int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, 00116 const unsigned char *ad, size_t ad_len ) 00117 { 00118 if (cipher_stub.int_zero_counter) { 00119 cipher_stub.int_zero_counter--; 00120 return 0; 00121 } 00122 return cipher_stub.int_value; 00123 } 00124 00125 int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input, 00126 size_t ilen, unsigned char *output, size_t *olen ) 00127 { 00128 if (cipher_stub.int_zero_counter) { 00129 cipher_stub.int_zero_counter--; 00130 return 0; 00131 } 00132 return cipher_stub.int_value; 00133 } 00134 00135 int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, 00136 unsigned char *output, size_t *olen ) 00137 { 00138 if (cipher_stub.int_zero_counter) { 00139 cipher_stub.int_zero_counter--; 00140 return 0; 00141 } 00142 return cipher_stub.int_value; 00143 } 00144 00145 int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode ) 00146 { 00147 if (cipher_stub.int_zero_counter) { 00148 cipher_stub.int_zero_counter--; 00149 return 0; 00150 } 00151 return cipher_stub.int_value; 00152 } 00153 00154 int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx, 00155 unsigned char *tag, size_t tag_len ) 00156 { 00157 if (cipher_stub.int_zero_counter) { 00158 cipher_stub.int_zero_counter--; 00159 return 0; 00160 } 00161 return cipher_stub.int_value; 00162 } 00163 00164 int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx, 00165 const unsigned char *tag, size_t tag_len ) 00166 { 00167 if (cipher_stub.int_zero_counter) { 00168 cipher_stub.int_zero_counter--; 00169 return 0; 00170 } 00171 return cipher_stub.int_value; 00172 } 00173 00174 int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, 00175 const unsigned char *iv, size_t iv_len, 00176 const unsigned char *input, size_t ilen, 00177 unsigned char *output, size_t *olen ) 00178 { 00179 if (cipher_stub.int_zero_counter) { 00180 cipher_stub.int_zero_counter--; 00181 return 0; 00182 } 00183 return cipher_stub.int_value; 00184 } 00185 00186 int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, 00187 const unsigned char *iv, size_t iv_len, 00188 const unsigned char *ad, size_t ad_len, 00189 const unsigned char *input, size_t ilen, 00190 unsigned char *output, size_t *olen, 00191 unsigned char *tag, size_t tag_len ) 00192 { 00193 if (cipher_stub.int_zero_counter) { 00194 cipher_stub.int_zero_counter--; 00195 return 0; 00196 } 00197 return cipher_stub.int_value; 00198 } 00199 00200 int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx, 00201 const unsigned char *iv, size_t iv_len, 00202 const unsigned char *ad, size_t ad_len, 00203 const unsigned char *input, size_t ilen, 00204 unsigned char *output, size_t *olen, 00205 const unsigned char *tag, size_t tag_len ) 00206 { 00207 if (cipher_stub.int_zero_counter) { 00208 cipher_stub.int_zero_counter--; 00209 return 0; 00210 } 00211 return cipher_stub.int_value; 00212 } 00213
Generated on Tue Aug 9 2022 00:37:04 by
1.7.2