summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/evp_pbe.c17
-rw-r--r--crypto/evp/pmeth_lib.c20
2 files changed, 22 insertions, 15 deletions
diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c
index 8fecd34221..7d6a50266a 100644
--- a/crypto/evp/evp_pbe.c
+++ b/crypto/evp/evp_pbe.c
@@ -189,10 +189,10 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
return 1;
}
-static int pbe_cmp2(const void *a, const void *b)
+DECLARE_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe_cmp2);
+
+static int pbe_cmp2(const EVP_PBE_CTL *pbe1, const EVP_PBE_CTL *pbe2)
{
- const EVP_PBE_CTL *pbe1 = a;
- const EVP_PBE_CTL *pbe2 = b;
int ret = pbe1->pbe_type - pbe2->pbe_type;
if (ret)
return ret;
@@ -200,6 +200,8 @@ static int pbe_cmp2(const void *a, const void *b)
return pbe1->pbe_nid - pbe2->pbe_nid;
}
+IMPLEMENT_OBJ_BSEARCH_CMP_FN(EVP_PBE_CTL, EVP_PBE_CTL, pbe_cmp2);
+
static int pbe_cmp(const EVP_PBE_CTL * const *a, const EVP_PBE_CTL * const *b)
{
int ret = (*a)->pbe_type - (*b)->pbe_type;
@@ -269,11 +271,10 @@ int EVP_PBE_find(int type, int pbe_nid,
}
if (pbetmp == NULL)
{
- pbetmp = (EVP_PBE_CTL *) OBJ_bsearch((char *)&pbelu,
- (char *)builtin_pbe,
- sizeof(builtin_pbe)/sizeof(EVP_PBE_CTL),
- sizeof(EVP_PBE_CTL),
- pbe_cmp2);
+ pbetmp = OBJ_bsearch(EVP_PBE_CTL, &pbelu,
+ EVP_PBE_CTL, builtin_pbe,
+ sizeof(builtin_pbe)/sizeof(EVP_PBE_CTL),
+ pbe_cmp2);
}
if (pbetmp == NULL)
return 0;
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index 765a6c07db..3fd11cbb5a 100644
--- a/crypto/evp/pmeth_lib.c
+++ b/crypto/evp/pmeth_lib.c
@@ -84,15 +84,22 @@ static const EVP_PKEY_METHOD *standard_methods[] =
&hmac_pkey_meth,
};
+DECLARE_OBJ_BSEARCH_CMP_FN(EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *,
+ pmeth_cmp);
+
static int pmeth_cmp(const EVP_PKEY_METHOD * const *a,
- const EVP_PKEY_METHOD * const *b)
+ const EVP_PKEY_METHOD * const *b)
{
return ((*a)->pkey_id - (*b)->pkey_id);
}
+IMPLEMENT_OBJ_BSEARCH_CMP_FN(EVP_PKEY_METHOD *, const EVP_PKEY_METHOD *,
+ pmeth_cmp);
+
const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type)
{
- EVP_PKEY_METHOD tmp, *t = &tmp, **ret;
+ EVP_PKEY_METHOD tmp, *t = &tmp;
+ const EVP_PKEY_METHOD **ret;
tmp.pkey_id = type;
if (app_pkey_methods)
{
@@ -101,11 +108,10 @@ const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type)
if (idx >= 0)
return sk_EVP_PKEY_METHOD_value(app_pkey_methods, idx);
}
- ret = (EVP_PKEY_METHOD **) OBJ_bsearch((char *)&t,
- (char *)standard_methods,
- sizeof(standard_methods)/sizeof(EVP_PKEY_METHOD *),
- sizeof(EVP_PKEY_METHOD *),
- (int (*)(const void *, const void *))pmeth_cmp);
+ ret = OBJ_bsearch(EVP_PKEY_METHOD *, &t,
+ const EVP_PKEY_METHOD *, standard_methods,
+ sizeof(standard_methods)/sizeof(EVP_PKEY_METHOD *),
+ pmeth_cmp);
if (!ret || !*ret)
return NULL;
return *ret;