smimeasym ~issue2_use_default_cc_and_ar
A wrapper around openssl's S/MIME asymmetrical encryption, that is compatible with the openssl cli
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
smimeasym S/MIME asymmetrical encryption
So the problem to solve is that I needed a function that encrypts an array of ubytes with multiple public keys. The resulting, encrypted, array of bytes, when saved to a file, should be decrypted-able by any private key matching any of the used public key. This should be possible with the openssl cli.
Usage
Key pair suitable
openssl req -x509 -newkey rsa:4096 -days 3650 -nodes -subj "/C=US/ST=*/L=*/O=*/OU=*/CN=Frank/" -keyout frank.key -out frank.pub
There are two main functions
ubyte[] smimeEncryption(ubyte[] buf, string[] publicKeyFilenames);
ubyte[] smimeDecryption(ubyte[] buf, string privateKeyFilename);
X509* loadCert(string filename);
X509* loadCertFromString(string theCert);
void freeCert(X509* certToFree);
ubyte[] smimeEncryptionWithCerts(ubyte[] buf, X509*[] certs);
EVP_PKEY* loadKeyFromString(string data, string password = "");
ubyte[] smimeDecryptionWithKey(ubyte[] buf, EVP_PKEY* key);
The opencli should be able to decrypt created files from the data from smimeEncryption with the following shell command
openssl smime -decrypt -in secrets.txt.enc -inform PEM -inkey bob.key
Tests
The password for the private key frankwithpass.key is foobar.
- Registered by Robert Schadek
- ~issue2_use_default_cc_and_ar released 2 years ago
- symmetryinvestments/smimeasym
- AGPL3
- Copyright © 2021, Symmetry Investments
- Authors:
- Dependencies:
- none
- Versions:
-
3.3.0 2022-Feb-04 3.2.0 2021-May-21 3.1.0 2021-May-21 3.0.0 2021-May-18 2.0.4 2021-May-13 - Download Stats:
-
-
3 downloads today
-
27 downloads this week
-
145 downloads this month
-
6981 downloads total
-
- Score:
- 2.8
- Short URL:
- smimeasym.dub.pm