1

To generate self signed certificate for AES128-SHA256 cipher using openssl, following commands are used.

AES128-SHA256 cipher commands :-

 openssl genrsa -aes128 -out 1.key 2048 
 openssl req -config csr.conf-new -key 1.key -out 1.csr 
 cp -f 1.key orig.1.key 
 openssl rsa -in orig.1.key -out 1.key 
 openssl x509 -req -sha256 -in 1.csr -signkey 1.key -out 1.crt 
 openssl x509 -inform PEM -in 1.crt -outform DER -out rsacert.der

Can anyone help to know parameters to generate self signed certificate for AES128-GCM-SHA256 cipher suite certificate which I can test using openssl s_server and s_client?

  • Yup, on my openssl 1.0.2g the AES ciphers offered are -aes128, -aes192, -aes256 encrypt PEM output with cbc aes only seem to offer CBC mode. Unless there are magic hidden commands in the openssl command-line wrapper, my guess is that you'll need to write some c code against openssl's c library (libssl). – Mike Ounsworth Jul 6 '17 at 1:10
  • Do you mean the cipher used to encrypt the privatekey file, or the TLS ciphersuite used for communication between client and server? The former does not use SHA256 ever and does not support GCM at all. The latter uses exactly the same (RSA) key&cert for all ciphersuites whose keyexchange includes RSA regardless of what the symmetric cipher and MAC are. Incidentally, if you want the privatekey unencrypted, it's a silly waste to encrypt and then decrypt; generate it unencrypted to start with. Plus you can generate key AND selfsigned cert in one step see stackoverflow.com/q/10175812 – dave_thompson_085 Jul 6 '17 at 5:35
  • @Mike Ounsworth Thanks for your comments. Yes command line result gives "openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:4096 | openssl enc -aes-128-gcm -in - -out encrypted.ca.pem AEAD ciphers not supported by the enc utility". I am just beginner to security world also writing some c code is out of scope now as working hours time is under clients control. – Sachin Jul 6 '17 at 16:44
  • I have tried selecting same RSA key for different cipher while starting server as below $ openssl s_server -key 1.key -cert 1.crt -accept 1440 -www -cipher AES128-SHA256 with s_client pointing to same certificate. It works. when you keep same RSA certificate and change cipher to "-cipher AES128-GCM-SHA256" then s_client doesn't work for this cipher. which is expected. Mainly I am trying to understand algorithm flow for each cipher. – Sachin Jul 6 '17 at 16:52
1

AES128-GCM-SHA256 and AES128-SHA256 both use RSA certificates for authentication and key exchange. They only differ in the symmetric cipher and MAC used - which are independent of the certificate. This means that you can use the same RSA certificate with both ciphers, i.e. there are no changes needed in certificate creation specific to AES128-GCM-SHA256 compared to AES128-SHA256.

Note also, that the algorithm you have specified to protect the private key (i.e. genrsa -aes128) has nothing to do with the cipher used in the TLS connection. Similar the signature algorithm you have specified for the certificate (x509 req -sha256) has nothing to do with the cipher used. The meaning of AES128 and SHA256 in AES128-SHA256 is instead that AES128 is used as the symmetric algorithm to encrypt the traffic (not the private key) while SHA256 is used as MAC for integrity checks on the traffic (and not as signature algorithm on the certificate).

  • same certificate can't be used to test both ciphers. I am testing individual ciphers like below command. "$ openssl s_server -key 1.key -cert 1.crt -accept 1440 -www -cipher AES128-SHA256" then above step generated certificate works. But when I have tried "$ openssl s_server -key 1.key -cert 1.crt -accept 1440 -www -cipher AES128-GCM-SHA256" with above certificate then it doesn't work. my main motivation is I wanted to test my algorithm works for each cipher. same certificate is pointed in s_client as well. – Sachin Jul 6 '17 at 16:00
  • @Sachin: what exactly "does not work". Please provide the detailed error messages. Also, make sure client and server side support TLS 1.2 since GCM ciphers are only support since TLS 1.2. – Steffen Ullrich Jul 6 '17 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.