Skip to content

Commit

Permalink
Adding profile for using SunPKCS11-NSS-FIPS provider (apache#6773)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriOndrusek committed Nov 13, 2024
1 parent 17df274 commit acb0d83
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
9 changes: 7 additions & 2 deletions integration-tests/crypto/README.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
== FIPS

Please utilize the fips profile when executing tests within a FIPS-enabled environment. The tests must employ the BouncyCastle-FIPS dependency instead of the standard BouncyCastle library.
Please utilize the fips profile when executing tests within a FIPS-enabled environment.
There are two profiles:

* Use `bcfips` profile to employ the BouncyCastle-FIPS security provider.
* Use `fips` profile to employ the SunPKCS11-NSS-FIPS security provider.
Example of usage:
```
mvn clean test -Dfips
mvn clean test -Dfips or mvn clean test -Dbcfips
```
21 changes: 19 additions & 2 deletions integration-tests/crypto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@

<profiles>
<profile>
<id>fips</id>
<id>bcfips</id>
<activation>
<property>
<name>fips</name>
<name>bcfips</name>
</property>
</activation>
<properties>
Expand All @@ -110,6 +110,23 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>fips</id>
<activation>
<property>
<name>fips</name>
</property>
</activation>
<properties>
<cq-security-provider>quarkus.security.security-providers=SunPKCS11-NSS-FIPS</cq-security-provider>
</properties>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-security</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>native</id>
<activation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ public void configure() throws Exception {

private CryptoDataFormat getCryptoDataFormat() throws NoSuchAlgorithmException {
KeyGenerator generator = KeyGenerator.getInstance("DES");
return new CryptoDataFormat("DES", generator.generateKey());
CryptoDataFormat cdf = new CryptoDataFormat("DES", generator.generateKey());
//workaround for SunPKCS11-NSS-FIPS
cdf.setShouldAppendHMAC(false);
return cdf;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
## ---------------------------------------------------------------------------
quarkus.native.resources.includes=*.jks

#FIPS profile adds BCFIPS provider
#profile adds SunPKCS11-NSS-FIPS or BCFIPS provider
${cq-security-provider}

0 comments on commit acb0d83

Please sign in to comment.