2014-07-14 23:28:14 +01:00
|
|
|
/* Originally written by Bodo Moeller for the OpenSSL project.
|
|
|
|
* ====================================================================
|
|
|
|
* Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* 3. All advertising materials mentioning features or use of this
|
|
|
|
* software must display the following acknowledgment:
|
|
|
|
* "This product includes software developed by the OpenSSL Project
|
|
|
|
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
|
|
|
*
|
|
|
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
|
|
|
* endorse or promote products derived from this software without
|
|
|
|
* prior written permission. For written permission, please contact
|
|
|
|
* openssl-core@openssl.org.
|
|
|
|
*
|
|
|
|
* 5. Products derived from this software may not be called "OpenSSL"
|
|
|
|
* nor may "OpenSSL" appear in their names without prior written
|
|
|
|
* permission of the OpenSSL Project.
|
|
|
|
*
|
|
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
|
|
|
* acknowledgment:
|
|
|
|
* "This product includes software developed by the OpenSSL Project
|
|
|
|
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
|
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
|
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
* ====================================================================
|
|
|
|
*
|
|
|
|
* This product includes cryptographic software written by Eric Young
|
|
|
|
* (eay@cryptsoft.com). This product includes software written by Tim
|
|
|
|
* Hudson (tjh@cryptsoft.com).
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/* ====================================================================
|
|
|
|
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
|
|
|
*
|
|
|
|
* Portions of the attached software ("Contribution") are developed by
|
|
|
|
* SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
|
|
|
|
*
|
|
|
|
* The Contribution is licensed pursuant to the OpenSSL open source
|
|
|
|
* license provided above.
|
|
|
|
*
|
|
|
|
* The elliptic curve binary polynomial software is originally written by
|
|
|
|
* Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems
|
|
|
|
* Laboratories. */
|
|
|
|
|
|
|
|
#ifndef OPENSSL_HEADER_EC_KEY_H
|
|
|
|
#define OPENSSL_HEADER_EC_KEY_H
|
|
|
|
|
|
|
|
#include <openssl/base.h>
|
|
|
|
|
|
|
|
#include <openssl/ec.h>
|
|
|
|
#include <openssl/engine.h>
|
|
|
|
#include <openssl/ex_data.h>
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// ec_key.h contains functions that handle elliptic-curve points that are
|
|
|
|
// public/private keys.
|
2014-07-14 23:28:14 +01:00
|
|
|
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC key objects.
|
2018-08-24 20:58:18 +01:00
|
|
|
//
|
|
|
|
// An |EC_KEY| object represents a public or private EC key. A given object may
|
|
|
|
// be used concurrently on multiple threads by non-mutating functions, provided
|
|
|
|
// no other thread is concurrently calling a mutating function. Unless otherwise
|
|
|
|
// documented, functions which take a |const| pointer are non-mutating and
|
|
|
|
// functions which take a non-|const| pointer are mutating.
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_new returns a fresh |EC_KEY| object or NULL on error.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT EC_KEY *EC_KEY_new(void);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_new_method acts the same as |EC_KEY_new|, but takes an explicit
|
|
|
|
// |ENGINE|.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT EC_KEY *EC_KEY_new_method(const ENGINE *engine);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_new_by_curve_name returns a fresh EC_KEY for group specified by |nid|
|
|
|
|
// or NULL on error.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT EC_KEY *EC_KEY_new_by_curve_name(int nid);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_free frees all the data owned by |key| and |key| itself.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT void EC_KEY_free(EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_dup returns a fresh copy of |src| or NULL on error.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT EC_KEY *EC_KEY_dup(const EC_KEY *src);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2018-08-24 20:58:18 +01:00
|
|
|
// EC_KEY_up_ref increases the reference count of |key| and returns one. It does
|
|
|
|
// not mutate |key| for thread-safety purposes and may be used concurrently.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_up_ref(EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_is_opaque returns one if |key| is opaque and doesn't expose its key
|
|
|
|
// material. Otherwise it return zero.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_is_opaque(const EC_KEY *key);
|
2014-07-18 23:39:42 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_get0_group returns a pointer to the |EC_GROUP| object inside |key|.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_set_group sets the |EC_GROUP| object that |key| will use to |group|.
|
2018-08-14 00:02:05 +01:00
|
|
|
// It returns one on success and zero if |key| is already configured with a
|
|
|
|
// different group.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_get0_private_key returns a pointer to the private key inside |key|.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_set_private_key sets the private key of |key| to |priv|. It returns
|
2017-12-16 20:34:00 +00:00
|
|
|
// one on success and zero otherwise. |key| must already have had a group
|
|
|
|
// configured (see |EC_KEY_set_group| and |EC_KEY_new_by_curve_name|).
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_get0_public_key returns a pointer to the public key point inside
|
|
|
|
// |key|.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_set_public_key sets the public key of |key| to |pub|, by copying it.
|
2017-12-16 20:34:00 +00:00
|
|
|
// It returns one on success and zero otherwise. |key| must already have had a
|
|
|
|
// group configured (see |EC_KEY_set_group| and |EC_KEY_new_by_curve_name|), and
|
|
|
|
// |pub| must also belong to that group.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
|
|
|
#define EC_PKEY_NO_PARAMETERS 0x001
|
|
|
|
#define EC_PKEY_NO_PUBKEY 0x002
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_get_enc_flags returns the encoding flags for |key|, which is a
|
|
|
|
// bitwise-OR of |EC_PKEY_*| values.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT unsigned EC_KEY_get_enc_flags(const EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_set_enc_flags sets the encoding flags for |key|, which is a
|
|
|
|
// bitwise-OR of |EC_PKEY_*| values.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT void EC_KEY_set_enc_flags(EC_KEY *key, unsigned flags);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_get_conv_form returns the conversation form that will be used by
|
|
|
|
// |key|.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_set_conv_form sets the conversion form to be used by |key|.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT void EC_KEY_set_conv_form(EC_KEY *key,
|
|
|
|
point_conversion_form_t cform);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_check_key performs several checks on |key| (possibly including an
|
|
|
|
// expensive check that the public key is in the primary subgroup). It returns
|
|
|
|
// one if all checks pass and zero otherwise. If it returns zero then detail
|
|
|
|
// about the problem can be found on the error stack.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_check_key(const EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_check_fips performs a signing pairwise consistency test (FIPS 140-2
|
|
|
|
// 4.9.2). It returns one if it passes and zero otherwise.
|
2017-04-06 19:55:18 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_check_fips(const EC_KEY *key);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_set_public_key_affine_coordinates sets the public key in |key| to
|
|
|
|
// (|x|, |y|). It returns one on success and zero otherwise.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key,
|
|
|
|
BIGNUM *x,
|
|
|
|
BIGNUM *y);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2018-12-19 22:46:14 +00:00
|
|
|
// EC_KEY_key2buf encodes the public key in |key| to an allocated octet string
|
|
|
|
// and sets |*out_buf| to point to it. It returns the length of the encoded
|
|
|
|
// octet string or zero if an error occurred.
|
|
|
|
OPENSSL_EXPORT size_t EC_KEY_key2buf(EC_KEY *key, point_conversion_form_t form,
|
|
|
|
unsigned char **out_buf, BN_CTX *ctx);
|
|
|
|
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// Key generation.
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_generate_key generates a random, private key, calculates the
|
|
|
|
// corresponding public key and stores both in |key|. It returns one on success
|
|
|
|
// or zero otherwise.
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_generate_key(EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_generate_key_fips behaves like |EC_KEY_generate_key| but performs
|
|
|
|
// additional checks for FIPS compliance.
|
2017-05-16 19:35:22 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_generate_key_fips(EC_KEY *key);
|
|
|
|
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// Serialisation.
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_parse_private_key parses a DER-encoded ECPrivateKey structure (RFC
|
|
|
|
// 5915) from |cbs| and advances |cbs|. It returns a newly-allocated |EC_KEY| or
|
|
|
|
// NULL on error. If |group| is non-null, the parameters field of the
|
|
|
|
// ECPrivateKey may be omitted (but must match |group| if present). Otherwise,
|
|
|
|
// the parameters field is required.
|
2016-01-03 08:57:37 +00:00
|
|
|
OPENSSL_EXPORT EC_KEY *EC_KEY_parse_private_key(CBS *cbs,
|
|
|
|
const EC_GROUP *group);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_marshal_private_key marshals |key| as a DER-encoded ECPrivateKey
|
|
|
|
// structure (RFC 5915) and appends the result to |cbb|. It returns one on
|
|
|
|
// success and zero on failure. |enc_flags| is a combination of |EC_PKEY_*|
|
|
|
|
// values and controls whether corresponding fields are omitted.
|
2016-01-03 08:57:37 +00:00
|
|
|
OPENSSL_EXPORT int EC_KEY_marshal_private_key(CBB *cbb, const EC_KEY *key,
|
|
|
|
unsigned enc_flags);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_parse_curve_name parses a DER-encoded OBJECT IDENTIFIER as a curve
|
|
|
|
// name from |cbs| and advances |cbs|. It returns a newly-allocated |EC_GROUP|
|
|
|
|
// or NULL on error.
|
2016-03-25 22:07:15 +00:00
|
|
|
OPENSSL_EXPORT EC_GROUP *EC_KEY_parse_curve_name(CBS *cbs);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_marshal_curve_name marshals |group| as a DER-encoded OBJECT IDENTIFIER
|
|
|
|
// and appends the result to |cbb|. It returns one on success and zero on
|
|
|
|
// failure.
|
2016-03-25 22:07:15 +00:00
|
|
|
OPENSSL_EXPORT int EC_KEY_marshal_curve_name(CBB *cbb, const EC_GROUP *group);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_parse_parameters parses a DER-encoded ECParameters structure (RFC
|
|
|
|
// 5480) from |cbs| and advances |cbs|. It returns a newly-allocated |EC_GROUP|
|
|
|
|
// or NULL on error. It supports the namedCurve and specifiedCurve options, but
|
|
|
|
// use of specifiedCurve is deprecated. Use |EC_KEY_parse_curve_name|
|
|
|
|
// instead.
|
2016-01-03 08:57:37 +00:00
|
|
|
OPENSSL_EXPORT EC_GROUP *EC_KEY_parse_parameters(CBS *cbs);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// ex_data functions.
|
|
|
|
//
|
|
|
|
// These functions are wrappers. See |ex_data.h| for details.
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2014-07-31 00:02:14 +01:00
|
|
|
OPENSSL_EXPORT int EC_KEY_get_ex_new_index(long argl, void *argp,
|
2015-12-05 04:14:35 +00:00
|
|
|
CRYPTO_EX_unused *unused,
|
2017-05-14 22:10:18 +01:00
|
|
|
CRYPTO_EX_dup *dup_unused,
|
2014-07-31 00:02:14 +01:00
|
|
|
CRYPTO_EX_free *free_func);
|
|
|
|
OPENSSL_EXPORT int EC_KEY_set_ex_data(EC_KEY *r, int idx, void *arg);
|
|
|
|
OPENSSL_EXPORT void *EC_KEY_get_ex_data(const EC_KEY *r, int idx);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// ECDSA method.
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// ECDSA_FLAG_OPAQUE specifies that this ECDSA_METHOD does not expose its key
|
|
|
|
// material. This may be set if, for instance, it is wrapping some other crypto
|
|
|
|
// API, like a platform key store.
|
2014-07-18 23:39:42 +01:00
|
|
|
#define ECDSA_FLAG_OPAQUE 1
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// ecdsa_method_st is a structure of function pointers for implementing ECDSA.
|
|
|
|
// See engine.h.
|
2014-07-14 23:28:14 +01:00
|
|
|
struct ecdsa_method_st {
|
|
|
|
struct openssl_method_common_st common;
|
|
|
|
|
|
|
|
void *app_data;
|
|
|
|
|
|
|
|
int (*init)(EC_KEY *key);
|
|
|
|
int (*finish)(EC_KEY *key);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// group_order_size returns the number of bytes needed to represent the order
|
|
|
|
// of the group. This is used to calculate the maximum size of an ECDSA
|
|
|
|
// signature in |ECDSA_size|.
|
2014-07-15 23:15:09 +01:00
|
|
|
size_t (*group_order_size)(const EC_KEY *key);
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// sign matches the arguments and behaviour of |ECDSA_sign|.
|
2014-07-14 23:28:14 +01:00
|
|
|
int (*sign)(const uint8_t *digest, size_t digest_len, uint8_t *sig,
|
|
|
|
unsigned int *sig_len, EC_KEY *eckey);
|
|
|
|
|
2014-07-18 23:39:42 +01:00
|
|
|
int flags;
|
2014-07-14 23:28:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// Deprecated functions.
|
2015-04-13 22:34:17 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// EC_KEY_set_asn1_flag does nothing.
|
2015-04-13 22:34:17 +01:00
|
|
|
OPENSSL_EXPORT void EC_KEY_set_asn1_flag(EC_KEY *key, int flag);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// d2i_ECPrivateKey parses an ASN.1, DER-encoded, private key from |len| bytes
|
|
|
|
// at |*inp|. If |out_key| is not NULL then, on exit, a pointer to the result
|
|
|
|
// is in |*out_key|. Note that, even if |*out_key| is already non-NULL on entry,
|
|
|
|
// it * will not be written to. Rather, a fresh |EC_KEY| is allocated and the
|
|
|
|
// previous * one is freed. On successful exit, |*inp| is advanced past the DER
|
|
|
|
// structure. It returns the result or NULL on error.
|
|
|
|
//
|
|
|
|
// On input, if |*out_key| is non-NULL and has a group configured, the
|
|
|
|
// parameters field may be omitted but must match that group if present.
|
|
|
|
//
|
|
|
|
// Use |EC_KEY_parse_private_key| instead.
|
2016-01-03 08:57:37 +00:00
|
|
|
OPENSSL_EXPORT EC_KEY *d2i_ECPrivateKey(EC_KEY **out_key, const uint8_t **inp,
|
|
|
|
long len);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// i2d_ECPrivateKey marshals an EC private key from |key| to an ASN.1, DER
|
|
|
|
// structure. If |outp| is not NULL then the result is written to |*outp| and
|
|
|
|
// |*outp| is advanced just past the output. It returns the number of bytes in
|
|
|
|
// the result, whether written or not, or a negative value on error.
|
|
|
|
//
|
|
|
|
// Use |EC_KEY_marshal_private_key| instead.
|
2016-01-03 08:57:37 +00:00
|
|
|
OPENSSL_EXPORT int i2d_ECPrivateKey(const EC_KEY *key, uint8_t **outp);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// d2i_ECParameters parses an ASN.1, DER-encoded, set of EC parameters from
|
|
|
|
// |len| bytes at |*inp|. If |out_key| is not NULL then, on exit, a pointer to
|
|
|
|
// the result is in |*out_key|. Note that, even if |*out_key| is already
|
|
|
|
// non-NULL on entry, it will not be written to. Rather, a fresh |EC_KEY| is
|
|
|
|
// allocated and the previous one is freed. On successful exit, |*inp| is
|
|
|
|
// advanced past the DER structure. It returns the result or NULL on error.
|
|
|
|
//
|
|
|
|
// Use |EC_KEY_parse_parameters| or |EC_KEY_parse_curve_name| instead.
|
2016-01-03 08:57:37 +00:00
|
|
|
OPENSSL_EXPORT EC_KEY *d2i_ECParameters(EC_KEY **out_key, const uint8_t **inp,
|
|
|
|
long len);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// i2d_ECParameters marshals EC parameters from |key| to an ASN.1, DER
|
|
|
|
// structure. If |outp| is not NULL then the result is written to |*outp| and
|
|
|
|
// |*outp| is advanced just past the output. It returns the number of bytes in
|
|
|
|
// the result, whether written or not, or a negative value on error.
|
|
|
|
//
|
|
|
|
// Use |EC_KEY_marshal_curve_name| instead.
|
2016-01-03 08:57:37 +00:00
|
|
|
OPENSSL_EXPORT int i2d_ECParameters(const EC_KEY *key, uint8_t **outp);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// o2i_ECPublicKey parses an EC point from |len| bytes at |*inp| into
|
|
|
|
// |*out_key|. Note that this differs from the d2i format in that |*out_key|
|
|
|
|
// must be non-NULL with a group set. On successful exit, |*inp| is advanced by
|
|
|
|
// |len| bytes. It returns |*out_key| or NULL on error.
|
|
|
|
//
|
|
|
|
// Use |EC_POINT_oct2point| instead.
|
2016-01-03 08:57:37 +00:00
|
|
|
OPENSSL_EXPORT EC_KEY *o2i_ECPublicKey(EC_KEY **out_key, const uint8_t **inp,
|
|
|
|
long len);
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// i2o_ECPublicKey marshals an EC point from |key|. If |outp| is not NULL then
|
|
|
|
// the result is written to |*outp| and |*outp| is advanced just past the
|
|
|
|
// output. It returns the number of bytes in the result, whether written or
|
|
|
|
// not, or a negative value on error.
|
|
|
|
//
|
|
|
|
// Use |EC_POINT_point2cbb| instead.
|
2016-01-03 08:57:37 +00:00
|
|
|
OPENSSL_EXPORT int i2o_ECPublicKey(const EC_KEY *key, unsigned char **outp);
|
|
|
|
|
2015-04-13 22:34:17 +01:00
|
|
|
|
2014-07-14 23:28:14 +01:00
|
|
|
#if defined(__cplusplus)
|
2017-08-19 00:21:50 +01:00
|
|
|
} // extern C
|
2016-08-18 04:10:28 +01:00
|
|
|
|
|
|
|
extern "C++" {
|
|
|
|
|
Support symbol prefixes
- In base.h, if BORINGSSL_PREFIX is defined, include
boringssl_prefix_symbols.h
- In all .S files, if BORINGSSL_PREFIX is defined, include
boringssl_prefix_symbols_asm.h
- In base.h, BSSL_NAMESPACE_BEGIN and BSSL_NAMESPACE_END are
defined with appropriate values depending on whether
BORINGSSL_PREFIX is defined; these macros are used in place
of 'namespace bssl {' and '}'
- Add util/make_prefix_headers.go, which takes a list of symbols
and auto-generates the header files mentioned above
- In CMakeLists.txt, if BORINGSSL_PREFIX and BORINGSSL_PREFIX_SYMBOLS
are defined, run util/make_prefix_headers.go to generate header
files
- In various CMakeLists.txt files, add "global_target" that all
targets depend on to give us a place to hook logic that must run
before all other targets (in particular, the header file generation
logic)
- Document this in BUILDING.md, including the fact that it is
the caller's responsibility to provide the symbol list and keep it
up to date
- Note that this scheme has not been tested on Windows, and likely
does not work on it; Windows support will need to be added in a
future commit
Change-Id: If66a7157f46b5b66230ef91e15826b910cf979a2
Reviewed-on: https://boringssl-review.googlesource.com/31364
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-08-27 02:53:36 +01:00
|
|
|
BSSL_NAMESPACE_BEGIN
|
2016-08-18 04:10:28 +01:00
|
|
|
|
|
|
|
BORINGSSL_MAKE_DELETER(EC_KEY, EC_KEY_free)
|
2018-09-14 17:34:17 +01:00
|
|
|
BORINGSSL_MAKE_UP_REF(EC_KEY, EC_KEY_up_ref)
|
2016-08-18 04:10:28 +01:00
|
|
|
|
Support symbol prefixes
- In base.h, if BORINGSSL_PREFIX is defined, include
boringssl_prefix_symbols.h
- In all .S files, if BORINGSSL_PREFIX is defined, include
boringssl_prefix_symbols_asm.h
- In base.h, BSSL_NAMESPACE_BEGIN and BSSL_NAMESPACE_END are
defined with appropriate values depending on whether
BORINGSSL_PREFIX is defined; these macros are used in place
of 'namespace bssl {' and '}'
- Add util/make_prefix_headers.go, which takes a list of symbols
and auto-generates the header files mentioned above
- In CMakeLists.txt, if BORINGSSL_PREFIX and BORINGSSL_PREFIX_SYMBOLS
are defined, run util/make_prefix_headers.go to generate header
files
- In various CMakeLists.txt files, add "global_target" that all
targets depend on to give us a place to hook logic that must run
before all other targets (in particular, the header file generation
logic)
- Document this in BUILDING.md, including the fact that it is
the caller's responsibility to provide the symbol list and keep it
up to date
- Note that this scheme has not been tested on Windows, and likely
does not work on it; Windows support will need to be added in a
future commit
Change-Id: If66a7157f46b5b66230ef91e15826b910cf979a2
Reviewed-on: https://boringssl-review.googlesource.com/31364
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-08-27 02:53:36 +01:00
|
|
|
BSSL_NAMESPACE_END
|
2016-08-18 04:10:28 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
} // extern C++
|
2016-08-18 04:10:28 +01:00
|
|
|
|
2014-07-14 23:28:14 +01:00
|
|
|
#endif
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
#endif // OPENSSL_HEADER_EC_KEY_H
|