VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.4/include/crypto/ec.h@ 103873

Last change on this file since 103873 was 102863, checked in by vboxsync, 10 months ago

openssl-3.1.4: Applied and adjusted our OpenSSL changes to 3.1.3. bugref:10577

File size: 4.4 KB
Line 
1/*
2 * Copyright 2018-2021 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 EC functions for other submodules: not for application use */
11
12#ifndef OSSL_CRYPTO_EC_H
13# define OSSL_CRYPTO_EC_H
14# ifndef RT_WITHOUT_PRAGMA_ONCE /* VBOX */
15# pragma once
16# endif /* VBOX */
17
18# include <openssl/opensslconf.h>
19# include <openssl/evp.h>
20
21int ossl_ec_curve_name2nid(const char *name);
22const char *ossl_ec_curve_nid2nist_int(int nid);
23int ossl_ec_curve_nist2nid_int(const char *name);
24int evp_pkey_ctx_set_ec_param_enc_prov(EVP_PKEY_CTX *ctx, int param_enc);
25
26# ifndef OPENSSL_NO_EC
27# include <openssl/core.h>
28# include <openssl/ec.h>
29# include "crypto/types.h"
30
31/*-
32 * Computes the multiplicative inverse of x in the range
33 * [1,EC_GROUP::order), where EC_GROUP::order is the cardinality of the
34 * subgroup generated by the generator G:
35 *
36 * res := x^(-1) (mod EC_GROUP::order).
37 *
38 * This function expects the following two conditions to hold:
39 * - the EC_GROUP order is prime, and
40 * - x is included in the range [1, EC_GROUP::order).
41 *
42 * This function returns 1 on success, 0 on error.
43 *
44 * If the EC_GROUP order is even, this function explicitly returns 0 as
45 * an error.
46 * In case any of the two conditions stated above is not satisfied,
47 * the correctness of its output is not guaranteed, even if the return
48 * value could still be 1 (as primality testing and a conditional modular
49 * reduction round on the input can be omitted by the underlying
50 * implementations for better SCA properties on regular input values).
51 */
52__owur int ossl_ec_group_do_inverse_ord(const EC_GROUP *group, BIGNUM *res,
53 const BIGNUM *x, BN_CTX *ctx);
54
55/*-
56 * ECDH Key Derivation Function as defined in ANSI X9.63
57 */
58int ossl_ecdh_kdf_X9_63(unsigned char *out, size_t outlen,
59 const unsigned char *Z, size_t Zlen,
60 const unsigned char *sinfo, size_t sinfolen,
61 const EVP_MD *md, OSSL_LIB_CTX *libctx,
62 const char *propq);
63
64int ossl_ec_key_public_check(const EC_KEY *eckey, BN_CTX *ctx);
65int ossl_ec_key_public_check_quick(const EC_KEY *eckey, BN_CTX *ctx);
66int ossl_ec_key_private_check(const EC_KEY *eckey);
67int ossl_ec_key_pairwise_check(const EC_KEY *eckey, BN_CTX *ctx);
68OSSL_LIB_CTX *ossl_ec_key_get_libctx(const EC_KEY *eckey);
69const char *ossl_ec_key_get0_propq(const EC_KEY *eckey);
70void ossl_ec_key_set0_libctx(EC_KEY *key, OSSL_LIB_CTX *libctx);
71
72/* Backend support */
73int ossl_ec_group_todata(const EC_GROUP *group, OSSL_PARAM_BLD *tmpl,
74 OSSL_PARAM params[], OSSL_LIB_CTX *libctx,
75 const char *propq,
76 BN_CTX *bnctx, unsigned char **genbuf);
77int ossl_ec_group_fromdata(EC_KEY *ec, const OSSL_PARAM params[]);
78int ossl_ec_group_set_params(EC_GROUP *group, const OSSL_PARAM params[]);
79int ossl_ec_key_fromdata(EC_KEY *ecx, const OSSL_PARAM params[],
80 int include_private);
81int ossl_ec_key_otherparams_fromdata(EC_KEY *ec, const OSSL_PARAM params[]);
82int ossl_ec_key_is_foreign(const EC_KEY *ec);
83EC_KEY *ossl_ec_key_dup(const EC_KEY *key, int selection);
84int ossl_x509_algor_is_sm2(const X509_ALGOR *palg);
85EC_KEY *ossl_ec_key_param_from_x509_algor(const X509_ALGOR *palg,
86 OSSL_LIB_CTX *libctx,
87 const char *propq);
88EC_KEY *ossl_ec_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf,
89 OSSL_LIB_CTX *libctx, const char *propq);
90
91int ossl_ec_set_ecdh_cofactor_mode(EC_KEY *ec, int mode);
92int ossl_ec_encoding_name2id(const char *name);
93int ossl_ec_encoding_param2id(const OSSL_PARAM *p, int *id);
94int ossl_ec_pt_format_name2id(const char *name);
95int ossl_ec_pt_format_param2id(const OSSL_PARAM *p, int *id);
96char *ossl_ec_pt_format_id2name(int id);
97
98char *ossl_ec_check_group_type_id2name(int flags);
99int ossl_ec_set_check_group_type_from_name(EC_KEY *ec, const char *name);
100
101# endif /* OPENSSL_NO_EC */
102#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette