diff options
author | rsc <devnull@localhost> | 2006-04-01 19:24:03 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-04-01 19:24:03 +0000 |
commit | cbeb0b26e4c7caa8d1b47de791a7418dc20a4567 (patch) | |
tree | e0f7e445de1aa22a42ef873dc4b1118a8105ae93 /include/libsec.h | |
parent | 226d80b8213821af0cbf092d1507c52b504fd368 (diff) | |
download | plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.tar.gz plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.tar.bz2 plan9port-cbeb0b26e4c7caa8d1b47de791a7418dc20a4567.zip |
Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.
Diffstat (limited to 'include/libsec.h')
-rw-r--r-- | include/libsec.h | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/include/libsec.h b/include/libsec.h index c0c964fc..73d22c75 100644 --- a/include/libsec.h +++ b/include/libsec.h @@ -14,9 +14,9 @@ AUTOLIB(sec) typedef struct mpint mpint; #endif -///////////////////////////////////////////////////////// -// AES definitions -///////////////////////////////////////////////////////// +/*******************************************************/ +/* AES definitions */ +/*******************************************************/ enum { @@ -41,9 +41,9 @@ void setupAESstate(AESstate *s, uchar key[], int keybytes, uchar *ivec); void aesCBCencrypt(uchar *p, int len, AESstate *s); void aesCBCdecrypt(uchar *p, int len, AESstate *s); -///////////////////////////////////////////////////////// -// Blowfish Definitions -///////////////////////////////////////////////////////// +/*******************************************************/ +/* Blowfish Definitions */ +/*******************************************************/ enum { @@ -51,7 +51,7 @@ enum BFrounds = 16 }; -// 16-round Blowfish +/* 16-round Blowfish */ typedef struct BFstate BFstate; struct BFstate { @@ -70,16 +70,16 @@ void bfCBCdecrypt(uchar*, int, BFstate*); void bfECBencrypt(uchar*, int, BFstate*); void bfECBdecrypt(uchar*, int, BFstate*); -///////////////////////////////////////////////////////// -// DES definitions -///////////////////////////////////////////////////////// +/*******************************************************/ +/* DES definitions */ +/*******************************************************/ enum { DESbsize= 8 }; -// single des +/* single des */ typedef struct DESstate DESstate; struct DESstate { @@ -97,12 +97,12 @@ void desCBCdecrypt(uchar*, int, DESstate*); void desECBencrypt(uchar*, int, DESstate*); void desECBdecrypt(uchar*, int, DESstate*); -// for backward compatibility with 7 byte DES key format +/* for backward compatibility with 7 byte DES key format */ void des56to64(uchar *k56, uchar *k64); void des64to56(uchar *k64, uchar *k56); void key_setup(uchar[7], ulong[32]); -// triple des encrypt/decrypt orderings +/* triple des encrypt/decrypt orderings */ enum { DES3E= 0, DES3D= 1, @@ -128,9 +128,9 @@ void des3CBCdecrypt(uchar*, int, DES3state*); void des3ECBencrypt(uchar*, int, DES3state*); void des3ECBdecrypt(uchar*, int, DES3state*); -///////////////////////////////////////////////////////// -// digests -///////////////////////////////////////////////////////// +/*******************************************************/ +/* digests */ +/*******************************************************/ enum { @@ -162,27 +162,27 @@ DigestState* hmac_sha1(uchar*, ulong, uchar*, ulong, uchar*, DigestState*); char* sha1pickle(SHA1state*); SHA1state* sha1unpickle(char*); -///////////////////////////////////////////////////////// -// random number generation -///////////////////////////////////////////////////////// +/*******************************************************/ +/* random number generation */ +/*******************************************************/ void genrandom(uchar *buf, int nbytes); void prng(uchar *buf, int nbytes); ulong fastrand(void); ulong nfastrand(ulong); -///////////////////////////////////////////////////////// -// primes -///////////////////////////////////////////////////////// -void genprime(mpint *p, int n, int accuracy); // generate an n bit probable prime -void gensafeprime(mpint *p, mpint *alpha, int n, int accuracy); // prime and generator -void genstrongprime(mpint *p, int n, int accuracy); // generate an n bit strong prime +/*******************************************************/ +/* primes */ +/*******************************************************/ +void genprime(mpint *p, int n, int accuracy); /* generate an n bit probable prime */ +void gensafeprime(mpint *p, mpint *alpha, int n, int accuracy); /* prime and generator */ +void genstrongprime(mpint *p, int n, int accuracy); /* generate an n bit strong prime */ void DSAprimes(mpint *q, mpint *p, uchar seed[SHA1dlen]); -int probably_prime(mpint *n, int nrep); // miller-rabin test -int smallprimetest(mpint *p); // returns -1 if not prime, 0 otherwise +int probably_prime(mpint *n, int nrep); /* miller-rabin test */ +int smallprimetest(mpint *p); /* returns -1 if not prime, 0 otherwise */ -///////////////////////////////////////////////////////// -// rc4 -///////////////////////////////////////////////////////// +/*******************************************************/ +/* rc4 */ +/*******************************************************/ typedef struct RC4state RC4state; struct RC4state { @@ -196,33 +196,33 @@ void rc4(RC4state*, uchar*, int); void rc4skip(RC4state*, int); void rc4back(RC4state*, int); -///////////////////////////////////////////////////////// -// rsa -///////////////////////////////////////////////////////// +/*******************************************************/ +/* rsa */ +/*******************************************************/ typedef struct RSApub RSApub; typedef struct RSApriv RSApriv; typedef struct PEMChain PEMChain; -// public/encryption key +/* public/encryption key */ struct RSApub { - mpint *n; // modulus - mpint *ek; // exp (encryption key) + mpint *n; /* modulus */ + mpint *ek; /* exp (encryption key) */ }; -// private/decryption key +/* private/decryption key */ struct RSApriv { RSApub pub; - mpint *dk; // exp (decryption key) + mpint *dk; /* exp (decryption key) */ - // precomputed values to help with chinese remainder theorem calc + /* precomputed values to help with chinese remainder theorem calc */ mpint *p; mpint *q; - mpint *kp; // dk mod p-1 - mpint *kq; // dk mod q-1 - mpint *c2; // (inv p) mod q + mpint *kp; /* dk mod p-1 */ + mpint *kq; /* dk mod q-1 */ + mpint *c2; /* (inv p) mod q */ }; struct PEMChain @@ -248,29 +248,29 @@ uchar* X509gen(RSApriv *priv, char *subj, ulong valid[2], int *certlen); RSApriv* rsafill(mpint *n, mpint *ek, mpint *dk, mpint *p, mpint *q); uchar* X509req(RSApriv *priv, char *subj, int *certlen); -///////////////////////////////////////////////////////// -// elgamal -///////////////////////////////////////////////////////// +/*******************************************************/ +/* elgamal */ +/*******************************************************/ typedef struct EGpub EGpub; typedef struct EGpriv EGpriv; typedef struct EGsig EGsig; -// public/encryption key +/* public/encryption key */ struct EGpub { - mpint *p; // modulus - mpint *alpha; // generator - mpint *key; // (encryption key) alpha**secret mod p + mpint *p; /* modulus */ + mpint *alpha; /* generator */ + mpint *key; /* (encryption key) alpha**secret mod p */ }; -// private/decryption key +/* private/decryption key */ struct EGpriv { EGpub pub; - mpint *secret; // (decryption key) + mpint *secret; /* (decryption key) */ }; -// signature +/* signature */ struct EGsig { mpint *r, *s; @@ -289,30 +289,30 @@ EGsig* egsigalloc(void); void egsigfree(EGsig*); EGpub* egprivtopub(EGpriv*); -///////////////////////////////////////////////////////// -// dsa -///////////////////////////////////////////////////////// +/*******************************************************/ +/* dsa */ +/*******************************************************/ typedef struct DSApub DSApub; typedef struct DSApriv DSApriv; typedef struct DSAsig DSAsig; -// public/encryption key +/* public/encryption key */ struct DSApub { - mpint *p; // modulus - mpint *q; // group order, q divides p-1 - mpint *alpha; // group generator - mpint *key; // (encryption key) alpha**secret mod p + mpint *p; /* modulus */ + mpint *q; /* group order, q divides p-1 */ + mpint *alpha; /* group generator */ + mpint *key; /* (encryption key) alpha**secret mod p */ }; -// private/decryption key +/* private/decryption key */ struct DSApriv { DSApub pub; - mpint *secret; // (decryption key) + mpint *secret; /* (decryption key) */ }; -// signature +/* signature */ struct DSAsig { mpint *r, *s; @@ -330,33 +330,33 @@ void dsasigfree(DSAsig*); DSApub* dsaprivtopub(DSApriv*); DSApriv* asn1toDSApriv(uchar*, int); -///////////////////////////////////////////////////////// -// TLS -///////////////////////////////////////////////////////// +/*******************************************************/ +/* TLS */ +/*******************************************************/ typedef struct Thumbprint{ struct Thumbprint *next; uchar sha1[SHA1dlen]; } Thumbprint; typedef struct TLSconn{ - char dir[40]; // connection directory - uchar *cert; // certificate (local on input, remote on output) + char dir[40]; /* connection directory */ + uchar *cert; /* certificate (local on input, remote on output) */ uchar *sessionID; int certlen, sessionIDlen; int (*trace)(char*fmt, ...); PEMChain *chain; } TLSconn; -// tlshand.c +/* tlshand.c */ extern int tlsClient(int fd, TLSconn *c); extern int tlsServer(int fd, TLSconn *c); -// thumb.c +/* thumb.c */ extern Thumbprint* initThumbprints(char *ok, char *crl); extern void freeThumbprints(Thumbprint *ok); extern int okThumbprint(uchar *sha1, Thumbprint *ok); -// readcert.c +/* readcert.c */ extern uchar *readcert(char *filename, int *pcertlen); PEMChain *readcertchain(char *filename); |