Advertisement
gareins

openssl cms usage

Mar 4th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. operation = 83
  2. signerfile = "**.cert"
  3.  
  4. sksigners = sk_OPENSSL_STRING_new_null()
  5. sk_OPENSSL_STRING_push(sksigners, signerfile)
  6.  
  7. keyfile = signerfile
  8. skkeys = sk_OPENSSL_STRING_new_null()
  9. sk_OPENSSL_STRING_push(skkeys, keyfile)
  10.  
  11. // again
  12. in = bio_open_default("infile", 'r', 32775)
  13. out = bio_open_default("outfile", 'w', 4)
  14.  
  15. cms = CMS_sign(NULL, NULL, NULL, in, 16384)
  16.  
  17. signerfile = sk_OPENSSL_STRING_value(sksigners, 0);
  18. keyfile = sk_OPENSSL_STRING_value(skkeys, 0);
  19.  
  20. signer = load_cert(signerfile, FORMAT_PEM, "signer certificate")
  21. key = load_key(keyfile, keyform, 0, passin, e, "signing key file")
  22.  
  23. si = CMS_add1_signer(cms, signer, key, 0, 16384)
  24.  
  25. CMS_final(cms, in, NULL, flags)
  26.  
  27. i2d_CMS_bio_stream(out, cms, in, 16384)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement