Skip to content

Commit

Permalink
Add control to retrieve signature MD.
Browse files Browse the repository at this point in the history
(cherry picked from commit 8106395)
  • Loading branch information
snhenson committed Oct 1, 2013
1 parent eebd5e5 commit d6dc5c5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crypto/dsa/dsa_pmeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions crypto/ec/ec_pmeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions crypto/evp/evp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,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

Expand All @@ -1118,6 +1122,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


Expand Down
4 changes: 4 additions & 0 deletions crypto/rsa/rsa_pmeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,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)
Expand Down
8 changes: 8 additions & 0 deletions engines/ccgost/gost_pmeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d6dc5c5

Please sign in to comment.