Back to index

lightning-sunbird  0.9+nobinonly
signtool.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 #ifndef SIGNTOOL_H
00038 #define SIGNTOOL_H
00039  
00040 #define DJN_TEST
00041 
00042 #include <stdio.h>
00043 #include <string.h>
00044 #include <errno.h>
00045 
00046 #include "prprf.h"
00047 #include "prio.h"
00048 #include "secutil.h"
00049 #include "ocsp.h"
00050 #include "jar.h"
00051 #include "jarfile.h"
00052 #include "secpkcs7.h"
00053 #include "pk11func.h"
00054 #include "secmod.h"
00055 #include "secmodi.h"
00056 #include "plhash.h"
00057 #include "nss.h"
00058 
00059 #ifdef _UNIX
00060 #include <unistd.h> 
00061 #endif
00062 
00063 /**********************************************************************
00064  * General Defines
00065  */
00066 #define JAR_BASE_END JAR_BASE + 100
00067 #define ERRX (-1)    /* the exit code used on failure */
00068 #define FNSIZE 256   /* the maximum length for filenames */
00069 #define MAX_RSA_KEY_SIZE 4096
00070 #define DEFAULT_RSA_KEY_SIZE 1024
00071 #define MANIFEST "manifest.mf"
00072 #define DEFAULT_X509_BASENAME "x509"
00073 #define DEFAULT_COMMON_NAME "Signtool " NSS_VERSION " Testing Certificate"
00074 #define CREATOR  "Signtool (signtool " NSS_VERSION ")"
00075 #define BREAKAGE "PLEASE DO NOT EDIT THIS FILE. YOU WILL BREAK IT."
00076 #define MIN_COMPRESSION_LEVEL (-1)
00077 #define MAX_COMPRESSION_LEVEL 9
00078 #define DEFAULT_COMPRESSION_LEVEL (-1) /* zlib understands this to be default*/
00079 #define STDIN_BUF_SIZE 160
00080 #define PROGRAM_NAME "signtool"
00081 #define LONG_PROGRAM_NAME "Signing Tool"
00082 #define DEFAULT_BASE_NAME "zigbert"
00083 #define TMP_OUTPUT "signtool.tmp"
00084 #define XPI_TEXT "Creating XPI Compatible Archive"
00085 
00086 /***************************************************************
00087  * Main Task Functions
00088  */
00089 int GenerateCert(char *nickname, int keysize, char *token);
00090 int ListCerts(char *key, int list_certs);
00091 int VerifyJar(char *filename);
00092 int SignArchive(char *tree, char *keyName, char *zip_file, int javascript,
00093        char *meta_file, char *install_script, int _optimize, PRBool recurse);
00094 int SignAllArc(char *jartree, char *keyName, int javascript, char *metafile,
00095        char *install_script, int optimize, PRBool recurse);
00096 int InlineJavaScript(char *dir, PRBool recurse);
00097 int JarWho(char *filename);
00098 void JarListModules(void);
00099 
00100 /**************************************************************
00101  * Utility Functions
00102  */
00103 CERTCertDBHandle *OpenCertDB (PRBool readOnly);
00104 
00105 int RemoveAllArc(char *tree);
00106 void VerifyCertDir(char *dir, char *keyName);
00107 int InitCrypto(char *cert_dir, PRBool readOnly);
00108 int foreach (char *dirname, char *prefix,
00109        int (*fn)(char *filename, char *dirname, char *basedir,char *base,void*arg),
00110        PRBool recurse, PRBool includeDirs, void *arg);
00111 void print_error (int i);
00112 void give_help (int status);
00113 const char* secErrorString(long code);
00114 void displayVerifyLog(CERTVerifyLog *log);
00115 void usage (void);
00116 char* chop(char*);
00117 void out_of_memory(void);
00118 void FatalError(char *msg);
00119 char* get_default_cert_dir(void);
00120 SECItem *password_hardcode(void *arg, void *handle);
00121 char* pk11_password_hardcode(PK11SlotInfo *slot, PRBool retry, void *arg);
00122 int rm_dash_r(char *path);
00123 char* pr_fgets(char *buf, int size, PRFileDesc *file);
00124 
00125 
00126 /*****************************************************************
00127  * Global Variables (*gag*)
00128  */
00129 extern char *password;      /* the password passed in on the command line */
00130 extern PLHashTable *excludeDirs;  /* directory entry to skip while recursing */
00131 extern int no_time;
00132 extern int xpi_arc;
00133 extern char *base;          /* basename of ".rsa" and ".sf" files */
00134 extern long *mozilla_event_queue;
00135 extern char *progName; /* argv[0] */
00136 extern PLHashTable *extensions;/* only sign files with this extension */
00137 extern PRBool extensionsGiven;
00138 extern char *scriptdir;
00139 extern int compression_level;
00140 extern PRFileDesc *outputFD, *errorFD;
00141 extern int verbosity;
00142 extern int errorCount;
00143 extern int warningCount;
00144 
00145 #endif /* SIGNTOOL_H */