~ubuntu-branches/ubuntu/jaunty/heimdal/jaunty

« back to all changes in this revision

Viewing changes to lib/hcrypto/pkcs12.c

  • Committer: Bazaar Package Importer
  • Author(s): Nick Ellery
  • Date: 2008-11-17 22:25:58 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20081117222558-jd1aj1jth6ycdb0x
Tags: 1.2.dfsg.1-2.1ubuntu1
* Merge from debian unstable, remaining changes (LP: #299345):
  - Change libdb4.2-dev to libdb4.6-dev in build-deps
  - Add netbase to heimdal-kdc depends.
  - Set CPPFLAGS=-DLDAP_DEPRECATED to fix build with OpenLDAP 2.4 on
    64-bit architectures.
* Remove dependency on update-inetd to heimdal-servers and heimdal-kdc,
  as packages should rely on the inet-superserver to provide the
  update-inetd command.
* Drop the addition of -1 to the version of comerr-dev in build depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <config.h>
36
36
#endif
37
37
 
38
 
RCSID("$Id: pkcs12.c 21155 2007-06-18 21:59:44Z lha $");
 
38
RCSID("$Id: pkcs12.c 23137 2008-04-29 05:46:48Z lha $");
39
39
 
40
40
#include <stdio.h>
41
41
#include <stdlib.h>
55
55
    unsigned char *v, *I, hash[EVP_MAX_MD_SIZE];
56
56
    unsigned int size, size_I = 0;
57
57
    unsigned char idc = id;
58
 
    EVP_MD_CTX ctx;
 
58
    EVP_MD_CTX *ctx;
59
59
    unsigned char *outp = out;
60
60
    int i, vlen;
61
61
 
62
 
    EVP_MD_CTX_init(&ctx);
 
62
    ctx = EVP_MD_CTX_create();
 
63
    if (ctx == NULL)
 
64
        return 0;
63
65
 
64
66
    vlen = EVP_MD_block_size(md);
65
67
    v = malloc(vlen + 1);
66
 
    if (v == NULL)
 
68
    if (v == NULL) {
 
69
        EVP_MD_CTX_destroy(ctx);
67
70
        return 0;
 
71
    }
68
72
 
69
73
    I = calloc(1, vlen * 2);
70
74
    if (I == NULL) {
 
75
        EVP_MD_CTX_destroy(ctx);
71
76
        free(v);
72
77
        return 0;
73
78
    }
93
98
    while (1) {
94
99
        BIGNUM *bnB, *bnOne;
95
100
 
96
 
        if (!EVP_DigestInit_ex(&ctx, md, NULL)) {
 
101
        if (!EVP_DigestInit_ex(ctx, md, NULL)) {
 
102
            EVP_MD_CTX_destroy(ctx);
97
103
            free(I);
98
104
            free(v);
99
105
            return 0;
100
106
        }
101
107
        for (i = 0; i < vlen; i++)
102
 
            EVP_DigestUpdate(&ctx, &idc, 1);
103
 
        EVP_DigestUpdate(&ctx, I, size_I);
104
 
        EVP_DigestFinal_ex(&ctx, hash, &size);
 
108
            EVP_DigestUpdate(ctx, &idc, 1);
 
109
        EVP_DigestUpdate(ctx, I, size_I);
 
110
        EVP_DigestFinal_ex(ctx, hash, &size);
105
111
 
106
112
        for (i = 1; i < iteration; i++)
107
113
            EVP_Digest(hash, size, hash, &size, md, NULL);
145
151
        size_I = vlen * 2;
146
152
    }
147
153
 
148
 
    EVP_MD_CTX_cleanup(&ctx);
 
154
    EVP_MD_CTX_destroy(ctx);
149
155
    free(I);
150
156
    free(v);
151
157