#include "ies.h"
#include <iostream>
#include <vector>
-#include <openssl/ecdh.h>
#define SET_ERROR(string) \
sprintf(error, "%s %s:%d", (string), __FILE__, __LINE__)
cryptogram_t * ecies_encrypt(const ies_ctx_t *ctx, const unsigned char *data, size_t length, char *error) {
- const size_t block_length = EVP_CIPHER_block_size(ctx->cipher);
- const size_t mac_length = EVP_MD_size(ctx->md);
- cryptogram_t *cryptogram = NULL;
- unsigned char *envelope_key = NULL;
-
if (!ctx || !data || !length) {
SET_ERROR("Invalid arguments");
return NULL;
}
+ const size_t block_length = EVP_CIPHER_block_size(ctx->cipher);
+ const size_t mac_length = EVP_MD_size(ctx->md);
+ cryptogram_t *cryptogram = NULL;
+ unsigned char *envelope_key = NULL;
+
if (block_length == 0 || block_length > EVP_MAX_BLOCK_LENGTH) {
SET_ERROR("Derived block size is incorrect");
return NULL;
#include <openssl/ecdsa.h>
#include <openssl/obj_mac.h>
-#include <openssl/ssl.h>
-#include <openssl/ecdh.h>
#include "key.h"
#include "base58.h"
-#include "ies.h"
// Generate a private key from just the secret parameter
int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key)
unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake)
{
- CBigNum bnTargetLimit = !fProofOfStake ? bnProofOfWorkLimit : GetProofOfStakeLimit(pindexLast->nHeight, pindexLast->nTime);
-
if (pindexLast == NULL)
return bnTargetLimit.GetCompact(); // genesis block
+ CBigNum bnTargetLimit = !fProofOfStake ? bnProofOfWorkLimit : GetProofOfStakeLimit(pindexLast->nHeight, pindexLast->nTime);
+
const CBlockIndex* pindexPrev = GetLastBlockIndex(pindexLast, fProofOfStake);
if (pindexPrev->pprev == NULL)
return bnTargetLimit.GetCompact(); // first block
return error("AddToBlockIndex() : %s already exists", hash.ToString().substr(0,20).c_str());
// Construct new block index object
- CBlockIndex* pindexNew = new CBlockIndex(nFile, nBlockPos, *this);
+ CBlockIndex* pindexNew = new(nothrow) CBlockIndex(nFile, nBlockPos, *this);
if (!pindexNew)
return error("AddToBlockIndex() : new CBlockIndex failed");
pindexNew->phashBlock = &hash;
#include "main.h"
#include "net.h"
#include "wallet.h"
-#include "script.h"
-#include "util.h"
using namespace std;
using namespace boost;
return (*mi).second;
// Create new
- CBlockIndex* pindexNew = new CBlockIndex();
+ CBlockIndex* pindexNew = new(nothrow) CBlockIndex();
if (!pindexNew)
throw runtime_error("LoadBlockIndex() : new CBlockIndex failed");
mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
return (*mi).second;
// Create new
- CBlockIndex* pindexNew = new CBlockIndex();
+ CBlockIndex* pindexNew = new(nothrow) CBlockIndex();
if (!pindexNew)
throw runtime_error("LoadBlockIndex() : new CBlockIndex failed");
mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first;
if (p != buffer)
delete[] p;
limit *= 2;
- p = new char[limit];
+ p = new(nothrow) char[limit];
if (p == NULL)
throw std::bad_alloc();
}