Hello again:
I am re-posting this message with additional information.. While I have no expectation that there will be any reply, I am hopeful there may be. In any case, I have been struggling with this, and cannot get it to work with EC certificates. I am now wondering if this is a bug or a, currently, unsupported function in Libressl.. $ openssl version LibreSSL 3.3.2 > Hello > > > I recently decided to change from RSA to EC keys/certs. > I do this primarily as a learning exercise (there is no real corporate > or > professional demand to have this working). > I am running OpenBSD current (6.9) from about 1 month ago. > > Now that I am migrating to EC keys/certificates, I need to switch to > "openssl cms". It is my understanding that openssl smime only supports RSA certs, but openssl cms should support RSA and EC certificates. > > However, I am unable to encrypt using the EC certificate. > > When I use: > (I am going to obfuscate the emails in plain text.) > > cat text.in | /usr/bin/openssl cms -encrypt -from 'User > <u...@example.com>' -to 'Admin <ad...@example.com>' -subject "Test > Email" > -aes256 encryption.pem > encrypted.out > > with the old RSA certificate, everything works as expected. > > But, when I replace the RSA cert with the EC certificate, it does not. > Instead, I see: > > 15724089243112:error:2EFFF06F:CMS routines:CRYPTO_internal:ctrl > failure:/usr/src/lib/libcrypto/cms/cms_env.c:124: > 15724089243112:error:2EFFF074:CMS routines:CRYPTO_internal:error > setting > recipientinfo:/usr/src/lib/libcrypto/cms/cms_env.c:944: > 15724089243112:error:2EFFF068:CMS routines:CRYPTO_internal:cms > lib:/usr/src/lib/libcrypto/cms/cms_smime.c:850: > > And the output file is zero size. > > I tried a more basic command: > > openssl cms -encrypt -in text.in -out encrypted.out -recip > encryption.pem > > Works with RSA certificate, same error with EC certificate. > > I also tried (not really understanding): > > openssl cms -encrypt -in text.in -out encrypted.out -recip > encryption.pem > -keyopt ecdh_kdf_md:sha256 > > and got the same error. > > I then created some very basic self-signed EC certs. > ... > > The second with the CN as the email, but no email in the DN: > > Certificate: > Data: > Version: 1 (0x0) > Serial Number: > e5:fd:15:21:f1:b2:71:de > Signature Algorithm: ecdsa-with-SHA384 > Issuer: C=US, ST=State, L=City, O=Org, OU=Home, > CN=ad...@example.com > Validity > Not Before: May 6 17:18:43 2021 GMT > Not After : May 6 17:18:43 2022 GMT > Subject: C=US, ST=State, L=City, O=Org, OU=Home, > CN=ad...@example.com > Subject Public Key Info: > Public Key Algorithm: id-ecPublicKey > Public-Key: (384 bit) > pub: > 04:8e:11:20:73:c8:8d:5d:61:43:c4:6b:bf:04:fe: > c6:5d:a8:22:79:ae:0a:eb:de:0b:67:e6:32:24:43: > 30:56:61:0a:e6:31:e4:82:cc:a8:9c:37:e9:90:01: > df:e7:90:79:dc:d5:f1:c6:0c:6e:2f:bd:51:f8:98: > 4e:4b:1b:16:52:73:73:d6:fd:1f:00:a1:f6:39:03: > 98:3e:64:43:77:c3:c5:95:61:c3:22:05:3c:e6:d2: > 86:29:e1:a3:9c:b9:32 > ASN1 OID: secp384r1 > NIST CURVE: P-384 > Signature Algorithm: ecdsa-with-SHA384 > 30:64:02:30:3f:06:2c:b1:e1:2f:b1:0b:1e:a1:1a:eb:29:1e: > 8c:e5:c4:6a:73:f5:43:4e:24:77:88:bf:b1:99:51:15:02:50: > 12:cd:50:ae:d1:7f:4f:e5:3b:ba:38:06:c4:26:ea:4b:02:30: > 66:9d:a4:38:7e:45:ed:7d:db:7c:3e:f9:f7:68:80:e0:13:79: > 8b:85:9c:5d:b6:29:91:73:59:04:6a:73:8e:bb:bb:15:49:cc: > 68:63:25:b9:c6:fe:30:40:39:65:97:57 > > Both using the same EC secp384r1 key. > > When I try to do the most (I think) basic openssl cms -encrypt, I get > the > same error. > > openssl cms -encrypt -in in.txt -out encrypt.out test.pem > openssl cms -encrypt -in in.txt -out encrypt.out -recip test.pem > openssl cms -encrypt -in in.txt -out encrypt.out -recip test.pem - > keyopt > ecdh_kdf_md:sha256 > > with either of the certificates (email in DN or not), they all produce: > > 11034533897704:error:2EFFF06F:CMS routines:CRYPTO_internal:ctrl > failure:/usr/src/lib/libcrypto/cms/cms_env.c:124: > 11034533897704:error:2EFFF074:CMS routines:CRYPTO_internal:error > setting > recipientinfo:/usr/src/lib/libcrypto/cms/cms_env.c:944: > 11034533897704:error:2EFFF068:CMS routines:CRYPTO_internal:cms > lib:/usr/src/lib/libcrypto/cms/cms_smime.c:850: However, if I do the same thing (create a basic, self signed RSA certificate): Certificate: Data: Version: 1 (0x0) Serial Number: df:31:84:a5:79:b6:d4:7a Signature Algorithm: sha384WithRSAEncryption Issuer: C=US, ST=State, L=City, O=Org, OU=Home, CN=ad...@example.com Validity Not Before: May 8 13:18:17 2021 GMT Not After : May 8 13:18:17 2022 GMT Subject: C=US, ST=State, L=City, O=Org, OU=Home, CN=ad...@example.com Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public-Key: (4096 bit) Modulus: 00:b0:d7:22:59:62:e8:b0:f9:d8:e7:48:ee:12:dc: da:16:8c:c4:a5:2d:74:86:08:2f:b0:58:fd:80:8b: 0d:d1:58:5a:9d:27:07:82:e5:cd:7b:c6:22:96:92: 86:46:bd:a4:3f:50:79:28:16:e3:20:f4:af:b7:da: 31:e3:54:fe:97:fa:e9:b4:fd:9b:fa:40:d2:64:37: 7c:4e:48:6a:61:2d:99:c2:f8:6a:c8:b0:47:26:9d: 91:9e:61:cf:34:16:51:d8:5b:1e:f0:40:b7:b7:87: ae:4c:65:fc:9e:5b:f2:2e:db:30:ef:83:e9:9e:f0: 39:bd:aa:f4:78:ec:36:af:38:e7:8b:05:6f:91:5d: 4f:3d:02:ea:1d:0a:c6:fb:a3:2a:70:e7:12:35:c4: 08:16:40:17:43:81:03:df:1b:c3:af:1b:73:6a:0c: 61:f5:5c:f0:64:c9:83:a4:41:63:0f:28:a0:8d:4d: d0:db:09:25:54:eb:56:58:16:71:18:da:1a:5a:42: 64:be:46:2d:52:68:6a:50:05:a2:72:1c:55:4d:b7: e3:27:7a:96:f4:c5:b5:29:e1:a7:ca:7d:f5:92:fb: 3e:6e:15:38:30:4f:4a:68:cb:9b:73:07:82:7a:64: 14:9c:67:a6:a5:92:b5:91:e2:f1:e9:63:7c:f5:1b: 01:48:99:54:09:42:9d:d2:05:68:00:6e:63:1e:c0: 68:61:a6:36:c5:d2:14:f1:39:8e:e4:e0:b8:6e:c5: c5:5a:9a:3a:da:52:13:0c:b5:8c:1b:c4:48:0b:a8: 59:db:cb:bb:4b:89:00:fb:6f:e9:65:77:89:a7:c4: 3d:a2:9e:e8:9a:67:26:d2:2d:da:d9:e3:9c:2d:97: 2c:59:8d:85:e1:b4:ba:07:ab:e1:34:fc:62:8f:4b: 1c:02:e3:9e:1d:27:83:da:8d:f1:a4:56:15:14:ba: 28:d6:54:58:47:33:11:93:c9:a2:bb:83:a0:3d:8e: a6:c4:f8:70:72:7a:4d:31:7e:1b:fd:a1:a2:1e:c4: c1:79:88:c6:33:48:50:e0:85:0f:57:f3:81:71:ed: 1b:32:79:63:14:ff:51:1c:88:c1:d7:e9:76:25:93: 94:d3:06:54:c0:29:c7:d0:c1:15:55:40:8d:0c:01: 2d:88:82:47:0d:52:eb:13:d3:48:69:bc:bf:d5:eb: e1:dd:43:36:31:2e:6f:ce:0f:ad:90:0a:c3:81:c2: 5f:94:b3:ed:58:d3:80:44:37:d4:c5:86:ea:b7:cc: 8b:b4:b3:a0:f5:e8:7d:9f:7c:b1:cd:c0:04:c8:41: 41:e3:5c:8b:60:2f:5f:ba:00:6c:06:cc:7f:b7:e3: fc:c6:77 Exponent: 65537 (0x10001) Signature Algorithm: sha384WithRSAEncryption 92:26:cb:0d:8c:e9:37:f9:dc:ee:8d:5d:80:cd:db:bd:2a:5c: a0:eb:88:2f:f6:b0:94:ff:fe:8d:40:25:9d:6d:49:45:13:92: 58:32:8d:bd:ae:15:e9:91:af:ff:3c:37:f3:bd:45:17:90:4d: 30:90:20:2a:d5:6d:32:d9:36:8a:cd:99:3f:c7:8d:ce:a7:eb: 8c:5e:39:29:94:e3:df:70:45:f6:91:a1:1c:ed:19:48:a8:66: f3:74:d1:82:39:0f:bd:1c:d4:0c:13:5c:56:6f:4c:37:ca:21: 60:65:2d:2b:23:45:0e:44:c3:46:88:fd:b8:37:68:72:c2:58: d4:d5:9d:ab:f9:b5:dd:6d:95:56:a7:a3:1b:e6:df:7d:02:4a: 7b:a0:7b:d9:9e:43:ae:a5:f9:1f:55:0e:b3:3b:2b:56:2b:18: b0:00:7f:fb:a6:1e:ba:f6:f7:69:83:db:f6:14:41:4c:e4:c8: 4f:c9:f5:17:a9:d2:5a:22:ff:b6:71:ee:62:5a:d1:1d:27:b4: 91:4f:4a:2e:e5:b2:8f:4b:bc:20:cb:37:a5:6c:ba:1f:76:6d: 16:a4:b9:7b:a5:0e:6b:47:66:f7:ad:55:e8:5a:13:6c:e7:df: 66:0c:4d:6c:89:b4:d6:b4:3f:4e:57:4b:e0:06:34:e9:75:37: 1d:d5:68:9d:3d:6b:b0:23:a2:2b:1c:3e:9f:b0:6f:17:5a:36: 79:cc:b7:b6:26:54:c2:4f:71:57:3e:88:a6:20:3f:a2:49:f0: 25:e8:03:8f:9f:ed:bd:62:0f:65:44:11:97:7a:7a:a9:cc:d4: e1:8a:aa:f2:65:47:9c:e9:de:41:fe:81:8b:73:0f:be:52:e5: 83:71:47:c6:c1:24:10:5d:be:c7:a4:fe:78:0e:3f:09:d8:7b: f2:b6:83:10:49:d3:1c:b8:9a:26:9d:82:0a:24:62:64:06:5c: 31:a5:de:69:ba:8b:39:4f:b6:d7:58:6b:6e:14:64:43:3b:81: e2:a8:5c:d2:e3:04:fb:28:04:d4:f1:ee:13:76:8f:fd:fa:4b: 14:18:70:29:4d:98:eb:1b:e2:87:45:84:24:f4:03:c6:a9:cc: 1d:b9:86:6c:36:70:6a:cb:6d:50:6c:d8:1c:39:ff:72:bf:f9: ab:ba:17:f3:7c:e5:16:9f:e3:35:31:61:76:89:b4:30:21:60: e0:10:59:04:08:21:7d:78:06:dd:c7:97:8c:88:e5:f5:78:d3: 0d:8a:56:71:8f:4d:df:30:c9:ef:cc:58:c1:d7:8b:ca:33:55: 42:69:f3:14:29:59:40:f5:fa:68:dc:06:c7:be:0e:45:34:ba: b3:95:66:9d:00:24:31:5c and then use the RSA cert: openssl cms -encrypt -in in.txt -out encrypt.out test.rsa.pem the data is encrypted without errors. > I am not sure what this error means, or how to address it. > > Any suggestions would be great. > > Thanks > > Ted