diff options
Diffstat (limited to 'src/plugins/preauth/pkinit')
-rw-r--r-- | src/plugins/preauth/pkinit/Makefile.in | 6 | ||||
-rw-r--r-- | src/plugins/preauth/pkinit/pkinit.h | 4 | ||||
-rw-r--r-- | src/plugins/preauth/pkinit/pkinit_clnt.c | 10 | ||||
-rw-r--r-- | src/plugins/preauth/pkinit/pkinit_crypto_openssl.c | 20 | ||||
-rw-r--r-- | src/plugins/preauth/pkinit/pkinit_kdf_constants.c | 2 | ||||
-rw-r--r-- | src/plugins/preauth/pkinit/pkinit_kdf_test.c | 36 | ||||
-rw-r--r-- | src/plugins/preauth/pkinit/pkinit_lib.c | 3 |
7 files changed, 37 insertions, 44 deletions
diff --git a/src/plugins/preauth/pkinit/Makefile.in b/src/plugins/preauth/pkinit/Makefile.in index 1f81d1c..c148d5a 100644 --- a/src/plugins/preauth/pkinit/Makefile.in +++ b/src/plugins/preauth/pkinit/Makefile.in @@ -30,7 +30,7 @@ STLIBOBJS= \ pkinit_srv.o \ pkinit_lib.o \ pkinit_clnt.o \ - pkinit_kdf_constants.o \ + pkinit_kdf_constants.o \ pkinit_profile.o \ pkinit_identity.o \ pkinit_matching.o \ @@ -57,10 +57,10 @@ clean:: $(RM) pkinit_test_kdf check-unix:: pkinit_kdf_test - $(RUN_SETUP) $(VALGRIND) ./pkinit_kdf_test + $(RUN_SETUP) $(VALGRIND) ./pkinit_kdf_test pkinit_kdf_test: pkinit_kdf_test.o $(STLIBOBJS) $(SHLIB_EXPDEPS) - $(CC_LINK) -o $@ pkinit_kdf_test.o $(STLIBOBJS) $(SHLIB_EXPLIBS) + $(CC_LINK) -o $@ pkinit_kdf_test.o $(STLIBOBJS) $(SHLIB_EXPLIBS) @libnover_frag@ @libobj_frag@ diff --git a/src/plugins/preauth/pkinit/pkinit.h b/src/plugins/preauth/pkinit/pkinit.h index 8928e9d..ffe2a14 100644 --- a/src/plugins/preauth/pkinit/pkinit.h +++ b/src/plugins/preauth/pkinit/pkinit.h @@ -219,13 +219,13 @@ typedef struct _pkinit_context *pkinit_context; * Client's per-request context */ struct _pkinit_req_context { - unsigned int magic; + unsigned int magic; pkinit_req_crypto_context cryptoctx; pkinit_req_opts *opts; pkinit_identity_crypto_context idctx; pkinit_identity_opts *idopts; krb5_preauthtype pa_type; - int rfc6112_kdc; + int rfc6112_kdc; }; typedef struct _pkinit_req_context *pkinit_req_context; diff --git a/src/plugins/preauth/pkinit/pkinit_clnt.c b/src/plugins/preauth/pkinit/pkinit_clnt.c index 85b0167..3d3dceb 100644 --- a/src/plugins/preauth/pkinit/pkinit_clnt.c +++ b/src/plugins/preauth/pkinit/pkinit_clnt.c @@ -70,9 +70,9 @@ use_content_info(krb5_context context, pkinit_req_context req, return 0; if (krb5_principal_compare_any_realm(context, client, krb5_anonymous_principal())) - return 1; + return 1; return 0; - } +} static krb5_error_code pkinit_as_req_create(krb5_context context, pkinit_context plgctx, @@ -364,7 +364,7 @@ pkinit_as_req_create(krb5_context context, retval = ENOMEM; goto cleanup; } - if (use_content_info(context, reqctx, client)) + if (use_content_info(context, reqctx, client)) { retval = cms_contentinfo_create(context, plgctx->cryptoctx, reqctx->cryptoctx, reqctx->idctx, CMS_SIGN_CLIENT, (unsigned char *) @@ -372,7 +372,7 @@ pkinit_as_req_create(krb5_context context, coded_auth_pack->length, &req->signedAuthPack.data, &req->signedAuthPack.length); - else { + } else { retval = cms_signeddata_create(context, plgctx->cryptoctx, reqctx->cryptoctx, reqctx->idctx, CMS_SIGN_CLIENT, 1, @@ -1030,7 +1030,7 @@ pkinit_client_process(krb5_context context, krb5_clpreauth_moddata moddata, case KRB5_PADATA_PKINIT_KX: reqctx->rfc6112_kdc = 1; return 0; - case KRB5_PADATA_PK_AS_REQ: + case KRB5_PADATA_PK_AS_REQ: pkiDebug("processing KRB5_PADATA_PK_AS_REQ\n"); processing_request = 1; break; diff --git a/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c b/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c index 37685f3..f6c7d5b 100644 --- a/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c +++ b/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c @@ -2103,7 +2103,8 @@ pkinit_octetstring2key(krb5_context context, unsigned char *key, unsigned int dh_key_len, krb5_keyblock *key_block) -{ krb5_error_code retval; +{ + krb5_error_code retval; unsigned char *buf = NULL; unsigned char md[SHA_DIGEST_LENGTH]; unsigned char counter; @@ -2183,22 +2184,19 @@ pkinit_alg_values(krb5_context context, *hash_bytes = 20; *func = &EVP_sha1; return 0; - } - else if ((alg_id->length == krb5_pkinit_sha256_oid_len) && - (0 == memcmp(alg_id->data, krb5_pkinit_sha256_oid, - krb5_pkinit_sha256_oid_len))) { + } else if ((alg_id->length == krb5_pkinit_sha256_oid_len) && + (0 == memcmp(alg_id->data, krb5_pkinit_sha256_oid, + krb5_pkinit_sha256_oid_len))) { *hash_bytes = 32; *func = &EVP_sha256; return 0; - } - else if ((alg_id->length == krb5_pkinit_sha512_oid_len) && - (0 == memcmp(alg_id->data, krb5_pkinit_sha512_oid, - krb5_pkinit_sha512_oid_len))) { + } else if ((alg_id->length == krb5_pkinit_sha512_oid_len) && + (0 == memcmp(alg_id->data, krb5_pkinit_sha512_oid, + krb5_pkinit_sha512_oid_len))) { *hash_bytes = 32; *func = &EVP_sha512; return 0; - } - else { + } else { krb5_set_error_message(context, KRB5_ERR_BAD_S2K_PARAMS, "Bad algorithm ID passed to PK-INIT KDF."); return KRB5_ERR_BAD_S2K_PARAMS; diff --git a/src/plugins/preauth/pkinit/pkinit_kdf_constants.c b/src/plugins/preauth/pkinit/pkinit_kdf_constants.c index e967f38..f29764a 100644 --- a/src/plugins/preauth/pkinit/pkinit_kdf_constants.c +++ b/src/plugins/preauth/pkinit/pkinit_kdf_constants.c @@ -1,5 +1,5 @@ /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* prototype/prototype.c */ +/* plugins/preauth/pkinit/pkinit_kdf_constants.c */ /* * Copyright (C) 2011 by the Massachusetts Institute of Technology. * All rights reserved. diff --git a/src/plugins/preauth/pkinit/pkinit_kdf_test.c b/src/plugins/preauth/pkinit/pkinit_kdf_test.c index 3f7c7c4..bb967bf 100644 --- a/src/plugins/preauth/pkinit/pkinit_kdf_test.c +++ b/src/plugins/preauth/pkinit/pkinit_kdf_test.c @@ -1,5 +1,5 @@ /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* prototype/prototype.c */ +/* plugins/preauth/pkinit/pkinit_kdf_test.c */ /* * Copyright (C) 2011 by the Massachusetts Institute of Technology. * All rights reserved. @@ -55,10 +55,10 @@ int secret_len = 256; char twenty_as[10]; char eighteen_bs[9] ; -char party_u_name [] = "lha@SU.SE"; -char party_v_name [] = "krbtgt/SU.SE@SU.SE"; +char party_u_name[] = "lha@SU.SE"; +char party_v_name[] = "krbtgt/SU.SE@SU.SE"; int enctype_value = 18; -krb5_octet key_hex [] = +krb5_octet key_hex[] = {0xe6, 0xAB, 0x38, 0xC9, 0x41, 0x3E, 0x03, 0x5B, 0xB0, 0x79, 0x20, 0x1E, 0xD0, 0xB6, 0xB7, 0x3D, 0x8D, 0x49, 0xA8, 0x14, 0xA7, 0x37, 0xC0, 0x4E, @@ -66,8 +66,7 @@ krb5_octet key_hex [] = const krb5_data lha_data = DATA_FROM_STRING("lha"); int -main (int argc, - char **argv) +main(int argc, char **argv) { /* arguments for calls to pkinit_alg_agility_kdf() */ krb5_context context = 0; @@ -87,13 +86,13 @@ main (int argc, /* initialize variables that get malloc'ed, so cleanup is safe */ krb5_init_context (&context); - memset (&alg_id, 0, sizeof(alg_id)); - memset (&as_req, 0, sizeof(as_req)); - memset (&pk_as_rep, 0, sizeof(pk_as_rep)); - memset (&key_block, 0, sizeof(key_block)); + memset(&alg_id, 0, sizeof(alg_id)); + memset(&as_req, 0, sizeof(as_req)); + memset(&pk_as_rep, 0, sizeof(pk_as_rep)); + memset(&key_block, 0, sizeof(key_block)); /* set up algorithm id */ - alg_id.algorithm.data = (unsigned char *) &krb5_pkinit_sha1_oid; + alg_id.algorithm.data = (unsigned char *)&krb5_pkinit_sha1_oid; alg_id.algorithm.length = krb5_pkinit_sha1_oid_len; /* set up a 256-byte, ALL-ZEROS secret */ @@ -134,7 +133,8 @@ main (int argc, } /* call pkinit_alg_agility_kdf() with test vector values*/ - if (0 != (retval = pkinit_alg_agility_kdf(context, &secret, &alg_id.algorithm, + if (0 != (retval = pkinit_alg_agility_kdf(context, &secret, + &alg_id.algorithm, u_principal, v_principal, enctype, &as_req, &pk_as_rep, &key_block))) { @@ -149,20 +149,16 @@ main (int argc, (0 == memcmp(key_block.contents, key_hex, key_block.length))) { printf("SUCCESS: Correct key value generated!"); retval = 0; - } - else { + } else { printf("FAILURE: Incorrect key value generated!"); retval = 1; } cleanup: /* release all allocated resources, whether good or bad return */ - if (secret.data) - free(secret.data); - if (u_principal) - free(u_principal); - if (v_principal) - free(v_principal); + free(secret.data); + free(u_principal); + free(v_principal); krb5_free_keyblock_contents(context, &key_block); exit(retval); } diff --git a/src/plugins/preauth/pkinit/pkinit_lib.c b/src/plugins/preauth/pkinit/pkinit_lib.c index 034587b..f93c074 100644 --- a/src/plugins/preauth/pkinit/pkinit_lib.c +++ b/src/plugins/preauth/pkinit/pkinit_lib.c @@ -164,8 +164,7 @@ free_krb5_auth_pack(krb5_auth_pack **in) if ((*in)->supportedCMSTypes != NULL) free_krb5_algorithm_identifiers(&((*in)->supportedCMSTypes)); if ((*in)->supportedKDFs) { - krb5_octet_data **supportedKDFs = - (*in)->supportedKDFs; + krb5_octet_data **supportedKDFs = (*in)->supportedKDFs; unsigned i; for (i = 0; supportedKDFs[i]; i++) krb5_free_octet_data(NULL, supportedKDFs[i]); |