/* taken from ClawsMail passcrypt.c */
static void passcrypt_decrypt(gchar *password, guint len)
{
	char des_key[8] = PASSCRYPT_KEY;

	des_setparity(des_key);
	ecb_crypt(des_key, password, len, DES_DECRYPT);
}
Ejemplo n.º 2
0
void des_encrypt(const char *key, char *data, int len)
{
    char pkey[8];
    strncpy(pkey, key, 8);
    des_setparity(pkey);
    do {
        data[len++] = '\x8';
    } while (len % 8 != 0);
    ecb_crypt(pkey, data, len, DES_ENCRYPT);
}
Ejemplo n.º 3
0
/*
 * Turn password into DES key
 */
void
passwd2des(char *pw, char *key)
{
	int i;

	bzero(key, 8);
	for (i = 0; *pw; i = (i+1)%8) {
		key[i] ^= *pw++ << 1;
	}
	des_setparity(key);
}
Ejemplo n.º 4
0
/*
 * Turn password into DES key
 */
void
passwd2des_internal (char *pw, char *key)
{
    int i;

    memset (key, 0, 8);
    for (i = 0; *pw && i < 8; ++i)
        key[i] ^= *pw++ << 1;

    des_setparity (key);
}
Ejemplo n.º 5
0
/* ARGSUSED */
des_block *
key_gen_1_svc_prog(void *v, struct svc_req *s)
{
	struct timeval time;
	static des_block keygen;
	static des_block key;

	gettimeofday(&time, NULL);
	keygen.key.high += (time.tv_sec ^ time.tv_usec);
	keygen.key.low += (time.tv_sec ^ time.tv_usec);
	ecb_crypt((char *)&masterkey, (char *)&keygen, sizeof (keygen),
		DES_ENCRYPT | DES_HW);
	key = keygen;
	des_setparity((char *)&key);
	if (debugging) {
		fprintf(stderr, "gen() = %08x%08x\n", key.key.high,
					key.key.low);
		fflush(stderr);
	}
	return (&key);
}