Browse Source
Ensure that ECDSA constant sizes are correctly-sized
pull/40/head^2
Jack Grigg
7 years ago
No known key found for this signature in database
GPG Key ID: 665DBCD284F7DAFF
2 changed files with
6 additions and
0 deletions
-
src/key.cpp
-
src/pubkey.h
|
|
@ -92,6 +92,9 @@ static int ec_privkey_import_der(const secp256k1_context* ctx, unsigned char *ou |
|
|
|
*/ |
|
|
|
static int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed) { |
|
|
|
assert(*privkeylen >= PRIVATE_KEY_SIZE); |
|
|
|
static_assert( |
|
|
|
PRIVATE_KEY_SIZE >= COMPRESSED_PRIVATE_KEY_SIZE, |
|
|
|
"COMPRESSED_PRIVATE_KEY_SIZE is larger than PRIVATE_KEY_SIZE"); |
|
|
|
secp256k1_pubkey pubkey; |
|
|
|
size_t pubkeylen = 0; |
|
|
|
if (!secp256k1_ec_pubkey_create(ctx, &pubkey, key32)) { |
|
|
|
|
|
@ -46,6 +46,9 @@ private: |
|
|
|
* Its length can very cheaply be computed from the first byte. |
|
|
|
*/ |
|
|
|
unsigned char vch[PUBLIC_KEY_SIZE]; |
|
|
|
static_assert( |
|
|
|
PUBLIC_KEY_SIZE >= COMPRESSED_PUBLIC_KEY_SIZE, |
|
|
|
"COMPRESSED_PUBLIC_KEY_SIZE is larger than PUBLIC_KEY_SIZE"); |
|
|
|
|
|
|
|
//! Compute the length of a pubkey with a given first byte.
|
|
|
|
unsigned int static GetLen(unsigned char chHeader) |
|
|
|