1.\" $OpenBSD: EVP_PKEY_CTX_get_operation.3,v 1.3 2023/09/12 16:15:23 schwarze Exp $ 2.\" 3.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: September 12 2023 $ 18.Dt EVP_PKEY_CTX_GET_OPERATION 3 19.Os 20.Sh NAME 21.Nm EVP_PKEY_CTX_get_operation , 22.Nm EVP_PKEY_CTX_get0_pkey 23.Nd inspect EVP_PKEY_CTX objects 24.Sh SYNOPSIS 25.In openssl/evp.h 26.Ft int 27.Fo EVP_PKEY_CTX_get_operation 28.Fa "EVP_PKEY_CTX *ctx" 29.Fc 30.Ft EVP_PKEY * 31.Fo EVP_PKEY_CTX_get0_pkey 32.Fa "EVP_PKEY_CTX *ctx" 33.Fc 34.Sh DESCRIPTION 35.Fn EVP_PKEY_CTX_get_operation 36finds out which initialization function has been called on 37.Fa ctx , 38if any: 39.Bl -column EVP_PKEY_OP_VERIFYRECO EVP_PKEY_verify_recover_init 40.It return value Ta initialized with Ta e.g. for 41.It Dv EVP_PKEY_OP_DECRYPT Ta Xr EVP_PKEY_decrypt_init 3 Ta RSA, SM2 42.It Dv EVP_PKEY_OP_DERIVE Ta Xr EVP_PKEY_derive_init 3 Ta HKDF 43.It Dv EVP_PKEY_OP_ENCRYPT Ta Xr EVP_PKEY_encrypt_init 3 Ta RSA, SM2 44.It Dv EVP_PKEY_OP_KEYGEN Ta Xr EVP_PKEY_keygen_init 3 Ta almost all 45.It Dv EVP_PKEY_OP_PARAMGEN Ta Xr EVP_PKEY_paramgen_init 3 Ta DH, DSA, EC 46.It Dv EVP_PKEY_OP_SIGN Ta Xr EVP_PKEY_sign_init 3 Ta DSA,EC,RSA,SM2 47.It Dv EVP_PKEY_OP_SIGN Ta Xr EVP_DigestSignInit 3 Ta ED25519 48.It Dv EVP_PKEY_OP_SIGNCTX Ta Xr EVP_DigestSignInit 3 Ta CMAC, HMAC 49.It Dv EVP_PKEY_OP_UNDEFINED Ta not initialized Ta NONE 50.It Dv EVP_PKEY_OP_VERIFY Ta Xr EVP_PKEY_verify_init 3 Ta DSA,EC,RSA,SM2 51.It Dv EVP_PKEY_OP_VERIFY Ta Xr EVP_DigestVerifyInit 3 Ta ED25519 52.It Dv EVP_PKEY_OP_VERIFYCTX Ta Xr EVP_DigestVerifyInit 3 Ta no built-in 53.It Dv EVP_PKEY_OP_VERIFYRECOVER Ta Xr EVP_PKEY_verify_recover_init 3 Ta RSA 54.El 55.Pp 56The rightmost column of the above table shows examples of algorithms 57the return values can occur for. 58For example, if 59.Xr EVP_PKEY_base_id 3 60returns 61.Dv EVP_PKEY_HKDF , 62then calling 63.Fn EVP_PKEY_CTX_get_operation 64on a 65.Vt EVP_PKEY_CTX 66using that key may return 67.Dv EVP_PKEY_OP_DERIVE . 68.Pp 69If the return value is 70.Dv EVP_PKEY_OP_SIGNCTX 71or 72.Dv EVP_PKEY_OP_VERIFYCTX , 73the 74.Fa ctx 75supports 76.Xr EVP_DigestSignUpdate 3 77or 78.Xr EVP_DigestVerifyUpdate 3 , 79respectively. 80If the return value is 81.Dv EVP_PKEY_OP_SIGN 82or 83.Dv EVP_PKEY_OP_VERIFY , 84if does not, and only one-shot signing or verification is supported. 85.Pp 86The return value 87.Dv EVP_PKEY_OP_UNDEFINED 88can for example occur if the 89.Fa ctx 90was freshly returned from 91.Xr EVP_PKEY_CTX_new 3 92or 93.Xr EVP_PKEY_CTX_new_id 3 94and not yet initialized. 95.Pp 96The following masks are defined as the logical OR of two or more of the above 97.Dv EVP_PKEY_OP_* 98bits: 99.Pp 100.Bl -tag -width EVP_PKEY_OP_TYPE_NOGEN -compact 101.It Dv EVP_PKEY_OP_TYPE_CRYPT 102DECRYPT | ENCRYPT 103.It Dv EVP_PKEY_OP_TYPE_GEN 104KEYGEN | PARAMGEN 105.It Dv EVP_PKEY_OP_TYPE_NOGEN 106CRYPT | DERIVE | SIG 107.It Dv EVP_PKEY_OP_TYPE_SIG 108SIGN | SIGNCTX | VERIFY | VERIFYCTX | VERIFYRECOVER 109.El 110.Sh RETURN VALUES 111.Fn EVP_PKEY_CTX_get_operation 112returns one of the single-bit 113.Dv EVP_PKEY_OP_* 114constants or 115.Dv EVP_PKEY_OP_UNDEFINED 116if 117.Fa ctx 118is not initialized. 119.Pp 120.Fn EVP_PKEY_CTX_get0_pkey 121returns an internal pointer to the 122.Vt EVP_PKEY 123object used by 124.Fa ctx , 125without incrementing its reference count. 126.Sh SEE ALSO 127.Xr evp 3 , 128.Xr EVP_PKEY_base_id 3 , 129.Xr EVP_PKEY_CTX_ctrl 3 , 130.Xr EVP_PKEY_CTX_new 3 , 131.Xr EVP_PKEY_new 3 132.Sh HISTORY 133.Fn EVP_PKEY_CTX_get_operation 134and 135.Fn EVP_PKEY_CTX_get0_pkey 136first appeared in OpenSSL 1.0.0 and have been available since 137.Ox 4.9 . 138