Skip to contentSkip to conversation

unit: Generate encrypted keys in gencerts.sh

PATCH In review Andrew Zaborowski 2 participants 3 messages Aug 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unit: Generate encrypted keys in gencerts.sh

---
 unit/gencerts.sh | 5 +++++
 1 file changed, 5 insertions(+)
unit/gencerts.sh +5 -0
index 790c715..419afa8 100755
@@ -17,6 +17,11 @@ openssl pkcs8 -topk8 -nocrypt -in cert-client-key.pem -out cert-client-key-pkcs8
 openssl req -new -extensions cert_ext -config ./gencerts.cnf -subj '/O=Bar Example Organization/CN=Bar Example Organization/emailAddress=bar(a)mail.example' -key cert-client-key.pem -out cert-client.csr
 openssl x509 -req -extensions cert_ext -extfile ./gencerts.cnf -in cert-client.csr -CA cert-ca.pem -CAkey cert-ca-key.pem -CAcreateserial -sha256 -days 10000 -out cert-client.pem
 openssl verify -CAfile cert-ca.pem cert-client.pem
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8 -passout pass:abc
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc -passout pass:abc
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc -passout pass:abc
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128 -passout pass:abc
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256 -passout pass:abc
 
 echo -e "\n*** Intermediate Certificate ***"
 openssl genrsa -out cert-intca-key.pem
Signature · 1 line
2.11.0
#1 lore raw

Hi Andrew -

Quoted 13 lines · Andrew Zaborowski

---
unit/gencerts.sh | 5 +++++

1 file changed, 5 insertions(+)
unit/gencerts.sh +0 -0
index 790c715..419afa8 100755
@@ -17,6 +17,11 @@ openssl pkcs8 -topk8 -nocrypt -in cert-client-key.pem -out cert-client-key-pkcs8

openssl req -new -extensions cert_ext -config ./gencerts.cnf -subj '/O=Bar Example Organization/CN=Bar Example Organization/emailAddress=bar(a)mail.example' -key cert-client-key.pem -out cert-client.csr openssl x509 -req -extensions cert_ext -extfile ./gencerts.cnf -in cert-client.csr -CA cert-ca.pem -CAkey cert-ca-key.pem -CAcreateserial -sha256 -days 10000 -out cert-client.pem openssl verify -CAfile cert-ca.pem cert-client.pem

unit/gencerts.sh openssl pkcs8 -topk8 -nocrypt -in cert-client-key.pem -out cert-client-key-pkcs8 · line 24

Quoted 5 lines
unit/gencerts.sh +5 -0
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8 -passout pass:abc
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc -passout pass:abc
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc -passout pass:abc
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128 -passout pass:abc
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256 -passout pass:abc

I was looking at cert generation yesterday, and found that the above commands did not work with openssl 1.1. I believe these work with both 1.0 and 1.1:

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8 -v1 PBE-MD5-DES -passout pass:abc openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc -v2prf hmacWithSHA1 -passout pass:abc openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc -v2prf hmacWithSHA1 -passout pass:abc openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128 -v2prf hmacWithSHA1 -passout pass:abc openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256 -v2prf hmacWithSHA1 -passout pass:abc

I had to add "-v2prf hmacWithSHA1" to get the unit tests to pass when the certs are created with openssl 1.1. The default changed from hmacWithSHA1 in 1.0 to hmacWithSHA256 in 1.1. Would you expect the tests to pass either way?

Regards,

--
Mat Martineau
Intel OTC

#2 lore raw

Hi Mat,

Quoted 36 lines · Mat Martineau
Quoted 20 lines · Andrew Zaborowski

---
unit/gencerts.sh | 5 +++++

1 file changed, 5 insertions(+)
unit/gencerts.sh +0 -1
index 790c715..419afa8 100755
@@ -17,6 +17,11 @@ openssl pkcs8 -topk8 -nocrypt -in cert-client-key.pem
-out cert-client-key-pkcs8

openssl req -new -extensions cert_ext -config ./gencerts.cnf -subj '/O=Bar Example Organization/CN=Bar Example Organization/emailAddress=bar(a)mail.example' -key cert-client-key.pem -out cert-client.csr
openssl x509 -req -extensions cert_ext -extfile ./gencerts.cnf -in cert-client.csr -CA cert-ca.pem -CAkey cert-ca-key.pem -CAcreateserial -sha256 -days 10000 -out cert-client.pem
openssl verify -CAfile cert-ca.pem cert-client.pem
+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8 -passout pass:abc

Quoted 9 lines

+openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc -passout pass:abc +openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc -passout pass:abc +openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128 -passout pass:abc +openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256 -passout pass:abc

I was looking at cert generation yesterday, and found that the above commands did not work with openssl 1.1. I believe these work with both 1.0 and 1.1:

Quoted 13 lines

openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-md5-des.pem -topk8 -v1 PBE-MD5-DES -passout pass:abc
openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des.pem -topk8 -v2 des-cbc -v2prf hmacWithSHA1 -passout pass:abc
openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-des-ede3.pem -topk8 -v2 des-ede3-cbc -v2prf hmacWithSHA1 -passout pass:abc
openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes128.pem -topk8 -v2 aes128 -v2prf hmacWithSHA1 -passout pass:abc
openssl pkcs8 -in cert-client-key-pkcs8.pem -out cert-client-key-v2-aes256.pem -topk8 -v2 aes256 -v2prf hmacWithSHA1 -passout pass:abc

Thanks for checking, I'll use those then. They do work on my standard ubuntu install.

Quoted 4 lines

I had to add "-v2prf hmacWithSHA1" to get the unit tests to pass when the certs are created with openssl 1.1. The default changed from hmacWithSHA1 in 1.0 to hmacWithSHA256 in 1.1. Would you expect the tests to pass either way?

Yep, both should work, I'm going to try debug this.

Best regards