Mac OS X x86 assembler support.
[openssl.git] / crypto / evp / p_sign.c
index 1fa32ac..8df6d48 100644 (file)
@@ -65,7 +65,7 @@
 #ifdef undef
 void EVP_SignInit(EVP_MD_CTX *ctx, EVP_MD *type)
        {
-       EVP_DigestInit(ctx,type);
+       EVP_DigestInit_ex(ctx,type);
        }
 
 void EVP_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data,
@@ -84,8 +84,32 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
        MS_STATIC EVP_MD_CTX tmp_ctx;
 
        *siglen=0;
-       EVP_MD_CTX_copy(&tmp_ctx,ctx);   
-       EVP_DigestFinal(&tmp_ctx,&(m[0]),&m_len);
+       EVP_MD_CTX_init(&tmp_ctx);
+       EVP_MD_CTX_copy_ex(&tmp_ctx,ctx);   
+       EVP_DigestFinal_ex(&tmp_ctx,&(m[0]),&m_len);
+       EVP_MD_CTX_cleanup(&tmp_ctx);
+
+       if (ctx->digest->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE)
+               {
+               EVP_PKEY_CTX *pkctx = NULL;
+               size_t sltmp = (size_t)EVP_PKEY_size(pkey);
+               i = 0;
+               pkctx = EVP_PKEY_CTX_new(pkey, NULL);
+               if (!pkctx)
+                       goto err;
+               if (EVP_PKEY_sign_init(pkctx) <= 0)
+                       goto err;
+               if (EVP_PKEY_CTX_set_signature_md(pkctx, ctx->digest) <= 0)
+                       goto err;
+               if (EVP_PKEY_sign(pkctx, sigret, &sltmp, m, m_len) <= 0)
+                       goto err;
+               *siglen = sltmp;
+               i = 1;
+               err:
+               EVP_PKEY_CTX_free(pkctx);
+               return i;
+               }
+
        for (i=0; i<4; i++)
                {
                v=ctx->digest->required_pkey_type[i];
@@ -101,6 +125,7 @@ int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen,
                EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE);
                return(0);
                }
+
        if (ctx->digest->sign == NULL)
                {
                EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_NO_SIGN_FUNCTION_CONFIGURED);