Bitcoin Core  22.99.0
P2P Digital Currency
lax_der_privatekey_parsing.h
Go to the documentation of this file.
1 /***********************************************************************
2  * Copyright (c) 2014, 2015 Pieter Wuille *
3  * Distributed under the MIT software license, see the accompanying *
4  * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
5  ***********************************************************************/
6 
7 /****
8  * Please do not link this file directly. It is not part of the libsecp256k1
9  * project and does not promise any stability in its API, functionality or
10  * presence. Projects which use this code should instead copy this header
11  * and its accompanying .c file directly into their codebase.
12  ****/
13 
14 /* This file contains code snippets that parse DER private keys with
15  * various errors and violations. This is not a part of the library
16  * itself, because the allowed violations are chosen arbitrarily and
17  * do not follow or establish any standard.
18  *
19  * It also contains code to serialize private keys in a compatible
20  * manner.
21  *
22  * These functions are meant for compatibility with applications
23  * that require BER encoded keys. When working with secp256k1-specific
24  * code, the simple 32-byte private keys normally used by the
25  * library are sufficient.
26  */
27 
28 #ifndef SECP256K1_CONTRIB_BER_PRIVATEKEY_H
29 #define SECP256K1_CONTRIB_BER_PRIVATEKEY_H
30 
31 /* #include secp256k1.h only when it hasn't been included yet.
32  This enables this file to be #included directly in other project
33  files (such as tests.c) without the need to set an explicit -I flag,
34  which would be necessary to locate secp256k1.h. */
35 #ifndef SECP256K1_H
36 #include <secp256k1.h>
37 #endif
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
64  const secp256k1_context* ctx,
65  unsigned char *privkey,
66  size_t *privkeylen,
67  const unsigned char *seckey,
68  int compressed
70 
86  const secp256k1_context* ctx,
87  unsigned char *seckey,
88  const unsigned char *privkey,
89  size_t privkeylen
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif /* SECP256K1_CONTRIB_BER_PRIVATEKEY_H */
secp256k1_context_struct
Definition: secp256k1.c:75
ec_privkey_import_der
SECP256K1_WARN_UNUSED_RESULT int ec_privkey_import_der(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *privkey, size_t privkeylen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Import a private key in DER format.
Definition: lax_der_privatekey_parsing.c:11
secp256k1.h
ec_privkey_export_der
SECP256K1_WARN_UNUSED_RESULT int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *seckey, int compressed) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Export a private key in DER format.
Definition: lax_der_privatekey_parsing.c:55
SECP256K1_WARN_UNUSED_RESULT
#define SECP256K1_WARN_UNUSED_RESULT
Warning attributes NONNULL is not used if SECP256K1_BUILD is set to avoid the compiler optimizing out...
Definition: secp256k1.h:164
SECP256K1_ARG_NONNULL
#define SECP256K1_ARG_NONNULL(_x)
Definition: secp256k1.h:169
ctx
static secp256k1_context * ctx
Definition: tests.c:42