Plan 9 from Bell Labs’s /usr/web/sources/contrib/rcbilson/s3venti/crypt.c

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


/* Copyright (c) 2008 Richard Bilson */
#include "stdinc.h"
#include "dat.h"
#include "fns.h"

void
encryptblock(uchar *block, int size, uchar *key)
{
	AESstate aes;
#ifdef __linux__
	int fd = open("/dev/urandom", OREAD);
	read(fd, block, AESbsize);
	close(fd);
#else
	genrandom(block, AESbsize);
#endif
	setupAESstate(&aes, key, 16, block);
	aesCBCencrypt(block+AESbsize, size, &aes);
}

void
decryptblock(uchar *block, int size, uchar *key)
{
	AESstate aes;
	setupAESstate(&aes, key, 16, block);
	aesCBCdecrypt(block+AESbsize, size, &aes);
}

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.