Add functions returning security bits.
[openssl.git] / crypto / dh / dh_ameth.c
index 141c09ba5437a94d641743c6b825a60f0ed7c40e..ce1edcb0d92c6a5999a825fd846256a9cbf19f0a 100644 (file)
@@ -200,7 +200,7 @@ static int dh_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey)
 
 
 /* PKCS#8 DH is defined in PKCS#11 of all places. It is similar to DH in
- * that the AlgorithmIdentifier contains the paramaters, the private key
+ * that the AlgorithmIdentifier contains the parameters, the private key
  * is explcitly included and the pubkey must be recalculated.
  */
        
@@ -448,6 +448,11 @@ static int dh_bits(const EVP_PKEY *pkey)
        return BN_num_bits(pkey->pkey.dh->p);
        }
 
+static int dh_security_bits(const EVP_PKEY *pkey)
+       {
+       return DH_security_bits(pkey->pkey.dh);
+       }
+
 static int dh_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
        {
        if (    BN_cmp(a->pkey.dh->p,b->pkey.dh->p) ||
@@ -620,6 +625,7 @@ const EVP_PKEY_ASN1_METHOD dh_asn1_meth =
 
        int_dh_size,
        dh_bits,
+       dh_security_bits,
 
        dh_param_decode,
        dh_param_encode,
@@ -653,6 +659,7 @@ const EVP_PKEY_ASN1_METHOD dhx_asn1_meth =
 
        int_dh_size,
        dh_bits,
+       dh_security_bits,
 
        dh_param_decode,
        dh_param_encode,
@@ -673,12 +680,13 @@ static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
        ASN1_OBJECT *aoid;
        int atype;
        void *aval;
-       ASN1_INTEGER *public_key;
+       ASN1_INTEGER *public_key = NULL;
        int rv = 0;
        EVP_PKEY *pkpeer = NULL, *pk = NULL;
        DH *dhpeer = NULL;
        const unsigned char *p;
        int plen;
+
        X509_ALGOR_get0(&aoid, &atype, &aval, alg);
        if (OBJ_obj2nid(aoid) != NID_dhpublicnumber)
                goto err;
@@ -737,7 +745,7 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
        ASN1_OCTET_STRING *ukm;
        const unsigned char *p;
        unsigned char *dukm = NULL;
-       size_t dukmlen;
+       size_t dukmlen = 0;
        int keylen, plen;
        const EVP_CIPHER *kekcipher;
        EVP_CIPHER_CTX *kekctx;
@@ -852,7 +860,7 @@ static int dh_cms_encrypt(CMS_RecipientInfo *ri)
        ASN1_OCTET_STRING *ukm;
        unsigned char *penc = NULL, *dukm = NULL;
        int penclen;
-       size_t dukmlen;
+       size_t dukmlen = 0;
        int rv = 0;
        int kdf_type, wrap_nid;
        const EVP_MD *kdf_md;