File: ec_genpkey_parameters.sh

package info (click to toggle)
tpm2-openssl 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,172 kB
  • sloc: ansic: 6,075; sh: 5,400; makefile: 152
file content (20 lines) | stat: -rwxr-xr-x 613 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
set -eufx

# create EC PARAMETERS file
openssl ecparam -name prime256v1 -out testparam.pem

# generate private key as PEM
openssl genpkey -provider tpm2 -provider base -paramfile testparam.pem -out testkey.pem

# display private key info
openssl ec -provider tpm2 -provider base -in testkey.pem -check -text -noout

# read PEM and export public key as PEM
openssl pkey -provider tpm2 -provider base -in testkey.pem -pubout -out pubkey.pem

# display public key info
openssl ec -pubin -in pubkey.pem -text -noout

rm testparam.pem testkey.pem pubkey.pem