All Products
Search
Document Center

Mobile Platform as a Service:Key generation methods

Last Updated:Jan 29, 2026

This document describes how to generate RSA, ECC, and SM2 keys.

Prerequisites

You have downloaded and installed the OpenSSL tool (version 1.1.1 or later) from the official OpenSSL website.

Generate an RSA key

  1. Open the OpenSSL tool and run the following command to generate an RSA private key. You can generate a 1024 bit or 2048 bit private key.

    openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048
  2. Generate an RSA public key from the RSA private key.

    openssl rsa -pubout -in private_key.pem -out public_key.pem

Generate an ECC key

  1. Open the OpenSSL tool and run the following command to generate an ECC key pair. You must select the secp256k1 elliptic curve algorithm.

    openssl ecparam -name secp256k1 -genkey -noout -out secp256k1-key.pem
  2. Generate an ECC public key from the secp256k1-key.pem key pair.

    openssl ec -in secp256k1-key.pem -pubout -out ecpubkey.pem

Generate an SM key

  1. Open the OpenSSL tool and run the following command to generate the SM2 private key sm2-key.pem.

    openssl ecparam -name SM2 -genkey -noout -out sm2-key.pem
  2. Generate the SM2 public key sm2pubkey.pem from the sm2-key.pem key pair.

    openssl ec -in sm2-key.pem -pubout -out sm2pubkey.pem