cipherblowfish.c 631 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "ssh.h"
  2. struct CipherState
  3. {
  4. BFstate enc;
  5. BFstate dec;
  6. };
  7. static CipherState*
  8. initblowfish(Conn *c, int)
  9. {
  10. CipherState *cs;
  11. cs = emalloc(sizeof(CipherState));
  12. setupBFstate(&cs->enc, c->sesskey, SESSKEYLEN, nil);
  13. setupBFstate(&cs->dec, c->sesskey, SESSKEYLEN, nil);
  14. return cs;
  15. }
  16. static void
  17. encryptblowfish(CipherState *cs, uchar *buf, int nbuf)
  18. {
  19. bfCBCencrypt(buf, nbuf, &cs->enc);
  20. }
  21. static void
  22. decryptblowfish(CipherState *cs, uchar *buf, int nbuf)
  23. {
  24. bfCBCdecrypt(buf, nbuf, &cs->dec);
  25. }
  26. Cipher cipherblowfish =
  27. {
  28. SSH_CIPHER_BLOWFISH,
  29. "blowfish",
  30. initblowfish,
  31. encryptblowfish,
  32. decryptblowfish,
  33. };