c3b5520593ff4e97f02dc1d734509967bbaf17f7
[openssl.git] / crypto / evp / evp_utils.c
1 /*
2  * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 /* Internal EVP utility functions */
11
12 #include <openssl/core.h>
13 #include <openssl/evp.h>
14 #include <openssl/err.h>
15 #include <openssl/asn1.h>        /* evp_locl.h needs it */
16 #include <openssl/safestack.h>   /* evp_locl.h needs it */
17 #include "internal/evp_int.h"    /* evp_locl.h needs it */
18 #include "evp_locl.h"
19
20 int evp_do_ciph_getparams(const EVP_CIPHER *ciph, OSSL_PARAM params[])
21 {
22     if (ciph->prov == NULL)
23         return -2;
24     if (ciph->get_params == NULL)
25         return -1;
26     return ciph->get_params(params);
27 }
28
29 int evp_do_ciph_ctx_getparams(const EVP_CIPHER *ciph, void *provctx,
30                               OSSL_PARAM params[])
31 {
32     if (ciph->prov == NULL)
33         return -2;
34     if (ciph->ctx_get_params == NULL)
35         return -1;
36     return ciph->ctx_get_params(provctx, params);
37 }
38
39 int evp_do_ciph_ctx_setparams(const EVP_CIPHER *ciph, void *provctx,
40                               OSSL_PARAM params[])
41 {
42     if (ciph->prov == NULL)
43         return -2;
44     if (ciph->ctx_set_params == NULL)
45         return -1;
46     return ciph->ctx_set_params(provctx, params);
47 }