aboutsummaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2015-09-03 15:46:43 +0100
committerDr. Stephen Henson <steve@openssl.org>2015-09-03 18:37:27 +0100
commitd95466931ddf6f26f840ae3e42594924d25f395e (patch)
tree469dcd700d1b3804de97ab634cc87f3b86cad7df /crypto
parent66c103bdaba21749555c8073a3f20b7741fa5869 (diff)
downloadopenssl-d95466931ddf6f26f840ae3e42594924d25f395e.zip
openssl-d95466931ddf6f26f840ae3e42594924d25f395e.tar.gz
openssl-d95466931ddf6f26f840ae3e42594924d25f395e.tar.bz2
PBE lookup test
Add test to check PBE lookups: these can fail if the PBE table is not correctly orders. Add to "make test". Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/evp_pbe.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c
index 13d9658..b9330f5 100644
--- a/crypto/evp/evp_pbe.c
+++ b/crypto/evp/evp_pbe.c
@@ -122,31 +122,6 @@ static const EVP_PBE_CTL builtin_pbe[] = {
{EVP_PBE_TYPE_KDF, NID_id_scrypt, -1, -1, PKCS5_v2_scrypt_keyivgen}
};
-#ifdef TEST
-int main(int argc, char **argv)
-{
- int i, nid_md, nid_cipher;
- EVP_PBE_CTL *tpbe, *tpbe2;
- /*
- * OpenSSL_add_all_algorithms();
- */
-
- for (i = 0; i < OSSL_NELEM(builtin_pbe); i++) {
- tpbe = builtin_pbe + i;
- fprintf(stderr, "%d %d %s ", tpbe->pbe_type, tpbe->pbe_nid,
- OBJ_nid2sn(tpbe->pbe_nid));
- if (EVP_PBE_find(tpbe->pbe_type, tpbe->pbe_nid,
- &nid_cipher, &nid_md, 0))
- fprintf(stderr, "Found %s %s\n",
- OBJ_nid2sn(nid_cipher), OBJ_nid2sn(nid_md));
- else
- fprintf(stderr, "Find ERROR!!\n");
- }
-
- return 0;
-}
-#endif
-
int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de)
{
@@ -302,3 +277,18 @@ void EVP_PBE_cleanup(void)
sk_EVP_PBE_CTL_pop_free(pbe_algs, free_evp_pbe_ctl);
pbe_algs = NULL;
}
+
+int EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num)
+{
+ const EVP_PBE_CTL *tpbe;
+
+ if (num >= OSSL_NELEM(builtin_pbe))
+ return 0;
+
+ tpbe = builtin_pbe + num;
+ if (ptype)
+ *ptype = tpbe->pbe_type;
+ if (ppbe_nid)
+ *ppbe_nid = tpbe->pbe_nid;
+ return 1;
+}