blowfish.h

Go to the documentation of this file.
00001 
00023 #ifndef MBEDTLS_BLOWFISH_H
00024 #define MBEDTLS_BLOWFISH_H
00025 
00026 #if !defined(MBEDTLS_CONFIG_FILE)
00027 #include "config.h"
00028 #else
00029 #include MBEDTLS_CONFIG_FILE
00030 #endif
00031 
00032 #include <stddef.h>
00033 #include <stdint.h>
00034 
00035 #define MBEDTLS_BLOWFISH_ENCRYPT     1
00036 #define MBEDTLS_BLOWFISH_DECRYPT     0
00037 #define MBEDTLS_BLOWFISH_MAX_KEY_BITS     448
00038 #define MBEDTLS_BLOWFISH_MIN_KEY_BITS     32
00039 #define MBEDTLS_BLOWFISH_ROUNDS      16         
00040 #define MBEDTLS_BLOWFISH_BLOCKSIZE   8          /* Blowfish uses 64 bit blocks */
00041 
00042 #define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH                -0x0016  
00043 #define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH              -0x0018  
00045 #if !defined(MBEDTLS_BLOWFISH_ALT)
00046 // Regular implementation
00047 //
00048 
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052 
00056 typedef struct
00057 {
00058     uint32_t P[MBEDTLS_BLOWFISH_ROUNDS + 2];    
00059     uint32_t S[4][256];                 
00060 }
00061 mbedtls_blowfish_context;
00062 
00068 void mbedtls_blowfish_init( mbedtls_blowfish_context *ctx );
00069 
00075 void mbedtls_blowfish_free( mbedtls_blowfish_context *ctx );
00076 
00086 int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx, const unsigned char *key,
00087                      unsigned int keybits );
00088 
00099 int mbedtls_blowfish_crypt_ecb( mbedtls_blowfish_context *ctx,
00100                         int mode,
00101                         const unsigned char input[MBEDTLS_BLOWFISH_BLOCKSIZE],
00102                         unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE] );
00103 
00104 #if defined(MBEDTLS_CIPHER_MODE_CBC)
00105 
00128 int mbedtls_blowfish_crypt_cbc( mbedtls_blowfish_context *ctx,
00129                         int mode,
00130                         size_t length,
00131                         unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE],
00132                         const unsigned char *input,
00133                         unsigned char *output );
00134 #endif /* MBEDTLS_CIPHER_MODE_CBC */
00135 
00136 #if defined(MBEDTLS_CIPHER_MODE_CFB)
00137 
00158 int mbedtls_blowfish_crypt_cfb64( mbedtls_blowfish_context *ctx,
00159                           int mode,
00160                           size_t length,
00161                           size_t *iv_off,
00162                           unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE],
00163                           const unsigned char *input,
00164                           unsigned char *output );
00165 #endif /*MBEDTLS_CIPHER_MODE_CFB */
00166 
00167 #if defined(MBEDTLS_CIPHER_MODE_CTR)
00168 
00186 int mbedtls_blowfish_crypt_ctr( mbedtls_blowfish_context *ctx,
00187                         size_t length,
00188                         size_t *nc_off,
00189                         unsigned char nonce_counter[MBEDTLS_BLOWFISH_BLOCKSIZE],
00190                         unsigned char stream_block[MBEDTLS_BLOWFISH_BLOCKSIZE],
00191                         const unsigned char *input,
00192                         unsigned char *output );
00193 #endif /* MBEDTLS_CIPHER_MODE_CTR */
00194 
00195 #ifdef __cplusplus
00196 }
00197 #endif
00198 
00199 #else  /* MBEDTLS_BLOWFISH_ALT */
00200 #include "blowfish_alt.h"
00201 #endif /* MBEDTLS_BLOWFISH_ALT */
00202 
00203 #endif /* blowfish.h */

Generated on 11 Mar 2017 for mbed TLS v2.4.2 by  doxygen 1.4.7