BIGNUM *n, *e;
const unsigned char *p = blob, *end = blob + blen;
- rsa = RSA_new();
- if (!rsa)
- return -E_BIGNUM;
+ assert((rsa = RSA_new()));
ret = read_bignum(p, end - p, &e);
if (ret < 0)
goto free_rsa;
static int read_pem_private_key(const char *path, struct asymmetric_key *priv)
{
EVP_PKEY *pkey;
- BIO *bio = BIO_new(BIO_s_file());
+ BIO *bio;
+ assert((bio = BIO_new(BIO_s_file())));
priv->rsa = NULL;
- if (!bio)
- return -E_PRIVATE_KEY;
if (BIO_read_filename(bio, path) <= 0)
goto bio_free;
pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
BIGNUM *n, *e, *d, *iqmp, *p, *q; /* stored in the key file */
const unsigned char *cp = blob;
- rsa = RSA_new();
- if (!rsa)
- return -E_BIGNUM;
+ assert((rsa = RSA_new()));
ret = read_bignum(cp, end - cp, &n);
if (ret < 0)
goto free_rsa;
struct stream_cipher *sc = alloc(sizeof(*sc));
assert(len >= 2 * AES_CRT128_BLOCK_SIZE);
- sc->aes = EVP_CIPHER_CTX_new();
+ assert((sc->aes = EVP_CIPHER_CTX_new()));
EVP_EncryptInit_ex(sc->aes, EVP_aes_128_ctr(), NULL, data,
data + AES_CRT128_BLOCK_SIZE);
return sc;
void hash_function(const char *data, unsigned long len, unsigned char *hash)
{
- EVP_MD_CTX *c = EVP_MD_CTX_new();
- int ret = EVP_DigestInit_ex(c, EVP_sha1(), NULL);
+ int ret;
+ EVP_MD_CTX *c;
+
+ assert((c = EVP_MD_CTX_new()));
+ ret = EVP_DigestInit_ex(c, EVP_sha1(), NULL);
assert(ret != 0);
ret = EVP_DigestUpdate(c, data, len);
assert(ret != 0);
void hash2_function(const char *data, unsigned long len, unsigned char *hash)
{
- EVP_MD_CTX *c = EVP_MD_CTX_new();
- int ret = EVP_DigestInit_ex(c, EVP_sha256(), NULL);
+ int ret;
+ EVP_MD_CTX *c;
+
+ assert((c = EVP_MD_CTX_new()));
+ ret = EVP_DigestInit_ex(c, EVP_sha256(), NULL);
assert(ret != 0);
ret = EVP_DigestUpdate(c, data, len);
assert(ret != 0);