diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2008-03-19 18:39:51 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2008-03-19 18:39:51 +0000 |
commit | eeb9cdfc945783753c1de319a76608422df878aa (patch) | |
tree | 67642f619f65efa6cf0e093aa2c8f7a11f31a4d9 /apps | |
parent | 16fe5f8b506e92d8d23f76d07baf5bb298edf85a (diff) |
Add support for KEK decrypt in cms utility.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/cms.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/apps/cms.c b/apps/cms.c index 6c5c4eb819..2cbd43b2a6 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -465,7 +465,7 @@ int MAIN(int argc, char **argv) } else if (operation == SMIME_DECRYPT) { - if (!recipfile && !keyfile) + if (!recipfile && !keyfile && !secret_key) { BIO_printf(bio_err, "No recipient certificate or key specified\n"); badarg = 1; @@ -838,7 +838,30 @@ int MAIN(int argc, char **argv) ret = 4; if (operation == SMIME_DECRYPT) { - if (!CMS_decrypt(cms, key, recip, indata, out, flags)) + + if (secret_key) + { + if (!CMS_decrypt_set1_key(cms, + secret_key, secret_keylen, + secret_keyid, secret_keyidlen)) + { + BIO_puts(bio_err, + "Error decrypting CMS using secret key\n"); + goto end; + } + } + + if (key) + { + if (!CMS_decrypt_set1_pkey(cms, key, recip)) + { + BIO_puts(bio_err, + "Error decrypting CMS using private key\n"); + goto end; + } + } + + if (!CMS_decrypt(cms, NULL, NULL, indata, out, flags)) { BIO_printf(bio_err, "Error decrypting CMS structure\n"); goto end; |