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 SIGNTOOL_H 6 #define SIGNTOOL_H 7 8 #define DJN_TEST 9 10 #include <stdio.h> 11 #include <string.h> 12 #include <errno.h> 13 14 #include "prprf.h" 15 #include "prio.h" 16 #include "secutil.h" 17 #include "ocsp.h" 18 #include "jar.h" 19 #include "jarfile.h" 20 #include "secpkcs7.h" 21 #include "pk11func.h" 22 #include "secmod.h" 23 #include "plhash.h" 24 #include "nss.h" 25 26 #ifdef _UNIX 27 #include <unistd.h> 28 #endif 29 30 /********************************************************************** 31 * General Defines 32 */ 33 #define JAR_BASE_END JAR_BASE + 100 34 #define ERRX (-1) /* the exit code used on failure */ 35 #define FNSIZE 256 /* the maximum length for filenames */ 36 #define MAX_RSA_KEY_SIZE 4096 37 #define DEFAULT_RSA_KEY_SIZE 1024 38 #define MANIFEST "manifest.mf" 39 #define DEFAULT_X509_BASENAME "x509" 40 #define DEFAULT_COMMON_NAME "Signtool " NSS_VERSION " Testing Certificate" 41 #define CREATOR "Signtool (signtool " NSS_VERSION ")" 42 #define BREAKAGE "PLEASE DO NOT EDIT THIS FILE. YOU WILL BREAK IT." 43 #define MIN_COMPRESSION_LEVEL (-1) 44 #define MAX_COMPRESSION_LEVEL 9 45 #define DEFAULT_COMPRESSION_LEVEL (-1) /* zlib understands this to be default*/ 46 #define STDIN_BUF_SIZE 160 47 #define PROGRAM_NAME "signtool" 48 #define LONG_PROGRAM_NAME "Signing Tool" 49 #define DEFAULT_BASE_NAME "zigbert" 50 #define TMP_OUTPUT "signtool.tmp" 51 #define XPI_TEXT "Creating XPI Compatible Archive" 52 53 /*************************************************************** 54 * Main Task Functions 55 */ 56 int GenerateCert(char *nickname, int keysize, char *token); 57 int ListCerts(char *key, int list_certs); 58 int VerifyJar(char *filename); 59 int SignArchive(char *tree, char *keyName, char *zip_file, int javascript, 60 char *meta_file, char *install_script, int _optimize, PRBool recurse); 61 int SignAllArc(char *jartree, char *keyName, int javascript, char *metafile, 62 char *install_script, int optimize, PRBool recurse); 63 int InlineJavaScript(char *dir, PRBool recurse); 64 int JarWho(char *filename); 65 void JarListModules(void); 66 67 /************************************************************** 68 * Utility Functions 69 */ 70 CERTCertDBHandle *OpenCertDB(PRBool readOnly); 71 72 int RemoveAllArc(char *tree); 73 void VerifyCertDir(char *dir, char *keyName); 74 int InitCrypto(char *cert_dir, PRBool readOnly); 75 int foreach (char *dirname, char *prefix, 76 int (*fn)(char *filename, char *dirname, char *basedir, char *base, void *arg), 77 PRBool recurse, PRBool includeDirs, void *arg); 78 void print_error(int i); 79 void give_help(int status); 80 const char *secErrorString(long code); 81 void displayVerifyLog(CERTVerifyLog *log); 82 void Usage(void); 83 void LongUsage(void); 84 char *chop(char *); 85 void out_of_memory(void); 86 void FatalError(char *msg); 87 char *get_default_cert_dir(void); 88 SECItem *password_hardcode(void *arg, void *handle); 89 char *pk11_password_hardcode(PK11SlotInfo *slot, PRBool retry, void *arg); 90 int rm_dash_r(char *path); 91 char *pr_fgets(char *buf, int size, PRFileDesc *file); 92 93 /***************************************************************** 94 * Global Variables (*gag*) 95 */ 96 extern char *password; /* the password passed in on the command line */ 97 extern PLHashTable *excludeDirs; /* directory entry to skip while recursing */ 98 extern int no_time; 99 extern int xpi_arc; 100 extern char *base; /* basename of ".rsa" and ".sf" files */ 101 extern long *mozilla_event_queue; 102 extern char *progName; /* argv[0] */ 103 extern PLHashTable *extensions; /* only sign files with this extension */ 104 extern PRBool extensionsGiven; 105 extern char *scriptdir; 106 extern int compression_level; 107 extern PRFileDesc *outputFD, *errorFD; 108 extern int verbosity; 109 extern int errorCount; 110 extern int warningCount; 111 extern secuPWData pwdata; 112 113 #endif /* SIGNTOOL_H */ 114