various changes from plan 9

This commit is contained in:
rsc 2004-12-27 00:14:43 +00:00
parent e1dc7e4511
commit 678ede7e54
5 changed files with 20 additions and 3 deletions

View file

@ -235,6 +235,7 @@ ulong hdate2sec(char*);
int hdatefmt(Fmt*); int hdatefmt(Fmt*);
int hfail(HConnect*, int, ...); int hfail(HConnect*, int, ...);
int hflush(Hio*); int hflush(Hio*);
int hlflush(Hio*);
int hgetc(Hio*); int hgetc(Hio*);
int hgethead(HConnect *c, int many); int hgethead(HConnect *c, int many);
int hinit(Hio*, int, int); int hinit(Hio*, int, int);

View file

@ -3,6 +3,7 @@
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
/* /*
#pragma src "/sys/src/libip" #pragma src "/sys/src/libip"
#pragma lib "libip.a" #pragma lib "libip.a"
@ -106,9 +107,11 @@ long udpwrite(int, Udphdr*, void*, long);
Ipifc* readipifc(char*, Ipifc*, int); Ipifc* readipifc(char*, Ipifc*, int);
void hnputv(void*, uvlong);
void hnputl(void*, uint); void hnputl(void*, uint);
void hnputs(void*, ushort); void hnputs(void*, ushort);
uint nhgetl(void*); uint nhgetl(void*);
uvlong nhgetv(void*);
ushort nhgets(void*); ushort nhgets(void*);
ushort ptclbsum(uchar*, int); ushort ptclbsum(uchar*, int);

View file

@ -715,8 +715,8 @@ extern int unmount(char*, char*);
*/ */
extern int noted(int); extern int noted(int);
extern int notify(void(*)(void*, char*)); extern int notify(void(*)(void*, char*));
extern void notifyenable(char*); extern void noteenable(char*);
extern void notifydisable(char*); extern void notedisable(char*);
extern void notifyon(char*); extern void notifyon(char*);
extern void notifyoff(char*); extern void notifyoff(char*);
extern int p9open(char*, int); extern int p9open(char*, int);

View file

@ -199,6 +199,7 @@ void rc4back(RC4state*, int);
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
typedef struct RSApub RSApub; typedef struct RSApub RSApub;
typedef struct RSApriv RSApriv; typedef struct RSApriv RSApriv;
typedef struct PEMChain PEMChain;
// public/encryption key // public/encryption key
struct RSApub struct RSApub
@ -222,6 +223,13 @@ struct RSApriv
mpint *c2; // (inv p) mod q mpint *c2; // (inv p) mod q
}; };
struct PEMChain
{
PEMChain *next;
uchar *pem;
int pemlen;
};
RSApriv* rsagen(int nlen, int elen, int rounds); RSApriv* rsagen(int nlen, int elen, int rounds);
mpint* rsaencrypt(RSApub *k, mpint *in, mpint *out); mpint* rsaencrypt(RSApub *k, mpint *in, mpint *out);
mpint* rsadecrypt(RSApriv *k, mpint *in, mpint *out); mpint* rsadecrypt(RSApriv *k, mpint *in, mpint *out);
@ -232,7 +240,8 @@ void rsaprivfree(RSApriv*);
RSApub* rsaprivtopub(RSApriv*); RSApub* rsaprivtopub(RSApriv*);
RSApub* X509toRSApub(uchar*, int, char*, int); RSApub* X509toRSApub(uchar*, int, char*, int);
RSApriv* asn1toRSApriv(uchar*, int); RSApriv* asn1toRSApriv(uchar*, int);
uchar* decodepem(char *s, char *type, int *len); uchar* decodepem(char *s, char *type, int *len, char**);
PEMChain* decodepemchain(char *s, char *type);
uchar* X509gen(RSApriv *priv, char *subj, ulong valid[2], int *certlen); uchar* X509gen(RSApriv *priv, char *subj, ulong valid[2], int *certlen);
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
@ -330,6 +339,7 @@ typedef struct TLSconn{
uchar *sessionID; uchar *sessionID;
int certlen, sessionIDlen; int certlen, sessionIDlen;
int (*trace)(char*fmt, ...); int (*trace)(char*fmt, ...);
PEMChain *chain;
} TLSconn; } TLSconn;
// tlshand.c // tlshand.c
@ -343,6 +353,7 @@ extern int okThumbprint(uchar *sha1, Thumbprint *ok);
// readcert.c // readcert.c
extern uchar *readcert(char *filename, int *pcertlen); extern uchar *readcert(char *filename, int *pcertlen);
PEMChain *readcertchain(char *filename);
#if defined(__cplusplus) #if defined(__cplusplus)
} }

View file

@ -13,11 +13,13 @@ void threadexits(char *);
void threadexitsall(char *); void threadexitsall(char *);
void threadsetname(char*, ...); void threadsetname(char*, ...);
void threadsetstate(char*, ...); void threadsetstate(char*, ...);
void threadyield(void);
void _threadready(_Thread*); void _threadready(_Thread*);
void _threadswitch(void); void _threadswitch(void);
void _threadsetsysproc(void); void _threadsetsysproc(void);
void _threadsleep(Rendez*); void _threadsleep(Rendez*);
_Thread *_threadwakeup(Rendez*); _Thread *_threadwakeup(Rendez*);
#define yield threadyield
/* /*
* per proc and thread data * per proc and thread data