In BIO_write(), update the write statistics, not the read statistics.
[oweals/openssl.git] / crypto / asn1 / a_sign.c
index 042682a0615b7f086bda5385396bc2306e6b4e30..4dee45fbb83ab3a048ed85fad2f3a426be6fb7ac 100644 (file)
@@ -248,12 +248,12 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
                a->algorithm=OBJ_nid2obj(type->pkey_type);
                if (a->algorithm == NULL)
                        {
-                       ASN1err(ASN1_F_ASN1_SIGN,ASN1_R_UNKNOWN_OBJECT_TYPE);
+                       ASN1err(ASN1_F_ASN1_ITEM_SIGN,ASN1_R_UNKNOWN_OBJECT_TYPE);
                        goto err;
                        }
                if (a->algorithm->length == 0)
                        {
-                       ASN1err(ASN1_F_ASN1_SIGN,ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD);
+                       ASN1err(ASN1_F_ASN1_ITEM_SIGN,ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD);
                        goto err;
                        }
                }
@@ -263,17 +263,22 @@ int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
        if ((buf_in == NULL) || (buf_out == NULL))
                {
                outl=0;
-               ASN1err(ASN1_F_ASN1_SIGN,ERR_R_MALLOC_FAILURE);
+               ASN1err(ASN1_F_ASN1_ITEM_SIGN,ERR_R_MALLOC_FAILURE);
                goto err;
                }
 
-       EVP_SignInit_ex(&ctx,type, NULL);
+       if (!EVP_SignInit_ex(&ctx,type, NULL))
+               {
+               outl=0;
+               ASN1err(ASN1_F_ASN1_ITEM_SIGN,ERR_R_EVP_LIB);
+               goto err;
+               }
        EVP_SignUpdate(&ctx,(unsigned char *)buf_in,inl);
        if (!EVP_SignFinal(&ctx,(unsigned char *)buf_out,
                        (unsigned int *)&outl,pkey))
                {
                outl=0;
-               ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB);
+               ASN1err(ASN1_F_ASN1_ITEM_SIGN,ERR_R_EVP_LIB);
                goto err;
                }
        if (signature->data != NULL) OPENSSL_free(signature->data);