cipherdes.c 567 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "ssh.h"
  2. struct CipherState
  3. {
  4. DESstate enc;
  5. DESstate dec;
  6. };
  7. static CipherState*
  8. initdes(Conn *c, int)
  9. {
  10. CipherState *cs;
  11. cs = emalloc(sizeof(CipherState));
  12. setupDESstate(&cs->enc, c->sesskey, nil);
  13. setupDESstate(&cs->dec, c->sesskey, nil);
  14. return cs;
  15. }
  16. static void
  17. encryptdes(CipherState *cs, uchar *buf, int nbuf)
  18. {
  19. desCBCencrypt(buf, nbuf, &cs->enc);
  20. }
  21. static void
  22. decryptdes(CipherState *cs, uchar *buf, int nbuf)
  23. {
  24. desCBCdecrypt(buf, nbuf, &cs->dec);
  25. }
  26. Cipher cipherdes =
  27. {
  28. SSH_CIPHER_DES,
  29. "des",
  30. initdes,
  31. encryptdes,
  32. decryptdes,
  33. };