Add control to retrieve signature MD.
authorDr. Stephen Henson <steve@openssl.org>
Wed, 19 Jun 2013 17:20:03 +0000 (18:20 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 21 Jun 2013 20:33:00 +0000 (21:33 +0100)
crypto/dsa/dsa_pmeth.c
crypto/ec/ec_pmeth.c
crypto/evp/evp.h
crypto/rsa/rsa_pmeth.c
engines/ccgost/gost_pmeth.c

index 715d8d675bb766994d06d8ee2339bb71246a5a9a..4c7a5a847b3e8350ea4234360b6a5d1509e30dec 100644 (file)
@@ -199,6 +199,10 @@ static int pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
                dctx->md = p2;
                return 1;
 
+               case EVP_PKEY_CTRL_GET_MD:
+               *(const EVP_MD **)p2 = dctx->md;
+               return 1;
+
                case EVP_PKEY_CTRL_DIGESTINIT:
                case EVP_PKEY_CTRL_PKCS7_SIGN:
                case EVP_PKEY_CTRL_CMS_SIGN:
index 63eedca3c7dadc40b81f3e7cb757815626d65f06..4110d5e4f0c867ed8887fbd29bb7bda891fc8145 100644 (file)
@@ -242,6 +242,10 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
                dctx->md = p2;
                return 1;
 
+               case EVP_PKEY_CTRL_GET_MD:
+               *(const EVP_MD **)p2 = dctx->md;
+               return 1;
+
                case EVP_PKEY_CTRL_PEER_KEY:
                /* Default behaviour is OK */
                case EVP_PKEY_CTRL_DIGESTINIT:
index 64d7ed0413c968b081ee5a6e8755345b9b347b6b..619dfd5d699a0a5955cfb055fbdbcfb907797529 100644 (file)
@@ -1113,6 +1113,10 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
                EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \
                                        EVP_PKEY_CTRL_MD, 0, (void *)md)
 
+#define         EVP_PKEY_CTX_get_signature_md(ctx, pmd)        \
+               EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,  \
+                                       EVP_PKEY_CTRL_GET_MD, 0, (void *)pmd)
+
 #define EVP_PKEY_CTRL_MD               1
 #define EVP_PKEY_CTRL_PEER_KEY         2
 
@@ -1134,6 +1138,8 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
 
 #define EVP_PKEY_CTRL_CIPHER           12
 
+#define EVP_PKEY_CTRL_GET_MD           13
+
 #define EVP_PKEY_ALG_CTRL              0x1000
 
 
index 50e0d5c550bd76cb051d3847d9568d8350d1125f..085c73e8985f2318ce4edb251a2be164fc8727ba 100644 (file)
@@ -534,6 +534,10 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
                rctx->md = p2;
                return 1;
 
+               case EVP_PKEY_CTRL_GET_MD:
+               *(const EVP_MD **)p2 = rctx->md;
+               return 1;
+
                case EVP_PKEY_CTRL_RSA_MGF1_MD:
                case EVP_PKEY_CTRL_GET_RSA_MGF1_MD:
                if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING
index f91c9b193908e2aee93af6ffec319195d93a3f5b..3189798cf4b64337760fa248729ea8f98be66e27 100644 (file)
@@ -86,6 +86,10 @@ static int pkey_gost_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
                }
                break;
 
+               case EVP_PKEY_CTRL_GET_MD:
+               *(const EVP_MD **)p2 = pctx->md;
+               return 1;
+
                case EVP_PKEY_CTRL_PKCS7_ENCRYPT:
                case EVP_PKEY_CTRL_PKCS7_DECRYPT:
                case EVP_PKEY_CTRL_PKCS7_SIGN:
@@ -464,6 +468,10 @@ static int pkey_gost_mac_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
                }
                break;
 
+               case EVP_PKEY_CTRL_GET_MD:
+               *(const EVP_MD **)p2 = data->md;
+               return 1;
+
                case EVP_PKEY_CTRL_PKCS7_ENCRYPT:
                case EVP_PKEY_CTRL_PKCS7_DECRYPT:
                case EVP_PKEY_CTRL_PKCS7_SIGN: