Deleted Added
full compact
evp_pbe.c (194206) evp_pbe.c (215697)
1/* evp_pbe.c */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 102 unchanged lines hidden (view full) ---

111 return ((*pbe1)->pbe_nid - (*pbe2)->pbe_nid);
112}
113
114/* Add a PBE algorithm */
115
116int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
117 EVP_PBE_KEYGEN *keygen)
118{
1/* evp_pbe.c */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 102 unchanged lines hidden (view full) ---

111 return ((*pbe1)->pbe_nid - (*pbe2)->pbe_nid);
112}
113
114/* Add a PBE algorithm */
115
116int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
117 EVP_PBE_KEYGEN *keygen)
118{
119 EVP_PBE_CTL *pbe_tmp;
120 if (!pbe_algs) pbe_algs = sk_new(pbe_cmp);
121 if (!(pbe_tmp = (EVP_PBE_CTL*) OPENSSL_malloc (sizeof(EVP_PBE_CTL)))) {
122 EVPerr(EVP_F_EVP_PBE_ALG_ADD,ERR_R_MALLOC_FAILURE);
123 return 0;
124 }
125 pbe_tmp->pbe_nid = nid;
119 EVP_PBE_CTL *pbe_tmp = NULL, pbelu;
120 int i;
121 if (!pbe_algs)
122 {
123 pbe_algs = sk_new(pbe_cmp);
124 if (!pbe_algs)
125 {
126 EVPerr(EVP_F_EVP_PBE_ALG_ADD,ERR_R_MALLOC_FAILURE);
127 return 0;
128 }
129 }
130 else
131 {
132 /* Check if already present */
133 pbelu.pbe_nid = nid;
134 i = sk_find(pbe_algs, (char *)&pbelu);
135 if (i >= 0)
136 {
137 pbe_tmp = (EVP_PBE_CTL *)sk_value(pbe_algs, i);
138 /* If everything identical leave alone */
139 if (pbe_tmp->cipher == cipher
140 && pbe_tmp->md == md
141 && pbe_tmp->keygen == keygen)
142 return 1;
143 }
144 }
145
146 if (!pbe_tmp)
147 {
148 pbe_tmp = OPENSSL_malloc (sizeof(EVP_PBE_CTL));
149 if (!pbe_tmp)
150 {
151 EVPerr(EVP_F_EVP_PBE_ALG_ADD,ERR_R_MALLOC_FAILURE);
152 return 0;
153 }
154 /* If adding a new PBE, set nid, append and sort */
155 pbe_tmp->pbe_nid = nid;
156 sk_push (pbe_algs, (char *)pbe_tmp);
157 sk_sort(pbe_algs);
158 }
159
126 pbe_tmp->cipher = cipher;
127 pbe_tmp->md = md;
128 pbe_tmp->keygen = keygen;
160 pbe_tmp->cipher = cipher;
161 pbe_tmp->md = md;
162 pbe_tmp->keygen = keygen;
129 sk_push (pbe_algs, (char *)pbe_tmp);
130 return 1;
131}
132
133void EVP_PBE_cleanup(void)
134{
135 sk_pop_free(pbe_algs, OPENSSL_freeFunc);
136 pbe_algs = NULL;
137}
163 return 1;
164}
165
166void EVP_PBE_cleanup(void)
167{
168 sk_pop_free(pbe_algs, OPENSSL_freeFunc);
169 pbe_algs = NULL;
170}