English | 简体中文 | 繁體中文
查询

rnp_op_generate_key函数—用法及示例

「 生成密钥 」


(PECL rnp >= 0.1.1)

rnp_op_generate_key — 生成密钥

说明

rnp_op_generate_key(
    RnpFFI $ffi,
    string $userid,
    string $key_alg,
    string $sub_alg = ?,
    array $options = ?
): string|false

参数
ffi
The FFI object returned by rnp_ffi_create.

userid
PGP User ID - text that is intended to represent the name and email address of the key holder.

key_alg
Primary key algorithm (i.e. 'RSA', 'DSA', etc).

sub_alg
Subkey algorithm. If not set, subkey will not be generated.

options
An associative array with options.

KeyData type说明
"bits"integerPrimary key size in bits. Applicable only to RSA, DSA and El-Gamal keys.
"hash"stringHash algorithm used in self signature or subkey binding signature.
"dsa_qbits"integerSet size of a q parameter for DSA key. Note: appropriate default value will be set, depending on key bits. However you may override it if needed.
"curve"stringSet the curve used for ECC key. Note: this is only applicable for ECDSA, ECDH and SM2 keys.
"request_password"booleanEnable requesting password via password provider. This password will be used for key encryption. Password provider callback function should be set in advance by calling rnp_ffi_set_pass_provider(). Note: this setting will be ignored if password was set via"password"
"password"stringSet the password used to encrypt the secret key data.
"expiration"integerSet the key and subkey expiration time in seconds.
"sub_bits"integerSubkey size in bits. Applicable only to RSA, DSA and El-Gamal keys.
"sub_hash"stringHash algorithm used in subkey self signature or subkey binding signature.
"sub_curve"stringSet the curve used for ECC subkey. Note: this is only applicable for ECDSA, ECDH and SM2 keys.
返回值
生成的主键指纹。这个指纹以后可以用来引用签名和加密操作中的密钥。键数据存储在FFI内存上下文中,可以使用rnp_save_keys()或rnp_save_keys_to_path()保存。

补充纠错
上一个函数: rnp_key_revoke()函数
下一个函数: rrd_xport()函数
热门PHP函数
分享链接