cipherblowfish.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "ssh.h"
  10. struct CipherState
  11. {
  12. BFstate enc;
  13. BFstate dec;
  14. };
  15. static CipherState*
  16. initblowfish(Conn *c, int)
  17. {
  18. CipherState *cs;
  19. cs = emalloc(sizeof(CipherState));
  20. setupBFstate(&cs->enc, c->sesskey, SESSKEYLEN, nil);
  21. setupBFstate(&cs->dec, c->sesskey, SESSKEYLEN, nil);
  22. return cs;
  23. }
  24. static void
  25. encryptblowfish(CipherState *cs, uint8_t *buf, int nbuf)
  26. {
  27. bfCBCencrypt(buf, nbuf, &cs->enc);
  28. }
  29. static void
  30. decryptblowfish(CipherState *cs, uint8_t *buf, int nbuf)
  31. {
  32. bfCBCdecrypt(buf, nbuf, &cs->dec);
  33. }
  34. Cipher cipherblowfish =
  35. {
  36. SSH_CIPHER_BLOWFISH,
  37. "blowfish",
  38. initblowfish,
  39. encryptblowfish,
  40. decryptblowfish,
  41. };