xref: /netbsd-src/crypto/external/bsd/openssl.old/dist/include/openssl/blowfish.h (revision 4724848cf0da353df257f730694b7882798e5daf)
1*4724848cSchristos /*
2*4724848cSchristos  * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3*4724848cSchristos  *
4*4724848cSchristos  * Licensed under the OpenSSL license (the "License").  You may not use
5*4724848cSchristos  * this file except in compliance with the License.  You can obtain a copy
6*4724848cSchristos  * in the file LICENSE in the source distribution or at
7*4724848cSchristos  * https://www.openssl.org/source/license.html
8*4724848cSchristos  */
9*4724848cSchristos 
10*4724848cSchristos #ifndef HEADER_BLOWFISH_H
11*4724848cSchristos # define HEADER_BLOWFISH_H
12*4724848cSchristos 
13*4724848cSchristos # include <openssl/opensslconf.h>
14*4724848cSchristos 
15*4724848cSchristos # ifndef OPENSSL_NO_BF
16*4724848cSchristos # include <openssl/e_os2.h>
17*4724848cSchristos # ifdef  __cplusplus
18*4724848cSchristos extern "C" {
19*4724848cSchristos # endif
20*4724848cSchristos 
21*4724848cSchristos # define BF_ENCRYPT      1
22*4724848cSchristos # define BF_DECRYPT      0
23*4724848cSchristos 
24*4724848cSchristos /*-
25*4724848cSchristos  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26*4724848cSchristos  * ! BF_LONG has to be at least 32 bits wide.                     !
27*4724848cSchristos  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28*4724848cSchristos  */
29*4724848cSchristos # define BF_LONG unsigned int
30*4724848cSchristos 
31*4724848cSchristos # define BF_ROUNDS       16
32*4724848cSchristos # define BF_BLOCK        8
33*4724848cSchristos 
34*4724848cSchristos typedef struct bf_key_st {
35*4724848cSchristos     BF_LONG P[BF_ROUNDS + 2];
36*4724848cSchristos     BF_LONG S[4 * 256];
37*4724848cSchristos } BF_KEY;
38*4724848cSchristos 
39*4724848cSchristos void BF_set_key(BF_KEY *key, int len, const unsigned char *data);
40*4724848cSchristos 
41*4724848cSchristos void BF_encrypt(BF_LONG *data, const BF_KEY *key);
42*4724848cSchristos void BF_decrypt(BF_LONG *data, const BF_KEY *key);
43*4724848cSchristos 
44*4724848cSchristos void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
45*4724848cSchristos                     const BF_KEY *key, int enc);
46*4724848cSchristos void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
47*4724848cSchristos                     const BF_KEY *schedule, unsigned char *ivec, int enc);
48*4724848cSchristos void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
49*4724848cSchristos                       long length, const BF_KEY *schedule,
50*4724848cSchristos                       unsigned char *ivec, int *num, int enc);
51*4724848cSchristos void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out,
52*4724848cSchristos                       long length, const BF_KEY *schedule,
53*4724848cSchristos                       unsigned char *ivec, int *num);
54*4724848cSchristos const char *BF_options(void);
55*4724848cSchristos 
56*4724848cSchristos # ifdef  __cplusplus
57*4724848cSchristos }
58*4724848cSchristos # endif
59*4724848cSchristos # endif
60*4724848cSchristos 
61*4724848cSchristos #endif
62