aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJack Grigg <jack@z.cash>2017-06-08 16:07:49 +1200
committerJack Grigg <jack@z.cash>2017-07-17 11:57:23 -0500
commit1ce9f0a952a3d5d9442ad8251da898d96209c16c (patch)
treeb04830f99208d2a3db592572204dba96b70fc33b /src
parent48abe78e51e9a51fba8b93ff7faa32a14a2aa50c (diff)
downloadbitcoin-1ce9f0a952a3d5d9442ad8251da898d96209c16c.tar.xz
Ensure that ECDSA constant sizes are correctly-sized
Diffstat (limited to 'src')
-rw-r--r--src/key.cpp3
-rw-r--r--src/pubkey.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/key.cpp b/src/key.cpp
index 3a93187d76..42301e81a0 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -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)) {
diff --git a/src/pubkey.h b/src/pubkey.h
index 6e25ad7c49..a508c238e4 100644
--- a/src/pubkey.h
+++ b/src/pubkey.h
@@ -48,6 +48,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)