Plan 9 from Bell Labs’s /usr/web/sources/contrib/quanstro/root/sys/src/cmd/ssh2/cipher3des.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include <u.h>
#include <libc.h>
#include <mp.h>
#include <fcall.h>
#include <thread.h>
#include <9p.h>
#include <libsec.h>
#include "sshtun.h"

struct CipherState
{
	DES3state state;
};

static CipherState*
init3des(Conn *c, int dir)
{
	CipherState *cs;
	uchar key[3][8];

	cs = emalloc9p(sizeof(CipherState));
	if(dir){
		memmove(key, c->s2cek, 24);
		setupDES3state(&cs->state, key, c->s2civ);
	}
	else{
		memmove(key, c->c2sek, 24);
		setupDES3state(&cs->state, key, c->c2siv);
	}
	return cs;
}

static void
encrypt3des(CipherState *cs, uchar *buf, int nbuf)
{
	des3CBCencrypt(buf, nbuf, &cs->state);
}

static void
decrypt3des(CipherState *cs, uchar *buf, int nbuf)
{
	des3CBCdecrypt(buf, nbuf, &cs->state);
}

Cipher cipher3des =
{
	"3des-cbc",
	8,
	init3des,
	encrypt3des,
	decrypt3des,
};


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.