Skip to content

Commit 50ca5f0

Browse files
committed
GCM: new API function ica_allow_external_gcm_iv_in_fips_mode
When running in fips mode, the GCM iv is created internally via an approved random source. Applications are not allowed to use an own, external iv. The new API function allows to override this behavior and allow an external GCM iv in fips mode. In this case the application is responsible for creating the iv in a compliant way. Signed-off-by: Joerg Schmidbauer <jschmidb@de.ibm.com>
1 parent 66abdaa commit 50ca5f0

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

include/ica_api.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,17 @@ void ica_set_offload_mode(int offload_mode);
537537
ICA_EXPORT
538538
void ica_set_stats_mode(int stats_mode);
539539

540+
/**
541+
* Allow or disallow using an external GCM iv when running in fips mode.
542+
* When running in fips mode, the GCM iv is created internally via an approved
543+
* random source. Applications are not allowed to use an own, external iv. If
544+
* this function is called with allow = 1, libica will override this behavior
545+
* and allow an external GCM iv in fips mode. In this case the application is
546+
* responsible for creating the iv in a compliant way. Default is allow = 0.
547+
*/
548+
ICA_EXPORT
549+
void ica_allow_external_gcm_iv_in_fips_mode(int allow);
550+
540551
/**
541552
* Opens the specified adapter
542553
* @param adapter_handle Pointer to the file descriptor for the adapter or

libica.map

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,9 @@ LIBICA_4.1.2 {
196196
ica_get_build_version;
197197
local: *;
198198
} LIBICA_4.1.1;
199+
200+
LIBICA_4.3.0 {
201+
global:
202+
ica_allow_external_gcm_iv_in_fips_mode;
203+
local: *;
204+
} LIBICA_4.1.2;

src/ica_api.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ void ica_set_stats_mode(int stats_mode)
9292
ica_stats_enabled = stats_mode ? 1 : 0;
9393
}
9494

95+
int ica_external_gcm_iv_in_fips_mode_allowed = 0;
96+
97+
void ica_allow_external_gcm_iv_in_fips_mode(int allow)
98+
{
99+
ica_external_gcm_iv_in_fips_mode_allowed = allow ? 1 : 0;
100+
}
101+
102+
95103
#ifndef NO_CPACF
96104

97105
static unsigned int check_des_parms(unsigned int mode,
@@ -3728,7 +3736,8 @@ unsigned int ica_aes_gcm_initialize(const unsigned char *iv,
37283736
unsigned int direction)
37293737
{
37303738
#ifdef ICA_FIPS
3731-
if (direction == ENCRYPT && (fips & ICA_FIPS_MODE))
3739+
if (!ica_external_gcm_iv_in_fips_mode_allowed &&
3740+
direction == ENCRYPT && (fips & ICA_FIPS_MODE))
37323741
return EPERM;
37333742
#endif /* ICA_FIPS */
37343743

@@ -3976,7 +3985,8 @@ int ica_aes_gcm_kma_init(unsigned int direction,
39763985
kma_ctx* ctx)
39773986
{
39783987
#ifdef ICA_FIPS
3979-
if (direction == ICA_ENCRYPT && (fips & ICA_FIPS_MODE))
3988+
if (!ica_external_gcm_iv_in_fips_mode_allowed &&
3989+
direction == ICA_ENCRYPT && (fips & ICA_FIPS_MODE))
39803990
return EPERM;
39813991
#endif /* ICA_FIPS */
39823992

0 commit comments

Comments
 (0)