summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/auth
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2016-04-11 20:23:34 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2016-04-11 20:23:34 +0200
commit464763202be7bdafa703c8c2ecfe1f4a5142f26f (patch)
tree76487fcd0124776ac366efb1bbcb4b408aea46a9 /sys/src/ape/lib/auth
parent21aee5d8cbd1ebae796cdc58404b8d8902738370 (diff)
ape: add libauth, libbio, libmp and libsec as replacements for openssl
Diffstat (limited to 'sys/src/ape/lib/auth')
-rw-r--r--sys/src/ape/lib/auth/authsrv.h45
-rw-r--r--sys/src/ape/lib/auth/fcall.h20
-rw-r--r--sys/src/ape/lib/auth/mkfile43
3 files changed, 108 insertions, 0 deletions
diff --git a/sys/src/ape/lib/auth/authsrv.h b/sys/src/ape/lib/auth/authsrv.h
new file mode 100644
index 000000000..498dc9870
--- /dev/null
+++ b/sys/src/ape/lib/auth/authsrv.h
@@ -0,0 +1,45 @@
+enum
+{
+ ANAMELEN= 28, /* name max size in previous proto */
+ AERRLEN= 64, /* errstr max size in previous proto */
+ DOMLEN= 48, /* authentication domain name length */
+ DESKEYLEN= 7, /* encrypt/decrypt des key length */
+ AESKEYLEN= 16, /* encrypt/decrypt aes key length */
+
+ CHALLEN= 8, /* plan9 sk1 challenge length */
+ NETCHLEN= 16, /* max network challenge length (used in AS protocol) */
+ CONFIGLEN= 14,
+ SECRETLEN= 32, /* secret max size */
+
+ NONCELEN= 32,
+
+ KEYDBOFF= 8, /* bytes of random data at key file's start */
+ OKEYDBLEN= ANAMELEN+DESKEYLEN+4+2, /* old key file entry length */
+ KEYDBLEN= OKEYDBLEN+SECRETLEN, /* key file entry length */
+ OMD5LEN= 16,
+
+ /* AuthPAK constants */
+ PAKKEYLEN= 32,
+ PAKSLEN= (448+7)/8, /* ed448 scalar */
+ PAKPLEN= 4*PAKSLEN, /* point in extended format X,Y,Z,T */
+ PAKHASHLEN= 2*PAKPLEN, /* hashed points PM,PN */
+ PAKXLEN= PAKSLEN, /* random scalar secret key */
+ PAKYLEN= PAKSLEN, /* decaf encoded public key */
+};
+
+typedef struct Authkey Authkey;
+struct Authkey
+{
+ char des[DESKEYLEN]; /* DES key from password */
+ uchar aes[AESKEYLEN]; /* AES key from password */
+ uchar pakkey[PAKKEYLEN]; /* shared key from AuthPAK exchange (see authpak_finish()) */
+ uchar pakhash[PAKHASHLEN]; /* secret hash from AES key and user name (see authpak_hash()) */
+};
+
+/*
+ * convert ascii password to auth key
+ */
+extern void passtokey(Authkey*, char*);
+
+extern void passtodeskey(char key[DESKEYLEN], char *p);
+extern void passtoaeskey(uchar key[AESKEYLEN], char *p);
diff --git a/sys/src/ape/lib/auth/fcall.h b/sys/src/ape/lib/auth/fcall.h
new file mode 100644
index 000000000..6da9bbe1d
--- /dev/null
+++ b/sys/src/ape/lib/auth/fcall.h
@@ -0,0 +1,20 @@
+#define VERSION9P "9P2000"
+#define MAXWELEM 16
+
+#define GBIT8(p) ((p)[0])
+#define GBIT16(p) ((p)[0]|((p)[1]<<8))
+#define GBIT32(p) ((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24))
+#define GBIT64(p) ((u32int)((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)) |\
+ ((vlong)((p)[4]|((p)[5]<<8)|((p)[6]<<16)|((p)[7]<<24)) << 32))
+
+#define PBIT8(p,v) (p)[0]=(v)
+#define PBIT16(p,v) (p)[0]=(v);(p)[1]=(v)>>8
+#define PBIT32(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24
+#define PBIT64(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24;\
+ (p)[4]=(v)>>32;(p)[5]=(v)>>40;(p)[6]=(v)>>48;(p)[7]=(v)>>56
+
+#define BIT8SZ 1
+#define BIT16SZ 2
+#define BIT32SZ 4
+#define BIT64SZ 8
+#define QIDSZ (BIT8SZ+BIT32SZ+BIT64SZ)
diff --git a/sys/src/ape/lib/auth/mkfile b/sys/src/ape/lib/auth/mkfile
new file mode 100644
index 000000000..fa30d3a83
--- /dev/null
+++ b/sys/src/ape/lib/auth/mkfile
@@ -0,0 +1,43 @@
+APE=/sys/src/ape
+<$APE/config
+
+LIB=/$objtype/lib/ape/libauth.a
+OFILES=\
+ amount.$O\
+ amount_getkey.$O\
+ attr.$O\
+ auth_attr.$O\
+ auth_challenge.$O\
+ auth_chuid.$O\
+ auth_getkey.$O\
+ auth_getuserpasswd.$O\
+ auth_proxy.$O\
+ auth_respond.$O\
+ auth_rpc.$O\
+ auth_userpasswd.$O\
+ auth_wep.$O\
+ login.$O\
+ newns.$O\
+ noworld.$O\
+ passtokey.$O\
+
+HFILES=\
+ /sys/include/ape/auth.h\
+ /sys/src/libauth/authlocal.h\
+ ../9/libc.h
+
+UPDATE=\
+ mkfile\
+ $HFILES\
+ ${OFILES:%.$O=%.c}\
+ ${LIB:/$objtype/%=/386/%}\
+
+</sys/src/cmd/mksyslib
+
+CFLAGS=-TVwc -D_POSIX_SOURCE -D_PLAN9_SOURCE -D_NET_EXTENSION -I. -I../9 -I/sys/src/libauth
+
+%.$O: /sys/src/libauth/%.c
+ $CC $CFLAGS /sys/src/libauth/$stem.c
+
+passtokey.$O: /sys/src/libauthsrv/passtokey.c
+ $CC $CFLAGS /sys/src/libauthsrv/passtokey.c