Generate a key or key pair. Opcode: 2 (0x0002)


key_nameStringName of the key to generate
attributesKeyAttributesThe attributes of the new key
  • The key_type field of attributes can not be an asymmetric public key.


No values are returned by this operation.

Specific response status codes

  • PsaErrorAlreadyExists: There is already a key with the given name.
  • PsaErrorNotSupported: The key type or key size is not supported.
  • PsaErrorInvalidArgument: The key attributes, as a whole, are invalid.


The key is generated randomly. Its location, policy, type and size are taken from attributes.

The following type-specific considerations apply:

  • For RSA keys (key type is RsaKeyPair), the public exponent is 65537. The modulus is a product of two probabilistic primes between 2^{n-1} and 2^n where n is the bit size specified in the attributes.



Copyright 2019 Contributors to the Parsec project.