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