OLD | NEW |
1 /* crypto/bf/blowfish.h */ | 1 /* crypto/bf/blowfish.h */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #define BF_ENCRYPT 1 | 72 #define BF_ENCRYPT 1 |
73 #define BF_DECRYPT 0 | 73 #define BF_DECRYPT 0 |
74 | 74 |
75 /* | 75 /* |
76 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 76 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
77 * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! | 77 * ! BF_LONG has to be at least 32 bits wide. If it's wider, then ! |
78 * ! BF_LONG_LOG2 has to be defined along. ! | 78 * ! BF_LONG_LOG2 has to be defined along. ! |
79 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 79 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
80 */ | 80 */ |
81 | 81 |
82 #if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) | 82 #if defined(__LP32__) |
83 #define BF_LONG unsigned long | 83 #define BF_LONG unsigned long |
84 #elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) | 84 #elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) |
85 #define BF_LONG unsigned long | 85 #define BF_LONG unsigned long |
86 #define BF_LONG_LOG2 3 | 86 #define BF_LONG_LOG2 3 |
87 /* | 87 /* |
88 * _CRAY note. I could declare short, but I have no idea what impact | 88 * _CRAY note. I could declare short, but I have no idea what impact |
89 * does it have on performance on none-T3E machines. I could declare | 89 * does it have on performance on none-T3E machines. I could declare |
90 * int, but at least on C90 sizeof(int) can be chosen at compile time. | 90 * int, but at least on C90 sizeof(int) can be chosen at compile time. |
91 * So I've chosen long... | 91 * So I've chosen long... |
92 * <appro@fy.chalmers.se> | 92 * <appro@fy.chalmers.se> |
93 */ | 93 */ |
94 #else | 94 #else |
95 #define BF_LONG unsigned int | 95 #define BF_LONG unsigned int |
96 #endif | 96 #endif |
97 | 97 |
98 #define BF_ROUNDS 16 | 98 #define BF_ROUNDS 16 |
99 #define BF_BLOCK 8 | 99 #define BF_BLOCK 8 |
100 | 100 |
101 typedef struct bf_key_st | 101 typedef struct bf_key_st |
102 { | 102 { |
103 BF_LONG P[BF_ROUNDS+2]; | 103 BF_LONG P[BF_ROUNDS+2]; |
104 BF_LONG S[4*256]; | 104 BF_LONG S[4*256]; |
105 } BF_KEY; | 105 } BF_KEY; |
106 | 106 |
107 #ifdef OPENSSL_FIPS | 107 |
108 void private_BF_set_key(BF_KEY *key, int len, const unsigned char *data); | |
109 #endif | |
110 void BF_set_key(BF_KEY *key, int len, const unsigned char *data); | 108 void BF_set_key(BF_KEY *key, int len, const unsigned char *data); |
111 | 109 |
112 void BF_encrypt(BF_LONG *data,const BF_KEY *key); | 110 void BF_encrypt(BF_LONG *data,const BF_KEY *key); |
113 void BF_decrypt(BF_LONG *data,const BF_KEY *key); | 111 void BF_decrypt(BF_LONG *data,const BF_KEY *key); |
114 | 112 |
115 void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, | 113 void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, |
116 const BF_KEY *key, int enc); | 114 const BF_KEY *key, int enc); |
117 void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, | 115 void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, |
118 const BF_KEY *schedule, unsigned char *ivec, int enc); | 116 const BF_KEY *schedule, unsigned char *ivec, int enc); |
119 void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, | 117 void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, long length, |
120 const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); | 118 const BF_KEY *schedule, unsigned char *ivec, int *num, int enc); |
121 void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, | 119 void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, long length, |
122 const BF_KEY *schedule, unsigned char *ivec, int *num); | 120 const BF_KEY *schedule, unsigned char *ivec, int *num); |
123 const char *BF_options(void); | 121 const char *BF_options(void); |
124 | 122 |
125 #ifdef __cplusplus | 123 #ifdef __cplusplus |
126 } | 124 } |
127 #endif | 125 #endif |
128 | 126 |
129 #endif | 127 #endif |
OLD | NEW |