Skip to content

Commit

Permalink
fips: allow to customize provider vendor name
Browse files Browse the repository at this point in the history
FIPS providers need to specify identifiable names and versions. Allow
to customize the fips provider name prefix, via VERSION.dat which
already allows to customize version & buildinfo. With this patch
in-place it removes the need of patching code to set customized
provider name.

E.g. echo FIPSVENDOR=ACME >> VERSION.dat, results in

```
$ OPENSSL_CONF=fips-and-base.cnf ../util/wrap.pl ../apps/openssl list -providers --verbose
Providers:
  base
    name: OpenSSL Base Provider
    version: 3.4.0
    status: active
    build info: 3.4.0-dev
    gettable provider parameters:
      name: pointer to a UTF8 encoded string (arbitrary size)
      version: pointer to a UTF8 encoded string (arbitrary size)
      buildinfo: pointer to a UTF8 encoded string (arbitrary size)
      status: integer (arbitrary size)
  fips
    name: ACME OpenSSL FIPS Provider
    version: 3.4.0
    status: active
    build info: 3.4.0-dev
    gettable provider parameters:
      name: pointer to a UTF8 encoded string (arbitrary size)
      version: pointer to a UTF8 encoded string (arbitrary size)
      buildinfo: pointer to a UTF8 encoded string (arbitrary size)
      status: integer (arbitrary size)
      security-checks: integer (arbitrary size)
      tls1-prf-ems-check: integer (arbitrary size)
      drbg-no-trunc-md: integer (arbitrary size)
```
  • Loading branch information
xnox committed May 10, 2024
1 parent 4a50882 commit 5c7c29e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ jobs:
run: git submodule update --init --depth 1 fuzz/corpora
- name: localegen
run: sudo locale-gen tr_TR.UTF-8
- name: fipsvendor
# Make one fips build use a customized FIPS vendor
run: echo "FIPSVENDOR=CI" >> VERSION.dat
- name: config
# enable-quic is on by default, but we leave it here to check we're testing the explicit enable somewhere
run: CC=gcc ./config --banner=Configured enable-demos enable-h3demo enable-fips enable-quic --strict-warnings && perl configdata.pm --dump
Expand Down
2 changes: 2 additions & 0 deletions Configure
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ $config{release_date} = $version{RELEASE_DATE} // 'xx XXX xxxx';

$config{version} = "$config{major}.$config{minor}.$config{patch}";
$config{full_version} = "$config{version}$config{prerelease}$config{build_metadata}";
$config{FIPSVENDOR} =
(defined $version{FIPSVENDOR} ? "$version{FIPSVENDOR} " : "") . "OpenSSL FIPS Provider";

die "erroneous version information in VERSION.dat: ",
"$config{version}, $config{shlib_version}\n"
Expand Down
5 changes: 5 additions & 0 deletions include/openssl/fipskey.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ extern "C" {
*/
#define FIPS_KEY_STRING "{- $config{FIPSKEY} -}"

/*
* The FIPS provider vendor name, as a string.
*/
#define FIPS_VENDOR "{- $config{FIPSVENDOR} -}"

# ifdef __cplusplus
}
# endif
Expand Down
3 changes: 2 additions & 1 deletion providers/fips/fipsprov.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <openssl/core_names.h>
#include <openssl/params.h>
#include <openssl/fips_names.h>
#include <openssl/fipskey.h>
#include <openssl/rand.h> /* RAND_get0_public() */
#include <openssl/proverr.h>
#include "internal/cryptlib.h"
Expand Down Expand Up @@ -199,7 +200,7 @@ static int fips_get_params(void *provctx, OSSL_PARAM params[])
OSSL_LIB_CTX_FIPS_PROV_INDEX);

p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME);
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL FIPS Provider"))
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, FIPS_VENDOR))
return 0;
p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_VERSION);
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_VERSION_STR))
Expand Down
2 changes: 1 addition & 1 deletion test/drbgtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static int using_fips_rng(void)
if (!TEST_ptr(prov))
return 0;
name = OSSL_PROVIDER_get0_name(prov);
return strcmp(name, "OpenSSL FIPS Provider") == 0;
return strstr(name, "OpenSSL FIPS Provider") != NULL;
}

/*
Expand Down

0 comments on commit 5c7c29e

Please sign in to comment.