FIPS に準拠するよう Jtest を設定できます。
このセクションの内容
前提条件
https://www.bouncycastle.org/download/bouncy-castle-java-fips/ から以下の BouncyCastle FIPS ライブラリをダウンロードする必要があります。
- bc-fips-<VERSION>.jar (バージョン 2.0.0 でテスト済み)
- bctls-fips-<VERSION>.jar (バージョン 2.0.19 でテスト済み)
- bcutil-fips-<VERSION>.jar (バージョン 2.0.3 でテスト済み)
これらのライブラリは任意の場所に配置できます。以下の説明では、ライブラリの場所を <BC_DIR> と表記します。
jtestcliの FIPS モードの設定
bc-fips-<VERSION>.jar、bctls-fips-<VERSION>.jar および bcutil-fips-<VERSION>.jar を
<JTEST_INSTALL_DIR>/binディレクトリにコピーします。keytoolを使用して、cacerts ファイルを FIPS 準拠 BCFKS フォーマットに変換します。- コンソールを開いて次のコマンドを実行します。
cd <JTEST_INSTALL_DIR> mv bin/jre/lib/security/cacerts bin/jre/lib/security/cacerts.pkcs12 ./bin/jre/bin/keytool -importkeystore -srckeystore bin/jre/lib/security/cacerts.pkcs12 -srcstoretype PKCS12 -destkeystore bin/jre/lib/security/cacerts -deststoretype BCFKS -providername BCFIPS -providerclass org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider -providerpath bin/bc-fips-<VERSION>.jar -srcstorepass changeit -deststorepass changeit
<JTEST_INSTALL_DIR>/etcディレクトリにある jtestcli.jvm ファイルを開き、次の行を挿入します。java.arg=-Djavax.net.ssl.trustStorePassword=changeit
- コンソールを開いて次のコマンドを実行します。
- 変更を保存します。
<JTEST_INSTALL_DIR>/bin/jre/conf/security/ディレクトリにある java.security ファイルを開いて以下の変更を行います。security.provider.<number>という名前の既存のプロパティをすべてコメント アウトし、以下の行を挿入することでセキュリティ プロバイダーのリストを設定します。security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider security.provider.2=org.bouncycastle.jsse.provider.BouncyCastleJsseProvider fips:BCFIPS security.provider.3=SUN
javax.net.ssl package のキー マネージャー ファクトリおよびトラスト マネージャー ファクトリのアルゴリズムを PKIX に変更します。
ssl.KeyManagerFactory.algorithm=PKIX ssl.TrustManagerFactory.algorithm=PKIX
デフォルトのキーストア タイプを fips に変更し、JKS および PKCS12 キーストア タイプの互換モードを無効にします。
keystore.type=fips keystore.type.compat=false
(Linux の場合のみ) 既知の強力な SecureRandom 実装のリストに NativePRNGNonBlocking アルゴリズムを追加します。
securerandom.strongAlgorithms=NativePRNGNonBlocking:SUN,NativePRNGBlocking:SUN,DRBG:SUN
FIPS 認証済みのアルゴリズムだけを許可します。
org.bouncycastle.fips.approved_only=true
- 変更を保存します。
<JTEST_INSTALL_DIR>/bin/jre/conf/security/ディレクトリにある java.policy ファイルを開き、デフォルト ドメインに次のパーミッションを挿入します。permission java.lang.RuntimePermission "accessClassInPackage.sun.security.internal.spec"; permission org.bouncycastle.crypto.CryptoServicesPermission "tlsAlgorithmsEnabled";
- 変更を保存します。
<JTEST_INSTALL_DIR>/bin/jre/conf/ディレクトリにある logging.properties ファイルを開き、Bouncy Castle のロガー設定を挿入します。org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints.level=SEVERE org.bouncycastle.jsse.provider.PropertyUtils.level=SEVERE org.bouncycastle.jsse.provider.ProvTlsClient.level=SEVERE
変更を保存します。
jtestcov の FIPS モードの設定
keytoolを使用して、cacerts ファイルを FIPS 準拠 BCFKS フォーマットに変換します。コンソールを開いて次のコマンドを実行します。cd <JAVA_HOME> mv lib/security/cacerts lib/security/cacerts.pkcs12 ./bin/keytool -importkeystore -srckeystore lib/security/cacerts.pkcs12 -srcstoretype PKCS12 -destkeystore lib/security/cacerts -deststoretype BCFKS -providername BCFIPS -providerclass org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider -providerpath <BC_DIR>/bc-fips-<VERSION>.jar -srcstorepass changeit -deststorepass changeit
- 変更を保存します。
<JAVA_HOME>/conf/securityディレクトリにある java.security ファイルを開いて以下の変更を行います。security.provider.<number>およびfips.provider.<number>という名前の既存のプロパティをすべてコメント アウトし、以下の行を挿入することでセキュリティ プロバイダーのリストを設定します。security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider security.provider.2=org.bouncycastle.jsse.provider.BouncyCastleJsseProvider fips:BCFIPS security.provider.3=SUN
javax.net.sslpackage のキー マネージャー ファクトリおよびトラスト マネージャー ファクトリのアルゴリズムを PKIX に変更します。ssl.KeyManagerFactory.algorithm=PKIX ssl.TrustManagerFactory.algorithm=PKIX
デフォルトのキーストア タイプを fips に変更し、JKS および PKCS12 キーストア タイプの互換モードを無効にします。
keystore.type=fips keystore.type.compat=false
(Linux の場合のみ) 既知の強力な SecureRandom 実装のリストに
NativePRNGNonBlockingアルゴリズムを追加します。securerandom.strongAlgorithms=NativePRNGNonBlocking:SUN,NativePRNGBlocking:SUN,DRBG:SUN
- FIPS 認証済みのアルゴリズムだけを許可します。
org.bouncycastle.fips.approved_only=true
- 変更を保存します。
<JAVA_HOME>/conf/security ディレクトリにある java.policy ファイルを開き、デフォルト ドメインに次のパーミッションを挿入します。
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.internal.spec"; permission org.bouncycastle.crypto.CryptoServicesPermission "tlsAglorithmsEnabled";
- 変更を保存します。
<JAVA_HOME>/conf ディレクトリにある logging.properties ファイルを開き、Bouncy Castle のロガー設定を挿入します。
org.bouncycastle.jsse.provider.DisabledAlgorithmConstraints.level=SEVERE org.bouncycastle.jsse.provider.PropertyUtils.level=SEVERE org.bouncycastle.jsse.provider.ProvTlsClient.level=SEVERE
- 変更を保存します。
Bouncy Castle FIPS ライブラリを指すオプションおよびトラスト ストアにアクセスするのに必要なパスワードを指定するオプションを Java コマンド ラインに追加します。
--module-path=<BC_DIR> -Djavax.net.ssl.trustStorePassword=changeit