Mouse code for the MacroRat
mbed-dev/targets/TARGET_NUVOTON/TARGET_NUC472/crypto/des/des_alt_sw.h@46:b156ef445742, 2017-06-03 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sat Jun 03 00:22:44 2017 +0000
- Revision:
- 46:b156ef445742
- Parent:
- 18:6a4db94011d3
Final code for internal battlebot competition.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /** |
sahilmgandhi | 18:6a4db94011d3 | 2 | * \file des.h |
sahilmgandhi | 18:6a4db94011d3 | 3 | * |
sahilmgandhi | 18:6a4db94011d3 | 4 | * \brief DES block cipher |
sahilmgandhi | 18:6a4db94011d3 | 5 | * |
sahilmgandhi | 18:6a4db94011d3 | 6 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
sahilmgandhi | 18:6a4db94011d3 | 7 | * SPDX-License-Identifier: Apache-2.0 |
sahilmgandhi | 18:6a4db94011d3 | 8 | * |
sahilmgandhi | 18:6a4db94011d3 | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
sahilmgandhi | 18:6a4db94011d3 | 10 | * not use this file except in compliance with the License. |
sahilmgandhi | 18:6a4db94011d3 | 11 | * You may obtain a copy of the License at |
sahilmgandhi | 18:6a4db94011d3 | 12 | * |
sahilmgandhi | 18:6a4db94011d3 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
sahilmgandhi | 18:6a4db94011d3 | 14 | * |
sahilmgandhi | 18:6a4db94011d3 | 15 | * Unless required by applicable law or agreed to in writing, software |
sahilmgandhi | 18:6a4db94011d3 | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
sahilmgandhi | 18:6a4db94011d3 | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
sahilmgandhi | 18:6a4db94011d3 | 18 | * See the License for the specific language governing permissions and |
sahilmgandhi | 18:6a4db94011d3 | 19 | * limitations under the License. |
sahilmgandhi | 18:6a4db94011d3 | 20 | * |
sahilmgandhi | 18:6a4db94011d3 | 21 | * This file is part of mbed TLS (https://tls.mbed.org) |
sahilmgandhi | 18:6a4db94011d3 | 22 | */ |
sahilmgandhi | 18:6a4db94011d3 | 23 | #ifndef MBEDTLS_DES_ALT_SW_H |
sahilmgandhi | 18:6a4db94011d3 | 24 | #define MBEDTLS_DES_ALT_SW_H |
sahilmgandhi | 18:6a4db94011d3 | 25 | |
sahilmgandhi | 18:6a4db94011d3 | 26 | #if !defined(MBEDTLS_CONFIG_FILE) |
sahilmgandhi | 18:6a4db94011d3 | 27 | #include "config.h" |
sahilmgandhi | 18:6a4db94011d3 | 28 | #else |
sahilmgandhi | 18:6a4db94011d3 | 29 | #include MBEDTLS_CONFIG_FILE |
sahilmgandhi | 18:6a4db94011d3 | 30 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 31 | |
sahilmgandhi | 18:6a4db94011d3 | 32 | #if defined(MBEDTLS_DES_C) |
sahilmgandhi | 18:6a4db94011d3 | 33 | #if defined(MBEDTLS_DES_ALT) |
sahilmgandhi | 18:6a4db94011d3 | 34 | |
sahilmgandhi | 18:6a4db94011d3 | 35 | #include <stddef.h> |
sahilmgandhi | 18:6a4db94011d3 | 36 | #include <stdint.h> |
sahilmgandhi | 18:6a4db94011d3 | 37 | |
sahilmgandhi | 18:6a4db94011d3 | 38 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 39 | extern "C" { |
sahilmgandhi | 18:6a4db94011d3 | 40 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 41 | |
sahilmgandhi | 18:6a4db94011d3 | 42 | /** |
sahilmgandhi | 18:6a4db94011d3 | 43 | * \brief DES context structure |
sahilmgandhi | 18:6a4db94011d3 | 44 | */ |
sahilmgandhi | 18:6a4db94011d3 | 45 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 46 | { |
sahilmgandhi | 18:6a4db94011d3 | 47 | uint32_t sk[32]; /*!< DES subkeys */ |
sahilmgandhi | 18:6a4db94011d3 | 48 | } |
sahilmgandhi | 18:6a4db94011d3 | 49 | mbedtls_des_sw_context; |
sahilmgandhi | 18:6a4db94011d3 | 50 | |
sahilmgandhi | 18:6a4db94011d3 | 51 | /** |
sahilmgandhi | 18:6a4db94011d3 | 52 | * \brief Triple-DES context structure |
sahilmgandhi | 18:6a4db94011d3 | 53 | */ |
sahilmgandhi | 18:6a4db94011d3 | 54 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 55 | { |
sahilmgandhi | 18:6a4db94011d3 | 56 | uint32_t sk[96]; /*!< 3DES subkeys */ |
sahilmgandhi | 18:6a4db94011d3 | 57 | } |
sahilmgandhi | 18:6a4db94011d3 | 58 | mbedtls_des3_sw_context; |
sahilmgandhi | 18:6a4db94011d3 | 59 | |
sahilmgandhi | 18:6a4db94011d3 | 60 | /** |
sahilmgandhi | 18:6a4db94011d3 | 61 | * \brief Initialize DES context |
sahilmgandhi | 18:6a4db94011d3 | 62 | * |
sahilmgandhi | 18:6a4db94011d3 | 63 | * \param ctx DES context to be initialized |
sahilmgandhi | 18:6a4db94011d3 | 64 | */ |
sahilmgandhi | 18:6a4db94011d3 | 65 | void mbedtls_des_sw_init( mbedtls_des_sw_context *ctx ); |
sahilmgandhi | 18:6a4db94011d3 | 66 | |
sahilmgandhi | 18:6a4db94011d3 | 67 | /** |
sahilmgandhi | 18:6a4db94011d3 | 68 | * \brief Clear DES context |
sahilmgandhi | 18:6a4db94011d3 | 69 | * |
sahilmgandhi | 18:6a4db94011d3 | 70 | * \param ctx DES context to be cleared |
sahilmgandhi | 18:6a4db94011d3 | 71 | */ |
sahilmgandhi | 18:6a4db94011d3 | 72 | void mbedtls_des_sw_free( mbedtls_des_sw_context *ctx ); |
sahilmgandhi | 18:6a4db94011d3 | 73 | |
sahilmgandhi | 18:6a4db94011d3 | 74 | /** |
sahilmgandhi | 18:6a4db94011d3 | 75 | * \brief Initialize Triple-DES context |
sahilmgandhi | 18:6a4db94011d3 | 76 | * |
sahilmgandhi | 18:6a4db94011d3 | 77 | * \param ctx DES3 context to be initialized |
sahilmgandhi | 18:6a4db94011d3 | 78 | */ |
sahilmgandhi | 18:6a4db94011d3 | 79 | void mbedtls_des3_sw_init( mbedtls_des3_sw_context *ctx ); |
sahilmgandhi | 18:6a4db94011d3 | 80 | |
sahilmgandhi | 18:6a4db94011d3 | 81 | /** |
sahilmgandhi | 18:6a4db94011d3 | 82 | * \brief Clear Triple-DES context |
sahilmgandhi | 18:6a4db94011d3 | 83 | * |
sahilmgandhi | 18:6a4db94011d3 | 84 | * \param ctx DES3 context to be cleared |
sahilmgandhi | 18:6a4db94011d3 | 85 | */ |
sahilmgandhi | 18:6a4db94011d3 | 86 | void mbedtls_des3_sw_free( mbedtls_des3_sw_context *ctx ); |
sahilmgandhi | 18:6a4db94011d3 | 87 | |
sahilmgandhi | 18:6a4db94011d3 | 88 | /** |
sahilmgandhi | 18:6a4db94011d3 | 89 | * \brief Set key parity on the given key to odd. |
sahilmgandhi | 18:6a4db94011d3 | 90 | * |
sahilmgandhi | 18:6a4db94011d3 | 91 | * DES keys are 56 bits long, but each byte is padded with |
sahilmgandhi | 18:6a4db94011d3 | 92 | * a parity bit to allow verification. |
sahilmgandhi | 18:6a4db94011d3 | 93 | * |
sahilmgandhi | 18:6a4db94011d3 | 94 | * \param key 8-byte secret key |
sahilmgandhi | 18:6a4db94011d3 | 95 | */ |
sahilmgandhi | 18:6a4db94011d3 | 96 | void mbedtls_des_sw_key_set_parity( unsigned char key[MBEDTLS_DES_KEY_SIZE] ); |
sahilmgandhi | 18:6a4db94011d3 | 97 | |
sahilmgandhi | 18:6a4db94011d3 | 98 | /** |
sahilmgandhi | 18:6a4db94011d3 | 99 | * \brief Check that key parity on the given key is odd. |
sahilmgandhi | 18:6a4db94011d3 | 100 | * |
sahilmgandhi | 18:6a4db94011d3 | 101 | * DES keys are 56 bits long, but each byte is padded with |
sahilmgandhi | 18:6a4db94011d3 | 102 | * a parity bit to allow verification. |
sahilmgandhi | 18:6a4db94011d3 | 103 | * |
sahilmgandhi | 18:6a4db94011d3 | 104 | * \param key 8-byte secret key |
sahilmgandhi | 18:6a4db94011d3 | 105 | * |
sahilmgandhi | 18:6a4db94011d3 | 106 | * \return 0 is parity was ok, 1 if parity was not correct. |
sahilmgandhi | 18:6a4db94011d3 | 107 | */ |
sahilmgandhi | 18:6a4db94011d3 | 108 | int mbedtls_des_sw_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); |
sahilmgandhi | 18:6a4db94011d3 | 109 | |
sahilmgandhi | 18:6a4db94011d3 | 110 | /** |
sahilmgandhi | 18:6a4db94011d3 | 111 | * \brief Check that key is not a weak or semi-weak DES key |
sahilmgandhi | 18:6a4db94011d3 | 112 | * |
sahilmgandhi | 18:6a4db94011d3 | 113 | * \param key 8-byte secret key |
sahilmgandhi | 18:6a4db94011d3 | 114 | * |
sahilmgandhi | 18:6a4db94011d3 | 115 | * \return 0 if no weak key was found, 1 if a weak key was identified. |
sahilmgandhi | 18:6a4db94011d3 | 116 | */ |
sahilmgandhi | 18:6a4db94011d3 | 117 | int mbedtls_des_sw_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); |
sahilmgandhi | 18:6a4db94011d3 | 118 | |
sahilmgandhi | 18:6a4db94011d3 | 119 | /** |
sahilmgandhi | 18:6a4db94011d3 | 120 | * \brief DES key schedule (56-bit, encryption) |
sahilmgandhi | 18:6a4db94011d3 | 121 | * |
sahilmgandhi | 18:6a4db94011d3 | 122 | * \param ctx DES context to be initialized |
sahilmgandhi | 18:6a4db94011d3 | 123 | * \param key 8-byte secret key |
sahilmgandhi | 18:6a4db94011d3 | 124 | * |
sahilmgandhi | 18:6a4db94011d3 | 125 | * \return 0 |
sahilmgandhi | 18:6a4db94011d3 | 126 | */ |
sahilmgandhi | 18:6a4db94011d3 | 127 | int mbedtls_des_sw_setkey_enc( mbedtls_des_sw_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); |
sahilmgandhi | 18:6a4db94011d3 | 128 | |
sahilmgandhi | 18:6a4db94011d3 | 129 | /** |
sahilmgandhi | 18:6a4db94011d3 | 130 | * \brief DES key schedule (56-bit, decryption) |
sahilmgandhi | 18:6a4db94011d3 | 131 | * |
sahilmgandhi | 18:6a4db94011d3 | 132 | * \param ctx DES context to be initialized |
sahilmgandhi | 18:6a4db94011d3 | 133 | * \param key 8-byte secret key |
sahilmgandhi | 18:6a4db94011d3 | 134 | * |
sahilmgandhi | 18:6a4db94011d3 | 135 | * \return 0 |
sahilmgandhi | 18:6a4db94011d3 | 136 | */ |
sahilmgandhi | 18:6a4db94011d3 | 137 | int mbedtls_des_sw_setkey_dec( mbedtls_des_sw_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); |
sahilmgandhi | 18:6a4db94011d3 | 138 | |
sahilmgandhi | 18:6a4db94011d3 | 139 | /** |
sahilmgandhi | 18:6a4db94011d3 | 140 | * \brief Triple-DES key schedule (112-bit, encryption) |
sahilmgandhi | 18:6a4db94011d3 | 141 | * |
sahilmgandhi | 18:6a4db94011d3 | 142 | * \param ctx 3DES context to be initialized |
sahilmgandhi | 18:6a4db94011d3 | 143 | * \param key 16-byte secret key |
sahilmgandhi | 18:6a4db94011d3 | 144 | * |
sahilmgandhi | 18:6a4db94011d3 | 145 | * \return 0 |
sahilmgandhi | 18:6a4db94011d3 | 146 | */ |
sahilmgandhi | 18:6a4db94011d3 | 147 | int mbedtls_des3_sw_set2key_enc( mbedtls_des3_sw_context *ctx, |
sahilmgandhi | 18:6a4db94011d3 | 148 | const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); |
sahilmgandhi | 18:6a4db94011d3 | 149 | |
sahilmgandhi | 18:6a4db94011d3 | 150 | /** |
sahilmgandhi | 18:6a4db94011d3 | 151 | * \brief Triple-DES key schedule (112-bit, decryption) |
sahilmgandhi | 18:6a4db94011d3 | 152 | * |
sahilmgandhi | 18:6a4db94011d3 | 153 | * \param ctx 3DES context to be initialized |
sahilmgandhi | 18:6a4db94011d3 | 154 | * \param key 16-byte secret key |
sahilmgandhi | 18:6a4db94011d3 | 155 | * |
sahilmgandhi | 18:6a4db94011d3 | 156 | * \return 0 |
sahilmgandhi | 18:6a4db94011d3 | 157 | */ |
sahilmgandhi | 18:6a4db94011d3 | 158 | int mbedtls_des3_sw_set2key_dec( mbedtls_des3_sw_context *ctx, |
sahilmgandhi | 18:6a4db94011d3 | 159 | const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); |
sahilmgandhi | 18:6a4db94011d3 | 160 | |
sahilmgandhi | 18:6a4db94011d3 | 161 | /** |
sahilmgandhi | 18:6a4db94011d3 | 162 | * \brief Triple-DES key schedule (168-bit, encryption) |
sahilmgandhi | 18:6a4db94011d3 | 163 | * |
sahilmgandhi | 18:6a4db94011d3 | 164 | * \param ctx 3DES context to be initialized |
sahilmgandhi | 18:6a4db94011d3 | 165 | * \param key 24-byte secret key |
sahilmgandhi | 18:6a4db94011d3 | 166 | * |
sahilmgandhi | 18:6a4db94011d3 | 167 | * \return 0 |
sahilmgandhi | 18:6a4db94011d3 | 168 | */ |
sahilmgandhi | 18:6a4db94011d3 | 169 | int mbedtls_des3_sw_set3key_enc( mbedtls_des3_sw_context *ctx, |
sahilmgandhi | 18:6a4db94011d3 | 170 | const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); |
sahilmgandhi | 18:6a4db94011d3 | 171 | |
sahilmgandhi | 18:6a4db94011d3 | 172 | /** |
sahilmgandhi | 18:6a4db94011d3 | 173 | * \brief Triple-DES key schedule (168-bit, decryption) |
sahilmgandhi | 18:6a4db94011d3 | 174 | * |
sahilmgandhi | 18:6a4db94011d3 | 175 | * \param ctx 3DES context to be initialized |
sahilmgandhi | 18:6a4db94011d3 | 176 | * \param key 24-byte secret key |
sahilmgandhi | 18:6a4db94011d3 | 177 | * |
sahilmgandhi | 18:6a4db94011d3 | 178 | * \return 0 |
sahilmgandhi | 18:6a4db94011d3 | 179 | */ |
sahilmgandhi | 18:6a4db94011d3 | 180 | int mbedtls_des3_sw_set3key_dec( mbedtls_des3_sw_context *ctx, |
sahilmgandhi | 18:6a4db94011d3 | 181 | const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); |
sahilmgandhi | 18:6a4db94011d3 | 182 | |
sahilmgandhi | 18:6a4db94011d3 | 183 | /** |
sahilmgandhi | 18:6a4db94011d3 | 184 | * \brief DES-ECB block encryption/decryption |
sahilmgandhi | 18:6a4db94011d3 | 185 | * |
sahilmgandhi | 18:6a4db94011d3 | 186 | * \param ctx DES context |
sahilmgandhi | 18:6a4db94011d3 | 187 | * \param input 64-bit input block |
sahilmgandhi | 18:6a4db94011d3 | 188 | * \param output 64-bit output block |
sahilmgandhi | 18:6a4db94011d3 | 189 | * |
sahilmgandhi | 18:6a4db94011d3 | 190 | * \return 0 if successful |
sahilmgandhi | 18:6a4db94011d3 | 191 | */ |
sahilmgandhi | 18:6a4db94011d3 | 192 | int mbedtls_des_sw_crypt_ecb( mbedtls_des_sw_context *ctx, |
sahilmgandhi | 18:6a4db94011d3 | 193 | const unsigned char input[8], |
sahilmgandhi | 18:6a4db94011d3 | 194 | unsigned char output[8] ); |
sahilmgandhi | 18:6a4db94011d3 | 195 | |
sahilmgandhi | 18:6a4db94011d3 | 196 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
sahilmgandhi | 18:6a4db94011d3 | 197 | /** |
sahilmgandhi | 18:6a4db94011d3 | 198 | * \brief DES-CBC buffer encryption/decryption |
sahilmgandhi | 18:6a4db94011d3 | 199 | * |
sahilmgandhi | 18:6a4db94011d3 | 200 | * \note Upon exit, the content of the IV is updated so that you can |
sahilmgandhi | 18:6a4db94011d3 | 201 | * call the function same function again on the following |
sahilmgandhi | 18:6a4db94011d3 | 202 | * block(s) of data and get the same result as if it was |
sahilmgandhi | 18:6a4db94011d3 | 203 | * encrypted in one call. This allows a "streaming" usage. |
sahilmgandhi | 18:6a4db94011d3 | 204 | * If on the other hand you need to retain the contents of the |
sahilmgandhi | 18:6a4db94011d3 | 205 | * IV, you should either save it manually or use the cipher |
sahilmgandhi | 18:6a4db94011d3 | 206 | * module instead. |
sahilmgandhi | 18:6a4db94011d3 | 207 | * |
sahilmgandhi | 18:6a4db94011d3 | 208 | * \param ctx DES context |
sahilmgandhi | 18:6a4db94011d3 | 209 | * \param mode MBEDTLS_DES_ENCRYPT or MBEDTLS_DES_DECRYPT |
sahilmgandhi | 18:6a4db94011d3 | 210 | * \param length length of the input data |
sahilmgandhi | 18:6a4db94011d3 | 211 | * \param iv initialization vector (updated after use) |
sahilmgandhi | 18:6a4db94011d3 | 212 | * \param input buffer holding the input data |
sahilmgandhi | 18:6a4db94011d3 | 213 | * \param output buffer holding the output data |
sahilmgandhi | 18:6a4db94011d3 | 214 | */ |
sahilmgandhi | 18:6a4db94011d3 | 215 | int mbedtls_des_sw_crypt_cbc( mbedtls_des_sw_context *ctx, |
sahilmgandhi | 18:6a4db94011d3 | 216 | int mode, |
sahilmgandhi | 18:6a4db94011d3 | 217 | size_t length, |
sahilmgandhi | 18:6a4db94011d3 | 218 | unsigned char iv[8], |
sahilmgandhi | 18:6a4db94011d3 | 219 | const unsigned char *input, |
sahilmgandhi | 18:6a4db94011d3 | 220 | unsigned char *output ); |
sahilmgandhi | 18:6a4db94011d3 | 221 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
sahilmgandhi | 18:6a4db94011d3 | 222 | |
sahilmgandhi | 18:6a4db94011d3 | 223 | /** |
sahilmgandhi | 18:6a4db94011d3 | 224 | * \brief 3DES-ECB block encryption/decryption |
sahilmgandhi | 18:6a4db94011d3 | 225 | * |
sahilmgandhi | 18:6a4db94011d3 | 226 | * \param ctx 3DES context |
sahilmgandhi | 18:6a4db94011d3 | 227 | * \param input 64-bit input block |
sahilmgandhi | 18:6a4db94011d3 | 228 | * \param output 64-bit output block |
sahilmgandhi | 18:6a4db94011d3 | 229 | * |
sahilmgandhi | 18:6a4db94011d3 | 230 | * \return 0 if successful |
sahilmgandhi | 18:6a4db94011d3 | 231 | */ |
sahilmgandhi | 18:6a4db94011d3 | 232 | int mbedtls_des3_sw_crypt_ecb( mbedtls_des3_sw_context *ctx, |
sahilmgandhi | 18:6a4db94011d3 | 233 | const unsigned char input[8], |
sahilmgandhi | 18:6a4db94011d3 | 234 | unsigned char output[8] ); |
sahilmgandhi | 18:6a4db94011d3 | 235 | |
sahilmgandhi | 18:6a4db94011d3 | 236 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
sahilmgandhi | 18:6a4db94011d3 | 237 | /** |
sahilmgandhi | 18:6a4db94011d3 | 238 | * \brief 3DES-CBC buffer encryption/decryption |
sahilmgandhi | 18:6a4db94011d3 | 239 | * |
sahilmgandhi | 18:6a4db94011d3 | 240 | * \note Upon exit, the content of the IV is updated so that you can |
sahilmgandhi | 18:6a4db94011d3 | 241 | * call the function same function again on the following |
sahilmgandhi | 18:6a4db94011d3 | 242 | * block(s) of data and get the same result as if it was |
sahilmgandhi | 18:6a4db94011d3 | 243 | * encrypted in one call. This allows a "streaming" usage. |
sahilmgandhi | 18:6a4db94011d3 | 244 | * If on the other hand you need to retain the contents of the |
sahilmgandhi | 18:6a4db94011d3 | 245 | * IV, you should either save it manually or use the cipher |
sahilmgandhi | 18:6a4db94011d3 | 246 | * module instead. |
sahilmgandhi | 18:6a4db94011d3 | 247 | * |
sahilmgandhi | 18:6a4db94011d3 | 248 | * \param ctx 3DES context |
sahilmgandhi | 18:6a4db94011d3 | 249 | * \param mode MBEDTLS_DES_ENCRYPT or MBEDTLS_DES_DECRYPT |
sahilmgandhi | 18:6a4db94011d3 | 250 | * \param length length of the input data |
sahilmgandhi | 18:6a4db94011d3 | 251 | * \param iv initialization vector (updated after use) |
sahilmgandhi | 18:6a4db94011d3 | 252 | * \param input buffer holding the input data |
sahilmgandhi | 18:6a4db94011d3 | 253 | * \param output buffer holding the output data |
sahilmgandhi | 18:6a4db94011d3 | 254 | * |
sahilmgandhi | 18:6a4db94011d3 | 255 | * \return 0 if successful, or MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH |
sahilmgandhi | 18:6a4db94011d3 | 256 | */ |
sahilmgandhi | 18:6a4db94011d3 | 257 | int mbedtls_des3_sw_crypt_cbc( mbedtls_des3_sw_context *ctx, |
sahilmgandhi | 18:6a4db94011d3 | 258 | int mode, |
sahilmgandhi | 18:6a4db94011d3 | 259 | size_t length, |
sahilmgandhi | 18:6a4db94011d3 | 260 | unsigned char iv[8], |
sahilmgandhi | 18:6a4db94011d3 | 261 | const unsigned char *input, |
sahilmgandhi | 18:6a4db94011d3 | 262 | unsigned char *output ); |
sahilmgandhi | 18:6a4db94011d3 | 263 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
sahilmgandhi | 18:6a4db94011d3 | 264 | |
sahilmgandhi | 18:6a4db94011d3 | 265 | /** |
sahilmgandhi | 18:6a4db94011d3 | 266 | * \brief Internal function for key expansion. |
sahilmgandhi | 18:6a4db94011d3 | 267 | * (Only exposed to allow overriding it, |
sahilmgandhi | 18:6a4db94011d3 | 268 | * see MBEDTLS_DES_SETKEY_ALT) |
sahilmgandhi | 18:6a4db94011d3 | 269 | * |
sahilmgandhi | 18:6a4db94011d3 | 270 | * \param SK Round keys |
sahilmgandhi | 18:6a4db94011d3 | 271 | * \param key Base key |
sahilmgandhi | 18:6a4db94011d3 | 272 | */ |
sahilmgandhi | 18:6a4db94011d3 | 273 | void mbedtls_des_sw_setkey( uint32_t SK[32], |
sahilmgandhi | 18:6a4db94011d3 | 274 | const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); |
sahilmgandhi | 18:6a4db94011d3 | 275 | |
sahilmgandhi | 18:6a4db94011d3 | 276 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 277 | } |
sahilmgandhi | 18:6a4db94011d3 | 278 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 279 | |
sahilmgandhi | 18:6a4db94011d3 | 280 | #endif /* MBEDTLS_DES_ALT */ |
sahilmgandhi | 18:6a4db94011d3 | 281 | #endif /* MBEDTLS_DES_C */ |
sahilmgandhi | 18:6a4db94011d3 | 282 | |
sahilmgandhi | 18:6a4db94011d3 | 283 | #endif /* des.h */ |