diff options
Diffstat (limited to 'asn1/pkcs12')
-rw-r--r-- | asn1/pkcs12/packet-pkcs12-template.c | 91 |
1 files changed, 49 insertions, 42 deletions
diff --git a/asn1/pkcs12/packet-pkcs12-template.c b/asn1/pkcs12/packet-pkcs12-template.c index 261a5cdd88..77f6341998 100644 --- a/asn1/pkcs12/packet-pkcs12-template.c +++ b/asn1/pkcs12/packet-pkcs12-template.c @@ -140,70 +140,77 @@ generate_key_or_iv(unsigned int id, tvbuff_t *salt_tvb, unsigned int iter, else memset (p, 0, 64); - for (;;){ + for (;;) { err = gcry_md_open(&md, GCRY_MD_SHA1, 0); - if (gcry_err_code(err)) { - return FALSE; - } - for (i = 0; i < 64; i++) { - unsigned char lid = id & 0xFF; - gcry_md_write (md, &lid, 1); - } + if (gcry_err_code(err)) + { + return FALSE; + } + for (i = 0; i < 64; i++) + { + unsigned char lid = id & 0xFF; + gcry_md_write (md, &lid, 1); + } - gcry_md_write(md, buf_i, pw ? 128 : 64); + gcry_md_write(md, buf_i, pw ? 128 : 64); gcry_md_final (md); memcpy (hash, gcry_md_read (md, 0), 20); - gcry_md_close (md); + gcry_md_close (md); - for (i = 1; i < iter; i++) - gcry_md_hash_buffer (GCRY_MD_SHA1, hash, hash, 20); + for (i = 1; i < iter; i++) + gcry_md_hash_buffer (GCRY_MD_SHA1, hash, hash, 20); for (i = 0; i < 20 && cur_keylen < req_keylen; i++) - keybuf[cur_keylen++] = hash[i]; + keybuf[cur_keylen++] = hash[i]; - if (cur_keylen == req_keylen) { - gcry_mpi_release (num_b1); - return TRUE; /* ready */ - } + if (cur_keylen == req_keylen) + { + gcry_mpi_release (num_b1); + return TRUE; /* ready */ + } /* need more bytes. */ for (i = 0; i < 64; i++) - buf_b[i] = hash[i % 20]; + buf_b[i] = hash[i % 20]; - n = 64; + n = 64; - rc = gcry_mpi_scan (&num_b1, GCRYMPI_FMT_USG, buf_b, n, &n); + rc = gcry_mpi_scan (&num_b1, GCRYMPI_FMT_USG, buf_b, n, &n); - if (rc != 0) { - return FALSE; - } + if (rc != 0) + { + return FALSE; + } - gcry_mpi_add_ui (num_b1, num_b1, 1); + gcry_mpi_add_ui (num_b1, num_b1, 1); - for (i = 0; i < 128; i += 64) { - gcry_mpi_t num_ij; + for (i = 0; i < 128; i += 64) + { + gcry_mpi_t num_ij; - n = 64; - rc = gcry_mpi_scan (&num_ij, GCRYMPI_FMT_USG, buf_i + i, n, &n); + n = 64; + rc = gcry_mpi_scan (&num_ij, GCRYMPI_FMT_USG, buf_i + i, n, &n); - if (rc != 0) { - return FALSE; - } + if (rc != 0) + { + return FALSE; + } - gcry_mpi_add (num_ij, num_ij, num_b1); - gcry_mpi_clear_highbit (num_ij, 64 * 8); + gcry_mpi_add (num_ij, num_ij, num_b1); + gcry_mpi_clear_highbit (num_ij, 64 * 8); - n = 64; + n = 64; - rc = gcry_mpi_print (GCRYMPI_FMT_USG, buf_i + i, n, &n, num_ij); - if (rc != 0){ - return FALSE; - } + rc = gcry_mpi_print (GCRYMPI_FMT_USG, buf_i + i, n, &n, num_ij); + if (rc != 0) + { + return FALSE; + } - gcry_mpi_release (num_ij); - } + gcry_mpi_release (num_ij); + } } } @@ -413,7 +420,7 @@ static void dissect_AuthenticatedSafe_OCTETSTRING_PDU(tvbuff_t *tvb, packet_info if((offset = strip_octet_string(tvb)) > 0) dissect_pkcs12_AuthenticatedSafe(FALSE, tvb, offset, &asn1_ctx, tree, hf_pkcs12_AuthenticatedSafe_PDU); else - proto_tree_add_text(tree, tvb, 0, 1, "BER Error: OCTET STRING expected"); + proto_tree_add_text(tree, tvb, 0, 1, "BER Error: OCTET STRING expected"); } static void dissect_SafeContents_OCTETSTRING_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) @@ -444,7 +451,7 @@ void proto_register_pkcs12(void) { /* List of fields */ static hf_register_info hf[] = { - { &hf_pkcs12_X509Certificate_PDU, + { &hf_pkcs12_X509Certificate_PDU, { "X509Certificate", "pkcs12.X509Certificate", FT_NONE, BASE_NONE, NULL, 0, "pkcs12.X509Certificate", HFILL }}, |