diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2008-03-28 20:43:16 +0100 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2008-03-28 20:43:16 +0100 |
commit | 36309aa2be6c80fcb6500d3c189d1d6bc52e11f3 (patch) | |
tree | e9b4d2c831cb0af64346ceda54a8aac5b467ae58 /apps/cms.c | |
parent | Support for verification of signed receipts. (diff) | |
download | openssl-36309aa2be6c80fcb6500d3c189d1d6bc52e11f3.tar.xz openssl-36309aa2be6c80fcb6500d3c189d1d6bc52e11f3.zip |
Signed receipt generation code.
Diffstat (limited to 'apps/cms.c')
-rw-r--r-- | apps/cms.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/apps/cms.c b/apps/cms.c index ef873eef59..30dd296bc0 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -91,7 +91,7 @@ static CMS_ReceiptRequest *make_receipt_request(STACK *rr_to, int rr_allorfirst, #define SMIME_COMPRESS (12 | SMIME_OP) #define SMIME_ENCRYPTED_DECRYPT (13 | SMIME_IP) #define SMIME_ENCRYPTED_ENCRYPT (14 | SMIME_OP) -#define SMIME_SIGN_RECEIPT (15 | SMIME_OP | SMIME_IP) +#define SMIME_SIGN_RECEIPT (15 | SMIME_IP | SMIME_OP) #define SMIME_VERIFY_RECEIPT (16 | SMIME_IP) int MAIN(int, char **); @@ -159,6 +159,8 @@ int MAIN(int argc, char **argv) operation = SMIME_DECRYPT; else if (!strcmp (*args, "-sign")) operation = SMIME_SIGN; + else if (!strcmp (*args, "-sign_receipt")) + operation = SMIME_SIGN_RECEIPT; else if (!strcmp (*args, "-resign")) operation = SMIME_RESIGN; else if (!strcmp (*args, "-verify")) @@ -541,6 +543,7 @@ int MAIN(int argc, char **argv) keyfile = NULL; need_rand = 1; } + else if (operation == SMIME_DECRYPT) { if (!recipfile && !keyfile && !secret_key) @@ -724,12 +727,22 @@ int MAIN(int argc, char **argv) } } + if (operation == SMIME_SIGN_RECEIPT) + { + if (!(signer = load_cert(bio_err,signerfile,FORMAT_PEM,NULL, + e, "receipt signer certificate file"))) + { + ERR_print_errors(bio_err); + goto end; + } + } + if (operation == SMIME_DECRYPT) { if (!keyfile) keyfile = recipfile; } - else if (operation == SMIME_SIGN) + else if ((operation == SMIME_SIGN) || (operation == SMIME_SIGN_RECEIPT)) { if (!keyfile) keyfile = signerfile; @@ -889,6 +902,21 @@ int MAIN(int argc, char **argv) flags); } + else if (operation == SMIME_SIGN_RECEIPT) + { + CMS_ContentInfo *srcms = NULL; + STACK_OF(CMS_SignerInfo) *sis; + CMS_SignerInfo *si; + sis = CMS_get0_SignerInfos(cms); + if (!sis) + goto end; + si = sk_CMS_SignerInfo_value(sis, 0); + srcms = CMS_sign_receipt(si, signer, key, other, flags); + if (!srcms) + goto end; + CMS_ContentInfo_free(cms); + cms = srcms; + } else if (operation & SMIME_SIGNERS) { int i; |