ck_des.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. C K _ D E S . C - libDES interface for Kermit 95"
  3. Copyright (C) 1998, 2001, Trustees of Columbia University in the City of New
  4. York. The C-Kermit software may not be, in whole or in part, licensed or
  5. sold for profit as a software product itself, nor may it be included in or
  6. distributed with commercial products or otherwise distributed by commercial
  7. concerns to their clients or customers without written permission of the
  8. Office of Kermit Development and Distribution, Columbia University. This
  9. copyright notice must not be removed, altered, or obscured.
  10. Author:
  11. Jeffrey E Altman (jaltman@secure-endpoints.com)
  12. */
  13. /*
  14. This file contains wrappers so that the following functions will be imported
  15. into the k95crypt.dll/k2crypt.dll files in such a form that they can be
  16. re-exported to k95.exe/k2.exe. This subset of the DES library is needed to
  17. provide DES based Kerberos authentication.
  18. */
  19. #ifdef LIBDES
  20. /* The following is specific to my installation, but since I'm the only one */
  21. /* that uses this file ... */
  22. #include "ckcdeb.h"
  23. #include "ckuath.h"
  24. #define CK_DES_C
  25. #include "ckuat2.h"
  26. #ifdef NT
  27. #ifdef _M_ALPHA
  28. #include <c:\srp\des\des.h>
  29. #else
  30. #include <c:\src\srp\des\des.h>
  31. #endif
  32. #else
  33. #include <c:\srp\des\des.h>
  34. #endif
  35. int
  36. libdes_random_key(des_cblock B)
  37. {
  38. des_random_key(B);
  39. return(0);
  40. }
  41. void
  42. libdes_random_seed(des_cblock B)
  43. {
  44. des_random_seed(B);
  45. }
  46. void
  47. libdes_key_sched(des_cblock * B, des_key_schedule S)
  48. {
  49. des_key_sched(B,S);
  50. }
  51. void
  52. libdes_ecb_encrypt(des_cblock * B1, des_cblock * B2, des_key_schedule S, int n)
  53. {
  54. des_ecb_encrypt(B1,B2,S,n);
  55. }
  56. int
  57. libdes_string_to_key(char * s, des_cblock * B)
  58. {
  59. des_string_to_key(s,B);
  60. return(0);
  61. }
  62. void
  63. libdes_fixup_key_parity(des_cblock * B)
  64. {
  65. des_set_odd_parity(B);
  66. }
  67. void
  68. libdes_pcbc_encrypt(des_cblock *input, des_cblock *output, long length,
  69. des_key_schedule schedule, des_cblock *ivec, int enc)
  70. {
  71. des_pcbc_encrypt(input,output,length,schedule,ivec,enc);
  72. }
  73. void
  74. libdes_dll_init(struct _crypt_dll_init * init)
  75. {
  76. init->p_install_funcs("libdes_random_key",libdes_random_key);
  77. init->p_install_funcs("libdes_random_seed",libdes_random_seed);
  78. init->p_install_funcs("libdes_key_sched",libdes_key_sched);
  79. init->p_install_funcs("libdes_ecb_encrypt",libdes_ecb_encrypt);
  80. init->p_install_funcs("libdes_string_to_key",libdes_string_to_key);
  81. init->p_install_funcs("libdes_fixup_key_parity",libdes_fixup_key_parity);
  82. init->p_install_funcs("libdes_pcbc_encrypt",libdes_pcbc_encrypt);
  83. }
  84. #endif /* LIBDES */