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.
aes_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 00019 #if !defined(MBEDTLS_CONFIG_FILE) 00020 #include "mbedtls/config.h" 00021 #else 00022 #include MBEDTLS_CONFIG_FILE 00023 #endif 00024 00025 #include <string.h> 00026 00027 #include "mbedtls/aes.h" 00028 00029 #include "aes_stub.h" 00030 aes_stub_def aes_stub; 00031 00032 00033 void mbedtls_aes_init( mbedtls_aes_context *ctx ) 00034 { 00035 } 00036 00037 void mbedtls_aes_free( mbedtls_aes_context *ctx ) 00038 { 00039 } 00040 00041 #if defined(MBEDTLS_CIPHER_MODE_XTS) 00042 void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx ) 00043 { 00044 } 00045 00046 void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ) 00047 { 00048 } 00049 #endif 00050 00051 #if !defined(MBEDTLS_AES_SETKEY_ENC_ALT) 00052 int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, 00053 unsigned int keybits ) 00054 { 00055 if (aes_stub.int_zero_counter) { 00056 aes_stub.int_zero_counter--; 00057 return 0; 00058 } 00059 return aes_stub.int_value; 00060 } 00061 #endif 00062 00063 #if !defined(MBEDTLS_AES_SETKEY_DEC_ALT) 00064 int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, 00065 unsigned int keybits ) 00066 { 00067 if (aes_stub.int_zero_counter) { 00068 aes_stub.int_zero_counter--; 00069 return 0; 00070 } 00071 return aes_stub.int_value; 00072 } 00073 #endif 00074 00075 #if defined(MBEDTLS_CIPHER_MODE_XTS) 00076 int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, 00077 const unsigned char *key, 00078 unsigned int keybits) 00079 { 00080 if (aes_stub.int_zero_counter) { 00081 aes_stub.int_zero_counter--; 00082 return 0; 00083 } 00084 return aes_stub.int_value; 00085 } 00086 00087 int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, 00088 const unsigned char *key, 00089 unsigned int keybits) 00090 { 00091 if (aes_stub.int_zero_counter) { 00092 aes_stub.int_zero_counter--; 00093 return 0; 00094 } 00095 return aes_stub.int_value; 00096 } 00097 #endif 00098 00099 int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx, 00100 const unsigned char input[16], 00101 unsigned char output[16] ) 00102 { 00103 if (aes_stub.int_zero_counter) { 00104 aes_stub.int_zero_counter--; 00105 return 0; 00106 } 00107 return aes_stub.int_value; 00108 } 00109 00110 void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, 00111 const unsigned char input[16], 00112 unsigned char output[16] ) 00113 { 00114 } 00115 00116 int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, 00117 const unsigned char input[16], 00118 unsigned char output[16] ) 00119 { 00120 if (aes_stub.int_zero_counter) { 00121 aes_stub.int_zero_counter--; 00122 return 0; 00123 } 00124 return aes_stub.int_value; 00125 } 00126 00127 void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, 00128 const unsigned char input[16], 00129 unsigned char output[16] ) 00130 { 00131 } 00132 00133 int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, 00134 int mode, 00135 const unsigned char input[16], 00136 unsigned char output[16] ) 00137 { 00138 if (aes_stub.int_zero_counter) { 00139 aes_stub.int_zero_counter--; 00140 return 0; 00141 } 00142 return aes_stub.int_value; 00143 } 00144 00145 int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, 00146 int mode, 00147 size_t length, 00148 unsigned char iv[16], 00149 const unsigned char *input, 00150 unsigned char *output ) 00151 { 00152 if (aes_stub.int_zero_counter) { 00153 aes_stub.int_zero_counter--; 00154 return 0; 00155 } 00156 return aes_stub.int_value; 00157 } 00158 00159 00160 #if defined(MBEDTLS_CIPHER_MODE_XTS) 00161 int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx, 00162 int mode, 00163 size_t length, 00164 const unsigned char data_unit[16], 00165 const unsigned char *input, 00166 unsigned char *output ) 00167 { 00168 if (aes_stub.int_zero_counter) { 00169 aes_stub.int_zero_counter--; 00170 return 0; 00171 } 00172 return aes_stub.int_value; 00173 } 00174 #endif 00175 00176 int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, 00177 int mode, 00178 size_t length, 00179 size_t *iv_off, 00180 unsigned char iv[16], 00181 const unsigned char *input, 00182 unsigned char *output ) 00183 { 00184 if (aes_stub.int_zero_counter) { 00185 aes_stub.int_zero_counter--; 00186 return 0; 00187 } 00188 return aes_stub.int_value; 00189 } 00190 00191 int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, 00192 int mode, 00193 size_t length, 00194 unsigned char iv[16], 00195 const unsigned char *input, 00196 unsigned char *output ) 00197 { 00198 if (aes_stub.int_zero_counter) { 00199 aes_stub.int_zero_counter--; 00200 return 0; 00201 } 00202 return aes_stub.int_value; 00203 } 00204 00205 int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, 00206 size_t length, 00207 size_t *iv_off, 00208 unsigned char iv[16], 00209 const unsigned char *input, 00210 unsigned char *output ) 00211 { 00212 if (aes_stub.int_zero_counter) { 00213 aes_stub.int_zero_counter--; 00214 return 0; 00215 } 00216 return aes_stub.int_value; 00217 } 00218 00219 int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, 00220 size_t length, 00221 size_t *nc_off, 00222 unsigned char nonce_counter[16], 00223 unsigned char stream_block[16], 00224 const unsigned char *input, 00225 unsigned char *output ) 00226 { 00227 if (aes_stub.int_zero_counter) { 00228 aes_stub.int_zero_counter--; 00229 return 0; 00230 } 00231 return aes_stub.int_value; 00232 }
Generated on Tue Aug 9 2022 00:37:00 by
1.7.2