Bitcoin Core  22.99.0
P2P Digital Currency
Functions
secp256k1_ec_seckey_import_export_der.cpp File Reference
#include <key.h>
#include <secp256k1.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <cstdint>
#include <vector>
Include dependency graph for secp256k1_ec_seckey_import_export_der.cpp:

Go to the source code of this file.

Functions

int ec_seckey_import_der (const secp256k1_context *ctx, unsigned char *out32, const unsigned char *seckey, size_t seckeylen)
 These functions are taken from the libsecp256k1 distribution and are very ugly. More...
 
int ec_seckey_export_der (const secp256k1_context *ctx, unsigned char *seckey, size_t *seckeylen, const unsigned char *key32, bool compressed)
 This serializes to a DER encoding of the ECPrivateKey type from section C.4 of SEC 1 https://www.secg.org/sec1-v2.pdf. More...
 
 FUZZ_TARGET (secp256k1_ec_seckey_import_export_der)
 

Function Documentation

◆ ec_seckey_export_der()

int ec_seckey_export_der ( const secp256k1_context ctx,
unsigned char *  seckey,
size_t *  seckeylen,
const unsigned char *  key32,
bool  compressed 
)

This serializes to a DER encoding of the ECPrivateKey type from section C.4 of SEC 1 https://www.secg.org/sec1-v2.pdf.

The optional parameters and publicKey fields are included.

seckey must point to an output buffer of length at least CKey::SIZE bytes. seckeylen must initially be set to the size of the seckey buffer. Upon return it will be set to the number of bytes used in the buffer. key32 must point to a 32-byte raw private key.

Definition at line 94 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ec_seckey_import_der()

int ec_seckey_import_der ( const secp256k1_context ctx,
unsigned char *  out32,
const unsigned char *  seckey,
size_t  seckeylen 
)

These functions are taken from the libsecp256k1 distribution and are very ugly.

This parses a format loosely based on a DER encoding of the ECPrivateKey type from section C.4 of SEC 1 https://www.secg.org/sec1-v2.pdf, with the following caveats:

  • The octet-length of the SEQUENCE must be encoded as 1 or 2 octets. It is not required to be encoded as one octet if it is less than 256, as DER would require.
  • The octet-length of the SEQUENCE must not be greater than the remaining length of the key encoding, but need not match it (i.e. the encoding may contain junk after the encoded SEQUENCE).
  • The privateKey OCTET STRING is zero-filled on the left to 32 octets.
  • Anything after the encoding of the privateKey OCTET STRING is ignored, whether or not it is validly encoded DER.

out32 must point to an output buffer of length at least 32 bytes.

Definition at line 37 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FUZZ_TARGET()

FUZZ_TARGET ( secp256k1_ec_seckey_import_export_der  )

Definition at line 17 of file secp256k1_ec_seckey_import_export_der.cpp.

Here is the call graph for this function: