tor-browser

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

modutil.xml (39325B)


      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
      3  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
      4 <!ENTITY date SYSTEM "date.xml">
      5 <!ENTITY version SYSTEM "version.xml">
      6 ]>
      7 
      8 <refentry id="modutil">
      9 
     10  <refentryinfo>
     11    <date>&date;</date>
     12    <title>NSS Security Tools</title>
     13    <productname>nss-tools</productname>
     14    <productnumber>&version;</productnumber>
     15  </refentryinfo>
     16 
     17  <refmeta>
     18    <refentrytitle>MODUTIL</refentrytitle>
     19    <manvolnum>1</manvolnum>
     20  </refmeta>
     21 
     22  <refnamediv>
     23    <refname>modutil</refname>
     24    <refpurpose>Manage PKCS #11 module information within the security module database.</refpurpose>
     25  </refnamediv>
     26 
     27  <refsynopsisdiv>
     28    <cmdsynopsis>
     29      <command>modutil</command>
     30      <arg><replaceable>options</replaceable></arg>
     31      <arg>[<replaceable>arguments</replaceable>]</arg>
     32    </cmdsynopsis>
     33  </refsynopsisdiv>
     34 
     35  <refsection>
     36    <title>STATUS</title>
     37    <para>This documentation is still work in progress. Please contribute to the initial review in <ulink url="https://bugzilla.mozilla.org/show_bug.cgi?id=836477">Mozilla NSS bug 836477</ulink>
     38    </para>
     39  </refsection>
     40 
     41  <refsection id="description">
     42    <title>Description</title>
     43    <para>The Security Module Database Tool, <command>modutil</command>, is a command-line utility for managing PKCS #11 module information both within <filename>secmod.db</filename> files and within hardware tokens. <command>modutil</command> can add and delete PKCS #11 modules, change passwords on security databases, set defaults, list module contents, enable or disable slots, enable or disable FIPS 140-2 compliance, and assign default providers for cryptographic operations. This tool can also create certificate, key, and module security database files.</para>
     44 
     45 <para>The tasks associated with security module database management are part of a process that typically also involves managing key databases and certificate databases.</para>
     46  </refsection>
     47  
     48  <refsection id="options">
     49    <title>Options</title>
     50 <para>
     51 	Running <command>modutil</command> always requires one (and only one) option to specify the type of module operation. Each option may take arguments, anywhere from none to multiple arguments.
     52 </para>
     53   	<para><command>Options</command></para> 
     54 
     55 <variablelist>
     56 
     57      <varlistentry>
     58        <term>-add modulename</term>
     59   <listitem><para>Add the named PKCS #11 module to the database. Use this option with the <option>-libfile</option>, <option>-ciphers</option>, and <option>-mechanisms</option> arguments.</para></listitem>
     60      </varlistentry>
     61 
     62      <varlistentry>
     63        <term>-changepw tokenname</term>
     64   <listitem><para>Change the password on the named token. If the token has not been initialized, this option initializes the password. Use this option with the <option>-pwfile</option> and <option>-newpwfile</option> arguments. A <emphasis>password</emphasis> is equivalent to a personal identification number (PIN).</para></listitem>
     65      </varlistentry>
     66 
     67      <varlistentry>
     68        <term>-chkfips</term>
     69   <listitem><para>Verify whether the module is in the given FIPS mode. <command>true</command> means to verify that the module is in FIPS mode, while <command>false</command> means to verify that the module is not in FIPS mode.</para></listitem>
     70      </varlistentry>
     71 
     72      <varlistentry>
     73        <term>-create</term>
     74 <listitem><para>Create new certificate, key, and module databases. Use the <option>-dbdir</option> directory argument to specify a directory. If any of these databases already exist in a specified directory, <command>modutil</command> returns an error message.</para></listitem>
     75      </varlistentry>
     76 
     77      <varlistentry>
     78        <term>-default modulename</term>
     79   <listitem><para>Specify the security mechanisms for which the named module will be a default provider. The security mechanisms are specified with the <option>-mechanisms</option> argument.</para></listitem>
     80      </varlistentry>
     81 
     82      <varlistentry>
     83        <term>-delete modulename</term>
     84   <listitem><para>Delete the named module. The default NSS PKCS #11 module cannot be deleted.</para></listitem>
     85      </varlistentry>
     86 
     87      <varlistentry>
     88        <term>-disable modulename</term>
     89   <listitem><para>Disable all slots on the named module. Use the <option>-slot</option> argument to disable a specific slot.</para><para>The internal NSS PKCS #11 module cannot be disabled.</para></listitem>
     90      </varlistentry>
     91 
     92      <varlistentry>
     93        <term>-enable modulename</term>
     94   <listitem><para>Enable all slots on the named module. Use the <option>-slot</option> argument to enable a specific slot.</para></listitem>
     95      </varlistentry>
     96 
     97      <varlistentry>
     98        <term>-fips [true | false]</term>
     99   <listitem><para>Enable (true) or disable (false) FIPS 140-2 compliance for the default NSS module.</para></listitem>
    100      </varlistentry>
    101 
    102      <varlistentry>
    103        <term>-force</term>
    104   <listitem><para>Disable <command>modutil</command>'s interactive prompts so it can be run from a script. Use this option only after manually testing each planned operation to check for warnings and to ensure that bypassing the prompts will cause no security lapses or loss of database integrity.</para></listitem>
    105      </varlistentry>
    106 
    107      <varlistentry>
    108        <term>-jar JAR-file</term>
    109   <listitem><para>Add a new PKCS #11 module to the database using the named JAR file. Use this command with the <option>-installdir</option> and <option>-tempdir</option> arguments. The JAR file uses the NSS PKCS #11 JAR format to identify all the files to be installed, the module's name, the mechanism flags, and the cipher flags, as well as any files to be installed on the target machine, including the PKCS #11 module library file and other files such as documentation. This is covered in the JAR installation file section in the man page, which details the special script needed to perform an installation through a server or with <command>modutil</command>. </para></listitem>
    110      </varlistentry>
    111 
    112      <varlistentry>
    113          <term>-list [modulename]</term>
    114   <listitem><para>Display basic information about the contents of the <filename>secmod.db</filename> file. Specifying a <emphasis>modulename</emphasis> displays detailed information about a particular module and its slots and tokens.</para></listitem>
    115      </varlistentry>
    116 
    117      <varlistentry>
    118        <term>-rawadd</term>
    119   <listitem><para>Add the module spec string to the <filename>secmod.db</filename> database.</para></listitem>
    120      </varlistentry>
    121 
    122      <varlistentry>
    123        <term>-rawlist</term>
    124   <listitem><para>Display the module specs for a specified module or for all loadable modules.</para></listitem>
    125      </varlistentry>
    126 
    127      <varlistentry>
    128        <term>-undefault modulename</term>
    129   <listitem><para>Specify the security mechanisms for which the named module will not be a default provider. The security mechanisms are specified with the <option>-mechanisms</option> argument.</para></listitem>
    130      </varlistentry>
    131 </variablelist>
    132 
    133 <para><command>Arguments</command></para>
    134    <variablelist>
    135 
    136      <varlistentry>
    137        <term>MODULE</term>
    138   <listitem><para>Give the security module to access.</para></listitem>
    139      </varlistentry>
    140 
    141      <varlistentry>
    142        <term>MODULESPEC</term>
    143   <listitem><para>Give the security module spec to load into the security database.</para></listitem>
    144      </varlistentry>
    145 
    146      <varlistentry>
    147        <term>-ciphers cipher-enable-list</term>
    148   <listitem><para>Enable specific ciphers in a module that is being added to the database. The <emphasis>cipher-enable-list</emphasis> is a colon-delimited list of cipher names. Enclose this list in quotation marks if it contains spaces.</para></listitem>
    149      </varlistentry>
    150 
    151      <varlistentry>
    152        <term>-dbdir directory</term>
    153   <listitem><para>Specify the database directory in which to access or create security module database files.</para>
    154 <para><command>modutil</command> supports two types of databases: the legacy security databases (<filename>cert8.db</filename>, <filename>key3.db</filename>, and <filename>secmod.db</filename>) and SQLite databases (<filename>cert9.db</filename>, <filename>key4.db</filename>, and <filename>pkcs11.txt</filename>). If the prefix <command>dbm:</command> is not used, then the tool assumes that the given databases are in SQLite format.</para></listitem>
    155      </varlistentry>
    156 
    157      <varlistentry>
    158        <term>--dbprefix prefix</term>
    159   <listitem><para>Specify the prefix used on the database files, such as <filename>my_</filename> for <filename>my_cert9.db</filename>. This option is provided as a special case. Changing the names of the certificate and key databases is not recommended.</para></listitem>
    160      </varlistentry>
    161 
    162      <varlistentry>
    163        <term>-installdir root-installation-directory</term>
    164   <listitem><para>Specify the root installation directory relative to which files will be installed by the <option>-jar</option> option. This directory should be one below which it is appropriate to store dynamic library files, such as a server's root directory.</para></listitem>
    165      </varlistentry>
    166 
    167      <varlistentry>
    168        <term>-libfile library-file</term>
    169   <listitem><para>Specify a path to a library file containing the implementation of the PKCS #11 interface module that is being added to the database.</para></listitem>
    170      </varlistentry>
    171 
    172      <varlistentry>
    173        <term>-mechanisms mechanism-list</term>
    174   <listitem><para>Specify the security mechanisms for which a particular module will be flagged as a default provider. The <emphasis>mechanism-list</emphasis> is a colon-delimited list of mechanism names. Enclose this list in quotation marks if it contains spaces.</para>
    175 <para>The module becomes a default provider for the listed mechanisms when those mechanisms are enabled. If more than one module claims to be a particular mechanism's default provider, that mechanism's default provider is undefined.</para>
    176 <para><command>modutil</command> supports several mechanisms: RSA, DSA, RC2, RC4, RC5, AES, DES, DH, SHA1, SHA256, SHA512, SSL, TLS, MD5, MD2, RANDOM (for random number generation), and FRIENDLY (meaning certificates are publicly readable).</para></listitem>
    177      </varlistentry>
    178 
    179      <varlistentry>
    180        <term>-newpwfile new-password-file</term>
    181   <listitem><para>Specify a text file containing a token's new or replacement password so that a password can be entered automatically with the <option>-changepw</option> option.</para></listitem>
    182      </varlistentry>
    183 
    184      <varlistentry>
    185        <term>-nocertdb</term>
    186   <listitem><para>Do not open the certificate or key databases. This has several effects:</para>
    187 	<itemizedlist>
    188 	<listitem>
    189          <para>With the <option>-create</option> command, only a module security file is created; certificate and key databases are not created.</para>
    190 	</listitem>
    191 	<listitem>
    192          <para>With the <option>-jar</option> command, signatures on the JAR file are not checked.</para>
    193 	</listitem>
    194 	<listitem>
    195          <para>With the <option>-changepw</option> command, the password on the NSS internal module cannot be set or changed, since this password is stored in the key database.</para></listitem>
    196 	</itemizedlist>
    197 	</listitem>
    198      </varlistentry>
    199 
    200      <varlistentry>
    201        <term>-pwfile old-password-file</term>
    202   <listitem><para>Specify a text file containing a token's existing password so that a password can be entered automatically when the <option>-changepw</option> option is used to change passwords.</para></listitem>
    203      </varlistentry>
    204 
    205      <varlistentry>
    206        <term>-secmod secmodname</term>
    207   <listitem><para>Give the name of the security module database (like <filename>secmod.db</filename>) to load.</para></listitem>
    208      </varlistentry>
    209 
    210      <varlistentry>
    211        <term>-slot slotname</term>
    212   <listitem><para>Specify a particular slot to be enabled or disabled with the <option>-enable</option> or <option>-disable</option> options.</para></listitem>
    213      </varlistentry>
    214 
    215      <varlistentry>
    216        <term>-string CONFIG_STRING</term>
    217   <listitem><para>Pass a configuration string for the module being added to the database.</para></listitem>
    218      </varlistentry>
    219 
    220      <varlistentry>
    221        <term>-tempdir temporary-directory</term>
    222   <listitem><para>Give a directory location where temporary files are created during the installation by the <option>-jar</option> option. If no temporary directory is specified, the current directory is used.</para></listitem>
    223      </varlistentry>
    224    </variablelist>
    225  </refsection>
    226 
    227  <refsection id="usage-and-examples">
    228    <title>Usage and Examples</title>
    229 
    230    <para><command>Creating Database Files</command></para>
    231    <para>Before any operations can be performed, there must be a set of security databases available. <command>modutil</command> can be used to create these files. The only required argument is the database that where the databases will be located.</para>
    232 <programlisting>modutil -create -dbdir directory</programlisting>
    233 
    234 <para><command>Adding a Cryptographic Module</command></para>
    235 <para>Adding a PKCS #11 module means submitting a supporting library file, enabling its ciphers, and setting default provider status for various security mechanisms. This can be done by supplying all of the information through <command>modutil</command> directly or by running a JAR file and install script. For the most basic case, simply upload the library:</para>
    236 <programlisting>modutil -add modulename -libfile library-file [-ciphers cipher-enable-list] [-mechanisms mechanism-list] </programlisting>
    237 <para>For example:
    238 <programlisting>modutil -dbdir /home/my/sharednssdb -add "Example PKCS #11 Module" -libfile "/tmp/crypto.so" -mechanisms RSA:DSA:RC2:RANDOM 
    239 
    240 Using database directory ... 
    241 Module "Example PKCS #11 Module" added to database.</programlisting>
    242        </para>
    243 
    244 
    245 <para><command>Installing a Cryptographic Module from a JAR File</command></para>
    246 <para>PKCS #11 modules can also be loaded using a JAR file, which contains all of the required libraries and an installation script that describes how to install the module. The JAR install script is described in more detail in <xref linkend="jar-install-file" />.</para>
    247 <para>The JAR installation script defines the setup information for each platform that the module can be installed on. For example:</para>
    248 <programlisting>Platforms { 
    249   Linux:5.4.08:x86 { 
    250      ModuleName { "Example PKCS #11 Module" } 
    251      ModuleFile { crypto.so } 
    252      DefaultMechanismFlags{0x0000} 
    253      CipherEnableFlags{0x0000} 
    254      Files { 
    255         crypto.so { 
    256            Path{ /tmp/crypto.so } 
    257         } 
    258         setup.sh { 
    259            Executable 
    260            Path{ /tmp/setup.sh } 
    261         } 
    262      } 
    263   } 
    264   Linux:6.0.0:x86 { 
    265      EquivalentPlatform { Linux:5.4.08:x86 } 
    266   } 
    267 } </programlisting>
    268 <para>Both the install script and the required libraries must be bundled in a JAR file, which is specified with the <option>-jar</option> argument.</para>
    269 
    270 <programlisting>modutil -dbdir /home/mt"jar-install-filey/sharednssdb -jar install.jar -installdir /home/my/sharednssdb
    271 
    272 This installation JAR file was signed by: 
    273 ---------------------------------------------- 
    274 
    275 **SUBJECT NAME** 
    276 
    277 C=US, ST=California, L=Mountain View, CN=Cryptorific Inc., OU=Digital ID
    278 Class 3 - Netscape Object Signing, OU="www.verisign.com/repository/CPS
    279 Incorp. by Ref.,LIAB.LTD(c)9 6", OU=www.verisign.com/CPS Incorp.by Ref
    280 . LIABILITY LTD.(c)97 VeriSign, OU=VeriSign Object Signing CA - Class 3
    281 Organization, OU="VeriSign, Inc.", O=VeriSign Trust Network **ISSUER
    282 NAME**, OU=www.verisign.com/CPS Incorp.by Ref. LIABILITY LTD.(c)97
    283 VeriSign, OU=VeriSign Object Signing CA - Class 3 Organization,
    284 OU="VeriSign, Inc.", O=VeriSign Trust Network 
    285 ---------------------------------------------- 
    286 
    287 Do you wish to continue this installation? (y/n) y 
    288 Using installer script "installer_script" 
    289 Successfully parsed installation script 
    290 Current platform is Linux:5.4.08:x86 
    291 Using installation parameters for platform Linux:5.4.08:x86 
    292 Installed file crypto.so to /tmp/crypto.so
    293 Installed file setup.sh to ./pk11inst.dir/setup.sh 
    294 Executing "./pk11inst.dir/setup.sh"... 
    295 "./pk11inst.dir/setup.sh" executed successfully 
    296 Installed module "Example PKCS #11 Module" into module database 
    297 
    298 Installation completed successfully </programlisting>
    299 
    300 <para><command>Adding Module Spec</command></para>
    301 <para>Each module has information stored in the security database about its configuration and parameters. These can be added or edited using the <option>-rawadd</option> command. For the current settings or to see the format of the module spec in the database, use the <option>-rawlist</option> option.</para>
    302 <programlisting>modutil -rawadd modulespec</programlisting>
    303 
    304 
    305 <para><command>Deleting a Module</command></para>
    306    <para>A specific PKCS #11 module can be deleted from the <filename>secmod.db</filename> database:</para>
    307 <programlisting>modutil -delete modulename -dbdir directory </programlisting>
    308 
    309 <para><command>Displaying Module Information</command></para>
    310 <para>The <filename>secmod.db</filename> database contains information about the PKCS #11 modules that are available to an application or server to use. The list of all modules, information about specific modules, and database configuration specs for modules can all be viewed. </para>
    311    <para>To simply get a list of modules in the database, use the <option>-list</option> command.</para>
    312 <programlisting>modutil -list [modulename] -dbdir directory </programlisting>
    313 <para>Listing the modules shows the module name, their status, and other associated security databases for certificates and keys. For example:</para>
    314   
    315 <programlisting>modutil -list -dbdir /home/my/sharednssdb 
    316 
    317 Listing of PKCS #11 Modules
    318 -----------------------------------------------------------
    319  1. NSS Internal PKCS #11 Module
    320         slots: 2 slots attached
    321        status: loaded
    322 
    323         slot: NSS Internal Cryptographic Services                            
    324        token: NSS Generic Crypto Services
    325   uri: pkcs11:token=NSS%20Generic%20Crypto%20Services;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203
    326 
    327         slot: NSS User Private Key and Certificate Services                  
    328        token: NSS Certificate DB
    329   uri: pkcs11:token=NSS%20Certificate%20DB;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203
    330 -----------------------------------------------------------</programlisting>
    331 <para>Passing a specific module name with the <option>-list</option> returns details information about the module itself, like supported cipher mechanisms, version numbers, serial numbers, and other information about the module and the token it is loaded on. For example:</para>
    332 <programlisting> modutil -list "NSS Internal PKCS #11 Module" -dbdir /home/my/sharednssdb
    333 
    334 -----------------------------------------------------------
    335 Name: NSS Internal PKCS #11 Module
    336 Library file: **Internal ONLY module**
    337 Manufacturer: Mozilla Foundation              
    338 Description: NSS Internal Crypto Services    
    339 PKCS #11 Version 2.20
    340 Library Version: 3.11
    341 Cipher Enable Flags: None
    342 Default Mechanism Flags: RSA:RC2:RC4:DES:DH:SHA1:MD5:MD2:SSL:TLS:AES
    343 
    344  Slot: NSS Internal Cryptographic Services                            
    345  Slot Mechanism Flags: RSA:RC2:RC4:DES:DH:SHA1:MD5:MD2:SSL:TLS:AES
    346  Manufacturer: Mozilla Foundation              
    347  Type: Software
    348  Version Number: 3.11
    349  Firmware Version: 0.0
    350  Status: Enabled
    351  Token Name: NSS Generic Crypto Services     
    352  Token Manufacturer: Mozilla Foundation              
    353  Token Model: NSS 3           
    354  Token Serial Number: 0000000000000000
    355  Token Version: 4.0
    356  Token Firmware Version: 0.0
    357  Access: Write Protected
    358  Login Type: Public (no login required)
    359  User Pin: NOT Initialized
    360 
    361  Slot: NSS User Private Key and Certificate Services                  
    362  Slot Mechanism Flags: None
    363  Manufacturer: Mozilla Foundation              
    364  Type: Software
    365  Version Number: 3.11
    366  Firmware Version: 0.0
    367  Status: Enabled
    368  Token Name: NSS Certificate DB              
    369  Token Manufacturer: Mozilla Foundation              
    370  Token Model: NSS 3           
    371  Token Serial Number: 0000000000000000
    372  Token Version: 8.3
    373  Token Firmware Version: 0.0
    374  Access: NOT Write Protected
    375  Login Type: Login required
    376  User Pin: Initialized</programlisting>
    377 <para>A related command, <option>-rawlist</option> returns information about the database configuration for the modules. (This information can be edited by loading new specs using the <option>-rawadd</option> command.)</para>
    378 <programlisting> modutil -rawlist -dbdir /home/my/sharednssdb
    379 name="NSS Internal PKCS #11 Module" parameters="configdir=. certPrefix= keyPrefix= secmod=secmod.db flags=readOnly " NSS="trustOrder=75 cipherOrder=100 slotParams={0x00000001=[slotFlags=RSA,RC4,RC2,DES,DH,SHA1,MD5,MD2,SSL,TLS,AES,RANDOM askpw=any timeout=30 ] }  Flags=internal,critical"</programlisting>
    380 
    381 <para><command>Setting a Default Provider for Security Mechanisms</command></para>
    382 <para>Multiple security modules may provide support for the same security mechanisms. It is possible to set a specific security module as the default provider for a specific security mechanism (or, conversely, to prohibit a provider from supplying those mechanisms).</para>
    383 <programlisting>modutil -default modulename -mechanisms mechanism-list </programlisting>
    384 <para>To set a module as the default provider for mechanisms, use the <option>-default</option> command with a colon-separated list of mechanisms. The available mechanisms depend on the module; NSS supplies almost all common mechanisms. For example:</para>
    385 <programlisting>modutil -default "NSS Internal PKCS #11 Module" -dbdir -mechanisms RSA:DSA:RC2 
    386 
    387 Using database directory c:\databases...
    388 
    389 Successfully changed defaults.</programlisting>
    390 
    391    <para>Clearing the default provider has the same format:</para>
    392 <programlisting>modutil -undefault "NSS Internal PKCS #11 Module" -dbdir -mechanisms MD2:MD5</programlisting>
    393 
    394 <para><command>Enabling and Disabling Modules and Slots</command></para>
    395 <para>Modules, and specific slots on modules, can be selectively enabled or disabled using <command>modutil</command>. Both commands have the same format:</para>
    396 <programlisting>modutil -enable|-disable modulename [-slot slotname] </programlisting>
    397 
    398    <para>For example:</para>
    399 <programlisting>modutil -enable "NSS Internal PKCS #11 Module" -slot "NSS Internal Cryptographic Services                            " -dbdir .
    400 
    401 Slot "NSS Internal Cryptographic Services                            " enabled.</programlisting>
    402 <para>Be sure that the appropriate amount of trailing whitespace is after the slot name. Some slot names have a significant amount of whitespace that must be included, or the operation will fail.</para>
    403 
    404 <para><command>Enabling and Verifying FIPS Compliance</command></para>
    405 <para>The NSS modules can have FIPS 140-2 compliance enabled or disabled using <command>modutil</command> with the <option>-fips</option> option. For example:</para>
    406 <programlisting>modutil -fips true -dbdir /home/my/sharednssdb/
    407 
    408 FIPS mode enabled.</programlisting>
    409 <para>To verify that status of FIPS mode, run the <option>-chkfips</option> command with either a true or false flag (it doesn't matter which). The tool returns the current FIPS setting.</para>
    410 <programlisting>modutil -chkfips false -dbdir /home/my/sharednssdb/
    411 
    412 FIPS mode enabled.</programlisting>
    413 
    414 <para><command>Changing the Password on a Token</command></para>
    415 
    416    <para>Initializing or changing a token's password:</para>
    417 <programlisting>modutil -changepw tokenname [-pwfile old-password-file] [-newpwfile new-password-file] </programlisting>
    418 <programlisting>modutil -dbdir /home/my/sharednssdb -changepw "NSS Certificate DB" 
    419 
    420 Enter old password: 
    421 Incorrect password, try again... 
    422 Enter old password: 
    423 Enter new password: 
    424 Re-enter new password: 
    425 Token "Communicator Certificate DB" password changed successfully.</programlisting>
    426  </refsection>
    427 
    428  <refsection id="jar-install-file"><title>JAR Installation File Format</title>
    429     <para>When a JAR file is run by a server, by <command>modutil</command>, or by any program that does not interpret JavaScript, a special information file must be included to install the libraries. There are several things to keep in mind with this file:</para>
    430 <itemizedlist>
    431 	<listitem>
    432 		<para>
    433 			It must be declared in the JAR archive's manifest file. 
    434 		</para>
    435 	</listitem>
    436 	<listitem>
    437 		<para>
    438 			The script can have any name. 
    439 		</para>
    440 	</listitem>
    441 	<listitem>
    442 		<para>
    443 			The metainfo tag for this is <command>Pkcs11_install_script</command>. To declare meta-information in the manifest file, put it in a file that is passed to <command>signtool</command>.</para>
    444 	</listitem>
    445 </itemizedlist>
    446 
    447 <para><command>Sample Script</command></para>
    448 <para>For example, the PKCS #11 installer script could be in the file pk11install. If so, the metainfo file for <command>signtool</command> includes a line such as this:</para>
    449 <programlisting>+ Pkcs11_install_script: pk11install</programlisting>
    450 
    451 <para>The script must define the platform and version number, the module name and file, and any optional information like supported ciphers and mechanisms. Multiple platforms can be defined in a single install file.</para>
    452 <programlisting>ForwardCompatible { IRIX:6.2:mips SUNOS:5.5.1:sparc }
    453 Platforms {
    454   WINNT::x86 {
    455      ModuleName { "Example Module" }
    456      ModuleFile { win32/fort32.dll }
    457      DefaultMechanismFlags{0x0001}
    458      DefaultCipherFlags{0x0001}
    459      Files {
    460         win32/setup.exe {
    461            Executable
    462            RelativePath { %temp%/setup.exe }
    463         }
    464         win32/setup.hlp {
    465            RelativePath { %temp%/setup.hlp }
    466         }
    467         win32/setup.cab {
    468            RelativePath { %temp%/setup.cab }
    469         }
    470      }
    471   }
    472   SUNOS:5.5.1:sparc {
    473      ModuleName { "Example UNIX Module" }
    474      ModuleFile { unix/fort.so }
    475      DefaultMechanismFlags{0x0001}
    476      CipherEnableFlags{0x0001}
    477      Files {
    478         unix/fort.so {
    479            RelativePath{%root%/lib/fort.so}
    480            AbsolutePath{/usr/local/netscape/lib/fort.so}
    481            FilePermissions{555}
    482         }
    483         xplat/instr.html {
    484            RelativePath{%root%/docs/inst.html}
    485            AbsolutePath{/usr/local/netscape/docs/inst.html}
    486            FilePermissions{555}
    487         }
    488      }
    489   }
    490   IRIX:6.2:mips {
    491      EquivalentPlatform { SUNOS:5.5.1:sparc }
    492   }
    493 }</programlisting>
    494 
    495 <para><command>Script Grammar</command></para>
    496 <para>The script is basic Java, allowing lists, key-value pairs, strings, and combinations of all of them.</para>
    497 <programlisting>--> valuelist
    498 
    499 valuelist --> value valuelist
    500               &lt;null>
    501 
    502 value ---> key_value_pair
    503            string
    504 
    505 key_value_pair --> key { valuelist }
    506 
    507 key --> string
    508 
    509 string --> simple_string
    510            "complex_string"
    511 
    512 simple_string --> [^ \t\n\""{""}"]+ 
    513 
    514 complex_string --> ([^\"\\\r\n]|(\\\")|(\\\\))+ </programlisting>
    515 
    516 <para>Quotes and backslashes must be escaped with a backslash. A complex string must not include newlines or carriage returns.Outside of complex strings, all white space (for example, spaces, tabs, and carriage returns) is considered equal and is used only to delimit tokens.</para>
    517 
    518 <para><command>Keys</command></para>
    519 <para>The Java install file uses keys to define the platform and module information.</para>
    520 <para><command>ForwardCompatible</command> gives a list of platforms that are forward compatible. If the current platform cannot be found in the list of supported platforms, then the <command>ForwardCompatible</command> list is checked for any platforms that have the same OS and architecture in an earlier version. If one is found, its attributes are used for the current platform. </para>
    521 <para><command>Platforms</command> (required) Gives a list of platforms. Each entry in the list is itself a key-value pair: the key is the name of the platform and the value list contains various attributes of the platform. The platform string is in the format <emphasis>system name:OS release:architecture</emphasis>. The installer obtains these values from NSPR. OS release is an empty string on non-Unix operating systems. NSPR supports these platforms:</para>
    522 <itemizedlist>
    523 <listitem>
    524 <para>AIX (rs6000)</para>
    525 </listitem>
    526 <listitem>
    527 <para>BSDI (x86)</para>
    528 </listitem>
    529 <listitem>
    530 <para>FREEBSD (x86)</para>
    531 </listitem>
    532 <listitem>
    533 <para>HPUX (hppa1.1)</para>
    534 </listitem>
    535 <listitem>
    536 <para>IRIX (mips)</para>
    537 </listitem>
    538 <listitem>
    539 <para>LINUX (ppc, alpha, x86)</para>
    540 </listitem>
    541 <listitem>
    542 <para>MacOS (PowerPC)</para>
    543 </listitem>
    544 <listitem>
    545 <para>NCR (x86)</para>
    546 </listitem>
    547 <listitem>
    548 <para>NEC (mips)</para>
    549 </listitem>
    550 <listitem>
    551 <para>OSF (alpha)</para>
    552 </listitem>
    553 <listitem>
    554 <para>SOLARIS (sparc)</para>
    555 </listitem>
    556 <listitem>
    557 <para>SONY (mips)</para>
    558 </listitem>
    559 <listitem>
    560 <para>SUNOS (sparc)</para>
    561 </listitem>
    562 <listitem>
    563 <para>UnixWare (x86)</para>
    564 </listitem>
    565 <listitem>
    566 <para>WINNT (x86)</para>
    567 </listitem>
    568 </itemizedlist>
    569 
    570 <para>For example:</para>
    571 <programlisting>IRIX:6.2:mips
    572 SUNOS:5.5.1:sparc
    573 Linux:2.0.32:x86
    574 </programlisting>
    575 <para>The module information is defined independently for each platform in the <command>ModuleName</command>, <command>ModuleFile</command>, and <command>Files</command> attributes. These attributes must be given unless an <command>EquivalentPlatform</command> attribute is specified. </para>
    576 
    577 <para><command>Per-Platform Keys</command></para>
    578 <para>Per-platform keys have meaning only within the value list of an entry in the <command>Platforms</command> list.</para>
    579 <para><command>ModuleName</command> (required) gives the common name for the module. This name is used to reference the module by servers and by the <command>modutil</command> tool. </para>
    580 <para><command>ModuleFile</command> (required) names the PKCS #11 module file for this platform. The name is given as the relative path of the file within the JAR archive. </para>
    581 <para><command>Files</command> (required) lists the files that need to be installed for this module. Each entry in the file list is a key-value pair. The key is the path of the file in the JAR archive, and the value list contains attributes of the file. At least <command>RelativePath</command> or <command>AbsolutePath</command> must be specified for each file.</para>
    582 <para><command>DefaultMechanismFlags</command> specifies mechanisms for which this module is the default provider; this is equivalent to the <option>-mechanism</option> option with the <option>-add</option> command. This key-value pair is a bitstring specified in hexadecimal (0x) format. It is constructed as a bitwise OR. If the DefaultMechanismFlags entry is omitted, the value defaults to 0x0.</para>
    583 
    584 <programlisting>RSA:                   0x00000001
    585 DSA:                   0x00000002
    586 RC2:                   0x00000004
    587 RC4:                   0x00000008
    588 DES:                   0x00000010
    589 DH:                    0x00000020
    590 FORTEZZA:              0x00000040
    591 RC5:                   0x00000080
    592 SHA1:                  0x00000100
    593 MD5:                   0x00000200
    594 MD2:                   0x00000400
    595 RANDOM:                0x08000000
    596 FRIENDLY:              0x10000000
    597 OWN_PW_DEFAULTS:       0x20000000
    598 DISABLE:               0x40000000</programlisting>
    599 
    600 <para><command>CipherEnableFlags</command> specifies ciphers that this module provides that NSS does not provide (so that the module enables those ciphers for NSS). This is equivalent to the <option>-cipher</option> argument with the <option>-add</option> command. This key is a bitstring specified in hexadecimal (0x) format. It is constructed as a bitwise OR. If the <command>CipherEnableFlags</command> entry is omitted, the value defaults to 0x0.</para>
    601 
    602 <para><command>EquivalentPlatform</command> specifies that the attributes of the named platform should also be used for the current platform. This makes it easier when more than one platform uses the same settings.</para>
    603 
    604 <para><command>Per-File Keys</command></para>
    605 <para>Some keys have meaning only within the value list of an entry in a <command>Files</command> list.</para>
    606 <para>Each file requires a path key the identifies where the file is. Either <command>RelativePath</command> or <command>AbsolutePath</command> must be specified. If both are specified, the relative path is tried first, and the absolute path is used only if no relative root directory is provided by the installer program.</para>
    607 <para><command>RelativePath</command> specifies the destination directory of the file, relative to some directory decided at install time. Two variables can be used in the relative path: <command>%root%</command> and <command>%temp%</command>. <command>%root%</command> is replaced at run time with the directory relative to which files should be installed; for example, it may be the server's root directory. The <command>%temp%</command> directory is created at the beginning of the installation and destroyed at the end. The purpose of <command>%temp%</command> is to hold executable files (such as setup programs) or files that are used by these programs. Files destined for the temporary directory are guaranteed to be in place before any executable file is run; they are not deleted until all executable files have finished.</para>
    608 <para><command>AbsolutePath</command> specifies the destination directory of the file as an absolute path. </para>
    609 <para><command>Executable</command> specifies that the file is to be executed during the course of the installation. Typically, this string is used for a setup program provided by a module vendor, such as a self-extracting setup executable. More than one file can be specified as executable, in which case the files are run in the order in which they are specified in the script file.</para>
    610 <para><command>FilePermissions</command> sets permissions on any referenced files in a string of octal digits, according to the standard Unix format. This string is a bitwise OR.</para>
    611 
    612 <programlisting>
    613 user read:                0400
    614 user write:               0200
    615 user execute:             0100
    616 group read:               0040
    617 group write:              0020
    618 group execute:            0010
    619 other read:               0004
    620 other write:              0002
    621 other execute:            0001
    622 </programlisting>
    623 
    624 <para>Some platforms may not understand these permissions. They are applied only insofar as they make sense for the current platform. If this attribute is omitted, a default of 777 is assumed.</para>
    625  </refsection>
    626 
    627 <refsection id="databases"><title>NSS Database Types</title>
    628 <para>NSS originally used BerkeleyDB databases to store security information. 
    629 The last versions of these <emphasis>legacy</emphasis> databases are:</para>
    630 <itemizedlist>
    631 <listitem>
    632 	<para>
    633 		cert8.db for certificates
    634 	</para>
    635 </listitem>
    636 <listitem>
    637 	<para>
    638 		key3.db for keys
    639 	</para>
    640 </listitem>
    641 <listitem>
    642 	<para>
    643 		secmod.db for PKCS #11 module information
    644 	</para>
    645 </listitem>
    646 </itemizedlist>
    647 
    648 <para>BerkeleyDB has performance limitations, though, which prevent it from being easily used by multiple applications simultaneously. NSS has 
    649 some flexibility that allows applications to use their own, independent database engine while keeping a shared database and working around the access issues. Still, NSS
    650 requires more flexibility to provide a truly shared security database.</para>
    651 
    652 <para>In 2009, NSS introduced a new set of databases that are SQLite databases rather than 
    653 BerkleyDB. These new databases provide more accessibility and performance:</para>
    654 <itemizedlist>
    655 <listitem>
    656 	<para>
    657 		cert9.db for certificates
    658 	</para>
    659 </listitem>
    660 <listitem>
    661 	<para>
    662 		key4.db for keys
    663 	</para>
    664 </listitem>
    665 <listitem>
    666 	<para>
    667 		pkcs11.txt, which is listing of all of the PKCS #11 modules contained in a new subdirectory in the security databases directory
    668 	</para>
    669 </listitem>
    670 </itemizedlist>
    671 
    672 <para>Because the SQLite databases are designed to be shared, these are the <emphasis>shared</emphasis> database type. The shared database type is preferred; the legacy format is included for backward compatibility.</para>
    673 
    674 <para>By default, the tools (<command>certutil</command>, <command>pk12util</command>, <command>modutil</command>) assume that the given security databases use the SQLite type.
    675 Using the legacy databases must be manually specified by using the <command>dbm:</command> prefix with the given security directory. For example:</para>
    676 
    677 <programlisting>modutil -create -dbdir dbm:/home/my/sharednssdb</programlisting>
    678 
    679 <para>To set the legacy database type as the default type for the tools, set the <envar>NSS_DEFAULT_DB_TYPE</envar> environment variable to <envar>dbm</envar>:</para>
    680 <programlisting>export NSS_DEFAULT_DB_TYPE="dbm"</programlisting>
    681 
    682 <para>This line can be added to the <filename>~/.bashrc</filename> file to make the change permanent for the user.</para>
    683 
    684 <itemizedlist>
    685 <listitem>
    686 	<para>
    687 		https://wiki.mozilla.org/NSS_Shared_DB_Howto</para>
    688 </listitem>
    689 </itemizedlist>
    690 <para>For an engineering draft on the changes in the shared NSS databases, see the NSS project wiki:</para>
    691 <itemizedlist>
    692 <listitem>
    693 	<para>
    694 		https://wiki.mozilla.org/NSS_Shared_DB
    695 	</para>
    696 </listitem>
    697 </itemizedlist>
    698 </refsection>
    699 
    700  <refsection id="seealso">
    701    <title>See Also</title>
    702    <para>certutil (1)</para>
    703    <para>pk12util (1)</para>
    704    <para>signtool (1)</para>
    705 
    706 <para>The NSS wiki has information on the new database design and how to configure applications to use it.</para>
    707 <itemizedlist>
    708 <listitem>
    709 	<para>
    710 		https://wiki.mozilla.org/NSS_Shared_DB_Howto</para>
    711 </listitem>
    712 <listitem>
    713 	<para>
    714 		https://wiki.mozilla.org/NSS_Shared_DB
    715 	</para>
    716 </listitem>
    717 </itemizedlist>
    718  </refsection>
    719 
    720 <!-- don't change -->
    721  <refsection id="resources">
    722    <title>Additional Resources</title>
    723 <para>For information about NSS and other tools related to NSS (like JSS), check out the NSS project wiki at <ulink url="http://www.mozilla.org/projects/security/pki/nss/">http://www.mozilla.org/projects/security/pki/nss/</ulink>. The NSS site relates directly to NSS code changes and releases.</para>
    724 <para>Mailing lists: https://lists.mozilla.org/listinfo/dev-tech-crypto</para>
    725 <para>IRC: Freenode at #dogtag-pki</para>
    726  </refsection>
    727 
    728 <!-- fill in your name first; keep the other names for reference -->
    729  <refsection id="authors">
    730    <title>Authors</title>
    731    <para>The NSS tools were written and maintained by developers with Netscape, Red Hat,  Sun, Oracle, Mozilla, and Google.</para>
    732    <para>
    733 Authors: Elio Maldonado &lt;emaldona@redhat.com>, Deon Lackey &lt;dlackey@redhat.com>.
    734    </para>
    735  </refsection>
    736 
    737 <!-- don't change -->
    738  <refsection id="license">
    739    <title>LICENSE</title>
    740    <para>Licensed under the Mozilla Public License, v. 2.0.  If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
    741    </para>
    742  </refsection>
    743 
    744 </refentry>