tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

vfyserv.h (3008B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 #ifndef SSLSAMPLE_H
      6 #define SSLSAMPLE_H
      7 
      8 /* Generic header files */
      9 
     10 #include <stdio.h>
     11 #include <string.h>
     12 
     13 /* NSPR header files */
     14 
     15 #include "nspr.h"
     16 #include "prerror.h"
     17 #include "prnetdb.h"
     18 
     19 /* NSS header files */
     20 
     21 #include "pk11func.h"
     22 #include "secitem.h"
     23 #include "ssl.h"
     24 #include "certt.h"
     25 #include "nss.h"
     26 #include "secder.h"
     27 #include "keyhi.h"
     28 #include "sslproto.h"
     29 
     30 /* Custom header files */
     31 
     32 /*
     33 #include "sslerror.h"
     34 */
     35 
     36 #define BUFFER_SIZE 10240
     37 
     38 /* Declare SSL cipher suites. */
     39 
     40 extern int cipherSuites[];
     41 extern int ssl3CipherSuites[];
     42 
     43 /* Data buffer read from a socket. */
     44 typedef struct DataBufferStr {
     45    char data[BUFFER_SIZE];
     46    int index;
     47    int remaining;
     48    int dataStart;
     49    int dataEnd;
     50 } DataBuffer;
     51 
     52 /* SSL callback routines. */
     53 
     54 char *myPasswd(PK11SlotInfo *info, PRBool retry, void *arg);
     55 
     56 SECStatus myAuthCertificate(void *arg, PRFileDesc *socket,
     57                            PRBool checksig, PRBool isServer);
     58 
     59 SECStatus myBadCertHandler(void *arg, PRFileDesc *socket);
     60 
     61 void myHandshakeCallback(PRFileDesc *socket, void *arg);
     62 
     63 SECStatus myGetClientAuthData(void *arg, PRFileDesc *socket,
     64                              struct CERTDistNamesStr *caNames,
     65                              struct CERTCertificateStr **pRetCert,
     66                              struct SECKEYPrivateKeyStr **pRetKey);
     67 
     68 /* Disable all v2/v3 SSL ciphers. */
     69 
     70 void disableAllSSLCiphers(void);
     71 
     72 /* Error and information utilities. */
     73 
     74 void errWarn(char *function);
     75 
     76 void exitErr(char *function);
     77 
     78 void printSecurityInfo(FILE *outfile, PRFileDesc *fd);
     79 
     80 /* Some simple thread management routines. */
     81 
     82 #define MAX_THREADS 32
     83 
     84 typedef SECStatus startFn(void *a, int b);
     85 
     86 typedef enum { rs_idle = 0,
     87               rs_running = 1,
     88               rs_zombie = 2 } runState;
     89 
     90 typedef struct perThreadStr {
     91    PRFileDesc *a;
     92    int b;
     93    int rv;
     94    startFn *startFunc;
     95    PRThread *prThread;
     96    PRBool inUse;
     97    runState running;
     98 } perThread;
     99 
    100 typedef struct GlobalThreadMgrStr {
    101    PRLock *threadLock;
    102    PRCondVar *threadStartQ;
    103    PRCondVar *threadEndQ;
    104    perThread threads[MAX_THREADS];
    105    int index;
    106    int numUsed;
    107    int numRunning;
    108 } GlobalThreadMgr;
    109 
    110 void thread_wrapper(void *arg);
    111 
    112 SECStatus launch_thread(GlobalThreadMgr *threadMGR,
    113                        startFn *startFunc, void *a, int b);
    114 
    115 SECStatus reap_threads(GlobalThreadMgr *threadMGR);
    116 
    117 void destroy_thread_data(GlobalThreadMgr *threadMGR);
    118 
    119 /* Management of locked variables. */
    120 
    121 struct lockedVarsStr {
    122    PRLock *lock;
    123    int count;
    124    int waiters;
    125    PRCondVar *condVar;
    126 };
    127 
    128 typedef struct lockedVarsStr lockedVars;
    129 
    130 void lockedVars_Init(lockedVars *lv);
    131 
    132 void lockedVars_Destroy(lockedVars *lv);
    133 
    134 void lockedVars_WaitForDone(lockedVars *lv);
    135 
    136 int lockedVars_AddToCount(lockedVars *lv, int addend);
    137 
    138 #endif