Skip to content

Instantly share code, notes, and snippets.

@mylamour
Created April 1, 2021 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mylamour/76f23441d962ee5abf8a216cf53fdf2f to your computer and use it in GitHub Desktop.
Save mylamour/76f23441d962ee5abf8a216cf53fdf2f to your computer and use it in GitHub Desktop.
加key
#!/bin/bash
mkdir -p RSAKeypairs SM2Keypairs AESKeypairs SM4Keypairs
for i in $(seq -w 0 40)
do
echo "No. $i"
echo "create 2048/Short RSA KEY"
openssl genrsa -out ./RSAKeypairs/sh_hsm_supplement_rsa_short_private_$i.pem 2048
openssl rsa -in ./RSAKeypairs/sh_hsm_supplement_rsa_short_private_$i.pem -pubout -out ./RSAKeypairs/sh_hsm_supplement_rsa_short_public_$i.pem
echo "Create 4096/Long RSA KEY"
openssl genrsa -out ./RSAKeypairs/sh_hsm_supplement_rsa_long_private_$i.pem 4096
openssl rsa -in ./RSAKeypairs/sh_hsm_supplement_rsa_long_private_$i.pem -pubout -out ./RSAKeypairs/sh_hsm_supplement_rsa_long_public_$i.pem
echo "Create SM2 Key"
# gmssl ecparam -genkey -name sm2p256v1 -text -out ./SM2Keypairs/sh_hsm_supplement_sm2_private_$i.key
# gmssl sm2 -in ./SM2Keypairs/sh_hsm_supplement_sm2_private_$i.key -out ./SM2Keypairs/sh_hsm_supplement_sm2_private_$i.pem
gmssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:sm2p256v1 -out ./SM2Keypairs/sh_hsm_supplement_sm2_private_$i.pem
gmssl sm2 -in ./SM2Keypairs/sh_hsm_supplement_sm2_private_$i.pem -pubout -out ./SM2Keypairs/sh_hsm_supplement_sm2_public_$i.pem
echo "Create AES Key"
openssl enc -aes-256-cbc -k secret -P -md sha256 > ./AESKeypairs/sh_hsm_supplement_aes256_$i.aes
echo "Create SM4 Key"
openssl rand -hex 16 > ./SM4Keypairs/sh_hsm_supplement_sm4_$i.sm4
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment