Home | History | Annotate | Line # | Download | only in smime-certs
      1      1.1       spz #!/bin/sh
      2  1.1.1.3  christos # Copyright 2013-2022 The OpenSSL Project Authors. All Rights Reserved.
      3  1.1.1.2  christos #
      4  1.1.1.4  christos # Licensed under the Apache License 2.0 (the "License").  You may not use
      5  1.1.1.2  christos # this file except in compliance with the License.  You can obtain a copy
      6  1.1.1.2  christos # in the file LICENSE in the source distribution or at
      7  1.1.1.2  christos # https://www.openssl.org/source/license.html
      8  1.1.1.2  christos 
      9      1.1       spz 
     10      1.1       spz # Utility to recreate S/MIME certificates
     11      1.1       spz 
     12      1.1       spz OPENSSL=../../apps/openssl
     13      1.1       spz OPENSSL_CONF=./ca.cnf
     14      1.1       spz export OPENSSL_CONF
     15      1.1       spz 
     16      1.1       spz # Root CA: create certificate directly
     17  1.1.1.4  christos CN="Test S/MIME RSA Root" $OPENSSL req -config ca.cnf -x509 -noenc \
     18  1.1.1.3  christos 	-keyout smroot.pem -out smroot.pem -newkey rsa:2048 -days 36501
     19      1.1       spz 
     20      1.1       spz # EE RSA certificates: create request first
     21  1.1.1.4  christos CN="Test S/MIME EE RSA #1" $OPENSSL req -config ca.cnf -noenc \
     22      1.1       spz 	-keyout smrsa1.pem -out req.pem -newkey rsa:2048
     23      1.1       spz # Sign request: end entity extensions
     24  1.1.1.3  christos $OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     25      1.1       spz 	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa1.pem
     26      1.1       spz 
     27  1.1.1.4  christos CN="Test S/MIME EE RSA #2" $OPENSSL req -config ca.cnf -noenc \
     28      1.1       spz 	-keyout smrsa2.pem -out req.pem -newkey rsa:2048
     29  1.1.1.3  christos $OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     30      1.1       spz 	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa2.pem
     31      1.1       spz 
     32  1.1.1.4  christos CN="Test S/MIME EE RSA #3" $OPENSSL req -config ca.cnf -noenc \
     33      1.1       spz 	-keyout smrsa3.pem -out req.pem -newkey rsa:2048
     34  1.1.1.3  christos $OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     35      1.1       spz 	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smrsa3.pem
     36      1.1       spz 
     37      1.1       spz # Create DSA parameters
     38      1.1       spz 
     39      1.1       spz $OPENSSL dsaparam -out dsap.pem 2048
     40      1.1       spz 
     41  1.1.1.4  christos CN="Test S/MIME EE DSA #1" $OPENSSL req -config ca.cnf -noenc \
     42      1.1       spz 	-keyout smdsa1.pem -out req.pem -newkey dsa:dsap.pem
     43  1.1.1.3  christos $OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     44      1.1       spz 	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdsa1.pem
     45  1.1.1.4  christos CN="Test S/MIME EE DSA #2" $OPENSSL req -config ca.cnf -noenc \
     46      1.1       spz 	-keyout smdsa2.pem -out req.pem -newkey dsa:dsap.pem
     47  1.1.1.3  christos $OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     48      1.1       spz 	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdsa2.pem
     49  1.1.1.4  christos CN="Test S/MIME EE DSA #3" $OPENSSL req -config ca.cnf -noenc \
     50      1.1       spz 	-keyout smdsa3.pem -out req.pem -newkey dsa:dsap.pem
     51  1.1.1.3  christos $OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     52      1.1       spz 	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdsa3.pem
     53      1.1       spz 
     54      1.1       spz # Create EC parameters
     55      1.1       spz 
     56      1.1       spz $OPENSSL ecparam -out ecp.pem -name P-256
     57      1.1       spz $OPENSSL ecparam -out ecp2.pem -name K-283
     58      1.1       spz 
     59  1.1.1.4  christos CN="Test S/MIME EE EC #1" $OPENSSL req -config ca.cnf -noenc \
     60      1.1       spz 	-keyout smec1.pem -out req.pem -newkey ec:ecp.pem
     61  1.1.1.3  christos $OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     62      1.1       spz 	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smec1.pem
     63  1.1.1.4  christos CN="Test S/MIME EE EC #2" $OPENSSL req -config ca.cnf -noenc \
     64      1.1       spz 	-keyout smec2.pem -out req.pem -newkey ec:ecp2.pem
     65  1.1.1.3  christos $OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     66      1.1       spz 	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smec2.pem
     67  1.1.1.4  christos # Do not renew this cert as it is used for legacy data decrypt test
     68  1.1.1.4  christos #CN="Test S/MIME EE EC #3" $OPENSSL req -config ca.cnf -noenc \
     69  1.1.1.4  christos #	-keyout smec3.pem -out req.pem -newkey ec:ecp.pem
     70  1.1.1.4  christos #$OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     71  1.1.1.4  christos #	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smec3.pem
     72      1.1       spz # Create X9.42 DH parameters.
     73  1.1.1.4  christos $OPENSSL genpkey -genparam -algorithm DHX -out dhp.pem
     74      1.1       spz # Generate X9.42 DH key.
     75      1.1       spz $OPENSSL genpkey -paramfile dhp.pem -out smdh.pem
     76      1.1       spz $OPENSSL pkey -pubout -in smdh.pem -out dhpub.pem
     77      1.1       spz # Generate dummy request.
     78  1.1.1.4  christos CN="Test S/MIME EE DH #1" $OPENSSL req -config ca.cnf -noenc \
     79      1.1       spz 	-keyout smtmp.pem -out req.pem -newkey rsa:2048
     80      1.1       spz # Sign request but force public key to DH
     81  1.1.1.3  christos $OPENSSL x509 -req -in req.pem -CA smroot.pem -days 36500 \
     82      1.1       spz 	-force_pubkey dhpub.pem \
     83      1.1       spz 	-extfile ca.cnf -extensions usr_cert -CAcreateserial >>smdh.pem
     84      1.1       spz # Remove temp files.
     85      1.1       spz rm -f req.pem ecp.pem ecp2.pem dsap.pem dhp.pem dhpub.pem smtmp.pem smroot.srl
     86