version 1.2, 1999/09/26 21:02:15 |
version 1.3, 1999/09/26 22:53:25 |
|
|
/* memcpy(&iv1, iv2, 8); */ /* Note how iv1 == iv2 on entry and exit. */ |
/* memcpy(&iv1, iv2, 8); */ /* Note how iv1 == iv2 on entry and exit. */ |
} |
} |
|
|
#ifdef WITH_BLOWFISH |
|
/* |
/* |
* SSH uses a variation on Blowfish, all bytes must be swapped before |
* SSH uses a variation on Blowfish, all bytes must be swapped before |
* and after encryption/decryption. Thus the swap_bytes stuff (yuk). |
* and after encryption/decryption. Thus the swap_bytes stuff (yuk). |
|
|
*dst++ = t.i; |
*dst++ = t.i; |
} |
} |
} |
} |
#endif /* WITH_BLOWFISH */ |
|
|
|
void (*cipher_attack_detected)(const char *fmt, ...) = fatal; |
void (*cipher_attack_detected)(const char *fmt, ...) = fatal; |
|
|
|
|
#else |
#else |
"no rc4", |
"no rc4", |
#endif |
#endif |
#ifdef WITH_BLOWFISH |
|
"blowfish" |
"blowfish" |
#else |
|
"no blowfish" |
|
#endif |
|
}; |
}; |
|
|
/* Returns a bit mask indicating which ciphers are supported by this |
/* Returns a bit mask indicating which ciphers are supported by this |
|
|
#ifdef WITH_RC4 |
#ifdef WITH_RC4 |
mask |= 1 << SSH_CIPHER_RC4; |
mask |= 1 << SSH_CIPHER_RC4; |
#endif |
#endif |
#ifdef WITH_BLOWFISH |
|
mask |= 1 << SSH_CIPHER_BLOWFISH; |
mask |= 1 << SSH_CIPHER_BLOWFISH; |
#endif |
|
return mask; |
return mask; |
} |
} |
|
|
|
|
break; |
break; |
#endif /* WITH_RC4 */ |
#endif /* WITH_RC4 */ |
|
|
#ifdef WITH_BLOWFISH |
|
case SSH_CIPHER_BLOWFISH: |
case SSH_CIPHER_BLOWFISH: |
BF_set_key(&context->u.bf.key, keylen, padded); |
BF_set_key(&context->u.bf.key, keylen, padded); |
memset(context->u.bf.iv, 0, 8); |
memset(context->u.bf.iv, 0, 8); |
break; |
break; |
#endif /* WITH_BLOWFISH */ |
|
|
|
default: |
default: |
fatal("cipher_set_key: unknown cipher: %d", cipher); |
fatal("cipher_set_key: unknown cipher: %d", cipher); |
|
|
break; |
break; |
#endif /* WITH_RC4 */ |
#endif /* WITH_RC4 */ |
|
|
#ifdef WITH_BLOWFISH |
|
case SSH_CIPHER_BLOWFISH: |
case SSH_CIPHER_BLOWFISH: |
swap_bytes(src, dest, len); |
swap_bytes(src, dest, len); |
BF_cbc_encrypt(dest, dest, len, |
BF_cbc_encrypt(dest, dest, len, |
&context->u.bf.key, context->u.bf.iv, BF_ENCRYPT); |
&context->u.bf.key, context->u.bf.iv, BF_ENCRYPT); |
swap_bytes(dest, dest, len); |
swap_bytes(dest, dest, len); |
break; |
break; |
#endif /* WITH_BLOWFISH */ |
|
|
|
default: |
default: |
fatal("cipher_encrypt: unknown cipher: %d", context->type); |
fatal("cipher_encrypt: unknown cipher: %d", context->type); |
|
|
break; |
break; |
#endif /* WITH_RC4 */ |
#endif /* WITH_RC4 */ |
|
|
#ifdef WITH_BLOWFISH |
|
case SSH_CIPHER_BLOWFISH: |
case SSH_CIPHER_BLOWFISH: |
detect_cbc_attack(src, len); |
detect_cbc_attack(src, len); |
swap_bytes(src, dest, len); |
swap_bytes(src, dest, len); |
|
|
&context->u.bf.key, context->u.bf.iv, BF_DECRYPT); |
&context->u.bf.key, context->u.bf.iv, BF_DECRYPT); |
swap_bytes(dest, dest, len); |
swap_bytes(dest, dest, len); |
break; |
break; |
#endif /* WITH_BLOWFISH */ |
|
|
|
default: |
default: |
fatal("cipher_decrypt: unknown cipher: %d", context->type); |
fatal("cipher_decrypt: unknown cipher: %d", context->type); |