aboutsummaryrefslogtreecommitdiff
path: root/man/man3/encrypt.3
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-02-11 19:21:47 +0000
committerrsc <devnull@localhost>2005-02-11 19:21:47 +0000
commitd93fca6a7ab52f518d3e8aca1fc94139313b97ad (patch)
treeb2c26f27a62a45314add2905be70f1c0385c4e19 /man/man3/encrypt.3
parent7442c7ac4b30dd1945d00516931f548d65d3d814 (diff)
downloadplan9port-d93fca6a7ab52f518d3e8aca1fc94139313b97ad.tar.gz
plan9port-d93fca6a7ab52f518d3e8aca1fc94139313b97ad.tar.bz2
plan9port-d93fca6a7ab52f518d3e8aca1fc94139313b97ad.zip
new man pages
Diffstat (limited to 'man/man3/encrypt.3')
-rw-r--r--man/man3/encrypt.387
1 files changed, 87 insertions, 0 deletions
diff --git a/man/man3/encrypt.3 b/man/man3/encrypt.3
new file mode 100644
index 00000000..213f81da
--- /dev/null
+++ b/man/man3/encrypt.3
@@ -0,0 +1,87 @@
+.TH ENCRYPT 2
+.SH NAME
+encrypt, decrypt, netcrypt \- DES encryption
+.SH SYNOPSIS
+.B #include <u.h>
+.br
+.B #include <libc.h>
+.PP
+.B
+int encrypt(void *key, void *data, int len)
+.PP
+.B
+int decrypt(void *key, void *data, int len)
+.PP
+.B
+int netcrypt(void *key, void *data)
+.SH DESCRIPTION
+.I Encrypt
+and
+.I decrypt
+perform DES encryption and decryption.
+.I Key
+is an array of
+.B DESKEYLEN
+(defined as 7 in
+.BR <auth.h> )
+bytes containing the encryption key.
+.I Data
+is an array of
+.I len
+bytes;
+it must be at least 8 bytes long.
+The bytes are encrypted or decrypted in place.
+.PP
+The DES algorithm encrypts an individual 8-byte block of data.
+.I Encrypt
+uses the following method to encrypt data longer than 8 bytes.
+The first 8 bytes are encrypted as usual.
+The last byte of the encrypted result
+is prefixed to the next 7 unencrypted bytes to make the next 8
+bytes to encrypt.
+This is repeated until fewer than 7 bytes remain unencrypted.
+Any remaining unencrypted bytes are encrypted with enough of the preceding
+encrypted bytes to make a full 8-byte block.
+.I Decrypt
+uses the inverse algorithm.
+.PP
+.I Netcrypt
+performs the same encryption as a SecureNet Key.
+.I Data
+points to an
+.SM ASCII
+string of decimal digits with numeric value between 0 and 10000.
+These digits are copied into an 8-byte buffer with trailing binary zero fill
+and encrypted as one DES block.
+The first four bytes are each formatted as two digit
+.SM ASCII
+hexadecimal numbers,
+and the string is copied into
+.IR data .
+.SH SOURCE
+.B /sys/src/libc/port
+.SH DIAGNOSTICS
+These routines return 1 if the data was encrypted,
+and 0 if the encryption fails.
+.I Encrypt
+and
+.I decrypt
+fail if the data passed is less than 8 bytes long.
+.I Netcrypt
+can fail if it is passed invalid data.
+.\" .SH SEE ALSO
+.\" .IR securenet (8)
+.SH BUGS
+The implementation is broken in a way that makes
+it unsuitable for anything but authentication.
+.PP
+To avoid name conflicts with the underlying system,
+.IR encrypt
+and
+.IR decrypt
+are preprocessor macros defined as
+.IR p9encrypt
+and
+.IR p9decrypt ;
+see
+.IR intro (3).