<?Pub UDT _bookmark _target?><?Pub EntList bsol dash hellip gt lt minus?><?Pub CX solbook(book(title()bookinfo()part(3)part(title()partintro()chapter()?><chapter id="scftask-1"><?Pub Tag atict:info tracking="off" ref="0"?><?Pub Tag atict:user
user="sharonr" fullname="Sharon Veach"?><title>Solaris Cryptographic Framework
(Tasks)</title><highlights><itemizedlist><para>This chapter describes how to use the Solaris Cryptographic Framework.
The following is a list of information in this chapter.</para><listitem><para><olink targetptr="scftask-2" remap="internal">Using the Cryptographic Framework
(Task Map)</olink></para>
</listitem><listitem><para><olink targetptr="scftask-24" remap="internal">Protecting Files With the Solaris
Cryptographic Framework (Task Map)</olink></para>
</listitem><listitem><para><olink targetptr="scftask-28" remap="internal">Administering the Cryptographic
Framework (Task Map)</olink></para>
</listitem>
</itemizedlist>
</highlights><sect1 id="scftask-2"><title>Using the Cryptographic Framework (Task Map)</title><indexterm><primary>RC4</primary><see>ARCFOUR kernel provider</see>
</indexterm><indexterm><primary>using</primary><secondary>cryptographic framework task map</secondary>
</indexterm><indexterm><primary>task maps</primary><secondary>cryptographic framework</secondary>
</indexterm><indexterm><primary>task maps</primary><secondary>using the cryptographic framework</secondary>
</indexterm><indexterm><primary>cryptographic framework</primary><secondary>task maps</secondary>
</indexterm><para>The following task map points to tasks for using the cryptographic framework.</para><informaltable frame="all" pgwide="1"><tgroup cols="3" colsep="1" rowsep="1"><colspec colname="colspec0" colwidth="21.80*"/><colspec colname="colspec1" colwidth="44.20*"/><colspec colname="colspec2" colwidth="33.00*"/><thead><row rowsep="1"><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>Protect individual files or sets of files</para>
</entry><entry><para>Ensures that file content has not been tampered with. Prevents files
from being read by intruders. These procedures can be done by ordinary users.</para>
</entry><entry><para><olink targetptr="scftask-24" remap="internal">Protecting Files With the Solaris Cryptographic
Framework (Task Map)</olink></para>
</entry>
</row><row><entry><para>Administer the framework</para>
</entry><entry><para>Adds, configures, and removes software providers. Disables and enables
hardware provider mechanisms. These procedures are administrative procedures.</para>
</entry><entry><para><olink targetptr="scftask-28" remap="internal">Administering the Cryptographic Framework
(Task Map)</olink></para>
</entry>
</row><row><entry><para>Sign a provider</para>
</entry><entry><para>Enables a provider to be added to the Solaris Cryptographic Framework.
 These procedures are developer procedures.</para>
</entry><entry><para><olink targetdoc="gssapipg" targetptr="pkg" remap="external">Appendix F, <citetitle remap="appendix">Packaging and Signing Cryptographic Providers,</citetitle> in <citetitle remap="book">Solaris Security for Developers Guide</citetitle></olink>.</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="scftask-24"><title>Protecting Files With the Solaris Cryptographic
Framework (Task Map)</title><indexterm><primary>encrypting</primary><secondary>files</secondary>
</indexterm><indexterm><primary>hashing</primary><secondary>files</secondary>
</indexterm><indexterm><primary>files</primary><secondary>encrypting</secondary>
</indexterm><indexterm><primary>files</primary><secondary>security</secondary><tertiary>encryption</tertiary>
</indexterm><indexterm><primary>files</primary><secondary>hashing</secondary>
</indexterm><indexterm><primary>task maps</primary><secondary>protecting files with cryptographic mechanisms</secondary>
</indexterm><indexterm><primary>protecting</primary><secondary>files with cryptographic framework</secondary>
</indexterm><indexterm><primary>user procedures</primary><secondary>encrypting files</secondary>
</indexterm><para>The Solaris Cryptographic Framework can help you protect your files.
The following task map points to procedures for listing the available algorithms,
and for protecting your files cryptographically.</para><informaltable frame="all" pgwide="1"><tgroup cols="3" colsep="0" rowsep="0"><colspec colname="colspec0" colwidth="24.37*"/><colspec colname="colspec1" colwidth="41.22*"/><colspec colname="colspec2" colwidth="33.41*"/><thead><row rowsep="1"><entry colsep="1" rowsep="1"><para>Task</para>
</entry><entry colsep="1" rowsep="1"><para>Description</para>
</entry><entry colsep="1" rowsep="1"><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry colsep="1" rowsep="1"><para>Generate a symmetric key</para>
</entry><entry colsep="1" rowsep="1"><para>Generates a random key for use with algorithms that the user specifies.</para>
</entry><entry colsep="1" rowsep="1"><para><olink targetptr="scftask-10" remap="internal">How to Generate a Symmetric Key by Using the dd Command</olink></para>
</entry>
</row><row><entry colsep="1" rowsep="1">
</entry><entry colsep="1" rowsep="1"><para>Generates a key of user-specified length. Optionally, stores the key
in a file, a PKCS #11 keystore, or an NSS keystore.</para>
</entry><entry colsep="1" rowsep="1"><para><olink targetptr="kmf-20" remap="internal">How to Generate a Symmetric Key by Using the
pktool Command</olink></para>
</entry>
</row><row><entry colsep="1" rowsep="1"><para>Provide a checksum that ensures the integrity of a file</para>
</entry><entry colsep="1" rowsep="1"><para>Verifies that the receiver's copy of a file is identical to the file
that was sent.</para>
</entry><entry colsep="1" rowsep="1"><para><olink targetptr="scftask-22" remap="internal">How to Compute a Digest of a File</olink></para>
</entry>
</row><row><entry colsep="1" rowsep="1"><para>Protect a file with a message authentication code (MAC)</para>
</entry><entry colsep="1" rowsep="1"><para>Verifies to the receiver of your message that you were the sender.</para>
</entry><entry colsep="1" rowsep="1"><para><olink targetptr="scftask-20" remap="internal">How to Compute a MAC of a File</olink></para>
</entry>
</row><row><entry colsep="1" rowsep="1"><para>Encrypt a file, and then decrypt the encrypted file</para>
</entry><entry colsep="1" rowsep="1"><para>Protects the content of files by encrypting the file. Provides the encryption
parameters to decrypt the file.</para>
</entry><entry colsep="1" rowsep="1"><para><olink targetptr="scftask-4" remap="internal">How to Encrypt and Decrypt a File</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="scftask-3"><title>Protecting Files With the Solaris Cryptographic
Framework</title><para>This section describes how to generate symmetric keys, how to create
checksums for file integrity, and how to protect files from eavesdropping.
The commands in this section can be run by regular users. Developers can write
scripts that use these commands.</para><task id="scftask-10"><title>How to Generate a Symmetric Key by
Using the <command>dd</command> Command</title><indexterm><primary>generating</primary><secondary>symmetric key </secondary><tertiary>using the <command>dd</command> command</tertiary>
</indexterm><indexterm><primary>generating</primary><secondary>random number</secondary><tertiary>using the <command>dd</command> command</tertiary>
</indexterm><indexterm><primary>encryption</primary><secondary>generating symmetric key</secondary><tertiary>using the <command>dd</command> command</tertiary>
</indexterm><indexterm><primary>computing</primary><secondary>secret key</secondary>
</indexterm><indexterm><primary>keys</primary><secondary>generating symmetric key</secondary><tertiary>using the <command>dd</command> command</tertiary>
</indexterm><indexterm><primary>devices</primary><secondary><filename>/dev/urandom</filename> device</secondary>
</indexterm><indexterm><primary><filename>/dev/urandom</filename> device</primary>
</indexterm><indexterm><primary>secret keys</primary><secondary>creating</secondary>
</indexterm><indexterm><primary>creating</primary><secondary>secret keys</secondary><tertiary>for encryption</tertiary>
</indexterm><indexterm><primary>secret keys</primary><secondary>generating</secondary><tertiary>using the <command>dd</command> command</tertiary>
</indexterm><indexterm><primary>random numbers</primary><secondary><command>dd</command> command</secondary>
</indexterm><indexterm><primary><command>dd</command> command</primary><secondary>generating secret keys</secondary>
</indexterm><indexterm><primary>user procedures</primary><secondary>generating a symmetric key</secondary><tertiary>using the <command>dd</command> command</tertiary>
</indexterm><indexterm><primary>using</primary><secondary><command>dd</command> command</secondary>
</indexterm><tasksummary><para>A key is needed to encrypt files and to generate the MAC of a file.
The key should be derived from a random pool of numbers. To
create the key, you have three options:</para><itemizedlist><listitem><para>If your site has a random number generator, use the generator.</para>
</listitem><listitem><para>If you want to generate the key and store it, see <olink targetptr="kmf-20" remap="internal">How to Generate a Symmetric Key by Using the pktool Command</olink>.</para>
</listitem><listitem><para>Otherwise, use this procedure. This procedure requires that
you provide the key size in bites. In contrast, the <command>pktool</command> command
determines the correct key size according to the algorithm that you specify.</para>
</listitem>
</itemizedlist>
</tasksummary><procedure><step><para>Determine the key length that your algorithm requires.</para><substeps><step><para><indexterm><primary><command>encrypt</command> command</primary><secondary>syntax</secondary></indexterm><indexterm><primary><option>l</option> option</primary><secondary><command>encrypt</command> command</secondary></indexterm>List
the available algorithms.</para><screen>% encrypt -l
Algorithm       Keysize:  Min   Max (bits)
------------------------------------------
aes                       128   128
arcfour                     8   128
des                        64    64
3des                      192   192

% mac -l
Algorithm       Keysize:  Min   Max (bits)
------------------------------------------
des_mac                    64    64
sha1_hmac                   8   512
md5_hmac                    8   512</screen>
</step><step><para>Determine the key length in bytes to pass to the <command>dd</command> command.</para><para>Divide the minimum and maximum key sizes by 8. When the minimum
and maximum key sizes are different, intermediate key sizes are possible.
For example, the value 8, 16, or 64 can be passed to the <command>dd</command> command
for the <literal>sha1_hmac</literal> and <literal>md5_hmac</literal> functions.</para>
</step>
</substeps>
</step><step><para>Generate the symmetric key.</para><screen>% dd if=/dev/urandom of=<replaceable>keyfile</replaceable> bs=<replaceable>n</replaceable> count=<replaceable>n</replaceable></screen><variablelist><varlistentry><term><option role="nodash">if=</option><replaceable>file</replaceable></term><listitem><para>Is the input file. For a random key, use the <filename>/dev/urandom</filename> file.</para>
</listitem>
</varlistentry><varlistentry><term><option role="nodash">of=</option><replaceable>keyfile</replaceable></term><listitem><para>Is the output file that holds the generated key.</para>
</listitem>
</varlistentry><varlistentry><term><option role="nodash">bs=</option><replaceable>n</replaceable></term><listitem><para>Is the key size in bytes. For the length in bytes, divide
the key length in bits by 8.</para>
</listitem>
</varlistentry><varlistentry><term><option role="nodash">count=</option><replaceable>n</replaceable></term><listitem><para>Is the count of the input blocks. The number for <replaceable>n</replaceable> should
be <literal>1</literal>.</para>
</listitem>
</varlistentry>
</variablelist>
</step><step><para>Store your key in a protected directory.</para><para>The key file
should not be readable by anyone but the user.</para><screen>% chmod 400 <replaceable>keyfile</replaceable></screen>
</step>
</procedure><example id="scftask-18"><title>Creating a Key for the AES Algorithm</title><para>In the following example, a secret key for the AES algorithm is created.
The key is also stored for later decryption. AES mechanisms use a 128-bit
key. The key is expressed as 16 bytes in the <command>dd</command> command.</para><screen>% <userinput>ls -al ~/keyf</userinput>
drwx------   2 jdoe  staff        512 May 3 11:32 ./
% <userinput>dd if=/dev/urandom of=$HOME/keyf/05.07.aes16 bs=16  count=1</userinput>
% <userinput>chmod 400 ~/keyf/05.07.aes16</userinput></screen>
</example><example id="scftask-32"><title>Creating a Key for the DES Algorithm</title><para>In the following example, a secret key for the DES algorithm is created.
The key is also stored for later decryption. DES mechanisms use a 64-bit key.
The key is expressed as 8 bytes in the <command>dd</command> command.</para><screen>% <userinput>dd if=/dev/urandom of=$HOME/keyf/05.07.des8 bs=8  count=1</userinput>
% <userinput>chmod 400 ~/keyf/05.07.des8</userinput></screen>
</example><example id="scftask-33"><title>Creating a Key for the 3DES Algorithm</title><para>In the following example, a secret key for the 3DES algorithm is created.
The key is also stored for later decryption. 3DES mechanisms use a 192-bit
key. The key is expressed as 24 bytes in the <command>dd</command> command.</para><screen>% <userinput>dd if=/dev/urandom of=$HOME/keyf/05.07.3des.24 bs=24 count=1</userinput>
% <userinput>chmod 400 ~/keyf/05.07.3des.24</userinput></screen>
</example><example id="scftask-14"><title>Creating a Key for the MD5 Algorithm</title><para>In the following example, a secret key for the MD5 algorithm is created.
The key is also stored for later decryption.  The key is expressed as 64 bytes
in the <command>dd</command> command.</para><screen>% <userinput>dd if=/dev/urandom of=$HOME/keyf/05.07.mack64 bs=64 count=1</userinput>
% <userinput>chmod 400 ~/keyf/05.07.mack64</userinput></screen>
</example>
</task><task id="kmf-20"><title>How to Generate a Symmetric
Key by Using the <command>pktool</command> Command</title><indexterm><primary>computing</primary><secondary>secret key</secondary>
</indexterm><indexterm><primary>creating</primary><secondary>secret keys</secondary><tertiary>for encryption</tertiary>
</indexterm><indexterm><primary>encryption</primary><secondary>generating symmetric key</secondary><tertiary>using the <command>pktool</command> command</tertiary>
</indexterm><indexterm><primary>generating</primary><secondary>symmetric key </secondary><tertiary>using the <command>pktool</command> command</tertiary>
</indexterm><indexterm><primary>keys</primary><secondary>generating symmetric key</secondary><tertiary>using the <command>pktool</command> command</tertiary>
</indexterm><indexterm><primary>secret keys</primary><secondary>generating</secondary><tertiary>using the <command>pktool</command> command</tertiary>
</indexterm><indexterm><primary>generating</primary><secondary>random number</secondary><tertiary>using the <command>pktool</command> command</tertiary>
</indexterm><indexterm><primary>secret keys</primary><secondary>creating</secondary>
</indexterm><indexterm><primary>random numbers</primary><secondary><command>pktool</command> command</secondary>
</indexterm><indexterm><primary><command>pktool</command> command</primary><secondary>generating secret keys</secondary>
</indexterm><indexterm><primary>using</primary><secondary><command>pktool</command> command</secondary>
</indexterm><indexterm><primary>user procedures</primary><secondary>generating a symmetric key</secondary><tertiary>using the <command>pktool</command> command</tertiary>
</indexterm><indexterm><primary>users</primary><secondary>generating a symmetric key</secondary>
</indexterm><tasksummary><para>Some applications require a symmetric key for encryption and decryption
of communications. In this procedure, you create a symmetric key and store
it.</para><itemizedlist><listitem><para>If your site has a random number generator, you can use the
generator to create a random number for the key. This procedure does not use
your site's random number generator.</para>
</listitem><listitem><para>You can instead use the <command>dd</command> command with
the Solaris <filename>/dev/urandom</filename> device as input. The <command>dd</command> command
does not store the key. For the procedure, see <olink targetptr="scftask-10" remap="internal">How to Generate a Symmetric Key by Using the dd Command</olink>.</para>
</listitem>
</itemizedlist>
</tasksummary><procedure><step performance="optional" id="scftask-keystore-1"><para>If you plan to
use a keystore, create it.</para><stepalternatives><step><para>To create and initialize a PKCS #11 keystore, see <olink targetptr="kmf-9" remap="internal">How to Generate a Passphrase by Using the pktool&nbsp;setpin
Command</olink>.</para>
</step><step><para>To create and initialize an NSS database, see <olink targetptr="kmf-11" remap="internal">Example&nbsp;15&ndash;5</olink>.</para>
</step>
</stepalternatives>
</step><step><para>Generate a random number for use as a symmetric key.</para><para>Use
one of the following methods.</para><stepalternatives><step><para>Generate a key and store it in a file.</para><para>The advantage
of a file-stored key is that you can extract the key from this file for use
in an application's key file, such as the <filename>/etc/inet/secret/ipseckeys</filename> file
or IPsec.</para><screen>% pktool genkey keystore=file outkey=<replaceable>key-fn</replaceable> \ 
[keytype=generic|<replaceable>specific-symmetric-algorithm</replaceable>] [keylen=<replaceable>size-in-bits</replaceable>] \
[dir=<replaceable>directory</replaceable>] [print=n]</screen><variablelist termlength="wholeline"><varlistentry><term><literal>keystore</literal></term><listitem><para>The value <literal>file</literal> specifies the file type
of storage location for the key.</para>
</listitem>
</varlistentry><varlistentry><term><literal>outkey=</literal><replaceable>key-fn</replaceable></term><listitem><para>Is the filename when <literal>keystore=file</literal>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>keytype=</literal><replaceable>specific-symmetric-algorithm</replaceable></term><listitem><para>For a symmetric key of any length, the value is <literal>generic</literal>.
For a particular algorithm, specify <literal>aes</literal>, <literal>arcfour</literal>, <literal>des</literal>, or <literal>3des</literal>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>keylen=</literal><replaceable>size-in-bits</replaceable></term><listitem><para>Is the length of the key in bits. The number must be divisible
by 8. Do <emphasis>not</emphasis> specify for <literal>des</literal> or <literal>3des</literal>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>dir=</literal><replaceable>directory</replaceable></term><listitem><para>Is the directory path to <replaceable>key-fn</replaceable>.
By default, <replaceable>directory</replaceable> is the current directory.</para>
</listitem>
</varlistentry><varlistentry><term><literal>print=n</literal></term><listitem><para>Prints the key to the terminal window. By default, the value
of <literal>print</literal> is <literal>n</literal>.</para>
</listitem>
</varlistentry>
</variablelist>
</step><step><para>Generate a key and store it in a PKCS #11 keystore.</para><para>The
advantage of the PKCS #11 keystore is that you can retrieve the key by its
label. This method is useful for keys that encrypt and decrypt files. You
must complete <olink targetptr="scftask-keystore-1" remap="internal">Step&nbsp;1</olink> before
using this method.</para><screen>% pktool genkey label=<replaceable>key-label</replaceable> \ 
[keytype=generic|<replaceable>specific-symmetric-algorithm</replaceable>] [keylen=<replaceable>size-in-bits</replaceable>] [token=<replaceable>token</replaceable>] \
[sensitive=n] [extractable=y] [print=n]</screen><variablelist termlength="wholeline"><varlistentry><term><literal>label=</literal><replaceable>key-label</replaceable></term><listitem><para>Is a user-specified label for the key. The key can be retrieved
from the keystore by its label.</para>
</listitem>
</varlistentry><varlistentry><term><literal>keytype=</literal><replaceable>specific-symmetric-algorithm</replaceable></term><listitem><para>For a symmetric key of any length, the value is <literal>generic</literal>.
For a particular algorithm, specify <literal>aes</literal>, <literal>arcfour</literal>, <literal>des</literal>, or <literal>3des</literal>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>keylen=</literal><replaceable>size-in-bits</replaceable></term><listitem><para>Is the length of the key in bits. The number must be divisible
by 8. Do <emphasis>not</emphasis> specify for <literal>des</literal> or <literal>3des</literal>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>token=</literal><replaceable>token</replaceable></term><listitem><para>Is the token name. By default, the token is <literal>Sun Software
PKCS#11 softtoken</literal>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>sensitive=n</literal></term><listitem><para>Specifies the sensitivity of the key. When the value is <literal>y</literal>, the key cannot be printed by using the <literal>print=y</literal> argument.
By default, the value of <literal>sensitive</literal> is <literal>n</literal>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>extractable=y</literal></term><listitem><para>Specifies that the key can be extracted from the keystore.
Specify <literal>n</literal> to prevent the key from being extracted.</para>
</listitem>
</varlistentry><varlistentry><term><literal>print=n</literal></term><listitem><para>Prints the key to the terminal window. By default, the value
of <literal>print</literal> is <literal>n</literal>.</para>
</listitem>
</varlistentry>
</variablelist>
</step><step><para>Generate a key and store it in an NSS keystore.</para><para>You
must complete <olink targetptr="scftask-keystore-1" remap="internal">Step&nbsp;1</olink> before
using this method.</para><screen>% pktool keystore=nss genkey label=<replaceable>key-label</replaceable> \ 
[keytype=generic|<replaceable>specific-symmetric-algorithm</replaceable>] [keylen=<replaceable>size-in-bits</replaceable>] [token=<replaceable>token</replaceable>] \
[dir=<replaceable>directory-path</replaceable>] [prefix=<replaceable>database-prefix</replaceable>]</screen><variablelist termlength="wholeline"><varlistentry><term><literal>keystore</literal></term><listitem><para>The value <literal>nss</literal> specifies the NSS type of
storage location for the key.</para>
</listitem>
</varlistentry><varlistentry><term><literal>label=</literal><replaceable>key-label</replaceable></term><listitem><para>Is a user-specified label for the key. The key can be retrieved
from the keystore by its label.</para>
</listitem>
</varlistentry><varlistentry><term><literal>keytype=</literal><replaceable>specific-symmetric-algorithm</replaceable></term><listitem><para>For a symmetric key of any length, the value is <literal>generic</literal>.
For a particular algorithm, specify <literal>aes</literal>, <literal>arcfour</literal>, <literal>des</literal>, or <literal>3des</literal>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>keylen=</literal><replaceable>size-in-bits</replaceable></term><listitem><para>Is the length of the key in bits. The number must be divisible
by 8. Do <emphasis>not</emphasis> specify for <literal>des</literal> or <literal>3des</literal>.</para>
</listitem>
</varlistentry><varlistentry><term><literal>token=</literal><replaceable>token</replaceable></term><listitem><para>Is the token name. By default, the token is the NSS internal
token.</para>
</listitem>
</varlistentry><varlistentry><term><literal>dir=</literal><replaceable>directory</replaceable></term><listitem><para>Is the directory path to the NSS database. By default, <replaceable>directory</replaceable> is the current directory.</para>
</listitem>
</varlistentry><varlistentry><term><literal>prefix=</literal><replaceable>directory</replaceable></term><listitem><para>Is the prefix to the NSS database. The default is no prefix.</para>
</listitem>
</varlistentry><varlistentry><term><literal>print=n</literal></term><listitem><para>Prints the key to the terminal window. By default, the value
of <literal>print</literal> is <literal>n</literal>.</para>
</listitem>
</varlistentry>
</variablelist>
</step>
</stepalternatives>
</step><step performance="optional"><para>Verify that the key exists.</para><para>Use
one of the following commands, depending on where you stored the key.</para><stepalternatives><step><para>Verify the key in the <replaceable>key-fn</replaceable> file.</para><screen>% pktool list keystore=file objtype=key infile=<replaceable>key-fn</replaceable>
Found <replaceable>n</replaceable> keys.
Key #1 - <replaceable>keytype</replaceable>:<replaceable>location (keylen)</replaceable></screen>
</step><step><para>Verify the key in the PKCS #11 or the NSS keystore.</para><screen>$ pktool list objtype=key
Enter PIN for <replaceable>keystore</replaceable>:
Found <replaceable>n</replaceable> keys.
Key #1 - <replaceable>keytype</replaceable>:<replaceable>location (keylen)</replaceable></screen>
</step>
</stepalternatives>
</step>
</procedure><example id="kmf-21"><title>Creating a Symmetric Key by Using the <command>pktool</command> Command</title><para>In the following example, a user creates a PKCS #11 keystore for the
first time, and then generates a large symmetric key for an application. Finally,
the user verifies that the key is in the keystore.</para><screen># <userinput>pktool setpin</userinput>
Create new passphrase:<lineannotation>easily-remembered-hard-to-detect-password</lineannotation>
Re-enter new passphrase:<lineannotation>Retype password</lineannotation>
Passphrase changed.
% <userinput>pktool genkey label=specialappkey keytype=generic keylen=1024</userinput>
Enter PIN for Sun Software PKCS#11 softtoken  :<lineannotation>Type password</lineannotation>

% <userinput>pktool list objtype=key</userinput>
Enter PIN for Sun Software PKCS#11 softtoken  :<lineannotation>Type password</lineannotation>

Found 1 keys.
Key #1 - symmetric:  specialappkey (1024 bits)</screen>
</example><example id="scftask-53"><title>Creating a DES Key by Using the <command>pktool</command> Command</title><para>In the following example, a secret key for the DES algorithm is created.
The key is stored in a local file for later decryption. The command protects
the file with <literal>400</literal> permissions. When the key is created,
the <literal>print=y</literal> option displays the generated key in the terminal
window.</para><para>DES mechanisms use a 64-bit key. The user who owns the keyfile retrieves
the key by using the <command>od</command> command.</para><screen>% <userinput>pktool genkey keystore=file outkey=64bit.file1 keytype=des print=y</userinput>
        Key Value ="a3237b2c0a8ff9b3"
% <userinput>od -x 64bit.file1</userinput>
0000000 a323 7b2c 0a8f f9b3</screen>
</example><example id="scftask-55"><title>Creating a Symmetric Key for IPsec Security Associations</title><para>In the following example, the administrator manually creates the keying
material for IPsec SAs and stores them in files. Then, the administrator copies
the keys to the <filename>/etc/inet/secret/ipseckeys</filename> file and destroys
the original files.</para><itemizedlist><listitem><para>First, the administrator creates and displays the keys that
the IPsec policy requires:</para><screen># <userinput>pktool genkey keystore=file outkey=ipencrin1 keytype=generic keylen=192 print=y</userinput>
        Key Value ="294979e512cb8e79370dabecadc3fcbb849e78d2d6bd2049"
# <userinput>pktool genkey keystore=file outkey=ipencrout1 keytype=generic keylen=192 print=y</userinput>
        Key Value ="9678f80e33406c86e3d1686e50406bd0434819c20d09d204"
# <userinput>pktool genkey keystore=file outkey=ipspi1 keytype=generic keylen=32 print=y</userinput>
        Key Value ="acbeaa20"
# <userinput>pktool genkey keystore=file outkey=ipspi2 keytype=generic keylen=32 print=y</userinput>
        Key Value ="19174215"
# <userinput>pktool genkey keystore=file outkey=ipmd51 keytype=generic keylen=64 print=y</userinput>
        Key Value ="438c3ad2cec9a3621e90462d11ca7d2f"
# <userinput>pktool genkey keystore=file outkey=ipmd52 keytype=generic keylen=64 print=y</userinput>
        Key Value ="a61319630cf2abde7609ce24de3d029f"</screen>
</listitem><listitem><para>Then, the administrator creates the following <filename>/etc/inet/secret/ipseckeys</filename> file:</para><screen>##   SPI values require a leading 0x.
##   Backslashes indicate command continuation.
##
## for outbound packets on this system
add esp spi 0xacbeaa20 \
   src 192.168.1.1 dst 192.168.2.1 \
   encr_alg 3des auth_alg md5  \
   encrkey  294979e512cb8e79370dabecadc3fcbb849e78d2d6bd2049 \
   authkey  438c3ad2cec9a3621e90462d11ca7d2f
##
## for inbound packets
add esp spi 0x19174215 \
   src 192.168.2.1 dst 192.168.1.1 \
   encr_alg 3des auth_alg md5  \
   encrkey 9678f80e33406c86e3d1686e50406bd0434819c20d09d204 \
   authkey a61319630cf2abde7609ce24de3d029f</screen>
</listitem><listitem><para>After verifying that the syntax of the <filename>ipseckeys</filename> file
is valid, the administrator destroys the original key files.</para><screen># <userinput>ipseckey -c /etc/inet/secret/ipseckeys</userinput>
# <userinput>rm ipencrin1 ipencrout1 ipspi1 ipspi2 ipmd51 ipmd52</userinput></screen>
</listitem><listitem><para>The administrator copies the <filename>ipseckeys</filename> file
to the communicating system by using the <command>ssh</command> command or
another secure mechanism. On the communicating system, the protections are
reversed. The first entry in the <filename>ipseckeys</filename> file protects
inbound packets, and the second entry protects outbound packets. No keys are
generated on the communicating system.</para>
</listitem>
</itemizedlist>
</example>
</task><task id="scftask-22"><title>How to Compute a Digest of a File</title><indexterm><primary>new features</primary><secondary>commands</secondary><tertiary><command>digest</command></tertiary>
</indexterm><indexterm><primary>computing</primary><secondary>digest of a file</secondary>
</indexterm><indexterm><primary>digests</primary><secondary>computing for file</secondary>
</indexterm><indexterm><primary>files</primary><secondary>computing digests of</secondary>
</indexterm><indexterm><primary>security</primary><secondary>computing digest of files</secondary>
</indexterm><indexterm><primary>users</primary><secondary>computing digest of files</secondary>
</indexterm><indexterm><primary>using</primary><secondary><command>digest</command> command</secondary>
</indexterm><indexterm><primary>digests</primary><secondary>of files</secondary>
</indexterm><indexterm><primary>creating</primary><secondary>file digests</secondary>
</indexterm><indexterm><primary>files</primary><secondary>computing a digest</secondary>
</indexterm><indexterm><primary>files</primary><secondary>verifying integrity with <command>digest</command></secondary>
</indexterm><indexterm><primary>files</primary><secondary>digest of</secondary>
</indexterm><indexterm><primary>user procedures</primary><secondary>computing digest of a file</secondary>
</indexterm><tasksummary><para>When you compute a digest of a file, you can check to see that the file
has not been tampered with by comparing digest outputs. A digest does not
alter the original file.</para>
</tasksummary><procedure><step id="scftask-digest-1"><para><indexterm><primary><command>digest</command> command</primary><secondary>syntax</secondary></indexterm><indexterm><primary><option>l</option> option</primary><secondary><command>digest</command> command</secondary></indexterm>List
the available digest algorithms.</para><screen>% <userinput>digest -l</userinput>
sha1
md5
sha256
sha384
sha512</screen>
</step><step><para><indexterm><primary><option>a</option> option</primary><secondary><command>digest</command> command</secondary></indexterm><indexterm><primary><option>v</option> option</primary><secondary><command>digest</command> command</secondary></indexterm>Compute
the digest of the file and save the digest listing.</para><para>Provide an
algorithm with the <command>digest</command> command.</para><screen>% digest -v -a <replaceable>algorithm input-file</replaceable> &gt; <replaceable>digest-listing</replaceable></screen><variablelist><varlistentry><term><option>v</option></term><listitem><para>Displays the output in the following format:</para><screen><replaceable>algorithm</replaceable> (<replaceable>input-file</replaceable>) = <replaceable>digest</replaceable></screen>
</listitem>
</varlistentry><varlistentry><term><option>a</option> <replaceable>algorithm</replaceable></term><listitem><para>Is the algorithm to use to compute a digest of the file. Type
the algorithm as the algorithm appears in the output of <olink targetptr="scftask-digest-1" remap="internal">Step&nbsp;1</olink>.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>input-file</replaceable></term><listitem><para>Is the input file for the <command>digest</command> command.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>digest-listing</replaceable></term><listitem><para>Is the output file for the <command>digest</command> command.</para>
</listitem>
</varlistentry>
</variablelist>
</step>
</procedure><example id="scftask-34"><title>Computing a Digest With the MD5 Mechanism</title><para><indexterm><primary>digests</primary><secondary>of files</secondary></indexterm><indexterm><primary>files</primary><secondary>computing digests of</secondary></indexterm><indexterm><primary><command>digest</command> command</primary><secondary>example</secondary></indexterm><indexterm><primary>viewing</primary><secondary>digest of a file</secondary></indexterm>In the following example,
the <command>digest</command> command uses the MD5 mechanism to compute a
digest for an email attachment.</para><screen>% <userinput>digest -v -a md5 email.attach &gt;&gt;  $HOME/digest.emails.05.07</userinput>
% <userinput>cat  ~/digest.emails.05.07</userinput>
md5 (email.attach) = 85c0a53d1a5cc71ea34d9ee7b1b28b01</screen><para>When the <option>v</option> option is not used, the digest is saved
with no accompanying information:</para><screen>% <userinput>digest -a md5 email.attach &gt;&gt;  $HOME/digest.emails.05.07</userinput>
% <userinput>cat  ~/digest.emails.05.07</userinput>
85c0a53d1a5cc71ea34d9ee7b1b28b01</screen>
</example><example id="scftask-35"><title>Computing a Digest With the SHA1 Mechanism</title><para>In the following example, the <command>digest</command> command uses
the SHA1 mechanism to provide a directory listing. The results are placed
in a file.</para><screen>% <userinput>digest -v -a sha1 docs/* &gt; $HOME/digest.docs.legal.05.07</userinput>
% <userinput>more ~/digest.docs.legal.05.07</userinput>
sha1 (docs/legal1) = 1df50e8ad219e34f0b911e097b7b588e31f9b435
sha1 (docs/legal2) = 68efa5a636291bde8f33e046eb33508c94842c38
sha1 (docs/legal3) = 085d991238d61bd0cfa2946c183be8e32cccf6c9
sha1 (docs/legal4) = f3085eae7e2c8d008816564fdf28027d10e1d983</screen>
</example>
</task><task id="scftask-20"><title>How to Compute a MAC of a File</title><indexterm><primary>new features</primary><secondary>commands</secondary><tertiary><command>mac</command></tertiary>
</indexterm><indexterm><primary>computing</primary><secondary>MAC of a file</secondary>
</indexterm><indexterm><primary>message authentication code (MAC)</primary><secondary>computing for file</secondary>
</indexterm><indexterm><primary>files</primary><secondary>computing MAC of</secondary>
</indexterm><indexterm><primary>security</primary><secondary>computing MAC of files</secondary>
</indexterm><indexterm><primary>users</primary><secondary>computing MAC of files</secondary>
</indexterm><indexterm><primary>using</primary><secondary><command>mac</command> command</secondary>
</indexterm><indexterm><primary>user procedures</primary><secondary>computing MAC of a file</secondary>
</indexterm><tasksummary><para>A message authentication code, or MAC, computes a digest for the file
and uses a secret key to further protect the digest. A MAC does not alter
the original file.</para>
</tasksummary><procedure><step><para><indexterm><primary><command>mac</command> command</primary><secondary>syntax</secondary></indexterm><indexterm><primary><option>l</option> option</primary><secondary><command>mac</command> command</secondary></indexterm>List
the available mechanisms.</para><screen>% <userinput>mac -l</userinput>
Algorithm       Keysize:  Min   Max (bits)
------------------------------------------
des_mac                    64    64
sha1_hmac                   8   512
md5_hmac                    8   512
sha256_hmac                 8   512
sha384_hmac                 8  1024
sha512_hmac                 8  1024</screen>
</step><step id="scftask-genkey-1"><para>Generate a symmetric key of the appropriate
length.</para><para>You have two options. You can provide a <olink targetptr="glossary-101" remap="internal">passphrase</olink> from which a key will be generated.
Or you can provide a key.</para><itemizedlist><listitem><para><indexterm><primary>passphrases</primary><secondary><command>mac</command> command</secondary></indexterm>If you provide a passphrase, you must store or remember
the passphrase. If you store the passphrase online, the passphrase file should
be readable only by you.</para>
</listitem><listitem><para>If you provide a key, it must be the correct size for the
mechanism. For the procedure, see <olink targetptr="scftask-10" remap="internal">How to Generate a Symmetric Key by Using the dd Command</olink>.  You can also
use the <command>pktool</command> command. For the procedure and some examples,
see <olink targetptr="kmf-20" remap="internal">How to Generate a Symmetric Key by Using the
pktool Command</olink>.</para>
</listitem>
</itemizedlist>
</step><step><para><indexterm><primary><option>a</option> option</primary><secondary><command>mac</command> command</secondary></indexterm><indexterm><primary><option>v</option> option</primary><secondary><command>mac</command> command</secondary></indexterm><indexterm><primary sortas="k1"><option>k</option> option</primary><secondary><command>mac</command> command</secondary></indexterm>Create a MAC for a file.</para><para>Provide a key
and use a symmetric key algorithm with the <command>mac</command> command.</para><screen>% mac [-v] -a <replaceable>algorithm</replaceable> [-k <replaceable>keyfile</replaceable> | -K <replaceable>key-label</replaceable> [-T <replaceable>token</replaceable>]] <replaceable>input-file</replaceable></screen><variablelist><varlistentry><term><option>v</option></term><listitem><para>Displays the output in the following format:</para><screen><replaceable>algorithm</replaceable> (<replaceable>input-file</replaceable>) = <replaceable>mac</replaceable></screen>
</listitem>
</varlistentry><varlistentry><term><option>a</option> <replaceable>algorithm</replaceable></term><listitem><para>Is the algorithm to use to compute the MAC. Type the algorithm
as the algorithm appears in the output of the <command>mac -l</command> command.</para>
</listitem>
</varlistentry><varlistentry><term><option>k</option> <replaceable>keyfile</replaceable></term><listitem><para>Is the file that contains a key of algorithm-specified length.</para>
</listitem>
</varlistentry><varlistentry><term><option>K</option> <replaceable>key-label</replaceable></term><listitem><para><indexterm><primary><option>K</option> option</primary><secondary><command>mac</command> command</secondary></indexterm>Is the label
of a key in the PKCS #11 keystore.</para>
</listitem>
</varlistentry><varlistentry><term><option>T</option> <replaceable>token</replaceable></term><listitem><para><indexterm><primary><option>T</option> option</primary><secondary><command>mac</command> command</secondary></indexterm>Is the token
name. By default, the token is <literal>Sun Software PKCS#11 softtoken</literal>.
Is used only when the <option>K</option> <replaceable>key-label</replaceable> option
is used.</para>
</listitem>
</varlistentry><varlistentry><term><replaceable>input-file</replaceable></term><listitem><para>Is the input file for the MAC.</para>
</listitem>
</varlistentry>
</variablelist>
</step>
</procedure><example id="scftask-36"><title>Computing a MAC With DES_MAC and a Passphrase</title><indexterm><primary>passphrases</primary><secondary>using for MAC</secondary>
</indexterm><para>In the following example, the email attachment is authenticated with
the DES_MAC mechanism and a key that is derived from a passphrase. The MAC
listing is saved to a file. If the passphrase is stored in a file, the file
should not be readable by anyone but the user.</para><screen>% <userinput>mac -v -a des_mac email.attach</userinput>
Enter key: <lineannotation>&lt;Type passphrase&gt;</lineannotation>
des_mac (email.attach) = dd27870a
% <userinput>echo "des_mac (email.attach) = dd27870a" &gt;&gt; ~/desmac.daily.05.07</userinput></screen>
</example><example id="scftask-45"><title>Computing a MAC With MD5_HMAC and a Key File</title><indexterm><primary>keys</primary><secondary>using for MAC</secondary>
</indexterm><indexterm><primary>viewing</primary><secondary>MAC of a file</secondary>
</indexterm><para>In the following example, the email attachment is authenticated with
the MD5_HMAC mechanism and a secret key. The MAC listing is saved to a file.</para><screen>% <userinput>mac -v -a md5_hmac -k $HOME/keyf/05.07.mack64 email.attach</userinput>
md5_hmac (email.attach) = 02df6eb6c123ff25d78877eb1d55710c
% <userinput>echo "md5_hmac (email.attach) = 02df6eb6c123ff25d78877eb1d55710c" \</userinput>
<userinput>&gt;&gt; ~/mac.daily.05.07</userinput></screen>
</example><example id="scftask-37"><title>Computing a MAC With SHA1_HMAC and a Key File</title><para>In the following example, the directory manifest is authenticated with
the SHA1_HMAC mechanism and a secret key. The results are placed in a file.</para><screen>% <userinput>mac -v -a sha1_hmac \</userinput>
<userinput>-k $HOME/keyf/05.07.mack64 docs/* &gt; $HOME/mac.docs.legal.05.07</userinput>
% <userinput>more ~/mac.docs.legal.05.07</userinput>
sha1_hmac (docs/legal1) = 9b31536d3b3c0c6b25d653418db8e765e17fe07a
sha1_hmac (docs/legal2) = 865af61a3002f8a457462a428cdb1a88c1b51ff5
sha1_hmac (docs/legal3) = 076c944cb2528536c9aebd3b9fbe367e07b61dc7
sha1_hmac (docs/legal4) = 7aede27602ef6e4454748cbd3821e0152e45beb4</screen>
</example><example id="scftask-52"><title>Computing a MAC With SHA1_HMAC and a Key Label</title><para>In the following example, the directory manifest is authenticated with
the SHA1_HMAC mechanism and a secret key. The results are placed in the user's
PKCS #11 keystore. The user initially created the keystore and the password
to the keystore by using the <command>pktool setpin</command> command.</para><screen>% <userinput>mac -a sha1_hmac -K legaldocs0507 docs/*</userinput>
Enter pin for Sun Software PKCS#11 softtoken:<lineannotation>Type password</lineannotation></screen><para>To retrieve the MAC from the keystore, the user uses the verbose option,
and provides the key label and the name of the directory that was authenticated.</para><screen>% <userinput>mac -v -a sha1_hmac -K legaldocs0507  docs/*</userinput>
Enter pin for Sun Software PKCS#11 softtoken:<lineannotation>Type password</lineannotation>
sha1_hmac (docs/legal1) = 9b31536d3b3c0c6b25d653418db8e765e17fe07a
sha1_hmac (docs/legal2) = 865af61a3002f8a457462a428cdb1a88c1b51ff5
sha1_hmac (docs/legal3) = 076c944cb2528536c9aebd3b9fbe367e07b61dc7
sha1_hmac (docs/legal4) = 7aede27602ef6e4454748cbd3821e0152e45beb4</screen>
</example>
</task><task id="scftask-4"><title>How to Encrypt and Decrypt a File</title><indexterm><primary>new features</primary><secondary>commands</secondary><tertiary><command>encrypt</command></tertiary>
</indexterm><indexterm><primary>encrypting</primary><secondary><command>encrypt</command> command</secondary>
</indexterm><indexterm><primary>files</primary><secondary>encrypting</secondary>
</indexterm><indexterm><primary>security</primary><secondary>encrypting files</secondary>
</indexterm><indexterm><primary>users</primary><secondary>encrypting files</secondary>
</indexterm><indexterm><primary>using</primary><secondary><command>encrypt</command> command</secondary>
</indexterm><indexterm><primary>encrypting</primary><secondary>files</secondary>
</indexterm><indexterm><primary>user procedures</primary><secondary>decrypting files</secondary>
</indexterm><tasksummary><para>When you encrypt a file, the original file is not removed or changed.
The output file is encrypted.</para><para>For solutions to common errors from the <command>encrypt</command> command,
see the section that follows the examples.</para>
</tasksummary><procedure><step id="scftask-genkey-2"><para>Create a symmetric key of the appropriate
length.</para><para><indexterm><primary>passphrases</primary><secondary><command>encrypt</command> command</secondary></indexterm>You have two options. You
can provide a <olink targetptr="glossary-101" remap="internal">passphrase</olink> from which
a key will be generated. Or you can provide a key.</para><itemizedlist><listitem><para>If you provide a passphrase, you must store or remember the
passphrase. If you store the passphrase online, the passphrase file should
be readable only by you.</para>
</listitem><listitem><para>If you provide a key, it must be the correct size for the
mechanism. For the procedure, see <olink targetptr="scftask-10" remap="internal">How to Generate a Symmetric Key by Using the dd Command</olink>.  You can also
use the <command>pktool</command> command. For the procedure and some examples,
see <olink targetptr="kmf-20" remap="internal">How to Generate a Symmetric Key by Using the
pktool Command</olink>.</para>
</listitem>
</itemizedlist>
</step><step><para><indexterm><primary><option>a</option> option</primary><secondary><command>encrypt</command> command</secondary></indexterm><indexterm><primary><option>i</option> option</primary><secondary><command>encrypt</command> command</secondary></indexterm><indexterm><primary sortas="k1"><option>k</option> option</primary><secondary><command>encrypt</command> command</secondary></indexterm><indexterm><primary><option>o</option> option</primary><secondary><command>encrypt</command> command</secondary></indexterm>Encrypt
a file.</para><para>Provide a key and use a symmetric key algorithm with the <command>encrypt</command> command.</para><screen>% encrypt -a <replaceable>algorithm</replaceable> [-v] \
[-k <replaceable>keyfile</replaceable> | -K <replaceable>key-label</replaceable> [-T <replaceable>token</replaceable>]] [-i <replaceable>input-file</replaceable>] [-o <replaceable>output-file</replaceable>]</screen><variablelist><varlistentry><term><option>a</option> <replaceable>algorithm</replaceable></term><listitem><para>Is the algorithm to use to encrypt the file.  Type the algorithm
as the algorithm appears in the output of the <command>encrypt -l</command> command.</para>
</listitem>
</varlistentry><varlistentry><term><option>k</option> <replaceable>keyfile</replaceable></term><listitem><para>Is the file that contains a key of algorithm-specified length.
 The key length for each algorithm is listed, in bits, in the output of the <command>encrypt -l</command> command.</para>
</listitem>
</varlistentry><varlistentry><term><option>K</option> <replaceable>key-label</replaceable></term><listitem><para><indexterm><primary><option>K</option> option</primary><secondary><command>encrypt</command> command</secondary></indexterm>Is the
label of a key in the PKCS #11 keystore.</para>
</listitem>
</varlistentry><varlistentry><term><option>T</option> <replaceable>token</replaceable></term><listitem><para><indexterm><primary><option>T</option> option</primary><secondary><command>encrypt</command> command</secondary></indexterm>Is the
token name. By default, the token is <literal>Sun Software PKCS#11 softtoken</literal>.
Is used only when the <option>K</option> <replaceable>key-label</replaceable> option
is used.</para>
</listitem>
</varlistentry><varlistentry><term><option>i</option> <replaceable>input-file</replaceable></term><listitem><para>Is the input file that you want to encrypt. This file is left
unchanged by the command.</para>
</listitem>
</varlistentry><varlistentry><term><option>o</option> <replaceable>output-file</replaceable></term><listitem><para>Is the output file that is the encrypted form of the input
file.</para>
</listitem>
</varlistentry>
</variablelist>
</step>
</procedure><example id="scftask-54"><title>Creating an AES Key for Encrypting Your Files</title><para>In the following example, a user creates and stores an AES key in an
existing PKCS #11 keystore for use in encryption and decryption. The user
can verify that the key exists and can use the key, but cannot view the key
itself.</para><screen>% <userinput>pktool genkey label=MyAESkeynumber1 keytype=aes keylen=256</userinput>
Enter PIN for Sun Software PKCS#11 softtoken  :<lineannotation>Type password</lineannotation>

% <userinput>pktool list objtype=key</userinput>
Enter PIN for Sun Software PKCS#11 softtoken  :&lt;<replaceable>Type password</replaceable>&gt;
Found 1 key
Key #1 - Sun Software PKCS#11 softtoken: MyAESkeynumber1 (256)</screen><para>To use the key to encrypt a file, the user retrieves the key by its
label.</para><screen>% <userinput>encrypt -a aes -K MyAESkeynumber1 -i encryptthisfile -o encryptedthisfile</userinput></screen><para>To decrypt the <filename>encryptedthisfile</filename> file, the user
retrieves the key by its label.</para><screen>% <userinput>decrypt -a aes -K MyAESkeynumber1 -i encryptedthisfile -o sameasencryptthisfile</userinput></screen>
</example><example id="scftask-47"><title>Encrypting and Decrypting With AES and a Passphrase</title><indexterm><primary>decrypting</primary><secondary>files</secondary>
</indexterm><indexterm><primary>files</primary><secondary>decrypting</secondary>
</indexterm><indexterm><primary><command>decrypt</command> command</primary><secondary>syntax</secondary>
</indexterm><para><indexterm><primary>passphrases</primary><secondary>storing safely</secondary></indexterm><indexterm><primary>storing</primary><secondary>passphrase</secondary></indexterm>In the following example, a file is encrypted with the AES algorithm.
The key is generated from the passphrase. If the passphrase is stored in a
file, the file should not be readable by anyone but the user.</para><screen>% <userinput>encrypt -a aes -i ticket.to.ride -o ~/enc/e.ticket.to.ride</userinput>
Enter key: <lineannotation>&lt;Type passphrase&gt;</lineannotation></screen><para>The input file, <filename>ticket.to.ride</filename>, still exists in
its original form.</para><para><indexterm><primary>new features</primary><secondary>commands</secondary><tertiary><command>decrypt</command></tertiary></indexterm>To decrypt the
output file, the user uses the same passphrase and encryption mechanism that
encrypted the file.</para><screen>% <userinput>decrypt -a aes -i ~/enc/e.ticket.to.ride -o ~/d.ticket.to.ride</userinput>
Enter key: <lineannotation>&lt;Type passphrase&gt;</lineannotation></screen>
</example><example id="scftask-38"><title>Encrypting and Decrypting With AES and a Key File</title><para>In the following example, a file is encrypted with the AES algorithm.
AES mechanisms use a key of 128 bits, or 16 bytes.</para><screen>% <userinput>encrypt -a aes -k ~/keyf/05.07.aes16 \</userinput>
<userinput>-i ticket.to.ride -o ~/enc/e.ticket.to.ride</userinput> </screen><para>The input file, <filename>ticket.to.ride</filename>, still exists in
its original form.</para><para>To decrypt the output file, the user uses the same key and encryption
mechanism that encrypted the file.</para><screen>% <userinput>decrypt -a aes -k ~/keyf/05.07.aes16  \</userinput>
<userinput>-i ~/enc/e.ticket.to.ride -o ~/d.ticket.to.ride</userinput></screen>
</example><example id="scftask-39"><title>Encrypting and Decrypting With ARCFOUR and a Key File</title><para>In the following example, a file is encrypted with the ARCFOUR algorithm.
The ARCFOUR algorithm accepts a key of 8 bits (1 byte), 64 bits (8 bytes),
or 128 bits (16 bytes).</para><screen>% <userinput>encrypt -a arcfour -i personal.txt \</userinput>
<userinput>-k ~/keyf/05.07.rc4.8 -o ~/enc/e.personal.txt</userinput></screen><para>To decrypt the output file, the user uses the same key and encryption
mechanism that encrypted the file.</para><screen>% <userinput>decrypt -a arcfour -i ~/enc/e.personal.txt \</userinput>
<userinput>-k ~/keyf/05.07.rc4.8 -o ~/personal.txt</userinput></screen>
</example><example id="scftask-40"><title>Encrypting and Decrypting With 3DES and a Key File</title><para>In the following example, a file is encrypted with the 3DES algorithm.
The 3DES algorithm requires a key of 192 bits, or 24 bytes.</para><screen>% <userinput>encrypt -a 3des -k ~/keyf/05.07.des24 \</userinput>
<userinput>-i ~/personal2.txt -o ~/enc/e.personal2.txt</userinput></screen><para>To decrypt the output file, the user uses the same key and encryption
mechanism that encrypted the file.</para><screen>% <userinput>decrypt -a 3des -k ~/keyf/05.07.des24 \</userinput>
<userinput>-i ~/enc/e.personal2.txt -o ~/personal2.txt</userinput></screen>
</example><taskrelated role="troubleshooting"><para><indexterm><primary>cryptographic framework</primary><secondary>error messages</secondary></indexterm><indexterm><primary>troubleshooting</primary><secondary><command>encrypt</command> command</secondary></indexterm><indexterm><primary>error messages</primary><secondary><command>encrypt</command> command</secondary></indexterm><indexterm><primary>troubleshooting</primary><secondary><command>encrypt</command> command</secondary></indexterm><indexterm><primary><command>encrypt</command> command</primary><secondary>troubleshooting</secondary></indexterm><indexterm><primary><command>encrypt</command> command</primary><secondary>error messages</secondary></indexterm>The following messages indicate that the key that you provided
to the <command>encrypt</command> command is not permitted by the algorithm
that you are using.</para><itemizedlist><listitem><para><literal>encrypt: unable to create key for crypto operation:
CKR_ATTRIBUTE_VALUE_INVALID</literal></para>
</listitem><listitem><para><literal>encrypt: failed to initialize crypto operation: CKR_KEY_SIZE_RANGE</literal></para>
</listitem>
</itemizedlist><para>If you pass a key that does not meet the requirements of the algorithm,
you must supply a better key.</para><itemizedlist><listitem><para>One option is to use a passphrase. The framework then provides
a key that meets the requirements.</para>
</listitem><listitem><para>The second option is to pass a key size that the algorithm
accepts. For example, the DES algorithm requires a key of 64 bits. The 3DES
algorithm requires a key of 192 bits.</para>
</listitem>
</itemizedlist>
</taskrelated>
</task>
</sect1><sect1 id="scftask-28"><title>Administering the Cryptographic Framework
(Task Map)</title><indexterm><primary>task maps</primary><secondary>administering cryptographic framework</secondary>
</indexterm><indexterm><primary>administering</primary><secondary>cryptographic framework task map</secondary>
</indexterm><para>The following task map points to procedures for administering software
and hardware providers in the Solaris Cryptographic Framework.</para><informaltable frame="topbot" pgwide="1"><tgroup cols="3" colsep="1" rowsep="1"><colspec colname="colspec0" colwidth="24.40*"/><colspec colname="colspec1" colwidth="39.40*"/><colspec colname="colspec2" colwidth="35.20*"/><thead><row rowsep="1"><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>List the providers in the Solaris Cryptographic Framework</para>
</entry><entry><para>Lists the algorithms, libraries, and hardware devices that are available
for use in the Solaris Cryptographic Framework.</para>
</entry><entry><para><olink targetptr="scftask-6" remap="internal">How to List Available Providers</olink></para>
</entry>
</row><row><entry><para>Add a software provider</para>
</entry><entry><para>Adds a PKCS #11 library or a kernel module to the Solaris Cryptographic
Framework. The provider must be signed.</para>
</entry><entry><para><olink targetptr="scftask-11" remap="internal">How to Add a Software Provider</olink></para>
</entry>
</row><row><entry><para>Prevent the use of a user-level mechanism</para>
</entry><entry><para>Removes a software mechanism from use. The mechanism can be enabled
again.</para>
</entry><entry><para><olink targetptr="scftask-25" remap="internal">How to Prevent the Use of a User-Level
Mechanism</olink></para>
</entry>
</row><row><entry><para>Temporarily disable mechanisms from a kernel module</para>
</entry><entry><para>Temporarily removes a mechanism from use. Usually used for testing.</para>
</entry><entry><para><olink targetptr="scftask-17" remap="internal">How to Prevent the Use of a Kernel Software
Provider</olink></para>
</entry>
</row><row><entry><para>Uninstall a provider</para>
</entry><entry><para>Removes a kernel software provider from use.</para>
</entry><entry><para><olink targetptr="scftask-21" remap="internal">Example&nbsp;14&ndash;27</olink></para>
</entry>
</row><row><entry><para>List available hardware providers</para>
</entry><entry><para>Shows the attached hardware, shows the mechanisms that the hardware
provides, and shows which mechanisms are enabled for use.</para>
</entry><entry><para><olink targetptr="scftask-13" remap="internal">How to List Hardware Providers</olink></para>
</entry>
</row><row><entry><para>Disable mechanisms from a hardware provider</para>
</entry><entry><para>Ensures that selected mechanisms on a hardware accelerator are not used.</para>
</entry><entry><para><olink targetptr="scftask-41" remap="internal">How to Disable Hardware Provider Mechanisms
and Features</olink></para>
</entry>
</row><row><entry><para>Restart or refresh cryptographic services</para>
</entry><entry><para>Ensures that cryptographic services are available.</para>
</entry><entry><para><olink targetptr="scftask-50" remap="internal">How to Refresh or Restart All Cryptographic
Services</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="scftask-8"><title>Administering the Cryptographic Framework</title><para><indexterm><primary>using</primary><secondary><command>cryptoadm</command> command</secondary></indexterm><indexterm><primary>new features</primary><secondary>commands</secondary><tertiary><command>cryptoadm</command></tertiary></indexterm>This
section describes how to administer the software providers and the hardware
providers in the Solaris Cryptographic Framework. Software providers and hardware
providers can be removed from use when desirable. For example, you can disable
the implementation of an algorithm from one software provider. You can then
force the system to use the algorithm from a different software provider.</para><task id="scftask-6"><title>How to List Available Providers</title><indexterm><primary>listing</primary><secondary>available providers in cryptographic framework</secondary>
</indexterm><indexterm><primary>providers</primary><secondary>listing in cryptographic framework </secondary>
</indexterm><indexterm><primary>cryptographic framework</primary><secondary>listing providers</secondary>
</indexterm><indexterm><primary>listing</primary><secondary>providers in the cryptographic framework</secondary>
</indexterm><indexterm><primary>displaying</primary><secondary>providers in the cryptographic framework</secondary>
</indexterm><indexterm><primary>cryptographic framework</primary><secondary>listing providers</secondary>
</indexterm><indexterm><primary>algorithms</primary><secondary>listing in the cryptographic framework</secondary>
</indexterm><tasksummary><itemizedlist><para>The Solaris Cryptographic Framework provides algorithms for several
types of consumers:</para><listitem><para>User-level providers provide a PKCS #11 cryptographic interface
to applications that are linked with the <literal>libpkcs11</literal> library</para>
</listitem><listitem><para>Kernel software providers provide algorithms for IPsec, Kerberos,
and other Solaris kernel components</para>
</listitem><listitem><para>Kernel hardware providers provide algorithms that are available
to kernel consumers and to applications through the <literal>pkcs11_kernel</literal> library</para>
</listitem>
</itemizedlist>
</tasksummary><procedure><step><para><indexterm><primary><command>cryptoadm</command> command</primary><secondary>listing providers</secondary></indexterm><indexterm><primary>ARCFOUR kernel provider</primary></indexterm><indexterm><primary>AES kernel provider</primary></indexterm><indexterm><primary>Blowfish encryption algorithm</primary><secondary>kernel  provider</secondary></indexterm><indexterm><primary>DES encryption</primary><secondary>kernel  provider</secondary></indexterm><indexterm><primary>RSA kernel provider</primary></indexterm><indexterm><primary>SHA1 kernel provider</primary></indexterm><indexterm><primary>MD5 encryption algorithm</primary><secondary>kernel  provider</secondary></indexterm><indexterm><primary><filename>pkcs11_kernel.so</filename> user-level  provider</primary></indexterm><indexterm><primary><filename>pkcs11_softtoken.so</filename> user-level  provider</primary></indexterm><indexterm><primary>libraries</primary><secondary>user-level providers</secondary></indexterm><indexterm><primary>kernel providers</primary><secondary>listing</secondary></indexterm>List the providers
in a brief format.</para><para>Only those mechanisms at the user level are
available for use by regular users.</para><screen>% <userinput>cryptoadm list</userinput>
user-level providers:
    /usr/lib/security/$ISA/pkcs11_kernel.so
    /usr/lib/security/$ISA/pkcs11_softtoken.so

kernel software providers:
    des
    aes
    blowfish
    arcfour
    sha1
    md5
    rsa

kernel hardware providers:
    dca/0</screen>
</step><step><para>List the providers and their mechanisms in the Solaris Cryptographic
Framework.</para><para><indexterm><primary>viewing</primary><secondary>cryptographic mechanisms</secondary><tertiary>existing</tertiary></indexterm>All mechanisms
are listed in the following output. However, some of the listed mechanisms
might be unavailable for use. To list only the mechanisms that the administrator
has approved for use, see <olink targetptr="scftask-31" remap="internal">Example&nbsp;14&ndash;20</olink>.</para><para>The output is reformatted for display purposes.</para><screen>% <userinput>cryptoadm list -m</userinput>
user-level providers:
=====================
/usr/lib/security/$ISA/pkcs11_kernel.so: CKM_MD5,CKM_MD5_HMAC,
CKM_MD5_HMAC_GENERAL,CKM_SHA_1,CKM_SHA_1_HMAC,CKM_SHA_1_HMAC_GENERAL,
&hellip;
/usr/lib/security/$ISA/pkcs11_softtoken.so: 
CKM_DES_CBC,CKM_DES_CBC_PAD,CKM_DES_ECB,CKM_DES_KEY_GEN,
CKM_DES3_CBC,CKM_DES3_CBC_PAD,CKM_DES3_ECB,CKM_DES3_KEY_GEN,
CKM_AES_CBC,CKM_AES_CBC_PAD,CKM_AES_ECB,CKM_AES_KEY_GEN,
&hellip;
kernel software providers:
==========================
des: CKM_DES_ECB,CKM_DES_CBC,CKM_DES3_ECB,CKM_DES3_CBC
aes: CKM_AES_ECB,CKM_AES_CBC
blowfish: CKM_BF_ECB,CKM_BF_CBC
arcfour: CKM_RC4
sha1: CKM_SHA_1,CKM_SHA_1_HMAC,CKM_SHA_1_HMAC_GENERAL
md5: CKM_MD5,CKM_MD5_HMAC,CKM_MD5_HMAC_GENERAL
rsa: CKM_RSA_PKCS,CKM_RSA_X_509,CKM_MD5_RSA_PKCS,CKM_SHA1_RSA_PKCS
swrand: No mechanisms presented.

kernel hardware providers:
==========================
dca/0: CKM_RSA_PKCS, CKM_RSA_X_509, CKM_DSA, CKM_DES_CBC, CKM_DES3_CBC</screen>
</step>
</procedure><example id="scftask-12"><title>Finding the Existing Cryptographic Mechanisms</title><para><indexterm><primary>viewing</primary><secondary>cryptographic mechanisms</secondary><tertiary>existing</tertiary></indexterm><indexterm><primary>viewing</primary><secondary>existing cryptographic mechanisms</secondary></indexterm>In the
following example, all mechanisms that the user-level library, <literal>pkcs11_softtoken</literal>, offers are listed.</para><screen>% <userinput>cryptoadm list -m provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so</userinput>
/usr/lib/security/$ISA/pkcs11_softtoken.so:
CKM_DES_CBC,CKM_DES_CBC_PAD,CKM_DES_ECB,CKM_DES_KEY_GEN,
CKM_DES3_CBC,CKM_DES3_CBC_PAD,CKM_DES3_ECB,CKM_DES3_KEY_GEN,
&hellip;
CKM_SSL3_KEY_AND_MAC_DERIVE,CKM_TLS_KEY_AND_MAC_DERIVE</screen>
</example><example id="scftask-31"><title>Finding the Available Cryptographic Mechanisms</title><para><indexterm><primary>viewing</primary><secondary>cryptographic mechanisms</secondary><tertiary>available</tertiary></indexterm><indexterm><primary>viewing</primary><secondary>available cryptographic mechanisms</secondary></indexterm>Policy
determines which mechanisms are available for use. The administrator sets
the policy. An administrator can choose to disable mechanisms from a particular
provider. The <option>p</option> option displays the list of mechanisms that
are permitted by the policy that the administrator has set.</para><screen>% <userinput>cryptoadm list -p</userinput>
user-level providers:
=====================
/usr/lib/security/$ISA/pkcs11_kernel.so: all mechanisms are enabled.
random is enabled.
/usr/lib/security/$ISA/pkcs11_softtoken.so: all mechanisms are enabled.
random is enabled.

kernel software providers:
==========================
des: all mechanisms are enabled.
aes: all mechanisms are enabled.
blowfish: all mechanisms are enabled.
arcfour: all mechanisms are enabled.
sha1: all mechanisms are enabled.
md5: all mechanisms are enabled.
rsa: all mechanisms are enabled.
swrand: random is enabled.

kernel hardware providers:
==========================
dca/0: all mechanisms are enabled. random is enabled.</screen>
</example>
</task><task id="scftask-11"><title>How to Add a Software Provider</title><indexterm><primary>adding</primary><secondary>software provider</secondary>
</indexterm><indexterm><primary>providers</primary><secondary>adding software provider</secondary>
</indexterm><indexterm><primary>adding</primary><secondary>plugins to cryptographic framework</secondary>
</indexterm><indexterm><primary><command>svcadm</command> command</primary><secondary>refreshing cryptographic framework</secondary>
</indexterm><procedure><step><para>Assume the Primary Administrator role, or become superuser.</para><para>The Primary Administrator role includes the Primary Administrator profile.
To create the role and assign the role to a user, see <olink targetdoc="group-sa" targetptr="smcover-1" remap="external">Chapter 2, <citetitle remap="chapter">Working With the Solaris Management Console (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Basic Administration</citetitle></olink>.</para>
</step><step><para>List the software providers that are available to the system.</para><screen># <userinput>cryptoadm list</userinput>
user-level providers:
        /usr/lib/security/$ISA/pkcs11_kernel.so
        /usr/lib/security/$ISA/pkcs11_softtoken.so

kernel software providers:
    des
    aes
    blowfish
    arcfour
    sha1
    md5
    rsa
    swrand

kernel hardware providers:
     dca/0</screen>
</step><step><para><indexterm><primary><command>pkgadd</command> command</primary><secondary>installing third-party providers</secondary></indexterm>Add the
provider's package by using the <command>pkgadd</command> command.</para><screen># <userinput>pkgadd -d</userinput> <replaceable>/path/to/package</replaceable> <replaceable>pkginst</replaceable></screen><para>The package must include software that has been signed by a certificate
from Sun. To request a certificate from Sun and to sign a provider, see <olink targetdoc="gssapipg" targetptr="pkg" remap="external">Appendix F, <citetitle remap="appendix">Packaging and Signing Cryptographic Providers,</citetitle> in <citetitle remap="book">Solaris Security for Developers Guide</citetitle></olink>.</para><para>The package should have scripts that notify the cryptographic framework
that another provider with a set of mechanisms is available. For information
about the packaging requirements, see <olink targetdoc="gssapipg" targetptr="pkg" remap="external">Appendix F, <citetitle remap="appendix">Packaging and Signing Cryptographic Providers,</citetitle> in <citetitle remap="book">Solaris Security for Developers Guide</citetitle></olink>.</para>
</step><step><para>Refresh the providers.</para><para><indexterm><primary>service management facility</primary><secondary>refreshing cryptographic framework</secondary></indexterm>You need to refresh providers if you added a software provider,
or if you added hardware and specified policy for the hardware.</para><screen># <userinput>svcadm refresh svc:/system/cryptosvc</userinput></screen>
</step><step><para>Locate the new provider on the list.</para><para>In this case,
a new kernel software provider was installed.</para><screen># <userinput>cryptoadm list</userinput> 
&hellip;
kernel software providers:
    des
    aes
    blowfish
    arcfour
    sha1
    md5
    rsa
    swrand
    ecc <lineannotation>&lt;-- added provider</lineannotation>
&hellip;</screen>
</step>
</procedure><example id="scftask-48"><title>Adding a User-Level Software Provider</title><indexterm><primary>adding</primary><secondary>user-level software provider</secondary>
</indexterm><indexterm><primary>providers</primary><secondary>adding user-level software provider</secondary>
</indexterm><indexterm><primary>providers</primary><secondary>adding library</secondary>
</indexterm><indexterm><primary>adding</primary><secondary>library plugin</secondary>
</indexterm><indexterm><primary>PKCS #11 library</primary><secondary>adding as provider</secondary>
</indexterm><para>In the following example, a signed PKCS #11 library is installed.</para><screen># <userinput>pkgadd -d /cdrom/cdrom0/SolarisNew</userinput>
<lineannotation>Answer the prompts</lineannotation>
# <userinput>svcadm refresh system/cryptosvc</userinput>
# <userinput>cryptoadm list</userinput>
user-level providers:
==========================
    /usr/lib/security/$ISA/pkcs11_kernel.so
    /usr/lib/security/$ISA/pkcs11_softtoken.so
    /opt/SUNWconn/lib/$ISA/libpkcs11.so.1 <lineannotation>&lt;-- added provider</lineannotation></screen><para><indexterm><primary><command>cryptoadm</command> command</primary><secondary>installing PKCS #11 library</secondary></indexterm><indexterm><primary><command>cryptoadm install</command> command</primary><secondary>installing PKCS #11 library</secondary></indexterm><indexterm><primary><command>install</command> subcommand</primary><secondary><command>cryptoadm</command> command</secondary></indexterm>Developers who are testing a library with the cryptographic framework
can install the library manually.</para><screen># <userinput>cryptoadm install provider=/opt/SUNWconn/lib/'$ISA'/libpkcs11.so.1</userinput></screen>
</example>
</task><task id="scftask-25"><title>How to Prevent the Use of a User-Level
Mechanism</title><tasksummary><para><indexterm><primary><command>cryptoadm</command> command</primary><secondary>disabling cryptographic mechanisms</secondary></indexterm><indexterm><primary>disabling</primary><secondary>cryptographic mechanisms</secondary></indexterm>If some of the cryptographic mechanisms from a library provider
should not be used, you can remove selected mechanisms. This procedure uses
the DES mechanisms in the <filename>pkcs11_softtoken</filename> library as
an example.</para>
</tasksummary><procedure><step><para><indexterm><primary>Crypto Management (RBAC)</primary><secondary>use of rights profile</secondary></indexterm>Become superuser or assume a role
that includes the Crypto Management rights profile.</para><para>To create
a role that includes the Crypto Management rights profile and assign the role
to a user, see <olink targetptr="rbactask-17" remap="internal">Example&nbsp;9&ndash;7</olink>.</para>
</step><step><para><indexterm><primary><command>cryptoadm</command> command</primary><secondary><option>m</option> option</secondary></indexterm><indexterm><primary><option>m</option> option</primary><secondary><command>cryptoadm</command> command</secondary></indexterm>List the mechanisms that are offered by a particular user-level
software provider.</para><screen>% <userinput>cryptoadm list -m provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so</userinput>
/usr/lib/security/$ISA/pkcs11_softtoken.so:
CKM_DES_CBC,CKM_DES_CBC_PAD,CKM_DES_ECB,CKM_DES_KEY_GEN,
CKM_DES3_CBC,CKM_DES3_CBC_PAD,CKM_DES3_ECB,CKM_DES3_KEY_GEN,
CKM_AES_CBC,CKM_AES_CBC_PAD,CKM_AES_ECB,CKM_AES_KEY_GEN,
&hellip;</screen>
</step><step><para><indexterm><primary><command>cryptoadm</command> command</primary><secondary><option>p</option> option</secondary></indexterm><indexterm><primary><option>p</option> option</primary><secondary><command>cryptoadm</command> command</secondary></indexterm>List the mechanisms that are available for use.</para><screen>$ <userinput>cryptoadm list -p</userinput>
user-level providers:
=====================
&hellip;
/usr/lib/security/$ISA/pkcs11_softtoken.so: all mechanisms are enabled.
random is enabled.
&hellip;</screen>
</step><step><para>Disable the mechanisms that should not be used.</para><screen>$ <userinput>cryptoadm disable provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so \</userinput>
&gt; <userinput>mechanism=CKM_DES_CBC,CKM_DES_CBC_PAD,CKM_DES_ECB</userinput></screen>
</step><step><para>List the mechanisms that are available for use.</para><screen>$ <userinput>cryptoadm list -p provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so</userinput>
/usr/lib/security/$ISA/pkcs11_softtoken.so: all mechanisms are enabled,
except CKM_DES_ECB,CKM_DES_CBC_PAD,CKM_DES_CBC. random is enabled.</screen>
</step>
</procedure><example id="scftask-46"><title>Enabling a User-Level Software Provider Mechanism</title><para>In the following example, a disabled DES mechanism is again made available
for use.</para><screen>$ <userinput>cryptoadm list -m provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so</userinput>
/usr/lib/security/$ISA/pkcs11_softtoken.so:
CKM_DES_CBC,CKM_DES_CBC_PAD,CKM_DES_ECB,CKM_DES_KEY_GEN,
CKM_DES3_CBC,CKM_DES3_CBC_PAD,CKM_DES3_ECB,CKM_DES3_KEY_GEN,
&hellip;
$ <userinput>cryptoadm list -p provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so</userinput>
/usr/lib/security/$ISA/pkcs11_softtoken.so: all mechanisms are enabled,
except CKM_DES_ECB,CKM_DES_CBC_PAD,CKM_DES_CBC. random is enabled.
$ <userinput>cryptoadm enable provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so \</userinput>
&gt; <userinput>mechanism=CKM_DES_ECB</userinput>
$ <userinput>cryptoadm list -p provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so</userinput>
/usr/lib/security/$ISA/pkcs11_softtoken.so: all mechanisms are enabled,
except CKM_DES_CBC_PAD,CKM_DES_CBC. random is enabled.</screen>
</example><example id="scftask-44"><title>Enabling All User-Level Software Provider Mechanisms</title><para><indexterm><primary>enabling</primary><secondary>cryptographic mechanisms</secondary></indexterm>In the following example, all mechanisms from the user-level library
are enabled.</para><screen>$ <userinput>cryptoadm enable provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so all</userinput>
$ <userinput>cryptoadm list -p provider=/usr/lib/security/'$ISA'/pkcs11_softtoken.so</userinput>
/usr/lib/security/$ISA/pkcs11_softtoken.so: all mechanisms are enabled.
random is enabled.</screen>
</example><example id="scftask-43"><title>Permanently Removing User-Level Software Provider Availability</title><para><indexterm><primary>removing</primary><secondary>cryptographic providers</secondary></indexterm><indexterm><primary>uninstalling</primary><secondary>cryptographic providers</secondary></indexterm>In the following example, the <filename>libpkcs11.so.1</filename> library is removed.</para><screen>$ <userinput>cryptoadm uninstall provider=/opt/SUNWconn/lib/'$ISA'/libpkcs11.so.1</userinput>
$ <userinput>cryptoadm list</userinput>
user-level providers:
    /usr/lib/security/$ISA/pkcs11_kernel.so
    /usr/lib/security/$ISA/pkcs11_softtoken.so

kernel software providers:
&hellip;</screen>
</example>
</task><task id="scftask-17"><title>How to Prevent the Use of a Kernel
Software Provider</title><indexterm><primary>preventing</primary><secondary>kernel software provider use</secondary>
</indexterm><indexterm><primary>providers</primary><secondary>preventing use of kernel software provider</secondary>
</indexterm><tasksummary><para><indexterm><primary><command>cryptoadm</command> command</primary><secondary>disabling cryptographic mechanisms</secondary></indexterm><indexterm><primary>removing</primary><secondary>cryptographic providers</secondary></indexterm>If the cryptographic framework provides multiple modes of a provider
such as AES, you might remove a slow mechanism from use, or a corrupted mechanism.
This procedure uses the AES algorithm as an example.</para>
</tasksummary><procedure><step><para><indexterm><primary>Crypto Management (RBAC)</primary><secondary>use of rights profile</secondary></indexterm>Become superuser or assume a role
that includes the Crypto Management rights profile.</para><para>To create
a role that includes the Crypto Management rights profile and assign the role
to a user, see <olink targetptr="rbactask-17" remap="internal">Example&nbsp;9&ndash;7</olink>.</para>
</step><step><para><indexterm><primary><command>cryptoadm</command> command</primary><secondary><option>m</option> option</secondary></indexterm><indexterm><primary><option>m</option> option</primary><secondary><command>cryptoadm</command> command</secondary></indexterm><indexterm><primary>viewing</primary><secondary>cryptographic mechanisms</secondary><tertiary>available</tertiary></indexterm><indexterm><primary>viewing</primary><secondary>available cryptographic mechanisms</secondary></indexterm><indexterm><primary>viewing</primary><secondary>cryptographic mechanisms</secondary><tertiary>existing</tertiary></indexterm><indexterm><primary>viewing</primary><secondary>existing cryptographic mechanisms</secondary></indexterm>List the mechanisms that are offered by a particular kernel software
provider.</para><screen>$ <userinput>cryptoadm list -m provider=aes</userinput>
aes: CKM_AES_ECB,CKM_AES_CBC</screen>
</step><step><para>List the mechanisms that are available for use.</para><screen>$ <userinput>cryptoadm list -p provider=aes</userinput>
aes: all mechanisms are enabled.</screen>
</step><step><para><indexterm><primary><command>cryptoadm</command> command</primary><secondary><option>p</option> option</secondary></indexterm><indexterm><primary><option>p</option> option</primary><secondary><command>cryptoadm</command> command</secondary></indexterm>Disable the mechanism that should not be used.</para><screen>$ <userinput>cryptoadm disable provider=aes mechanism=CKM_AES_ECB</userinput></screen>
</step><step><para>List the mechanisms that are available for use.</para><screen>$ <userinput>cryptoadm list -p provider=aes</userinput>
aes: all mechanisms are enabled, except CKM_AES_ECB.</screen>
</step>
</procedure><example id="scftask-23"><title>Enabling a Kernel Software Provider Mechanism</title><indexterm><primary>enabling</primary><secondary>kernel software provider use</secondary>
</indexterm><indexterm><primary>providers</primary><secondary>restoring use of kernel software provider</secondary>
</indexterm><indexterm><primary><command>cryptoadm</command> command</primary><secondary>restoring kernel software provider</secondary>
</indexterm><indexterm><primary>restoring</primary><secondary>cryptographic providers</secondary>
</indexterm><para>In the following example, a disabled AES mechanism is again made available
for use.</para><screen><userinput>cryptoadm list -m provider=aes</userinput>
aes: CKM_AES_ECB,CKM_AES_CBC
$ <userinput>cryptoadm list -p provider=aes</userinput>
aes: all mechanisms are enabled, except CKM_AES_ECB.
$ <userinput>cryptoadm enable provider=aes mechanism=CKM_AES_ECB</userinput>
$ <userinput>cryptoadm list -p provider=aes</userinput>
aes: all mechanisms are enabled.</screen>
</example><example id="scftask-19"><title>Temporarily Removing Kernel Software Provider Availability</title><para><indexterm><primary>removing</primary><secondary>software providers</secondary><tertiary>temporarily</tertiary></indexterm>In the following example, the
AES provider is temporarily removed from use. The <literal>unload</literal> subcommand
is useful to prevent a provider from being loaded automatically while the
provider is being uninstalled. For example, the <command>unload</command> subcommand
would be used when installing a patch that affects the provider.</para><screen>$ <userinput>cryptoadm unload provider=aes</userinput>
$ <userinput>cryptoadm list</userinput>
...
kernel software providers:
         des
         aes (inactive)
         blowfish
         arcfour
         sha1
         md5
         rsa
         swrand</screen><para>The AES provider is unavailable until the cryptographic framework is
refreshed.</para><screen>$ <userinput>svcadm refresh system/cryptosvc</userinput>
$ <userinput>cryptoadm list</userinput>
...
kernel software providers:
         des
         aes
         blowfish
         arcfour
         sha1
         md5
         rsa
         swrand</screen><para>If a kernel consumer is using the kernel software provider, the software
is not unloaded. An error message is displayed and the provider continues
to be available for use.</para>
</example><example id="scftask-21"><title>Permanently Removing Software Provider Availability</title><para><indexterm><primary>removing</primary><secondary>software providers</secondary><tertiary>permanently</tertiary></indexterm>In the following example, the
AES provider is removed from use. Once removed, the AES provider does not
appear in the policy listing of kernel software providers.</para><screen>$ <userinput>cryptoadm uninstall provider=aes</userinput>
$ <userinput>cryptoadm list</userinput>
&hellip;
kernel software providers:
         des
         blowfish
         arcfour
         sha1
         md5
         rsa
         swrand</screen><para>If a kernel consumer is using the kernel software provider, an error
message is displayed and the provider continues to be available for use.</para>
</example><example id="scftask-26"><title>Reinstalling a Removed Kernel Software Provider</title><para><indexterm><primary>removing</primary><secondary>software providers</secondary><tertiary>permanently</tertiary></indexterm>In the following example, the
AES kernel software provider is reinstalled.</para><screen>$ <userinput>cryptoadm install provider=aes mechanism=CKM_AES_ECB,CKM_AES_CBC</userinput>
$ <userinput>cryptoadm list</userinput>
&hellip;
kernel software providers:
         des
         aes
         blowfish
         arcfour
         sha1
         md5
         rsa
         swrand</screen>
</example>
</task><task id="scftask-13"><title>How to List Hardware Providers</title><indexterm><primary>listing</primary><secondary>hardware providers</secondary>
</indexterm><indexterm><primary>providers</primary><secondary>listing hardware providers</secondary>
</indexterm><indexterm><primary>hardware providers</primary><secondary>listing</secondary>
</indexterm><indexterm><primary>listing</primary><secondary>cryptographic framework providers</secondary>
</indexterm><indexterm><primary>hardware</primary><secondary>listing attached hardware accelerators</secondary>
</indexterm><tasksummary><para><indexterm><primary>hardware providers</primary><secondary>loading</secondary></indexterm>Hardware providers are automatically located and loaded. For more
information, see <olink targetdoc="group-refman" targetptr="driver.conf-4" remap="external"><citerefentry><refentrytitle>driver.conf</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page.</para>
</tasksummary><taskprerequisites><para>When you add hardware that expects to be used within the Solaris Cryptographic
Framework, the hardware registers with the SPI in the kernel. The framework
checks that the hardware driver is signed. Specifically, the framework checks
that the object file of the driver is signed with a certificate that Sun issues.</para>
</taskprerequisites><procedure><step><para>List the hardware providers that are available on the system.</para><screen>% <userinput>cryptoadm list</userinput>
&hellip; 
kernel hardware providers:
   dca/0</screen>
</step><step><para>List the mechanisms that the board provides.</para><screen>% <userinput>cryptoadm list -m provider=dca/0</userinput>
dca/0: CKM_RSA_PKCS, CKM_RSA_X_509, CKM_DSA, CKM_DES_CBC, CKM_DES3_CBC</screen>
</step><step><para>List the mechanisms that are available for use on the board.</para><screen>% <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled. random is enabled.</screen>
</step>
</procedure>
</task><task id="scftask-41"><title>How to Disable Hardware Provider Mechanisms and
Features</title><indexterm><primary>providers</primary><secondary>disabling hardware mechanisms</secondary>
</indexterm><indexterm><primary>hardware providers</primary><secondary>disabling cryptographic mechanisms</secondary>
</indexterm><indexterm><primary><command>cryptoadm</command> command</primary><secondary>disabling hardware mechanisms</secondary>
</indexterm><indexterm><primary>disabling</primary><secondary>hardware mechanisms</secondary>
</indexterm><indexterm><primary>preventing</primary><secondary>use of hardware mechanism</secondary>
</indexterm><indexterm><primary>mechanisms</primary><secondary>disabling all on hardware provider</secondary>
</indexterm><tasksummary><para>You can selectively disable mechanisms and the random number feature
from a hardware provider. To enable them again, see <olink targetptr="scftask-42" remap="internal">Example&nbsp;14&ndash;29</olink>.</para>
</tasksummary><procedure><step><para>List the mechanisms and features that are available from the board.</para><screen>% <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled. random is enabled.</screen>
</step><step><para>Become superuser or assume a role that includes the Crypto Management
rights profile.</para><para>To create a role that includes the Crypto Management
rights profile and assign the role to a user, see <olink targetptr="rbactask-17" remap="internal">Example&nbsp;9&ndash;7</olink>.</para>
</step><step><para>Choose the mechanisms or feature to disable:</para><stepalternatives><step><para>Disable selected mechanisms.</para><screen># <userinput>cryptoadm list -m provider=dca/0</userinput>
dca/0: CKM_RSA_PKCS, CKM_RSA_X_509, CKM_DSA, CKM_DES_CBC, CKM_DES3_CBC
random is enabled.
# <userinput>cryptoadm disable provider=dca/0 mechanism=CKM_DES_CBC,CKM_DES3_CBC</userinput>
# <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled except CKM_DES_CBC,CKM_DES3_CBC.
random is enabled.</screen>
</step><step><para>Disable the random number generator.</para><screen># <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled. random is enabled.
# <userinput>cryptoadm disable provider=dca/0 random</userinput>
# <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled. random is disabled.</screen>
</step><step><para>Disable all mechanisms. Do not disable the random number generator.</para><screen># <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled. random is enabled.
# <userinput>cryptoadm disable provider=dca/0 mechanism=all</userinput>
# <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are disabled. random is enabled.</screen>
</step><step><para>Disable every feature and mechanism on the hardware.</para><screen># <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled. random is enabled.
# <userinput>cryptoadm disable provider=dca/0 all</userinput>
# <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are disabled. random is disabled.</screen>
</step>
</stepalternatives>
</step>
</procedure><example id="scftask-42"><title>Enabling Mechanisms and Features on a Hardware Provider</title><para><indexterm><primary>hardware providers</primary><secondary>enabling mechanisms and features on</secondary></indexterm><indexterm><primary>mechanisms</primary><secondary>enabling some on hardware provider</secondary></indexterm><indexterm><primary>adding</primary><secondary>hardware provider mechanisms and features</secondary></indexterm><indexterm><primary>enabling</primary><secondary>mechanisms and features on hardware provider</secondary></indexterm>In the following examples,
disabled mechanisms on a piece of hardware are selectively enabled.</para><screen># <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled except CKM_DES_ECB,CKM_DES3_ECB.
random is enabled.
# <userinput>cryptoadm enable provider=dca/0 mechanism=CKM_DES3_ECB</userinput>
# <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled except CKM_DES_ECB. random is enabled.</screen><para>In the following example, only the random generator is enabled.</para><screen># <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled, except CKM_MD5,CKM_MD5_HMAC,&hellip;. 
random is disabled.
# <userinput>cryptoadm enable provider=dca/0 random</userinput>
# <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled, except CKM_MD5,CKM_MD5_HMAC,&hellip;.
random is enabled.</screen><para>In the following example, only the mechanisms are enabled. The random
generator continues to be disabled.</para><screen># <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled, except CKM_MD5,CKM_MD5_HMAC,&hellip;. 
random is disabled.
# <userinput>cryptoadm enable provider=dca/0 mechanism=all</userinput>
# <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled. random is disabled.</screen><para>In the following example, every feature and mechanism on the board is
enabled.</para><screen># <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled, except CKM_DES_ECB,CKM_DES3_ECB.
random is disabled.
# <userinput>cryptoadm enable provider=dca/0 all</userinput>
# <userinput>cryptoadm list -p provider=dca/0</userinput>
dca/0: all mechanisms are enabled. random is enabled.</screen>
</example>
</task><task id="scftask-50"><title>How to Refresh or Restart All Cryptographic
Services</title><indexterm><primary>service management facility</primary><secondary>restarting cryptographic framework</secondary>
</indexterm><indexterm><primary><command>svcadm</command> command</primary><secondary>enabling cryptographic framework</secondary>
</indexterm><indexterm><primary><command>svcs</command> command</primary><secondary>listing cryptographic services</secondary>
</indexterm><indexterm><primary>restarting</primary><secondary>cryptographic services</secondary>
</indexterm><indexterm><primary>cryptographic framework</primary><secondary>restarting</secondary>
</indexterm><indexterm><primary>refreshing</primary><secondary>cryptographic services</secondary>
</indexterm><indexterm><primary>cryptographic framework</primary><secondary>refreshing</secondary>
</indexterm><indexterm><primary>cryptographic framework</primary><secondary>zones and</secondary>
</indexterm><indexterm><primary>zones</primary><secondary>cryptographic services and</secondary>
</indexterm><indexterm><primary>new features</primary><secondary>commands</secondary><tertiary><command>kcfd</command></tertiary>
</indexterm><indexterm><primary><command>kcfd</command> daemon</primary>
</indexterm><tasksummary><para>By default, the Solaris Cryptographic Framework is enabled. When the <command>kcfd</command> daemon fails for any reason, the service management facility
can be used to restart cryptographic services. For more information, see the <olink targetdoc="group-refman" targetptr="smf-5" remap="external"><citerefentry><refentrytitle>smf</refentrytitle><manvolnum>5</manvolnum></citerefentry></olink> and <olink targetdoc="group-refman" targetptr="svcadm-1m" remap="external"><citerefentry><refentrytitle>svcadm</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man pages.
For the effect on zones of restarting cryptographic services, see <olink targetptr="scf-17" remap="internal">Cryptographic Services and Zones</olink>.</para>
</tasksummary><procedure><step><para>Check the status of cryptographic services.</para><screen>% <userinput>svcs \*cryptosvc\*</userinput>
 STATE          STIME    FMRI
offline         Dec_09   svc:/system/cryptosvc:default</screen>
</step><step><para>Become superuser or assume an equivalent role to enable cryptographic
services.</para><para>Roles contain authorizations and privileged commands.
For more information about roles, see <olink targetptr="rbactask-15" remap="internal">Configuring
RBAC (Task Map)</olink>.</para><screen># <userinput>svcadm enable svc:/system/cryptosvc</userinput></screen>
</step>
</procedure><example id="scftask-51"><title>Refreshing Cryptographic Services</title><para>In the following example, cryptographic services are refreshed in the
global zone. Therefore, kernel-level cryptographic policy in every non-global
zone is also refreshed.</para><screen># <userinput>svcadm refresh system/cryptosvc</userinput></screen>
</example>
</task>
</sect1>
</chapter><?Pub *0000096228 0?>