X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=crypto%2Fasn1%2Fameth_lib.c;h=8060c18b19d97968f2615a3da3511cb7d9098ea7;hb=3418f7b7b01139dbf4a72d2bc71135d918d4cf11;hp=718aa521c5fbd669b369e5799f7f467131f60dfe;hpb=b548a1f11c06ccdfa4f52a539912d22d77ee309e;p=oweals%2Fopenssl.git diff --git a/crypto/asn1/ameth_lib.c b/crypto/asn1/ameth_lib.c index 718aa521c5..8060c18b19 100644 --- a/crypto/asn1/ameth_lib.c +++ b/crypto/asn1/ameth_lib.c @@ -57,7 +57,7 @@ */ #include -#include "cryptlib.h" +#include "internal/cryptlib.h" #include #include #ifndef OPENSSL_NO_ENGINE @@ -107,8 +107,7 @@ static STACK_OF(EVP_PKEY_ASN1_METHOD) *app_methods = NULL; void main() { int i; - for (i = 0; - i < sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *); i++) + for (i = 0; i < OSSL_NELEM(standard_methods); i++) fprintf(stderr, "Number %d id=%d (%s)\n", i, standard_methods[i]->pkey_id, OBJ_nid2sn(standard_methods[i]->pkey_id)); @@ -129,7 +128,7 @@ IMPLEMENT_OBJ_BSEARCH_CMP_FN(const EVP_PKEY_ASN1_METHOD *, int EVP_PKEY_asn1_get_count(void) { - int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *); + int num = OSSL_NELEM(standard_methods); if (app_methods) num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods); return num; @@ -137,7 +136,7 @@ int EVP_PKEY_asn1_get_count(void) const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx) { - int num = sizeof(standard_methods) / sizeof(EVP_PKEY_ASN1_METHOD *); + int num = OSSL_NELEM(standard_methods); if (idx < 0) return NULL; if (idx < num) @@ -157,8 +156,7 @@ static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type) if (idx >= 0) return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx); } - ret = OBJ_bsearch_ameth(&t, standard_methods, sizeof(standard_methods) - / sizeof(EVP_PKEY_ASN1_METHOD *)); + ret = OBJ_bsearch_ameth(&t, standard_methods, OSSL_NELEM(standard_methods)); if (!ret || !*ret) return NULL; return *ret; @@ -223,8 +221,8 @@ const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, ameth = EVP_PKEY_asn1_get0(i); if (ameth->pkey_flags & ASN1_PKEY_ALIAS) continue; - if (((int)strlen(ameth->pem_str) == len) && - !strncasecmp(ameth->pem_str, str, len)) + if (((int)strlen(ameth->pem_str) == len) + && (strncasecmp(ameth->pem_str, str, len) == 0)) return ameth; } return NULL; @@ -286,12 +284,11 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) { EVP_PKEY_ASN1_METHOD *ameth; - ameth = OPENSSL_malloc(sizeof(EVP_PKEY_ASN1_METHOD)); + ameth = OPENSSL_malloc(sizeof(*ameth)); if (!ameth) return NULL; - memset(ameth, 0, sizeof(EVP_PKEY_ASN1_METHOD)); - + memset(ameth, 0, sizeof(*ameth)); ameth->pkey_id = id; ameth->pkey_base_id = id; ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; @@ -469,3 +466,21 @@ void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth, { ameth->pkey_security_bits = pkey_security_bits; } + +void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth, + int (*item_verify) (EVP_MD_CTX *ctx, + const ASN1_ITEM *it, + void *asn, + X509_ALGOR *a, + ASN1_BIT_STRING *sig, + EVP_PKEY *pkey), + int (*item_sign) (EVP_MD_CTX *ctx, + const ASN1_ITEM *it, + void *asn, + X509_ALGOR *alg1, + X509_ALGOR *alg2, + ASN1_BIT_STRING *sig)) +{ + ameth->item_sign = item_sign; + ameth->item_verify = item_verify; +}