「SoftHSM」の版間の差分

提供: セキュリティ
移動: 案内検索
(ページの作成:「SoftHSM とは、PKCS #11 インタフェースを通してアクセスできる暗号ストアの実装です。HSMなしに、PKCS # 11 で検索するために...」)
 
 
(同じ利用者による、間の2版が非表示)
行7: 行7:
 
== 概要 ==
 
== 概要 ==
 
[[SoftHSM]]は、OpenDNSSECのプロジェクトで開発されました。
 
[[SoftHSM]]は、OpenDNSSECのプロジェクトで開発されました。
 +
 +
[[SoftHSM]]は、オブジェクトストアとしてファイルシステムやデータベースが利用できます。
 +
ファイルやSQLiteが選択できます。
 +
== HSMってなに? ==
 +
[[HSM]]とは、Hardware Security Module の略で、暗号処理や[[鍵]]の管理を行うためのハードウェアです。
 +
== PKCSってなに? ==
 +
PKCSとは、Public-Key Cryptography Standars の略で、[[公開鍵暗号]]標準のグループです。
 +
== PKCS#11ってなに? ==
 +
PKCS#11は、PKCSの標準の1つで、「'''暗号トークンインタフェース(Cryptoki)'''」です。暗号トークンへの汎用インタフェースを定義したものです。
 
== インストール ==
 
== インストール ==
 +
{{pkg|softhsm2}}
 +
{{pkg|softhsm}}
 +
== インストールされるファイル ==
 +
=== SoftHSM2の場合 ===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
softhsm2-2.0.0:
 +
        /usr/local/bin/softhsm2-dump-file
 +
        /usr/local/bin/softhsm2-keyconv
 +
        /usr/local/bin/softhsm2-util
 +
        /usr/local/etc/softhsm2.conf
 +
        /usr/local/etc/softhsm2.conf.sample
 +
        /usr/local/lib/softhsm/libsofthsm2.a
 +
        /usr/local/lib/softhsm/libsofthsm2.so
 +
        /usr/local/man/man1/softhsm2-dump-file.1.gz
 +
        /usr/local/man/man1/softhsm2-keyconv.1.gz
 +
        /usr/local/man/man1/softhsm2-util.1.gz
 +
        /usr/local/man/man5/softhsm2.conf.5.gz
 +
        /usr/local/share/licenses/softhsm2-2.0.0/BSD2CLAUSE
 +
        /usr/local/share/licenses/softhsm2-2.0.0/LICENSE
 +
        /usr/local/share/licenses/softhsm2-2.0.0/catalog.mk
 
</syntaxhighlight>
 
</syntaxhighlight>
 
== 使い方 ==
 
== 使い方 ==
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
cd /tmp
 +
mkdir hsm
 +
cd hsm
 +
cp /usr/local/etc/softhsm2.conf .
 +
</syntaxhighlight>
 +
 +
softhsm2.conf の内容を以下のように書き換えます。
 +
<syntaxhighlight lang="bash">
 +
# SoftHSM v2 configuration file
 +
 +
directories.tokendir = /tmp/hsm/
 +
objectstore.backend = file
 +
 +
# ERROR, WARNING, INFO, DEBUG
 +
log.level = INFO
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="bash">
 +
export SOFTHSM2_CONF=/tmp/hsm/softhsm2.conf
 +
</syntaxhighlight>
 +
 +
トークンを初期化します。
 +
<syntaxhighlight lang="bash">
 +
$ softhsm2-util --init-token --slot 0 --label "My token 1"
 +
*** SO PIN (4-255 characters) ***
 +
Please enter SO PIN:
 +
Please reenter SO PIN:
 +
*** User PIN (4-255 characters) ***
 +
Please enter user PIN:
 +
Please reenter user PIN:
 +
The token has been initialized.
 +
</syntaxhighlight>
 +
SO PINとユーザPINを要求されます。
 +
 +
以下のファイルが生成されます。
 +
<syntaxhighlight lang="bash">
 +
$ ls d7b6ca42-c0b9-aac7-2d33-df1844c3b5a0
 +
generation    token.lock    token.object
 +
</syntaxhighlight>
 +
== softhsm2-dump-file ==
 +
softhsm2-dump-file は、デバッグ用途のために使われるツールで、 SoftHSM v2 オブジェクトファイルをダンプするためのツールです。
 +
<syntaxhighlight lang="bash">
 +
$ /usr/local/bin/softhsm2-dump-file
 +
SoftHSM dump tool. From SoftHSM v2 object file.
 +
Usage: softhsm2-dump-file path
 +
</syntaxhighlight>
 +
 +
ダンプしたらこのようになりました。
 +
<syntaxhighlight lang="bash">
 +
$ softhsm2-dump-file d7b6ca42-c0b9-aac7-2d33-df1844c3b5a0/token.object
 +
Dump of object file "d7b6ca42-c0b9-aac7-2d33-df1844c3b5a0/token.object"
 +
00 00 00 00 00 00 00 09 generation 9
 +
00 00 00 00 80 00 53 49 CKA_OS_TOKENLABEL
 +
00 00 00 00 00 00 00 03 byte string attribute
 +
00 00 00 00 00 00 00 20 (length 32)
 +
4d 79 20 74 6f 6b 65 6e <My.token>
 +
20 31 20 20 20 20 20 20 <.1......>
 +
20 20 20 20 20 20 20 20 <........>
 +
20 20 20 20 20 20 20 20 <........>
 +
00 00 00 00 80 00 53 4a CKA_OS_TOKENSERIAL
 +
00 00 00 00 00 00 00 03 byte string attribute
 +
00 00 00 00 00 00 00 10 (length 16)
 +
32 64 33 33 64 66 31 38 <2d33df18>
 +
34 34 63 33 62 35 61 30 <44c3b5a0>
 +
00 00 00 00 80 00 53 4b CKA_OS_TOKENFLAGS
 +
00 00 00 00 00 00 00 02 unsigned long attribute
 +
00 00 00 00 00 00 04 2d CK_ULONG 1069(0x42d)
 +
00 00 00 00 80 00 53 4c CKA_OS_SOPIN
 +
00 00 00 00 00 00 00 03 byte string attribute
 +
00 00 00 00 00 00 00 48 (length 72)
 +
2d 07 79 a6 f2 d1 29 f5 <-.y...).>
 +
27 96 f7 a9 c9 e5 2a f0 <'.....*.>
 +
73 22 0d 4c 55 74 de d6 <s".LUt..>
 +
fc 69 e0 a9 d0 b7 9c 32 <.i.....2>
 +
be 31 8e 0d 13 b7 37 4d <.1....7M>
 +
76 a9 00 ef 46 5d bc dc <v...F]..>
 +
56 09 24 b8 27 fd 36 b0 <V.$.'.6.>
 +
70 b9 96 22 1c 70 60 10 <p..".p`.>
 +
b4 cf 22 20 19 7f 61 21 <.."...a!>
 +
00 00 00 00 80 00 53 4d CKA_OS_USERPIN
 +
00 00 00 00 00 00 00 03 byte string attribute
 +
00 00 00 00 00 00 00 48 (length 72)
 +
6a 37 4d 28 36 4a dd dc <j7M(6J..>
 +
5e 62 fd a2 75 b6 28 19 <^b..u.(.>
 +
d0 b8 6c 65 aa 48 15 4f <..le.H.O>
 +
19 c1 38 ed aa ec 1c 5b <..8....[>
 +
c2 3d 89 48 38 b8 ba dd <.=.H8...>
 +
80 38 1e b5 d6 05 aa 96 <.8......>
 +
97 52 bd a0 8b cd 3b ac <.R....;.>
 +
0a 31 93 f3 a0 06 0b af <.1......>
 +
21 17 31 87 b9 68 41 9c <!.1..hA.>
 +
</syntaxhighlight>
 +
== softhsm2-keyconv ==
 +
softhsm2-keyconv は、 BIND から PKCS#8 キーファイルフォーマットに変換するツールです。
 +
<syntaxhighlight lang="bash">
 +
$ /usr/local/bin/softhsm2-keyconv
 +
Converting from BIND .private-key format to PKCS#8 key file format.
 +
Usage: softhsm2-keyconv [OPTIONS]
 +
Options:
 +
  -h                  Shows this help screen.
 +
  --help              Shows this help screen.
 +
  --in <path>        The path to the input file.
 +
  --out <path>        The path to the output file.
 +
  --pin <PIN>        To encrypt PKCS#8 file. Optional.
 +
  -v                  Show version info.
 +
  --version          Show version info.
 +
</syntaxhighlight>
 +
== softhsm2-util ==
 +
softhsm2-util は、 libsofthsm2 のサポートツールです。
 +
<syntaxhighlight lang="bash">
 +
$ /usr/local/bin/softhsm2-util
 +
Support tool for PKCS#11
 +
Usage: softhsm2-util [ACTION] [OPTIONS]
 +
Action:
 +
  -h                Shows this help screen.
 +
  --help            Shows this help screen.
 +
  --import <path>  Import a key pair from the given path.
 +
                    The file must be in PKCS#8-format.
 +
                    Use with --file-pin, --slot, --label, --id,
 +
                    --no-public-key, and --pin.
 +
  --init-token      Initialize the token at a given slot.
 +
                    Use with --slot or --free, --label, --so-pin, and --pin.
 +
                    WARNING: Any content in token token will be erased.
 +
  --show-slots      Display all the available slots.
 +
  -v                Show version info.
 +
  --version        Show version info.
 +
Options:
 +
  --file-pin <PIN>  Supply a PIN if the file is encrypted.
 +
  --force          Used to override a warning.
 +
  --free            Initialize the first free token.
 +
  --id <hex>        Defines the ID of the object. Hexadecimal characters.
 +
                    Use with --force if multiple key pairs may share
 +
                    the same ID.
 +
  --label <text>    Defines the label of the object or the token.
 +
  --module <path>  Use another PKCS#11 library than SoftHSM.
 +
  --no-public-key  Do not import the public key.
 +
  --pin <PIN>      The PIN for the normal user.
 +
  --slot <number>  The slot where the token is located.
 +
  --so-pin <PIN>    The PIN for the Security Officer (SO).
 
</syntaxhighlight>
 
</syntaxhighlight>
 
== 関連項目 ==
 
== 関連項目 ==

2015年10月24日 (土) 17:55時点における最新版

SoftHSM とは、PKCS #11 インタフェースを通してアクセスできる暗号ストアの実装です。HSMなしに、PKCS # 11 で検索するために利用できます。

読み方

SoftHSM
そふとえいちえすえむ

概要

SoftHSMは、OpenDNSSECのプロジェクトで開発されました。

SoftHSMは、オブジェクトストアとしてファイルシステムやデータベースが利用できます。 ファイルやSQLiteが選択できます。

HSMってなに?

HSMとは、Hardware Security Module の略で、暗号処理やの管理を行うためのハードウェアです。

PKCSってなに?

PKCSとは、Public-Key Cryptography Standars の略で、公開鍵暗号標準のグループです。

PKCS#11ってなに?

PKCS#11は、PKCSの標準の1つで、「暗号トークンインタフェース(Cryptoki)」です。暗号トークンへの汎用インタフェースを定義したものです。

インストール

FreeBSDにインストールする場合

pkgコマンドでインストールする場合

sudo pkg install softhsm2

FreeBSDにインストールする場合

pkgコマンドでインストールする場合

sudo pkg install softhsm

インストールされるファイル

SoftHSM2の場合

softhsm2-2.0.0:
        /usr/local/bin/softhsm2-dump-file
        /usr/local/bin/softhsm2-keyconv
        /usr/local/bin/softhsm2-util
        /usr/local/etc/softhsm2.conf
        /usr/local/etc/softhsm2.conf.sample
        /usr/local/lib/softhsm/libsofthsm2.a
        /usr/local/lib/softhsm/libsofthsm2.so
        /usr/local/man/man1/softhsm2-dump-file.1.gz
        /usr/local/man/man1/softhsm2-keyconv.1.gz
        /usr/local/man/man1/softhsm2-util.1.gz
        /usr/local/man/man5/softhsm2.conf.5.gz
        /usr/local/share/licenses/softhsm2-2.0.0/BSD2CLAUSE
        /usr/local/share/licenses/softhsm2-2.0.0/LICENSE
        /usr/local/share/licenses/softhsm2-2.0.0/catalog.mk

使い方

cd /tmp
mkdir hsm
cd hsm
cp /usr/local/etc/softhsm2.conf .

softhsm2.conf の内容を以下のように書き換えます。

# SoftHSM v2 configuration file
 
directories.tokendir = /tmp/hsm/
objectstore.backend = file
 
# ERROR, WARNING, INFO, DEBUG
log.level = INFO
export SOFTHSM2_CONF=/tmp/hsm/softhsm2.conf

トークンを初期化します。

$ softhsm2-util --init-token --slot 0 --label "My token 1"
*** SO PIN (4-255 characters) ***
Please enter SO PIN:
Please reenter SO PIN:
*** User PIN (4-255 characters) ***
Please enter user PIN:
Please reenter user PIN:
The token has been initialized.

SO PINとユーザPINを要求されます。

以下のファイルが生成されます。

$ ls d7b6ca42-c0b9-aac7-2d33-df1844c3b5a0
generation    token.lock    token.object

softhsm2-dump-file

softhsm2-dump-file は、デバッグ用途のために使われるツールで、 SoftHSM v2 オブジェクトファイルをダンプするためのツールです。

$ /usr/local/bin/softhsm2-dump-file
SoftHSM dump tool. From SoftHSM v2 object file.
Usage: softhsm2-dump-file path

ダンプしたらこのようになりました。

$ softhsm2-dump-file d7b6ca42-c0b9-aac7-2d33-df1844c3b5a0/token.object
Dump of object file "d7b6ca42-c0b9-aac7-2d33-df1844c3b5a0/token.object"
00 00 00 00 00 00 00 09 generation 9
00 00 00 00 80 00 53 49 CKA_OS_TOKENLABEL
00 00 00 00 00 00 00 03 byte string attribute
00 00 00 00 00 00 00 20 (length 32)
4d 79 20 74 6f 6b 65 6e <My.token>
20 31 20 20 20 20 20 20 <.1......>
20 20 20 20 20 20 20 20 <........>
20 20 20 20 20 20 20 20 <........>
00 00 00 00 80 00 53 4a CKA_OS_TOKENSERIAL
00 00 00 00 00 00 00 03 byte string attribute
00 00 00 00 00 00 00 10 (length 16)
32 64 33 33 64 66 31 38 <2d33df18>
34 34 63 33 62 35 61 30 <44c3b5a0>
00 00 00 00 80 00 53 4b CKA_OS_TOKENFLAGS
00 00 00 00 00 00 00 02 unsigned long attribute
00 00 00 00 00 00 04 2d CK_ULONG 1069(0x42d)
00 00 00 00 80 00 53 4c CKA_OS_SOPIN
00 00 00 00 00 00 00 03 byte string attribute
00 00 00 00 00 00 00 48 (length 72)
2d 07 79 a6 f2 d1 29 f5 <-.y...).>
27 96 f7 a9 c9 e5 2a f0 <'.....*.>
73 22 0d 4c 55 74 de d6 <s".LUt..>
fc 69 e0 a9 d0 b7 9c 32 <.i.....2>
be 31 8e 0d 13 b7 37 4d <.1....7M>
76 a9 00 ef 46 5d bc dc <v...F]..>
56 09 24 b8 27 fd 36 b0 <V.$.'.6.>
70 b9 96 22 1c 70 60 10 <p..".p`.>
b4 cf 22 20 19 7f 61 21 <.."...a!>
00 00 00 00 80 00 53 4d CKA_OS_USERPIN
00 00 00 00 00 00 00 03 byte string attribute
00 00 00 00 00 00 00 48 (length 72)
6a 37 4d 28 36 4a dd dc <j7M(6J..>
5e 62 fd a2 75 b6 28 19 <^b..u.(.>
d0 b8 6c 65 aa 48 15 4f <..le.H.O>
19 c1 38 ed aa ec 1c 5b <..8....[>
c2 3d 89 48 38 b8 ba dd <.=.H8...>
80 38 1e b5 d6 05 aa 96 <.8......>
97 52 bd a0 8b cd 3b ac <.R....;.>
0a 31 93 f3 a0 06 0b af <.1......>
21 17 31 87 b9 68 41 9c <!.1..hA.>

softhsm2-keyconv

softhsm2-keyconv は、 BIND から PKCS#8 キーファイルフォーマットに変換するツールです。

$ /usr/local/bin/softhsm2-keyconv
Converting from BIND .private-key format to PKCS#8 key file format.
Usage: softhsm2-keyconv [OPTIONS]
Options:
  -h                  Shows this help screen.
  --help              Shows this help screen.
  --in <path>         The path to the input file.
  --out <path>        The path to the output file.
  --pin <PIN>         To encrypt PKCS#8 file. Optional.
  -v                  Show version info.
  --version           Show version info.

softhsm2-util

softhsm2-util は、 libsofthsm2 のサポートツールです。

$ /usr/local/bin/softhsm2-util
Support tool for PKCS#11
Usage: softhsm2-util [ACTION] [OPTIONS]
Action:
  -h                Shows this help screen.
  --help            Shows this help screen.
  --import <path>   Import a key pair from the given path.
                    The file must be in PKCS#8-format.
                    Use with --file-pin, --slot, --label, --id,
                    --no-public-key, and --pin.
  --init-token      Initialize the token at a given slot.
                    Use with --slot or --free, --label, --so-pin, and --pin.
                    WARNING: Any content in token token will be erased.
  --show-slots      Display all the available slots.
  -v                Show version info.
  --version         Show version info.
Options:
  --file-pin <PIN>  Supply a PIN if the file is encrypted.
  --force           Used to override a warning.
  --free            Initialize the first free token.
  --id <hex>        Defines the ID of the object. Hexadecimal characters.
                    Use with --force if multiple key pairs may share
                    the same ID.
  --label <text>    Defines the label of the object or the token.
  --module <path>   Use another PKCS#11 library than SoftHSM.
  --no-public-key   Do not import the public key.
  --pin <PIN>       The PIN for the normal user.
  --slot <number>   The slot where the token is located.
  --so-pin <PIN>    The PIN for the Security Officer (SO).

関連項目