rever.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright 2001 Sun Microsystems, Inc.
  3. * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <sys/types.h>
  9. #include "dirver.h"
  10. #include "rever.h"
  11. static Slapi_PluginDesc pdesc = { "des-storage-scheme", PLUGIN_MAGIC_VENDOR_STR, PRODUCTTEXT, "DES storage scheme plugin" };
  12. static char *plugin_name = "ReverStoragePlugin";
  13. int
  14. des_cmp( char *userpwd, char *dbpwd )
  15. {
  16. char *cipher = NULL;
  17. if ( encode(userpwd, &cipher) != 0 )
  18. return 1;
  19. else
  20. return( strcmp(cipher, dbpwd) );
  21. }
  22. char *
  23. des_enc( char *pwd )
  24. {
  25. char *cipher = NULL;
  26. if ( encode(pwd, &cipher) != 0 )
  27. return(NULL);
  28. else
  29. return( cipher );
  30. }
  31. char *
  32. des_dec( char *pwd )
  33. {
  34. char *plain = NULL;
  35. if ( decode(pwd, &plain) != 0 )
  36. return(NULL);
  37. else
  38. return( plain );
  39. }
  40. int
  41. des_init( Slapi_PBlock *pb )
  42. {
  43. int rc;
  44. char *name;
  45. slapi_log_error( SLAPI_LOG_PLUGIN, plugin_name, "=> des_init\n" );
  46. rc = slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
  47. (void *) SLAPI_PLUGIN_VERSION_01 );
  48. rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
  49. (void *)&pdesc );
  50. rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN,
  51. (void *) des_enc);
  52. rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN,
  53. (void *) des_cmp );
  54. rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DEC_FN,
  55. (void *) des_dec );
  56. name = slapi_ch_strdup(REVER_SCHEME_NAME);
  57. rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME,
  58. name );
  59. init_des_plugin();
  60. slapi_log_error( SLAPI_LOG_PLUGIN, plugin_name, "<= des_init %d\n\n", rc );
  61. return( rc );
  62. }