Skip to content

Commit fd4c13f

Browse files
committed
Some fixes for ifdef and spacing
1 parent 708a2fa commit fd4c13f

14 files changed

+33
-21
lines changed

app/app_kas_kdf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int app_kas_hkdf_handler(ACVP_TEST_CASE *test_case) {
4848
fixedInfoLen = stc->literalLen + stc->uPartyIdLen + stc->uEphemeralLen + stc->vPartyIdLen
4949
+ stc->vEphemeralLen + stc->algIdLen + stc->labelLen + stc->contextLen;
5050
//add 4 bytes for the int of lengths is used
51-
for(i = 0; i < ACVP_KAS_KDF_PATTERN_MAX; i++) {
51+
for (i = 0; i < ACVP_KAS_KDF_PATTERN_MAX; i++) {
5252
if (stc->fixedInfoPattern[i] == ACVP_KAS_KDF_PATTERN_L) {
5353
fixedInfoLen += 4;
5454
break;
@@ -284,7 +284,7 @@ int app_kas_hkdf_handler(ACVP_TEST_CASE *test_case) {
284284
if (expand_output) free(expand_output);
285285
if (result) free(result);
286286
#if OPENSSL_VERSION_NUMBER <= 0x10100000L
287-
if(hmac_ctx) HMAC_CTX_cleanup(hmac_ctx);
287+
if (hmac_ctx) HMAC_CTX_cleanup(hmac_ctx);
288288
#else
289289
if (hmac_ctx) HMAC_CTX_free(hmac_ctx);
290290
#endif
@@ -336,7 +336,7 @@ int app_kas_kdf_onestep_handler(ACVP_TEST_CASE *test_case) {
336336
fixedInfoLen = stc->literalLen + stc->uPartyIdLen + stc->uEphemeralLen + stc->vPartyIdLen
337337
+ stc->vEphemeralLen + stc->algIdLen + stc->labelLen + stc->contextLen;
338338
//add 4 bytes for the int of lengths is used
339-
for(i = 0; i < ACVP_KAS_KDF_PATTERN_MAX; i++) {
339+
for (i = 0; i < ACVP_KAS_KDF_PATTERN_MAX; i++) {
340340
if (stc->fixedInfoPattern[i] == ACVP_KAS_KDF_PATTERN_L) {
341341
fixedInfoLen += 4;
342342
break;

app/app_main.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ int fips_mode;
4141
#ifndef OPENSSL_NO_DSA
4242
static int enable_dsa(ACVP_CTX *ctx);
4343
static int enable_kas_ffc(ACVP_CTX *ctx);
44+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
4445
static int enable_safe_primes(ACVP_CTX *ctx);
4546
#endif
47+
#endif
4648
static int enable_aes(ACVP_CTX *ctx);
4749
static int enable_tdes(ACVP_CTX *ctx);
4850
static int enable_hash(ACVP_CTX *ctx);
@@ -328,15 +330,18 @@ int main(int argc, char **argv) {
328330
if (enable_kas_ffc(ctx)) goto end;
329331
}
330332
#endif
331-
if(cfg.kas_kdf) {
333+
if (cfg.kas_kdf) {
332334
if (enable_kas_kdf(ctx)) goto end;
333335
}
334336
}
335337

338+
339+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
336340
#ifndef OPENSSL_NO_DSA
337341
if (cfg.safe_primes) {
338342
if (enable_safe_primes(ctx)) goto end;
339343
}
344+
#endif
340345
#endif
341346
if (cfg.kat) {
342347
rv = acvp_load_kat_filename(ctx, cfg.kat_file);
@@ -402,7 +407,7 @@ int main(int argc, char **argv) {
402407
goto end;
403408
}
404409

405-
if(cfg.get_expected) {
410+
if (cfg.get_expected) {
406411
if (cfg.save_to) {
407412
rv = acvp_get_expected_results(ctx, cfg.session_file, cfg.save_file);
408413
} else {

ms/resources/Source.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ LIBRARY libacvp
22
EXPORTS
33
acvp_cap_sym_cipher_enable
44
acvp_cap_sym_cipher_set_parm
5+
acvp_cap_sym_cipher_set_domain
56
acvp_cap_hash_enable
67
acvp_cap_hash_set_parm
78
acvp_cap_hash_set_domain
@@ -10,6 +11,8 @@ EXPORTS
1011
acvp_cap_drbg_set_length
1112
acvp_cap_dsa_enable
1213
acvp_cap_dsa_set_parm
14+
acvp_cap_safe_primes_enable
15+
acvp_cap_safe_primes_set_parm
1316
acvp_cap_kas_ecc_enable
1417
acvp_cap_kas_ecc_set_prereq
1518
acvp_cap_kas_ecc_set_parm

ms/resources/libacvp.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@
413413
<ClCompile Include="..\..\src\acvp_operating_env.c" />
414414
<ClCompile Include="..\..\src\acvp_rsa_keygen.c" />
415415
<ClCompile Include="..\..\src\acvp_rsa_sig.c" />
416+
<ClCompile Include="..\..\src\acvp_safe_primes.c" />
416417
<ClCompile Include="..\..\src\acvp_transport.c" />
417418
<ClCompile Include="..\..\src\acvp_util.c" />
418419
<ClCompile Include="..\..\src\parson.c" />

ms/resources/libacvp.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
<ClCompile Include="..\..\src\acvp_util.c">
109109
<Filter>Source Files</Filter>
110110
</ClCompile>
111+
<ClCompile Include="..\..\src\acvp_safe_primes.c">
112+
<Filter>Source Files</Filter>
113+
</ClCompile>
111114
<ClCompile Include="..\..\src\parson.c">
112115
<Filter>Source Files</Filter>
113116
</ClCompile>

murl/test/ut_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int test_murl_locate_ipv6_address (char *address, int max_addr)
4343
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
4444
if (ifa->ifa_addr == NULL) continue;
4545

46-
if((ifa->ifa_addr->sa_family==AF_INET6)) {
46+
if ((ifa->ifa_addr->sa_family==AF_INET6)) {
4747
if (!strcmp(ifa->ifa_name, "lo")) {
4848
have_v6_loopback = 1;
4949
continue;

src/acvp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,7 +2931,7 @@ static ACVP_RESULT acvp_get_result_test_session(ACVP_CTX *ctx, char *session_url
29312931
}
29322932
testsCompleted++;
29332933
}
2934-
if(testsCompleted >= count) {
2934+
if (testsCompleted >= count) {
29352935
passed = json_object_get_boolean(obj, "passed");
29362936
if (passed == 1) {
29372937
/*
@@ -3010,7 +3010,7 @@ static ACVP_RESULT acvp_get_result_test_session(ACVP_CTX *ctx, char *session_url
30103010
if (failedAlgList) {
30113011
acvp_free_str_list(&failedAlgList);
30123012
}
3013-
if(failedVsList) {
3013+
if (failedVsList) {
30143014
acvp_free_str_list(&failedVsList);
30153015
}
30163016
return rv;

src/acvp_aes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ static ACVP_RESULT acvp_aes_output_tc(ACVP_CTX *ctx,
13521352
/*
13531353
* Only return IV on AES ciphers with internal IV generation
13541354
*/
1355-
if(stc->ivgen_source == ACVP_SYM_CIPH_IVGEN_SRC_INT &&
1355+
if (stc->ivgen_source == ACVP_SYM_CIPH_IVGEN_SRC_INT &&
13561356
(stc->cipher == ACVP_AES_GCM || stc->cipher == ACVP_AES_GMAC || stc->cipher == ACVP_AES_XPN ||
13571357
(stc->cipher == ACVP_AES_CTR && stc->conformance == ACVP_CONFORMANCE_RFC3686))) {
13581358
rv = acvp_bin_to_hexstr(stc->iv, stc->iv_len, tmp, ACVP_SYM_CT_MAX);

src/acvp_build_register.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ static ACVP_RESULT acvp_build_sym_cipher_register_cap(JSON_Object *cap_obj, ACVP
654654
|| (cap_entry->cipher == ACVP_AES_XPN)) {
655655
json_object_set_value(cap_obj, "aadLen", json_value_init_array());
656656
opts_arr = json_object_get_array(cap_obj, "aadLen");
657-
if(sym_cap->aadlen) {
657+
if (sym_cap->aadlen) {
658658
sl_list = sym_cap->aadlen;
659659
while (sl_list) {
660660
json_array_append_number(opts_arr, sl_list->length);

src/acvp_capabilities.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,7 @@ ACVP_RESULT acvp_cap_sym_cipher_set_parm(ACVP_CTX *ctx,
23852385
}
23862386

23872387
case ACVP_SYM_CIPH_PARM_PERFORM_CTR:
2388-
if(value == 0 || value == 1) {
2388+
if (value == 0 || value == 1) {
23892389
if (value == 0 && (cap->cap.sym_cap->ctr_incr || cap->cap.sym_cap->ctr_ovrflw)) {
23902390
ACVP_LOG_WARN("Perform counter test set to false, but value for ctr increment or ctr overflow already set. Server will ignore other values. Continuing...");
23912391
}
@@ -8779,7 +8779,7 @@ ACVP_RESULT acvp_cap_kas_kdf_set_parm(ACVP_CTX *ctx, ACVP_CIPHER cipher, ACVP_KA
87798779
free(cap_list->cap.kas_kdf_onestep_cap->literal_pattern_candidate);
87808780
cap_list->cap.kas_kdf_onestep_cap->literal_pattern_candidate = NULL;
87818781
}
8782-
if(value == ACVP_KAS_KDF_PATTERN_LITERAL) {
8782+
if (value == ACVP_KAS_KDF_PATTERN_LITERAL) {
87838783
int len = strnlen_s(string, ACVP_KAS_KDF_PATTERN_LITERAL_STR_LEN_MAX + 1);
87848784
if (len > ACVP_KAS_KDF_PATTERN_LITERAL_STR_LEN_MAX) {
87858785
ACVP_LOG_ERR("Provided literal string too long");
@@ -8907,7 +8907,7 @@ ACVP_RESULT acvp_cap_kas_kdf_set_parm(ACVP_CTX *ctx, ACVP_CIPHER cipher, ACVP_KA
89078907
free(cap_list->cap.kas_hkdf_cap->literal_pattern_candidate);
89088908
cap_list->cap.kas_hkdf_cap->literal_pattern_candidate = NULL;
89098909
}
8910-
if(value == ACVP_KAS_KDF_PATTERN_LITERAL) {
8910+
if (value == ACVP_KAS_KDF_PATTERN_LITERAL) {
89118911
int len = strnlen_s(string, ACVP_KAS_KDF_PATTERN_LITERAL_STR_LEN_MAX + 1);
89128912
if (len > ACVP_KAS_KDF_PATTERN_LITERAL_STR_LEN_MAX) {
89138913
ACVP_LOG_ERR("Provided literal string too long");
@@ -9238,7 +9238,7 @@ ACVP_RESULT acvp_cap_kts_ifc_set_scheme_parm(ACVP_CTX *ctx,
92389238
}
92399239

92409240
while (current_scheme) {
9241-
if(current_scheme->scheme != scheme) {
9241+
if (current_scheme->scheme != scheme) {
92429242
current_scheme = current_scheme->next;
92439243
}
92449244
break;
@@ -9373,7 +9373,7 @@ ACVP_RESULT acvp_cap_kts_ifc_set_scheme_string(ACVP_CTX *ctx,
93739373
}
93749374

93759375
while (current_scheme) {
9376-
if(current_scheme->scheme != scheme) {
9376+
if (current_scheme->scheme != scheme) {
93779377
current_scheme = current_scheme->next;
93789378
}
93799379
break;

src/acvp_kas_kdf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ static ACVP_RESULT acvp_kas_kdf_process(ACVP_CTX *ctx,
778778
l = json_object_get_number(configobj, "l");
779779
if (cipher == ACVP_KAS_HKDF) {
780780
kdfcap = acvp_locate_cap_entry(ctx, ACVP_KAS_HKDF);
781-
if(!kdfcap || !kdfcap->cap.kas_hkdf_cap) {
781+
if (!kdfcap || !kdfcap->cap.kas_hkdf_cap) {
782782
ACVP_LOG_ERR("Missing KAS_HKDF capability data");
783783
rv = ACVP_UNSUPPORTED_OP;
784784
goto err;
@@ -790,7 +790,7 @@ static ACVP_RESULT acvp_kas_kdf_process(ACVP_CTX *ctx,
790790
}
791791
} else {
792792
kdfcap = acvp_locate_cap_entry(ctx, ACVP_KAS_KDF_ONESTEP);
793-
if(!kdfcap || !kdfcap->cap.kas_kdf_onestep_cap) {
793+
if (!kdfcap || !kdfcap->cap.kas_kdf_onestep_cap) {
794794
ACVP_LOG_ERR("Missing KAS_KDF_ONESTEP capability data");
795795
rv = ACVP_UNSUPPORTED_OP;
796796
goto err;
@@ -808,7 +808,7 @@ static ACVP_RESULT acvp_kas_kdf_process(ACVP_CTX *ctx,
808808

809809
ACVP_LOG_VERBOSE(" Test group: %d", i);
810810
ACVP_LOG_VERBOSE(" test type: %s", test_type_str);
811-
if(cipher == ACVP_KAS_HKDF) {
811+
if (cipher == ACVP_KAS_HKDF) {
812812
ACVP_LOG_VERBOSE(" hmac: %s", alg_str);
813813
} else if (cipher == ACVP_KAS_KDF_ONESTEP) {
814814
ACVP_LOG_VERBOSE(" auxFunction: %s", alg_str);

src/acvp_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ int acvp_lookup_param_list(ACVP_PARAM_LIST *list, int value) {
10701070
return 0;
10711071
}
10721072
while(list) {
1073-
if(value == list->param) {
1073+
if (value == list->param) {
10741074
return 1;
10751075
} else {
10761076
list = list->next;

src/parson.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static void remove_comments(char *string, const char *start_token, const char *e
346346
} else if (current_char == '\"' && !escaped) {
347347
in_string = !in_string;
348348
} else if (!in_string && strncmp(string, start_token, start_token_len) == 0) {
349-
for(i = 0; i < start_token_len; i++) {
349+
for (i = 0; i < start_token_len; i++) {
350350
string[i] = ' ';
351351
}
352352
string = string + start_token_len;

test/test_app_kas_kdf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ int initialize_kas_kdf_onestep_tc(ACVP_KAS_KDF_ONESTEP_TC *stc,
244244
}
245245
}
246246

247-
if(uparty) {
247+
if (uparty) {
248248
stc->uPartyId = calloc(1, ACVP_KAS_KDF_FIXED_BYTE_MAX);
249249
if (!stc->uPartyId) { goto err; }
250250
rv = acvp_hexstr_to_bin(uparty, stc->uPartyId, ACVP_KAS_KDF_FIXED_BYTE_MAX, &(stc->uPartyIdLen));

0 commit comments

Comments
 (0)