ReactOS 0.4.15-dev-8064-gdaf8068
blowfish.h
Go to the documentation of this file.
1
6/*
7 * Copyright The Mbed TLS Contributors
8 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9 *
10 * This file is provided under the Apache License 2.0, or the
11 * GNU General Public License v2.0 or later.
12 *
13 * **********
14 * Apache License 2.0:
15 *
16 * Licensed under the Apache License, Version 2.0 (the "License"); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 *
28 * **********
29 *
30 * **********
31 * GNU General Public License v2.0 or later:
32 *
33 * This program is free software; you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation; either version 2 of the License, or
36 * (at your option) any later version.
37 *
38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
42 *
43 * You should have received a copy of the GNU General Public License along
44 * with this program; if not, write to the Free Software Foundation, Inc.,
45 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
46 *
47 * **********
48 */
49#ifndef MBEDTLS_BLOWFISH_H
50#define MBEDTLS_BLOWFISH_H
51
52#if !defined(MBEDTLS_CONFIG_FILE)
53#include "config.h"
54#else
55#include MBEDTLS_CONFIG_FILE
56#endif
57
58#include <stddef.h>
59#include <stdint.h>
60
61#include "platform_util.h"
62
63#define MBEDTLS_BLOWFISH_ENCRYPT 1
64#define MBEDTLS_BLOWFISH_DECRYPT 0
65#define MBEDTLS_BLOWFISH_MAX_KEY_BITS 448
66#define MBEDTLS_BLOWFISH_MIN_KEY_BITS 32
67#define MBEDTLS_BLOWFISH_ROUNDS 16
68#define MBEDTLS_BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */
69
70#if !defined(MBEDTLS_DEPRECATED_REMOVED)
71#define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x0016 )
72#endif /* !MBEDTLS_DEPRECATED_REMOVED */
73#define MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA -0x0016
75#define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018
77/* MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED is deprecated and should not be used.
78 */
79#define MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED -0x0017
81#ifdef __cplusplus
82extern "C" {
83#endif
84
85#if !defined(MBEDTLS_BLOWFISH_ALT)
86// Regular implementation
87//
88
93{
95 uint32_t S[4][256];
96}
98
99#else /* MBEDTLS_BLOWFISH_ALT */
100#include "blowfish_alt.h"
101#endif /* MBEDTLS_BLOWFISH_ALT */
102
110
120
134 unsigned int keybits );
135
153 int mode,
154 const unsigned char input[MBEDTLS_BLOWFISH_BLOCKSIZE],
155 unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE] );
156
157#if defined(MBEDTLS_CIPHER_MODE_CBC)
187 int mode,
188 size_t length,
189 unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE],
190 const unsigned char *input,
191 unsigned char *output );
192#endif /* MBEDTLS_CIPHER_MODE_CBC */
193
194#if defined(MBEDTLS_CIPHER_MODE_CFB)
227 int mode,
228 size_t length,
229 size_t *iv_off,
230 unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE],
231 const unsigned char *input,
232 unsigned char *output );
233#endif /*MBEDTLS_CIPHER_MODE_CFB */
234
235#if defined(MBEDTLS_CIPHER_MODE_CTR)
300 size_t length,
301 size_t *nc_off,
302 unsigned char nonce_counter[MBEDTLS_BLOWFISH_BLOCKSIZE],
303 unsigned char stream_block[MBEDTLS_BLOWFISH_BLOCKSIZE],
304 const unsigned char *input,
305 unsigned char *output );
306#endif /* MBEDTLS_CIPHER_MODE_CTR */
307
308#ifdef __cplusplus
309}
310#endif
311
312#endif /* blowfish.h */
int mbedtls_blowfish_crypt_cbc(mbedtls_blowfish_context *ctx, int mode, size_t length, unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
Perform a Blowfish-CBC buffer encryption/decryption operation.
int mbedtls_blowfish_setkey(mbedtls_blowfish_context *ctx, const unsigned char *key, unsigned int keybits)
Perform a Blowfish key schedule operation.
int mbedtls_blowfish_crypt_ctr(mbedtls_blowfish_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[MBEDTLS_BLOWFISH_BLOCKSIZE], unsigned char stream_block[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
Perform a Blowfish-CTR buffer encryption/decryption operation.
#define MBEDTLS_BLOWFISH_ROUNDS
Definition: blowfish.h:67
void mbedtls_blowfish_init(mbedtls_blowfish_context *ctx)
Initialize a Blowfish context.
void mbedtls_blowfish_free(mbedtls_blowfish_context *ctx)
Clear a Blowfish context.
#define MBEDTLS_BLOWFISH_BLOCKSIZE
Definition: blowfish.h:68
int mbedtls_blowfish_crypt_cfb64(mbedtls_blowfish_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[MBEDTLS_BLOWFISH_BLOCKSIZE], const unsigned char *input, unsigned char *output)
Perform a Blowfish CFB buffer encryption/decryption operation.
int mbedtls_blowfish_crypt_ecb(mbedtls_blowfish_context *ctx, int mode, const unsigned char input[MBEDTLS_BLOWFISH_BLOCKSIZE], unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE])
Perform a Blowfish-ECB block encryption/decryption operation.
UINT32 uint32_t
Definition: types.h:75
GLenum mode
Definition: glext.h:6217
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLenum GLenum GLenum input
Definition: glext.h:9031
Common and shared functions used by multiple modules in the Mbed TLS library.
Definition: movable.cpp:9
Definition: copy.c:22
Blowfish context structure.
Definition: blowfish.h:93
uint32_t P[MBEDTLS_BLOWFISH_ROUNDS+2]
Definition: blowfish.h:94