diff options
author | Damien Miller <djm@mindrot.org> | 1999-11-25 11:54:57 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-11-25 11:54:57 +1100 |
commit | 5428f646ad32da88ddd04a8c287d595524674fbf (patch) | |
tree | cc1f1e5d7852e1f44d41077f776abf7dab7ac06d /cipher.c | |
parent | 9072e1889648988da38b7b81bce95291c1dc3a23 (diff) |
- More reformatting merged from OpenBSD CVS
- Merged OpenBSD CVS changes:
- [channels.c]
report from mrwizard@psu.edu via djm@ibs.com.au
- [channels.c]
set SO_REUSEADDR and SO_LINGER for forwarded ports.
chip@valinux.com via damien@ibs.com.au
- [nchan.c]
it's not an error() if shutdown_write failes in nchan.
- [readconf.c]
remove dead #ifdef-0-code
- [readconf.c servconf.c]
strcasecmp instead of tolower
- [scp.c]
progress meter overflow fix from damien@ibs.com.au
- [ssh-add.1 ssh-add.c]
SSH_ASKPASS support
- [ssh.1 ssh.c]
postpone fork_after_authentication until command execution,
request/patch from jahakala@cc.jyu.fi via damien@ibs.com.au
plus: use daemon() for backgrounding
Diffstat (limited to 'cipher.c')
-rw-r--r-- | cipher.c | 43 |
1 files changed, 27 insertions, 16 deletions
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$Id: cipher.c,v 1.7 1999/11/24 13:26:22 damien Exp $"); | 15 | RCSID("$Id: cipher.c,v 1.8 1999/11/25 00:54:58 damien Exp $"); |
16 | 16 | ||
17 | #include "ssh.h" | 17 | #include "ssh.h" |
18 | #include "cipher.h" | 18 | #include "cipher.h" |
@@ -121,8 +121,10 @@ detect_cbc_attack(const unsigned char *src, | |||
121 | cipher_attack_detected("CRC-32 CBC insertion attack detected"); | 121 | cipher_attack_detected("CRC-32 CBC insertion attack detected"); |
122 | } | 122 | } |
123 | 123 | ||
124 | /* Names of all encryption algorithms. These must match the numbers defined | 124 | /* |
125 | int cipher.h. */ | 125 | * Names of all encryption algorithms. |
126 | * These must match the numbers defined in cipher.h. | ||
127 | */ | ||
126 | static char *cipher_names[] = | 128 | static char *cipher_names[] = |
127 | { | 129 | { |
128 | "none", | 130 | "none", |
@@ -134,9 +136,11 @@ static char *cipher_names[] = | |||
134 | "blowfish" | 136 | "blowfish" |
135 | }; | 137 | }; |
136 | 138 | ||
137 | /* Returns a bit mask indicating which ciphers are supported by this | 139 | /* |
138 | implementation. The bit mask has the corresponding bit set of each | 140 | * Returns a bit mask indicating which ciphers are supported by this |
139 | supported cipher. */ | 141 | * implementation. The bit mask has the corresponding bit set of each |
142 | * supported cipher. | ||
143 | */ | ||
140 | 144 | ||
141 | unsigned int | 145 | unsigned int |
142 | cipher_mask() | 146 | cipher_mask() |
@@ -158,8 +162,10 @@ cipher_name(int cipher) | |||
158 | return cipher_names[cipher]; | 162 | return cipher_names[cipher]; |
159 | } | 163 | } |
160 | 164 | ||
161 | /* Parses the name of the cipher. Returns the number of the corresponding | 165 | /* |
162 | cipher, or -1 on error. */ | 166 | * Parses the name of the cipher. Returns the number of the corresponding |
167 | * cipher, or -1 on error. | ||
168 | */ | ||
163 | 169 | ||
164 | int | 170 | int |
165 | cipher_number(const char *name) | 171 | cipher_number(const char *name) |
@@ -172,8 +178,10 @@ cipher_number(const char *name) | |||
172 | return -1; | 178 | return -1; |
173 | } | 179 | } |
174 | 180 | ||
175 | /* Selects the cipher, and keys if by computing the MD5 checksum of the | 181 | /* |
176 | passphrase and using the resulting 16 bytes as the key. */ | 182 | * Selects the cipher, and keys if by computing the MD5 checksum of the |
183 | * passphrase and using the resulting 16 bytes as the key. | ||
184 | */ | ||
177 | 185 | ||
178 | void | 186 | void |
179 | cipher_set_key_string(CipherContext *context, int cipher, | 187 | cipher_set_key_string(CipherContext *context, int cipher, |
@@ -211,15 +219,18 @@ cipher_set_key(CipherContext *context, int cipher, | |||
211 | /* Initialize the initialization vector. */ | 219 | /* Initialize the initialization vector. */ |
212 | switch (cipher) { | 220 | switch (cipher) { |
213 | case SSH_CIPHER_NONE: | 221 | case SSH_CIPHER_NONE: |
214 | /* Has to stay for authfile saving of private key with | 222 | /* |
215 | no passphrase */ | 223 | * Has to stay for authfile saving of private key with no |
224 | * passphrase | ||
225 | */ | ||
216 | break; | 226 | break; |
217 | 227 | ||
218 | case SSH_CIPHER_3DES: | 228 | case SSH_CIPHER_3DES: |
219 | /* Note: the least significant bit of each byte of key is | 229 | /* |
220 | parity, and must be ignored by the implementation. 16 | 230 | * Note: the least significant bit of each byte of key is |
221 | bytes of key are used (first and last keys are the | 231 | * parity, and must be ignored by the implementation. 16 |
222 | same). */ | 232 | * bytes of key are used (first and last keys are the same). |
233 | */ | ||
223 | if (keylen < 16) | 234 | if (keylen < 16) |
224 | error("Key length %d is insufficient for 3DES.", keylen); | 235 | error("Key length %d is insufficient for 3DES.", keylen); |
225 | des_set_key((void *) padded, context->u.des3.key1); | 236 | des_set_key((void *) padded, context->u.des3.key1); |