From 8a0fc5bdcf08e82fe2a636ee14145cb7751dbe55 Mon Sep 17 00:00:00 2001 From: nils Date: Wed, 19 Jan 2005 16:17:32 +0000 Subject: [PATCH] fix indent, patch supplied by Martin Paljak git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2082 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/libopensc/pkcs15-pin.c | 29 ++++++++++++++--------------- src/libopensc/pkcs15-sec.c | 31 ++++++++++++++++--------------- src/libopensc/reader-pcsc.c | 10 ++++------ src/libopensc/sec.c | 2 +- 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/libopensc/pkcs15-pin.c b/src/libopensc/pkcs15-pin.c index a618985d..fd81220a 100644 --- a/src/libopensc/pkcs15-pin.c +++ b/src/libopensc/pkcs15-pin.c @@ -55,18 +55,18 @@ int sc_pkcs15_decode_aodf_entry(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj, const u8 ** buf, size_t *buflen) { - struct sc_context *ctx = p15card->card->ctx; - struct sc_pkcs15_pin_info info; + struct sc_context *ctx = p15card->card->ctx; + struct sc_pkcs15_pin_info info; int r; size_t flags_len = sizeof(info.flags); - size_t padchar_len = 1; + size_t padchar_len = 1; struct sc_asn1_entry asn1_com_ao_attr[2], asn1_pin_attr[10], asn1_type_pin_attr[2]; struct sc_asn1_entry asn1_pin[2]; struct sc_asn1_pkcs15_object pin_obj = { obj, asn1_com_ao_attr, NULL, asn1_type_pin_attr }; - sc_copy_asn1_entry(c_asn1_pin, asn1_pin); - sc_copy_asn1_entry(c_asn1_type_pin_attr, asn1_type_pin_attr); - sc_copy_asn1_entry(c_asn1_pin_attr, asn1_pin_attr); - sc_copy_asn1_entry(c_asn1_com_ao_attr, asn1_com_ao_attr); + sc_copy_asn1_entry(c_asn1_pin, asn1_pin); + sc_copy_asn1_entry(c_asn1_type_pin_attr, asn1_type_pin_attr); + sc_copy_asn1_entry(c_asn1_pin_attr, asn1_pin_attr); + sc_copy_asn1_entry(c_asn1_com_ao_attr, asn1_com_ao_attr); sc_format_asn1_entry(asn1_pin + 0, &pin_obj, NULL, 0); @@ -79,13 +79,13 @@ int sc_pkcs15_decode_aodf_entry(struct sc_pkcs15_card *p15card, sc_format_asn1_entry(asn1_pin_attr + 4, &info.max_length, NULL, 0); sc_format_asn1_entry(asn1_pin_attr + 5, &info.reference, NULL, 0); sc_format_asn1_entry(asn1_pin_attr + 6, &info.pad_char, &padchar_len, 0); - /* We don't support lastPinChange yet. */ + /* We don't support lastPinChange yet. */ sc_format_asn1_entry(asn1_pin_attr + 8, &info.path, NULL, 0); sc_format_asn1_entry(asn1_com_ao_attr + 0, &info.auth_id, NULL, 0); - /* Fill in defaults */ - memset(&info, 0, sizeof(info)); + /* Fill in defaults */ + memset(&info, 0, sizeof(info)); info.reference = 0; info.tries_left = -1; @@ -121,11 +121,10 @@ int sc_pkcs15_encode_aodf_entry(struct sc_context *ctx, struct sc_pkcs15_pin_info *pin = (struct sc_pkcs15_pin_info *) obj->data; struct sc_asn1_pkcs15_object pin_obj = { (struct sc_pkcs15_object *) obj, - asn1_com_ao_attr, NULL, - asn1_type_pin_attr }; + asn1_com_ao_attr, NULL, asn1_type_pin_attr }; int r; size_t flags_len; - size_t padchar_len = 1; + size_t padchar_len = 1; sc_copy_asn1_entry(c_asn1_pin, asn1_pin); sc_copy_asn1_entry(c_asn1_type_pin_attr, asn1_type_pin_attr); @@ -141,7 +140,7 @@ int sc_pkcs15_encode_aodf_entry(struct sc_context *ctx, sc_format_asn1_entry(asn1_pin_attr + 1, &pin->type, NULL, 1); sc_format_asn1_entry(asn1_pin_attr + 2, &pin->min_length, NULL, 1); sc_format_asn1_entry(asn1_pin_attr + 3, &pin->stored_length, NULL, 1); - if (pin->reference >= 0) + if (pin->reference >= 0) sc_format_asn1_entry(asn1_pin_attr + 5, &pin->reference, NULL, 1); /* FIXME: check if pad_char present */ sc_format_asn1_entry(asn1_pin_attr + 6, &pin->pad_char, &padchar_len, 1); @@ -149,7 +148,7 @@ int sc_pkcs15_encode_aodf_entry(struct sc_context *ctx, sc_format_asn1_entry(asn1_com_ao_attr + 0, &pin->auth_id, NULL, 1); - assert(pin->magic == SC_PKCS15_PIN_MAGIC); + assert(pin->magic == SC_PKCS15_PIN_MAGIC); r = sc_asn1_encode(ctx, asn1_pin, buf, buflen); return r; diff --git a/src/libopensc/pkcs15-sec.c b/src/libopensc/pkcs15-sec.c index 4de20c5c..f64bc070 100644 --- a/src/libopensc/pkcs15-sec.c +++ b/src/libopensc/pkcs15-sec.c @@ -66,7 +66,7 @@ int sc_pkcs15_decipher(struct sc_pkcs15_card *p15card, struct sc_algorithm_info *alg_info; struct sc_security_env senv; struct sc_context *ctx = p15card->card->ctx; - const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data; + const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data; unsigned long pad_flags = 0; SC_FUNC_CALLED(ctx, 1); @@ -92,7 +92,7 @@ int sc_pkcs15_decipher(struct sc_pkcs15_card *p15card, if (!(alg_info->flags & SC_ALGORITHM_RSA_PAD_PKCS1)) pad_flags |= SC_ALGORITHM_RSA_PAD_PKCS1; else - senv.algorithm_flags |= SC_ALGORITHM_RSA_PAD_PKCS1; + senv.algorithm_flags |= SC_ALGORITHM_RSA_PAD_PKCS1; } else if ((flags & SC_ALGORITHM_RSA_PAD_ANSI) || (flags & SC_ALGORITHM_RSA_PAD_ISO9796)) { sc_error(ctx, "Only PKCS #1 padding method supported\n"); @@ -139,7 +139,7 @@ int sc_pkcs15_decipher(struct sc_pkcs15_card *p15card, /* Strip any padding */ if (pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1) { r = sc_pkcs1_strip_02_padding(out, (size_t)r, out, (size_t *) &r); - SC_TEST_RET(ctx, r, "Invalid PKCS#1 padding"); + SC_TEST_RET(ctx, r, "Invalid PKCS#1 padding"); } return r; @@ -154,7 +154,7 @@ int sc_pkcs15_compute_signature(struct sc_pkcs15_card *p15card, struct sc_security_env senv; struct sc_context *ctx = p15card->card->ctx; struct sc_algorithm_info *alg_info; - const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data; + const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data; u8 buf[512], *tmpin, *tmpout, *help; size_t tmpoutlen; unsigned long pad_flags = 0; @@ -208,35 +208,35 @@ int sc_pkcs15_compute_signature(struct sc_pkcs15_card *p15card, flags |= algo; } - senv.algorithm_flags = 0; + senv.algorithm_flags = 0; if (flags & SC_ALGORITHM_RSA_HASH_SHA1) { if (inlen != 20) SC_FUNC_RETURN(ctx, 0, SC_ERROR_WRONG_LENGTH); if (!(alg_info->flags & SC_ALGORITHM_RSA_HASH_SHA1)) pad_flags |= SC_ALGORITHM_RSA_HASH_SHA1; else - senv.algorithm_flags |= SC_ALGORITHM_RSA_HASH_SHA1; + senv.algorithm_flags |= SC_ALGORITHM_RSA_HASH_SHA1; } else if (flags & SC_ALGORITHM_RSA_HASH_MD5) { if (inlen != 16) SC_FUNC_RETURN(ctx, 0, SC_ERROR_WRONG_LENGTH); if (!(alg_info->flags & SC_ALGORITHM_RSA_HASH_MD5)) pad_flags |= SC_ALGORITHM_RSA_HASH_MD5; else - senv.algorithm_flags |= SC_ALGORITHM_RSA_HASH_MD5; + senv.algorithm_flags |= SC_ALGORITHM_RSA_HASH_MD5; } else if (flags & SC_ALGORITHM_RSA_HASH_RIPEMD160) { if (inlen != 20) SC_FUNC_RETURN(ctx, 0, SC_ERROR_WRONG_LENGTH); if (!(alg_info->flags & SC_ALGORITHM_RSA_HASH_RIPEMD160)) pad_flags |= SC_ALGORITHM_RSA_HASH_RIPEMD160; else - senv.algorithm_flags |= SC_ALGORITHM_RSA_HASH_RIPEMD160; + senv.algorithm_flags |= SC_ALGORITHM_RSA_HASH_RIPEMD160; } else if (flags & SC_ALGORITHM_RSA_HASH_MD5_SHA1) { if (inlen != 36) SC_FUNC_RETURN(ctx, 0, SC_ERROR_WRONG_LENGTH); if (!(alg_info->flags & SC_ALGORITHM_RSA_HASH_MD5_SHA1)) pad_flags |= SC_ALGORITHM_RSA_HASH_MD5_SHA1; else - senv.algorithm_flags |= SC_ALGORITHM_RSA_HASH_MD5_SHA1; + senv.algorithm_flags |= SC_ALGORITHM_RSA_HASH_MD5_SHA1; } else if (flags & SC_ALGORITHM_RSA_HASH_NONE || (flags & SC_ALGORITHM_RSA_HASHES) == 0) { pad_flags |= SC_ALGORITHM_RSA_HASH_NONE; @@ -246,7 +246,7 @@ int sc_pkcs15_compute_signature(struct sc_pkcs15_card *p15card, if (!(alg_info->flags & SC_ALGORITHM_RSA_PAD_PKCS1)) pad_flags |= SC_ALGORITHM_RSA_PAD_PKCS1; else - senv.algorithm_flags |= SC_ALGORITHM_RSA_PAD_PKCS1; + senv.algorithm_flags |= SC_ALGORITHM_RSA_PAD_PKCS1; } else if ((flags & SC_ALGORITHM_RSA_PAD_ANSI) || (flags & SC_ALGORITHM_RSA_PAD_ISO9796)) { sc_error(ctx, "Only PKCS #1 padding method supported\n"); @@ -274,11 +274,11 @@ int sc_pkcs15_compute_signature(struct sc_pkcs15_card *p15card, } if (pad_flags) { - tmpoutlen = sizeof(buf); + tmpoutlen = sizeof(buf); r = sc_pkcs1_encode(ctx, pad_flags, tmpin, inlen, tmpout, &tmpoutlen, - prkey->modulus_length/8); - SC_TEST_RET(ctx, r, "Unable to add padding"); - help = tmpin; + prkey->modulus_length/8); + SC_TEST_RET(ctx, r, "Unable to add padding"); + help = tmpin; tmpin = tmpout; tmpout = help; inlen = tmpoutlen; @@ -319,7 +319,8 @@ int sc_pkcs15_compute_signature(struct sc_pkcs15_card *p15card, * * Right now we work around this by assuming that eToken keys * always have algorithm RSA_PURE_SIG so the input buffer - * is padded and has the same length as the signature. --okir */ + * is padded and has the same length as the signature. --okir + */ if (tmpin == out) { memcpy(tmpout, tmpin, inlen); tmpin = tmpout; diff --git a/src/libopensc/reader-pcsc.c b/src/libopensc/reader-pcsc.c index 7fe52536..fe61853d 100644 --- a/src/libopensc/reader-pcsc.c +++ b/src/libopensc/reader-pcsc.c @@ -513,14 +513,12 @@ static int pcsc_init(struct sc_context *ctx, void **reader_data) int r; struct pcsc_global_private_data *gpriv; - rv = SCardEstablishContext(SCARD_SCOPE_GLOBAL, - NULL, - NULL, - &pcsc_ctx); + rv = SCardEstablishContext(SCARD_SCOPE_GLOBAL, + NULL, NULL, &pcsc_ctx); if (rv != SCARD_S_SUCCESS) return pcsc_ret_to_error(rv); rv = SCardListReaders(pcsc_ctx, NULL, NULL, - (LPDWORD) &reader_buf_size); + (LPDWORD) &reader_buf_size); if (rv != SCARD_S_SUCCESS || reader_buf_size < 2) { SCardReleaseContext(pcsc_ctx); return pcsc_ret_to_error(rv); /* No readers configured */ @@ -541,7 +539,7 @@ static int pcsc_init(struct sc_context *ctx, void **reader_data) return SC_ERROR_OUT_OF_MEMORY; } rv = SCardListReaders(pcsc_ctx, mszGroups, reader_buf, - (LPDWORD) &reader_buf_size); + (LPDWORD) &reader_buf_size); if (rv != SCARD_S_SUCCESS) { free(reader_buf); free(gpriv); diff --git a/src/libopensc/sec.c b/src/libopensc/sec.c index 188f710c..03571cdb 100644 --- a/src/libopensc/sec.c +++ b/src/libopensc/sec.c @@ -201,7 +201,7 @@ int sc_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, sc_error(card->ctx, "Use of pin pad not supported by card driver"); r = SC_ERROR_NOT_SUPPORTED; } - SC_FUNC_RETURN(card->ctx, 2, r); + SC_FUNC_RETURN(card->ctx, 2, r); } /*