Add functions returning security bits.
[openssl.git] / crypto / dsa / dsa_ameth.c
index b38e1a4..aa3f55e 100644 (file)
@@ -307,6 +307,12 @@ static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
        unsigned char *dp = NULL;
        int dplen;
 
+       if (!pkey->pkey.dsa->priv_key)
+               {
+               DSAerr(DSA_F_DSA_PRIV_ENCODE,DSA_R_MISSING_PARAMETERS);
+               goto err;
+               }
+
        params = ASN1_STRING_new();
 
        if (!params)
@@ -362,6 +368,11 @@ static int dsa_bits(const EVP_PKEY *pkey)
        return BN_num_bits(pkey->pkey.dsa->p);
        }
 
+static int dsa_security_bits(const EVP_PKEY *pkey)
+       {
+       return DSA_security_bits(pkey->pkey.dsa);
+       }
+
 static int dsa_missing_parameters(const EVP_PKEY *pkey)
        {
        DSA *dsa;
@@ -547,7 +558,15 @@ static int dsa_sig_print(BIO *bp, const X509_ALGOR *sigalg,
                                        int indent, ASN1_PCTX *pctx)
        {
        DSA_SIG *dsa_sig;
-       const unsigned char *p = sig->data;
+       const unsigned char *p;
+       if (!sig)
+               {
+               if (BIO_puts(bp, "\n") <= 0)
+                       return 0;
+               else
+                       return 1;
+               }
+       p = sig->data;
        dsa_sig = d2i_DSA_SIG(NULL, &p, sig->length);
        if (dsa_sig)
                {
@@ -617,6 +636,10 @@ static int dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
                        X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0);
                        }
                return 1;
+
+               case ASN1_PKEY_CTRL_CMS_RI_TYPE:
+               *(int *)arg2 = CMS_RECIPINFO_NONE;
+               return 1;
 #endif
 
                case ASN1_PKEY_CTRL_DEFAULT_MD_NID:
@@ -678,6 +701,7 @@ const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] =
 
                int_dsa_size,
                dsa_bits,
+               dsa_security_bits,
 
                dsa_param_decode,
                dsa_param_encode,