summaryrefslogtreecommitdiffstats
path: root/ldap/servers/plugins/rever/rever.c
blob: 10767944c6576de77d1b6e4a740ad4af0799cdfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/** BEGIN COPYRIGHT BLOCK
 * Copyright 2001 Sun Microsystems, Inc.
 * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "dirver.h"

#include "rever.h"

static Slapi_PluginDesc pdesc = { "des-storage-scheme", PLUGIN_MAGIC_VENDOR_STR, PRODUCTTEXT, "DES storage scheme plugin" };

static char *plugin_name = "ReverStoragePlugin";

int
des_cmp( char *userpwd, char *dbpwd )
{
	char *cipher = NULL;

	if ( encode(userpwd, &cipher) != 0 )
		return 1;
	else
		return( strcmp(cipher, dbpwd) );
}

char *
des_enc( char *pwd )
{
	char *cipher = NULL;
	
	if ( encode(pwd, &cipher) != 0 )
		return(NULL);
	else
		return( cipher );
}

char *
des_dec( char *pwd )
{
	char *plain = NULL;
	
	if ( decode(pwd, &plain) != 0 )
		return(NULL);
	else
		return( plain );
}

int
des_init( Slapi_PBlock *pb )
{
	int	rc;
	char *name;

	slapi_log_error( SLAPI_LOG_PLUGIN, plugin_name, "=> des_init\n" );

	rc = slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
	    (void *) SLAPI_PLUGIN_VERSION_01 );
	rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
	    (void *)&pdesc );
	rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_ENC_FN,
	    (void *) des_enc);
	rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_CMP_FN,
	    (void *) des_cmp );
	rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_DEC_FN,
	    (void *) des_dec );
	name = slapi_ch_strdup(REVER_SCHEME_NAME);
	rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_PWD_STORAGE_SCHEME_NAME,
	    name );

	init_des_plugin();

	slapi_log_error( SLAPI_LOG_PLUGIN, plugin_name, "<= des_init %d\n\n", rc );

	return( rc );
}