9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: presotto@plan9.bell-labs.com presotto@plan9.bell-labs.com
Subject: [9fans] encrypt(void*, void*, int) and authentication
Date: Mon,  8 May 2000 08:24:34 -0400	[thread overview]
Message-ID: <20000508122434.hfoqfYD01emklPErw2sPMZ-11ZH6At4oG1yPjlg1Je0@z> (raw)

#include <u.h>
#include <libc.h>
#include <auth.h>
#include <mp.h>
#include <libsec.h>

/*
 * destructively encrypt the buffer, which
 * must be at least 8 characters long.
 */
int
encrypt(void *key, void *vbuf, int n)
{
	ulong ekey[32];
	uchar *buf;
	int i, r;

	if(n < 8)
		return 0;
	key_setup(key, ekey);
	buf = vbuf;
	n--;
	r = n % 7;
	n /= 7;
	for(i = 0; i < n; i++){
		block_cipher(ekey, buf, 0);
		buf += 7;
	}
	if(r)
		block_cipher(ekey, buf - 7 + r, 0);
	return 1;
}

/*
 * destructively decrypt the buffer, which
 * must be at least 8 characters long.
 */
int
decrypt(void *key, void *vbuf, int n)
{
	ulong ekey[128];
	uchar *buf;
	int i, r;

	if(n < 8)
		return 0;
	key_setup(key, ekey);
	buf = vbuf;
	n--;
	r = n % 7;
	n /= 7;
	buf += n * 7;
	if(r)
		block_cipher(ekey, buf - 7 + r, 1);
	for(i = 0; i < n; i++){
		buf -= 7;
		block_cipher(ekey, buf, 1);
	}
	return 1;
}

block_cipher is des




             reply	other threads:[~2000-05-08 12:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-08 12:24 presotto [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-05-08 21:13 Roman
2000-05-08 15:46 forsyth
2000-05-08 13:06 Lucio
2000-05-08 12:45 Lucio
2000-05-08 12:37 Lucio
2000-05-08 12:31 rob
2000-05-08 12:28 presotto
2000-05-08 12:27 Markus
2000-05-08 12:16 Lucio
2000-05-08 11:12 Roman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000508122434.hfoqfYD01emklPErw2sPMZ-11ZH6At4oG1yPjlg1Je0@z \
    --to=presotto@plan9.bell-labs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).