diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2008-03-14 13:21:48 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2008-03-14 13:21:48 +0000 |
commit | b820455c6e0aa38e7bdf121ec971f72e0eb097d0 (patch) | |
tree | 0f10ad6bfc453e02a18feeb398d99f0aff256433 /apps | |
parent | 5c4436c97759a98794cd84dc37c937fa637aad61 (diff) |
Encrypted Data type processing. Add options to cms utility and run section 7
tests in RFC4134.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/cms.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/apps/cms.c b/apps/cms.c index 9fd0aa0a86..908e05acf0 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -86,6 +86,7 @@ static int smime_cb(int ok, X509_STORE_CTX *ctx); #define SMIME_DIGEST_CREATE (10 | SMIME_OP) #define SMIME_UNCOMPRESS (11 | SMIME_IP) #define SMIME_COMPRESS (12 | SMIME_OP) +#define SMIME_ENCRYPTED_DECRYPT (13 | SMIME_IP) int MAIN(int, char **); @@ -121,6 +122,8 @@ int MAIN(int argc, char **argv) #ifndef OPENSSL_NO_ENGINE char *engine=NULL; #endif + unsigned char *secret_key = NULL; + size_t secret_keylen; X509_VERIFY_PARAM *vpm = NULL; @@ -164,6 +167,8 @@ int MAIN(int argc, char **argv) operation = SMIME_COMPRESS; else if (!strcmp (*args, "-uncompress")) operation = SMIME_UNCOMPRESS; + else if (!strcmp (*args, "-EncrypedData_decrypt")) + operation = SMIME_ENCRYPTED_DECRYPT; #ifndef OPENSSL_NO_DES else if (!strcmp (*args, "-des3")) cipher = EVP_des_ede3_cbc(); @@ -233,6 +238,20 @@ int MAIN(int argc, char **argv) flags |= CMS_NOOLDMIMETYPE; else if (!strcmp (*args, "-crlfeol")) flags |= CMS_CRLFEOL; + else if (!strcmp(*args,"-secretkey")) + { + long ltmp; + if (!args[1]) + goto argerr; + args++; + secret_key = string_to_hex(*args, <mp); + if (!secret_key) + { + BIO_printf(bio_err, "Invalid key %s\n", *args); + goto argerr; + } + secret_keylen = (size_t)ltmp; + } else if (!strcmp(*args,"-rand")) { if (!args[1]) @@ -810,6 +829,12 @@ int MAIN(int argc, char **argv) goto end; } } + else if (operation == SMIME_ENCRYPTED_DECRYPT) + { + if (!CMS_EncryptedData_decrypt(cms, secret_key, secret_keylen, + indata, out, flags)) + goto end; + } else if (operation == SMIME_VERIFY) { if (CMS_verify(cms, other, store, indata, out, flags) > 0) @@ -878,6 +903,8 @@ end: sk_free(sksigners); if (skkeys) sk_free(skkeys); + if (secret_key) + OPENSSL_free(secret_key); X509_STORE_free(store); X509_free(cert); X509_free(recip); |