STACK_OF(CONF_VALUE) *sktmp;
CONF_VALUE *cnf;
int i;
- if (!(p = NCONF_get_string(conf, NULL, "oid_section"))) {
+
+ if ((p = NCONF_get_string(conf, NULL, "oid_section")) == NULL) {
ERR_clear_error();
return 1;
}
- if (!(sktmp = NCONF_get_section(conf, p))) {
+ if ((sktmp = NCONF_get_section(conf, p)) == NULL) {
BIO_printf(bio_err, "problem loading oid section %s\n", p);
return 0;
}
* Its best to dup the subject DN and then delete any email addresses
* because this retains its structure.
*/
- if (!(dn_subject = X509_NAME_dup(subject))) {
+ if ((dn_subject = X509_NAME_dup(subject)) == NULL) {
BIO_printf(bio_err, "Memory allocation failure\n");
goto end;
}
if ((encerts = sk_X509_new_null()) == NULL)
goto end;
while (*argv) {
- if (!(cert = load_cert(*argv, FORMAT_PEM,
- NULL, e, "recipient certificate file")))
+ if ((cert = load_cert(*argv, FORMAT_PEM, NULL, e,
+ "recipient certificate file")) == NULL)
goto end;
sk_X509_push(encerts, cert);
cert = NULL;
}
if (certfile) {
- if (!(other = load_certs(certfile, FORMAT_PEM, NULL,
- e, "certificate file"))) {
+ if ((other = load_certs(certfile, FORMAT_PEM, NULL, e,
+ "certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
}
if (recipfile && (operation == SMIME_DECRYPT)) {
- if (!(recip = load_cert(recipfile, FORMAT_PEM, NULL,
- e, "recipient certificate file"))) {
+ if ((recip = load_cert(recipfile, FORMAT_PEM, NULL, e,
+ "recipient certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
}
if (operation == SMIME_SIGN_RECEIPT) {
- if (!(signer = load_cert(signerfile, FORMAT_PEM, NULL,
- e, "receipt signer certificate file"))) {
+ if ((signer = load_cert(signerfile, FORMAT_PEM, NULL, e,
+ "receipt signer certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
}
if (contfile) {
BIO_free(indata);
- if (!(indata = BIO_new_file(contfile, "rb"))) {
+ if ((indata = BIO_new_file(contfile, "rb")) == NULL) {
BIO_printf(bio_err, "Can't read content file %s\n", contfile);
goto end;
}
if (rctfile) {
char *rctmode = (rctformat == FORMAT_ASN1) ? "rb" : "r";
- if (!(rctin = BIO_new_file(rctfile, rctmode))) {
+ if ((rctin = BIO_new_file(rctfile, rctmode)) == NULL) {
BIO_printf(bio_err, "Can't open receipt file %s\n", rctfile);
goto end;
}
goto end;
if ((operation == SMIME_VERIFY) || (operation == SMIME_VERIFY_RECEIPT)) {
- if (!(store = setup_verify(CAfile, CApath)))
+ if ((store = setup_verify(CAfile, CApath)) == NULL)
goto end;
X509_STORE_set_verify_cb(store, cms_cb);
if (vpmtouched)
goto end;
if (do_ver) {
- if (!(store = setup_verify(CAfile, CApath)))
+ if ((store = setup_verify(CAfile, CApath)) == NULL)
goto end;
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
if (lookup == NULL)
nocrl = 1;
break;
case OPT_CERTFILE:
- if (!certflst && !(certflst = sk_OPENSSL_STRING_new_null()))
+ if ((certflst == NULL)
+ && (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
goto end;
if (!sk_OPENSSL_STRING_push(certflst, *(++argv))) {
sk_OPENSSL_STRING_free(certflst);
/* Add any more certificates asked for */
if (certfile) {
STACK_OF(X509) *morecerts = NULL;
- if (!(morecerts = load_certs(certfile, FORMAT_PEM, NULL, e,
- "certificates from certfile")))
+ if ((morecerts = load_certs(certfile, FORMAT_PEM, NULL, e,
+ "certificates from certfile")) == NULL)
goto export_end;
while (sk_X509_num(morecerts) > 0)
sk_X509_push(certs, sk_X509_shift(morecerts));
int vret;
STACK_OF(X509) *chain2;
X509_STORE *store;
- if (!(store = setup_verify(CAfile, CApath)))
+ if ((store = setup_verify(CAfile, CApath)) == NULL)
goto export_end;
vret = get_cert_chain(ucert, store, &chain2);
}
- if (!(p12 = d2i_PKCS12_bio(in, NULL))) {
+ if ((p12 = d2i_PKCS12_bio(in, NULL)) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
int ret = 0;
PKCS7 *p7;
- if (!(asafes = PKCS12_unpack_authsafes(p12)))
+ if ((asafes = PKCS12_unpack_authsafes(p12)) == NULL)
return 0;
for (i = 0; i < sk_PKCS7_num(asafes); i++) {
p7 = sk_PKCS7_value(asafes, i);
return 1;
print_attribs(out, bag->attrib, "Bag Attributes");
p8 = bag->value.keybag;
- if (!(pkey = EVP_PKCS82PKEY(p8)))
+ if ((pkey = EVP_PKCS82PKEY(p8)) == NULL)
return 0;
print_attribs(out, p8->attributes, "Key Attributes");
PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, pempass);
if (options & NOKEYS)
return 1;
print_attribs(out, bag->attrib, "Bag Attributes");
- if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen)))
+ if ((p8 = PKCS12_decrypt_skey(bag, pass, passlen)) == NULL)
return 0;
- if (!(pkey = EVP_PKCS82PKEY(p8))) {
+ if ((pkey = EVP_PKCS82PKEY(p8)) == NULL) {
PKCS8_PRIV_KEY_INFO_free(p8);
return 0;
}
print_attribs(out, bag->attrib, "Bag Attributes");
if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate)
return 1;
- if (!(x509 = PKCS12_certbag2x509(bag)))
+ if ((x509 = PKCS12_certbag2x509(bag)) == NULL)
return 0;
dump_cert_text(out, x509);
PEM_write_bio_X509(out, x509);
pkey = load_key(infile, informat, 1, passin, e, "key");
if (!pkey)
goto end;
- if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) {
+ if ((p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken)) == NULL) {
BIO_printf(bio_err, "Error converting key\n");
ERR_print_errors(bio_err);
goto end;
goto end;
}
app_RAND_load_file(NULL, 0);
- if (!(p8 = PKCS8_encrypt(pbe_nid, cipher,
- p8pass, strlen(p8pass),
- NULL, 0, iter, p8inf))) {
+ if ((p8 = PKCS8_encrypt(pbe_nid, cipher,
+ p8pass, strlen(p8pass),
+ NULL, 0, iter, p8inf)) == NULL) {
BIO_printf(bio_err, "Error encrypting key\n");
ERR_print_errors(bio_err);
goto end;
goto end;
}
- if (!(pkey = EVP_PKCS82PKEY(p8inf))) {
+ if ((pkey = EVP_PKCS82PKEY(p8inf)) == NULL) {
BIO_printf(bio_err, "Error converting key\n");
ERR_print_errors(bio_err);
goto end;
{
X509_NAME *n;
- if (!(n = parse_name(subject, chtype, multirdn)))
+ if ((n = parse_name(subject, chtype, multirdn)) == NULL)
return 0;
if (!X509_REQ_set_subject_name(req, n)) {
{
SRP_ARG *srp_arg = (SRP_ARG *)arg;
BIGNUM *N = NULL, *g = NULL;
- if (!(N = SSL_get_srp_N(s)) || !(g = SSL_get_srp_g(s)))
+
+ if (((N = SSL_get_srp_N(s)) == NULL) || ((g = SSL_get_srp_g(s)) == NULL))
return 0;
if (srp_arg->debug || srp_arg->msg || srp_arg->amp == 1) {
BIO_printf(bio_err, "SRP parameters:\n");
}
if (certfile) {
- if (!(other = load_certs(certfile, FORMAT_PEM, NULL,
- e, "certificate file"))) {
+ if ((other = load_certs(certfile, FORMAT_PEM, NULL,
+ e, "certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
}
if (recipfile && (operation == SMIME_DECRYPT)) {
- if (!(recip = load_cert(recipfile, FORMAT_PEM, NULL,
- e, "recipient certificate file"))) {
+ if ((recip = load_cert(recipfile, FORMAT_PEM, NULL,
+ e, "recipient certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
}
if (contfile) {
BIO_free(indata);
- if (!(indata = BIO_new_file(contfile, "rb"))) {
+ if ((indata = BIO_new_file(contfile, "rb")) == NULL) {
BIO_printf(bio_err, "Can't read content file %s\n", contfile);
goto end;
}
goto end;
if (operation == SMIME_VERIFY) {
- if (!(store = setup_verify(CAfile, CApath)))
+ if ((store = setup_verify(CAfile, CApath)) == NULL)
goto end;
X509_STORE_set_verify_cb(store, smime_cb);
if (vpmtouched)
row[DB_srptype] = BUF_strdup("v");
row[DB_srpgN] = BUF_strdup(gNid);
- if (!row[DB_srpid] || !row[DB_srpgN] || !row[DB_srptype]
- || !row[DB_srpverifier] || !row[DB_srpsalt]
- || (userinfo &&
- (!(row [DB_srpinfo] = BUF_strdup (userinfo))))
+ if ((row[DB_srpid] == NULL)
+ || (row[DB_srpgN] == NULL)
+ || (row[DB_srptype] == NULL)
+ || (row[DB_srpverifier] == NULL)
+ || (row[DB_srpsalt] == NULL)
+ || (userinfo
+ && ((row[DB_srpinfo] = BUF_strdup(userinfo)) == NULL))
|| !update_index(db, row)) {
OPENSSL_free(row[DB_srpid]);
OPENSSL_free(row[DB_srpgN]);
row[DB_srptype][0] = 'v';
row[DB_srpgN] = BUF_strdup(gNid);
- if (!row[DB_srpid] || !row[DB_srpgN] || !row[DB_srptype]
- || !row[DB_srpverifier] || !row[DB_srpsalt]
+ if (row[DB_srpid] == NULL
+ || row[DB_srpgN] == NULL
+ || row[DB_srptype] == NULL
+ || row[DB_srpverifier] == NULL
+ || row[DB_srpsalt] == NULL
|| (userinfo
- && (!(row[DB_srpinfo] = BUF_strdup(userinfo)))))
+ && ((row[DB_srpinfo] = BUF_strdup(userinfo))
+ == NULL)))
goto end;
doupdatedb = 1;
user);
errors++;
} else {
- char **xpp =
- sk_OPENSSL_PSTRING_value(db->db->data, userindex);
- BIO_printf(bio_err, "user \"%s\" revoked. t\n", user);
+ char **xpp = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
+ BIO_printf(bio_err, "user \"%s\" revoked. t\n", user);
xpp[DB_srptype][0] = 'R';
-
doupdatedb = 1;
}
}
{
ASN1_OBJECT *oid_obj = NULL;
- if (!(oid_obj = OBJ_txt2obj(oid, 0)))
+ if ((oid_obj = OBJ_txt2obj(oid, 0)) == NULL)
BIO_printf(bio_err, "cannot convert %s to OID\n", oid);
return oid_obj;
configfile = getenv("SSLEAY_CONF");
if (configfile &&
- (!(conf = NCONF_new(NULL)) ||
- NCONF_load(conf, configfile, &errorline) <= 0)) {
+ ((conf = NCONF_new(NULL)) == NULL
+ || NCONF_load(conf, configfile, &errorline) <= 0)) {
if (errorline <= 0)
BIO_printf(bio_err, "error loading the config file "
"'%s'\n", configfile);
query = d2i_TS_REQ_bio(in_bio, NULL);
} else {
/* Open the file if no explicit digest bytes were specified. */
- if (!digest && !(data_bio = bio_open_default(data, "rb")))
+ if (digest == NULL
+ && (data_bio = bio_open_default(data, "rb")) == NULL)
goto end;
query = create_query(data_bio, digest, md, policy, no_nonce, cert);
}
ASN1_INTEGER *nonce_asn1 = NULL;
/* Setting default message digest. */
- if (!md && !(md = EVP_get_digestbyname("sha1")))
+ if (md == NULL && (md = EVP_get_digestbyname("sha1")) == NULL)
goto err;
/* Creating request object. */
- if (!(ts_req = TS_REQ_new()))
+ if ((ts_req = TS_REQ_new()) == NULL)
goto err;
/* Setting version. */
goto err;
/* Creating and adding MSG_IMPRINT object. */
- if (!(msg_imprint = TS_MSG_IMPRINT_new()))
+ if ((msg_imprint = TS_MSG_IMPRINT_new()) == NULL)
goto err;
/* Adding algorithm. */
- if (!(algo = X509_ALGOR_new()))
+ if ((algo = X509_ALGOR_new()) == NULL)
goto err;
- if (!(algo->algorithm = OBJ_nid2obj(EVP_MD_type(md))))
+ if ((algo->algorithm = OBJ_nid2obj(EVP_MD_type(md))) == NULL)
goto err;
- if (!(algo->parameter = ASN1_TYPE_new()))
+ if ((algo->parameter = ASN1_TYPE_new()) == NULL)
goto err;
algo->parameter->type = V_ASN1_NULL;
if (!TS_MSG_IMPRINT_set_algo(msg_imprint, algo))
goto err;
/* Setting policy if requested. */
- if (policy && !(policy_obj = txt2obj(policy)))
+ if (policy && (policy_obj = txt2obj(policy)) == NULL)
goto err;
if (policy_obj && !TS_REQ_set_policy_id(ts_req, policy_obj))
goto err;
/* Setting nonce if requested. */
- if (!no_nonce && !(nonce_asn1 = create_nonce(NONCE_LENGTH)))
+ if (!no_nonce && (nonce_asn1 = create_nonce(NONCE_LENGTH)) == NULL)
goto err;
if (nonce_asn1 && !TS_REQ_set_nonce(ts_req, nonce_asn1))
goto err;
goto err;
/* Find the first non-zero byte and creating ASN1_INTEGER object. */
- for (i = 0; i < len && !buf[i]; ++i) ;
- if (!(nonce = ASN1_INTEGER_new()))
+ for (i = 0; i < len && !buf[i]; ++i)
+ continue;
+ if ((nonce = ASN1_INTEGER_new()) == NULL)
goto err;
OPENSSL_free(nonce->data);
/* Allocate at least one byte. */
TS_STATUS_INFO *si = NULL;
/* Read PKCS7 object and extract the signed time stamp info. */
- if (!(token = d2i_PKCS7_bio(in_bio, NULL)))
+ if ((token = d2i_PKCS7_bio(in_bio, NULL)) == NULL)
goto end;
- if (!(tst_info = PKCS7_to_TS_TST_INFO(token)))
+ if ((tst_info = PKCS7_to_TS_TST_INFO(token)) == NULL)
goto end;
/* Creating response object. */
- if (!(resp = TS_RESP_new()))
+ if ((resp = TS_RESP_new()) == NULL)
goto end;
/* Create granted status info. */
- if (!(si = TS_STATUS_INFO_new()))
+ if ((si = TS_STATUS_INFO_new()) == NULL)
goto end;
if (!(ASN1_INTEGER_set(si->status, TS_STATUS_GRANTED)))
goto end;
BIO *query_bio = NULL;
TS_RESP_CTX *resp_ctx = NULL;
- if (!(query_bio = BIO_new_file(queryfile, "rb")))
+ if ((query_bio = BIO_new_file(queryfile, "rb")) == NULL)
goto end;
/* Getting TSA configuration section. */
- if (!(section = TS_CONF_get_tsa_section(conf, section)))
+ if ((section = TS_CONF_get_tsa_section(conf, section)) == NULL)
goto end;
/* Setting up response generation context. */
- if (!(resp_ctx = TS_RESP_CTX_new()))
+ if ((resp_ctx = TS_RESP_CTX_new()) == NULL)
goto end;
/* Setting serial number provider callback. */
goto end;
/* Creating the response. */
- if (!(response = TS_RESP_create_response(resp_ctx, query_bio)))
+ if ((response = TS_RESP_create_response(resp_ctx, query_bio)) == NULL)
goto end;
ret = 1;
ASN1_INTEGER *serial = NULL;
BIGNUM *bn = NULL;
- if (!(serial = ASN1_INTEGER_new()))
+ if ((serial = ASN1_INTEGER_new()) == NULL)
goto err;
- if (!(in = BIO_new_file(serialfile, "r"))) {
+ if ((in = BIO_new_file(serialfile, "r")) == NULL) {
ERR_clear_error();
BIO_printf(bio_err, "Warning: could not open file %s for "
"reading, using serial number: 1\n", serialfile);
serialfile);
goto err;
}
- if (!(bn = ASN1_INTEGER_to_BN(serial, NULL)))
+ if ((bn = ASN1_INTEGER_to_BN(serial, NULL)) == NULL)
goto err;
ASN1_INTEGER_free(serial);
serial = NULL;
if (!BN_add_word(bn, 1))
goto err;
- if (!(serial = BN_to_ASN1_INTEGER(bn, NULL)))
+ if ((serial = BN_to_ASN1_INTEGER(bn, NULL)) == NULL)
goto err;
}
ret = 1;
int ret = 0;
BIO *out = NULL;
- if (!(out = BIO_new_file(serialfile, "w")))
+ if ((out = BIO_new_file(serialfile, "w")) == NULL)
goto err;
if (i2a_ASN1_INTEGER(out, serial) <= 0)
goto err;
int ret = 0;
/* Decode the token (PKCS7) or response (TS_RESP) files. */
- if (!(in_bio = BIO_new_file(in, "rb")))
+ if ((in_bio = BIO_new_file(in, "rb")) == NULL)
goto end;
if (token_in) {
- if (!(token = d2i_PKCS7_bio(in_bio, NULL)))
+ if ((token = d2i_PKCS7_bio(in_bio, NULL)) == NULL)
goto end;
} else {
- if (!(response = d2i_TS_RESP_bio(in_bio, NULL)))
+ if ((response = d2i_TS_RESP_bio(in_bio, NULL)) == NULL)
goto end;
}
- if (!(verify_ctx = create_verify_ctx(data, digest, queryfile,
- CApath, CAfile, untrusted)))
+ if ((verify_ctx = create_verify_ctx(data, digest, queryfile,
+ CApath, CAfile, untrusted)) == NULL)
goto end;
/* Checking the token or response against the request. */
int ret = 0;
if (data != NULL || digest != NULL) {
- if (!(ctx = TS_VERIFY_CTX_new()))
+ if ((ctx = TS_VERIFY_CTX_new()) == NULL)
goto err;
ctx->flags = TS_VFY_VERSION | TS_VFY_SIGNER;
if (data != NULL) {
ctx->flags |= TS_VFY_DATA;
- if (!(ctx->data = BIO_new_file(data, "rb")))
+ if ((ctx->data = BIO_new_file(data, "rb")) == NULL)
goto err;
} else if (digest != NULL) {
long imprint_len;
ctx->flags |= TS_VFY_IMPRINT;
- if (!(ctx->imprint = string_to_hex(digest, &imprint_len))) {
+ if ((ctx->imprint = string_to_hex(digest, &imprint_len)) == NULL) {
BIO_printf(bio_err, "invalid digest string\n");
goto err;
}
* The request has just to be read, decoded and converted to a verify
* context object.
*/
- if (!(input = BIO_new_file(queryfile, "rb")))
+ if ((input = BIO_new_file(queryfile, "rb")) == NULL)
goto err;
- if (!(request = d2i_TS_REQ_bio(input, NULL)))
+ if ((request = d2i_TS_REQ_bio(input, NULL)) == NULL)
goto err;
- if (!(ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL)))
+ if ((ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL)) == NULL)
goto err;
} else
return NULL;
ctx->flags |= TS_VFY_SIGNATURE;
/* Initialising the X509_STORE object. */
- if (!(ctx->store = create_cert_store(CApath, CAfile)))
+ if ((ctx->store = create_cert_store(CApath, CAfile)) == NULL)
goto err;
/* Loading untrusted certificates. */
- if (untrusted && !(ctx->certs = TS_CONF_load_certs(untrusted)))
+ if (untrusted && (ctx->certs = TS_CONF_load_certs(untrusted)) == NULL)
goto err;
ret = 1;
argc = opt_num_rest();
argv = opt_rest();
- if (!(store = setup_verify(CAfile, CApath)))
+ if ((store = setup_verify(CAfile, CApath)) == NULL)
goto end;
X509_STORE_set_verify_cb(store, cb);
}
if (sno)
bs = sno;
- else if (!(bs = x509_load_serial(CAfile, serialfile, create)))
+ else if ((bs = x509_load_serial(CAfile, serialfile, create)) == NULL)
goto end;
-/* if (!X509_STORE_add_cert(ctx,x)) goto end;*/
-
/*
* NOTE: this certificate can/should be self signed, unless it was a
* certificate request in which case it is not.
cpyfunc = cpy_utf8;
break;
}
- if (!(p = OPENSSL_malloc(outlen + 1))) {
+ if ((p = OPENSSL_malloc(outlen + 1)) == NULL) {
if (free_out)
ASN1_STRING_free(dest);
ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ERR_R_MALLOC_FAILURE);
if (!ASN1_TIME_check(t))
return NULL;
- if (!out || !*out) {
- if (!(ret = ASN1_GENERALIZEDTIME_new()))
+ if (out == NULL || *out == NULL) {
+ if ((ret = ASN1_GENERALIZEDTIME_new()) == NULL)
return NULL;
if (out)
*out = ret;
if (derlen < 0)
goto bad;
-
- if (!(ret = ASN1_TYPE_new()))
+ if ((ret = ASN1_TYPE_new()) == NULL)
goto bad;
-
- if (!(ret->value.asn1_string = ASN1_STRING_type_new(utype)))
+ if ((ret->value.asn1_string = ASN1_STRING_type_new(utype)) == NULL)
goto bad;
ret->type = utype;
-
ret->value.asn1_string->data = der;
ret->value.asn1_string->length = derlen;
static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
{
ASN1_TYPE *atmp = NULL;
-
CONF_VALUE vtmp;
-
unsigned char *rdata;
long rdlen;
-
int no_unused = 1;
- if (!(atmp = ASN1_TYPE_new())) {
+ if ((atmp = ASN1_TYPE_new()) == NULL) {
ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
return NULL;
}
ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_INTEGER_NOT_ASCII_FORMAT);
goto bad_form;
}
- if (!(atmp->value.integer = s2i_ASN1_INTEGER(NULL, (char *)str))) {
+ if ((atmp->value.integer
+ = s2i_ASN1_INTEGER(NULL, (char *)str)) == NULL) {
ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_INTEGER);
goto bad_str;
}
ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_OBJECT_NOT_ASCII_FORMAT);
goto bad_form;
}
- if (!(atmp->value.object = OBJ_txt2obj(str, 0))) {
+ if ((atmp->value.object = OBJ_txt2obj(str, 0)) == NULL) {
ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_OBJECT);
goto bad_str;
}
ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_TIME_NOT_ASCII_FORMAT);
goto bad_form;
}
- if (!(atmp->value.asn1_string = ASN1_STRING_new())) {
+ if ((atmp->value.asn1_string = ASN1_STRING_new()) == NULL) {
ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
goto bad_str;
}
case V_ASN1_UNIVERSALSTRING:
case V_ASN1_GENERALSTRING:
case V_ASN1_NUMERICSTRING:
-
if (format == ASN1_GEN_FORMAT_ASCII)
format = MBSTRING_ASC;
else if (format == ASN1_GEN_FORMAT_UTF8)
break;
case V_ASN1_BIT_STRING:
-
case V_ASN1_OCTET_STRING:
-
- if (!(atmp->value.asn1_string = ASN1_STRING_new())) {
+ if ((atmp->value.asn1_string = ASN1_STRING_new()) == NULL) {
ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE);
goto bad_form;
}
if (format == ASN1_GEN_FORMAT_HEX) {
-
- if (!(rdata = string_to_hex((char *)str, &rdlen))) {
+ if ((rdata = string_to_hex((char *)str, &rdlen)) == NULL) {
ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_HEX);
goto bad_str;
}
-
atmp->value.asn1_string->data = rdata;
atmp->value.asn1_string->length = rdlen;
atmp->value.asn1_string->type = utype;
-
} else if (format == ASN1_GEN_FORMAT_ASCII)
ASN1_STRING_set(atmp->value.asn1_string, str, -1);
else if ((format == ASN1_GEN_FORMAT_BITLIST)
{
BIO *b64;
ASN1_VALUE *val;
- if (!(b64 = BIO_new(BIO_f_base64()))) {
+
+ if ((b64 = BIO_new(BIO_f_base64())) == NULL) {
ASN1err(ASN1_F_B64_READ_ASN1, ERR_R_MALLOC_FAILURE);
return 0;
}
if (bcont)
*bcont = NULL;
- if (!(headers = mime_parse_hdr(bio))) {
+ if ((headers = mime_parse_hdr(bio)) == NULL) {
ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_PARSE_ERROR);
return NULL;
}
- if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) {
+ if ((hdr = mime_hdr_find(headers, "content-type")) == NULL
+ || hdr->value == NULL) {
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_CONTENT_TYPE);
return NULL;
/* Parse the signature piece */
asnin = sk_BIO_value(parts, 1);
- if (!(headers = mime_parse_hdr(asnin))) {
+ if ((headers = mime_parse_hdr(asnin)) == NULL) {
ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_SIG_PARSE_ERROR);
sk_BIO_pop_free(parts, BIO_vfree);
return NULL;
/* Get content type */
- if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) {
+ if ((hdr = mime_hdr_find(headers, "content-type")) == NULL
+ || hdr->value == NULL) {
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_SIG_CONTENT_TYPE);
return NULL;
}
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
/* Read in ASN1 */
- if (!(val = b64_read_asn1(asnin, it))) {
+ if ((val = b64_read_asn1(asnin, it)) == NULL) {
ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_SIG_PARSE_ERROR);
sk_BIO_pop_free(parts, BIO_vfree);
return NULL;
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
- if (!(val = b64_read_asn1(bio, it))) {
+ if ((val = b64_read_asn1(bio, it)) == NULL) {
ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_PARSE_ERROR);
return NULL;
}
STACK_OF(MIME_HEADER) *headers;
MIME_HEADER *hdr;
- if (!(headers = mime_parse_hdr(in))) {
+ if ((headers = mime_parse_hdr(in)) == NULL) {
ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_PARSE_ERROR);
return 0;
}
- if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) {
+ if ((hdr = mime_hdr_find(headers, "content-type")) == NULL
+ || hdr->value == NULL) {
ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_NO_CONTENT_TYPE);
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
return 0;
MIME_HEADER *mhdr = NULL;
char *tmpname = NULL, *tmpval = NULL, *p;
int c;
+
if (name) {
- if (!(tmpname = BUF_strdup(name)))
+ if ((tmpname = BUF_strdup(name)) == NULL)
return NULL;
for (p = tmpname; *p; p++) {
c = (unsigned char)*p;
}
}
if (value) {
- if (!(tmpval = BUF_strdup(value)))
+ if ((tmpval = BUF_strdup(value)) == NULL)
goto err;
for (p = tmpval; *p; p++) {
c = (unsigned char)*p;
goto err;
mhdr->name = tmpname;
mhdr->value = tmpval;
- if (!(mhdr->params = sk_MIME_PARAM_new(mime_param_cmp)))
+ if ((mhdr->params = sk_MIME_PARAM_new(mime_param_cmp)) == NULL)
goto err;
return mhdr;
const char *oid_section;
STACK_OF(CONF_VALUE) *sktmp;
CONF_VALUE *oval;
+
oid_section = CONF_imodule_get_value(md);
- if (!(sktmp = NCONF_get_section(cnf, oid_section))) {
+ if ((sktmp = NCONF_get_section(cnf, oid_section)) == NULL) {
ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION);
return 0;
}
const char *stbl_section;
STACK_OF(CONF_VALUE) *sktmp;
CONF_VALUE *mval;
+
stbl_section = CONF_imodule_get_value(md);
- if (!(sktmp = NCONF_get_section(cnf, stbl_section))) {
+ if ((sktmp = NCONF_get_section(cnf, stbl_section)) == NULL) {
ASN1err(ASN1_F_STBL_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION);
return 0;
}
{
ASN1_STRING *octmp;
- if (!oct || !*oct) {
- if (!(octmp = ASN1_STRING_new())) {
+ if (oct == NULL|| *oct== NULL) {
+ if ((octmp = ASN1_STRING_new()) == NULL) {
ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE);
return NULL;
}
OPENSSL_free(octmp->data);
octmp->data = NULL;
- if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) {
+ if ((octmp->length = ASN1_item_i2d(obj, &octmp->data, it)) == 0) {
ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR);
return NULL;
}
void *ret;
p = oct->data;
- if (!(ret = ASN1_item_d2i(NULL, &p, oct->length, it)))
+ if ((ret = ASN1_item_d2i(NULL, &p, oct->length, it)) == NULL)
ASN1err(ASN1_F_ASN1_ITEM_UNPACK, ASN1_R_DECODE_ERROR);
return ret;
}
}
obj = OBJ_nid2obj(alg_nid);
- if (!(pbe2 = PBE2PARAM_new()))
+ if ((pbe2 = PBE2PARAM_new()) == NULL)
goto merr;
/* Setup the AlgorithmIdentifier for the encryption scheme */
scheme = pbe2->encryption;
-
scheme->algorithm = obj;
- if (!(scheme->parameter = ASN1_TYPE_new()))
+ if ((scheme->parameter = ASN1_TYPE_new()) == NULL)
goto merr;
/* Create random IV */
/* Now set up top level AlgorithmIdentifier */
- if (!(ret = X509_ALGOR_new()))
+ if ((ret = X509_ALGOR_new()) == NULL)
goto merr;
ret->algorithm = OBJ_nid2obj(NID_pbes2);
PBKDF2PARAM *kdf = NULL;
ASN1_OCTET_STRING *osalt = NULL;
- if (!(kdf = PBKDF2PARAM_new()))
+ if ((kdf = PBKDF2PARAM_new()) == NULL)
goto merr;
- if (!(osalt = ASN1_OCTET_STRING_new()))
+ if ((osalt = ASN1_OCTET_STRING_new()) == NULL)
goto merr;
kdf->salt->value.octet_string = osalt;
kdf->salt->type = V_ASN1_OCTET_STRING;
- if (!saltlen)
+ if (saltlen == 0)
saltlen = PKCS5_SALT_LEN;
- if (!(osalt->data = OPENSSL_malloc(saltlen)))
+ if ((osalt->data = OPENSSL_malloc(saltlen)) == NULL)
goto merr;
osalt->length = saltlen;
/* If have a key len set it up */
if (keylen > 0) {
- if (!(kdf->keylength = ASN1_INTEGER_new()))
+ if ((kdf->keylength = ASN1_INTEGER_new()) == NULL)
goto merr;
if (!ASN1_INTEGER_set(kdf->keylength, keylen))
goto merr;
static X509_CERT_AUX *aux_get(X509 *x)
{
- if (!x)
+ if (x == NULL)
return NULL;
- if (!x->aux && !(x->aux = X509_CERT_AUX_new()))
+ if (x->aux == NULL && (x->aux = X509_CERT_AUX_new()) == NULL)
return NULL;
return x->aux;
}
x->aux->alias = NULL;
return 1;
}
- if (!(aux = aux_get(x)))
+ if ((aux = aux_get(x)) == NULL)
return 0;
- if (!aux->alias && !(aux->alias = ASN1_UTF8STRING_new()))
+ if (aux->alias == NULL && (aux->alias = ASN1_UTF8STRING_new()) == NULL)
return 0;
return ASN1_STRING_set(aux->alias, name, len);
}
x->aux->keyid = NULL;
return 1;
}
- if (!(aux = aux_get(x)))
+ if ((aux = aux_get(x)) == NULL)
return 0;
- if (!aux->keyid && !(aux->keyid = ASN1_OCTET_STRING_new()))
+ if (aux->keyid ==NULL
+ && (aux->keyid = ASN1_OCTET_STRING_new()) == NULL)
return 0;
return ASN1_STRING_set(aux->keyid, id, len);
}
if (!objtmp)
return 0;
}
- if (!(aux = aux_get(x)))
+ if ((aux = aux_get(x)) == NULL)
goto err;
- if (!aux->trust && !(aux->trust = sk_ASN1_OBJECT_new_null()))
+ if (aux->trust == NULL
+ && (aux->trust = sk_ASN1_OBJECT_new_null()) == NULL)
goto err;
if (!objtmp || sk_ASN1_OBJECT_push(aux->trust, objtmp))
return 1;
{
X509_CERT_AUX *aux;
ASN1_OBJECT *objtmp;
- if (!(objtmp = OBJ_dup(obj)))
+ if ((objtmp = OBJ_dup(obj)) == NULL)
return 0;
- if (!(aux = aux_get(x)))
+ if ((aux = aux_get(x)) == NULL)
return 0;
- if (!aux->reject && !(aux->reject = sk_ASN1_OBJECT_new_null()))
+ if (aux->reject == NULL
+ && (aux->reject = sk_ASN1_OBJECT_new_null()) == NULL)
return 0;
return sk_ASN1_OBJECT_push(aux->reject, objtmp);
}
{
NBIO_TEST *nt;
- if (!(nt = OPENSSL_malloc(sizeof(*nt))))
+ if ((nt = OPENSSL_malloc(sizeof(*nt))) == NULL)
return (0);
nt->lrn = -1;
nt->lwn = -1;
}
if (cb != NULL) {
- if (!(ret = cb((BIO *)b, c->state, ret)))
+ if ((ret = cb((BIO *)b, c->state, ret)) == 0)
goto end;
}
}
if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) {
char *tmp;
data->saved_message.bio = b;
- if (!(tmp = OPENSSL_malloc(inl))) {
+ if ((tmp = OPENSSL_malloc(inl)) == NULL) {
BIOerr(BIO_F_DGRAM_SCTP_WRITE, ERR_R_MALLOC_FAILURE);
return -1;
}
BUF_MEM *b;
size_t sz;
- if (!buf) {
+ if (buf == NULL) {
BIOerr(BIO_F_BIO_NEW_MEM_BUF, BIO_R_NULL_PARAMETER);
return NULL;
}
sz = (len < 0) ? strlen(buf) : (size_t)len;
- if (!(ret = BIO_new(BIO_s_mem())))
+ if ((ret = BIO_new(BIO_s_mem())) == NULL)
return NULL;
b = (BUF_MEM *)ret->ptr;
b->data = buf;
{
BIO *cmsbio;
int ret = 0;
- if (!(cmsbio = CMS_dataInit(cms, dcont))) {
+
+ if ((cmsbio = CMS_dataInit(cms, dcont)) == NULL) {
CMSerr(CMS_F_CMS_FINAL, ERR_R_MALLOC_FAILURE);
return 0;
}
p++;
*p = '\0';
- if (!(v = OPENSSL_malloc(sizeof(*v)))) {
+ if ((v = OPENSSL_malloc(sizeof(*v))) == NULL) {
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
goto err;
}
{
BIO *btmp;
LHASH_OF(CONF_VALUE) *ltmp;
- if (!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) {
+ if ((btmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) {
CONFerr(CONF_F_CONF_LOAD_FP, ERR_R_BUF_LIB);
return NULL;
}
BIO *btmp;
int ret;
- if (!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) {
+ if ((btmp = BIO_new_fp(out, BIO_NOCLOSE)) == NULL) {
CONFerr(CONF_F_CONF_DUMP_FP, ERR_R_BUF_LIB);
return 0;
}
{
BIO *btmp;
int ret;
- if (!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) {
+ if ((btmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) {
CONFerr(CONF_F_NCONF_LOAD_FP, ERR_R_BUF_LIB);
return 0;
}
{
BIO *btmp;
int ret;
- if (!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) {
+ if ((btmp = BIO_new_fp(out, BIO_NOCLOSE)) == NULL) {
CONFerr(CONF_F_NCONF_DUMP_FP, ERR_R_BUF_LIB);
return 0;
}
pm = pstr->data;
pmlen = pstr->length;
- if (!(dh = d2i_dhp(pkey, &pm, pmlen))) {
+ if ((dh = d2i_dhp(pkey, &pm, pmlen)) == NULL) {
DHerr(DH_F_DH_PUB_DECODE, DH_R_DECODE_ERROR);
goto err;
}
- if (!(public_key = d2i_ASN1_INTEGER(NULL, &p, pklen))) {
+ if ((public_key = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL) {
DHerr(DH_F_DH_PUB_DECODE, DH_R_DECODE_ERROR);
goto err;
}
/* We have parameters now set public key */
- if (!(dh->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) {
+ if ((dh->pub_key = ASN1_INTEGER_to_BN(public_key, NULL)) == NULL) {
DHerr(DH_F_DH_PUB_DECODE, DH_R_BN_DECODE_ERROR);
goto err;
}
if (ptype != V_ASN1_SEQUENCE)
goto decerr;
-
- if (!(privkey = d2i_ASN1_INTEGER(NULL, &p, pklen)))
+ if ((privkey = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL)
goto decerr;
pstr = pval;
pm = pstr->data;
pmlen = pstr->length;
- if (!(dh = d2i_dhp(pkey, &pm, pmlen)))
+ if ((dh = d2i_dhp(pkey, &pm, pmlen)) == NULL)
goto decerr;
+
/* We have parameters now set private key */
- if (!(dh->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) {
+ if ((dh->priv_key = ASN1_INTEGER_to_BN(privkey, NULL)) == NULL) {
DHerr(DH_F_DH_PRIV_DECODE, DH_R_BN_ERROR);
goto dherr;
}
const unsigned char **pder, int derlen)
{
DH *dh;
- if (!(dh = d2i_dhp(pkey, pder, derlen))) {
+
+ if ((dh = d2i_dhp(pkey, pder, derlen)) == NULL) {
DHerr(DH_F_DH_PARAM_DECODE, ERR_R_DH_LIB);
return 0;
}
if (!p || !plen)
goto err;
- if (!(public_key = d2i_ASN1_INTEGER(NULL, &p, plen))) {
+ if ((public_key = d2i_ASN1_INTEGER(NULL, &p, plen)) == NULL) {
DHerr(DH_F_DH_CMS_SET_PEERKEY, DH_R_DECODE_ERROR);
goto err;
}
/* We have parameters now set public key */
- if (!(dhpeer->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) {
+ if ((dhpeer->pub_key = ASN1_INTEGER_to_BN(public_key, NULL)) == NULL) {
DHerr(DH_F_DH_CMS_SET_PEERKEY, DH_R_BN_DECODE_ERROR);
goto err;
}
pm = pstr->data;
pmlen = pstr->length;
- if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) {
+ if ((dsa = d2i_DSAparams(NULL, &pm, pmlen)) == NULL) {
DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR);
goto err;
}
} else if ((ptype == V_ASN1_NULL) || (ptype == V_ASN1_UNDEF)) {
- if (!(dsa = DSA_new())) {
+ if ((dsa = DSA_new()) == NULL) {
DSAerr(DSA_F_DSA_PUB_DECODE, ERR_R_MALLOC_FAILURE);
goto err;
}
goto err;
}
- if (!(public_key = d2i_ASN1_INTEGER(NULL, &p, pklen))) {
+ if ((public_key = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL) {
DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR);
goto err;
}
- if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) {
+ if ((dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL)) == NULL) {
DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_BN_DECODE_ERROR);
goto err;
}
/* Check for broken DSA PKCS#8, UGH! */
if (*p == (V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED)) {
ASN1_TYPE *t1, *t2;
- if (!(ndsa = d2i_ASN1_SEQUENCE_ANY(NULL, &p, pklen)))
+ if ((ndsa = d2i_ASN1_SEQUENCE_ANY(NULL, &p, pklen)) == NULL)
goto decerr;
if (sk_ASN1_TYPE_num(ndsa) != 2)
goto decerr;
privkey = t2->value.integer;
} else {
const unsigned char *q = p;
- if (!(privkey = d2i_ASN1_INTEGER(NULL, &p, pklen)))
+ if ((privkey = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL)
goto decerr;
if (privkey->type == V_ASN1_NEG_INTEGER) {
p8->broken = PKCS8_NEG_PRIVKEY;
ASN1_STRING_clear_free(privkey);
- if (!(privkey = d2i_ASN1_UINTEGER(NULL, &q, pklen)))
+ if ((privkey = d2i_ASN1_UINTEGER(NULL, &q, pklen)) == NULL)
goto decerr;
}
if (ptype != V_ASN1_SEQUENCE)
pstr = pval;
pm = pstr->data;
pmlen = pstr->length;
- if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen)))
+ if ((dsa = d2i_DSAparams(NULL, &pm, pmlen)) == NULL)
goto decerr;
/* We have parameters now set private key */
- if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) {
+ if ((dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL)) == NULL) {
DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_BN_ERROR);
goto dsaerr;
}
/* Calculate public key */
- if (!(dsa->pub_key = BN_new())) {
+ if ((dsa->pub_key = BN_new()) == NULL) {
DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE);
goto dsaerr;
}
- if (!(ctx = BN_CTX_new())) {
+ if ((ctx = BN_CTX_new()) == NULL) {
DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE);
goto dsaerr;
}
const unsigned char **pder, int derlen)
{
DSA *dsa;
- if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) {
+
+ if ((dsa = d2i_DSAparams(NULL, pder, derlen)) == NULL) {
DSAerr(DSA_F_DSA_PARAM_DECODE, ERR_R_DSA_LIB);
return 0;
}
const unsigned char **pder, int derlen)
{
DSA *dsa;
- if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) {
+
+ if ((dsa = d2i_DSAPrivateKey(NULL, pder, derlen)) == NULL) {
DSAerr(DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB);
return 0;
}
int pmlen;
pm = pstr->data;
pmlen = pstr->length;
- if (!(eckey = d2i_ECParameters(NULL, &pm, pmlen))) {
+ if ((eckey = d2i_ECParameters(NULL, &pm, pmlen)) == NULL) {
ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR);
goto ecerr;
}
const unsigned char **pder, int derlen)
{
EC_KEY *eckey;
- if (!(eckey = d2i_ECParameters(NULL, pder, derlen))) {
+
+ if ((eckey = d2i_ECParameters(NULL, pder, derlen)) == NULL) {
ECerr(EC_F_ECKEY_PARAM_DECODE, ERR_R_EC_LIB);
return 0;
}
const unsigned char **pder, int derlen)
{
EC_KEY *ec;
- if (!(ec = d2i_ECPrivateKey(NULL, pder, derlen))) {
+
+ if ((ec = d2i_ECPrivateKey(NULL, pder, derlen)) == NULL) {
ECerr(EC_F_OLD_EC_PRIV_DECODE, EC_R_DECODE_ERROR);
return 0;
}
/* extract seed (optional) */
if (params->curve->seed != NULL) {
OPENSSL_free(ret->seed);
- if (!(ret->seed = OPENSSL_malloc(params->curve->seed->length))) {
+ if ((ret->seed = OPENSSL_malloc(params->curve->seed->length)) == NULL) {
ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE);
goto err;
}
params = (const unsigned char *)(data + 1); /* skip header */
params += seed_len; /* skip seed */
- if (!(p = BN_bin2bn(params + 0 * param_len, param_len, NULL))
- || !(a = BN_bin2bn(params + 1 * param_len, param_len, NULL))
- || !(b = BN_bin2bn(params + 2 * param_len, param_len, NULL))) {
+ if ((p = BN_bin2bn(params + 0 * param_len, param_len, NULL)) == NULL
+ || (a = BN_bin2bn(params + 1 * param_len, param_len, NULL)) == NULL
+ || (b = BN_bin2bn(params + 2 * param_len, param_len, NULL)) == NULL) {
ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB);
goto err;
}
goto err;
}
- if (!(x = BN_bin2bn(params + 3 * param_len, param_len, NULL))
- || !(y = BN_bin2bn(params + 4 * param_len, param_len, NULL))) {
+ if ((x = BN_bin2bn(params + 3 * param_len, param_len, NULL)) == NULL
+ || (y = BN_bin2bn(params + 4 * param_len, param_len, NULL)) == NULL) {
ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB);
goto err;
}
ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB);
goto err;
}
- if (!(order = BN_bin2bn(params + 5 * param_len, param_len, NULL))
+ if ((order = BN_bin2bn(params + 5 * param_len, param_len, NULL)) == NULL
|| !BN_set_word(x, (BN_ULONG)data->cofactor)) {
ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB);
goto err;
goto err;
}
- if (!(tmp = EC_POINT_new(group)))
+ if ((tmp = EC_POINT_new(group)) == NULL)
goto err;
/*-
}
}
- if (!(tmp_point = EC_POINT_new(group)) || !(base = EC_POINT_new(group))) {
+ if ((tmp_point = EC_POINT_new(group)) == NULL
+ || (base = EC_POINT_new(group)) == NULL) {
ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE);
goto err;
}
return EVP_PKEY_CTX_set_ec_param_enc(ctx, param_enc);
} else if (strcmp(type, "ecdh_kdf_md") == 0) {
const EVP_MD *md;
- if (!(md = EVP_get_digestbyname(value))) {
+ if ((md = EVP_get_digestbyname(value)) == NULL) {
ECerr(EC_F_PKEY_EC_CTRL_STR, EC_R_INVALID_DIGEST);
return 0;
}
const char *oid_section;
STACK_OF(CONF_VALUE) *sktmp;
CONF_VALUE *oval;
+
oid_section = CONF_imodule_get_value(md);
- if (!(sktmp = NCONF_get_section(cnf, oid_section))) {
+ if ((sktmp = NCONF_get_section(cnf, oid_section)) == NULL) {
EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_ERROR_LOADING_SECTION);
return 0;
}
{
EVP_PBE_CTL *pbe_tmp;
- if (!pbe_algs)
+ if (pbe_algs == NULL)
pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp);
- if (!(pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp)))) {
+ if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL) {
EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE);
return 0;
}
EVP_PBE_KEYGEN *keygen)
{
int cipher_nid, md_nid;
+
if (cipher)
cipher_nid = EVP_CIPHER_nid(cipher);
else
if (!PKCS8_pkey_get0(&algoid, NULL, NULL, NULL, p8))
return NULL;
- if (!(pkey = EVP_PKEY_new())) {
+ if ((pkey = EVP_PKEY_new()) == NULL) {
EVPerr(EVP_F_EVP_PKCS82PKEY, ERR_R_MALLOC_FAILURE);
return NULL;
}
{
PKCS8_PRIV_KEY_INFO *p8;
- if (!(p8 = PKCS8_PRIV_KEY_INFO_new())) {
+ if ((p8 = PKCS8_PRIV_KEY_INFO_new()) == NULL) {
EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN, ERR_R_MALLOC_FAILURE);
return NULL;
}
}
if (strcmp(name, "digest") == 0) {
const EVP_MD *md;
- if (!value || !(md = EVP_get_digestbyname(value))) {
+ if (value == NULL || (md = EVP_get_digestbyname(value)) == NULL) {
EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR, EVP_R_INVALID_DIGEST);
return 0;
}
return (0);
if ((o = OBJ_dup(obj)) == NULL)
goto err;
- if (!(ao[ADDED_NID] = OPENSSL_malloc(sizeof(*ao))))
+ if ((ao[ADDED_NID] = OPENSSL_malloc(sizeof(*ao))) == NULL)
goto err2;
if ((o->length != 0) && (obj->data != NULL))
- if (!(ao[ADDED_DATA] = OPENSSL_malloc(sizeof(*ao))))
+ if ((ao[ADDED_DATA] = OPENSSL_malloc(sizeof(*ao))) == NULL)
goto err2;
if (o->sn != NULL)
- if (!(ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(*ao))))
+ if ((ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(*ao))) == NULL)
goto err2;
if (o->ln != NULL)
- if (!(ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(*ao))))
+ if ((ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(*ao))) == NULL)
goto err2;
for (i = ADDED_DATA; i <= ADDED_NID; i++) {
if (!(c & 0x80))
break;
if (!use_bn && (l > (ULONG_MAX >> 7L))) {
- if (!bl && !(bl = BN_new()))
+ if (bl == NULL && (bl = BN_new()) == NULL)
goto err;
if (!BN_set_word(bl, l))
goto err;
{
OCSP_ONEREQ *one = NULL;
- if (!(one = OCSP_ONEREQ_new()))
+ if ((one = OCSP_ONEREQ_new()) == NULL)
goto err;
OCSP_CERTID_free(one->reqCert);
one->reqCert = cid;
return 0;
if (!cert)
return 1;
- if (!sig->certs && !(sig->certs = sk_X509_new_null()))
+ if (sig->certs == NULL
+ && (sig->certs = sk_X509_new_null()) == NULL)
return 0;
if (!sk_X509_push(sig->certs, cert))
if (!OCSP_request_set1_name(req, X509_get_subject_name(signer)))
goto err;
- if (!(req->optionalSignature = OCSP_SIGNATURE_new()))
+ if ((req->optionalSignature = OCSP_SIGNATURE_new()) == NULL)
goto err;
if (key) {
if (!X509_check_private_key(signer, key)) {
X509_EXTENSION *x = NULL;
OCSP_CRLID *cid = NULL;
- if (!(cid = OCSP_CRLID_new()))
+ if ((cid = OCSP_CRLID_new()) == NULL)
goto err;
if (url) {
- if (!(cid->crlUrl = ASN1_IA5STRING_new()))
+ if ((cid->crlUrl = ASN1_IA5STRING_new()) == NULL)
goto err;
if (!(ASN1_STRING_set(cid->crlUrl, url, -1)))
goto err;
}
if (n) {
- if (!(cid->crlNum = ASN1_INTEGER_new()))
+ if ((cid->crlNum = ASN1_INTEGER_new()) == NULL)
goto err;
if (!(ASN1_INTEGER_set(cid->crlNum, *n)))
goto err;
}
if (tim) {
- if (!(cid->crlTime = ASN1_GENERALIZEDTIME_new()))
+ if ((cid->crlTime = ASN1_GENERALIZEDTIME_new()) == NULL)
goto err;
if (!(ASN1_GENERALIZEDTIME_set_string(cid->crlTime, tim)))
goto err;
ASN1_OBJECT *o = NULL;
X509_EXTENSION *x = NULL;
- if (!(sk = sk_ASN1_OBJECT_new_null()))
+ if ((sk = sk_ASN1_OBJECT_new_null()) == NULL)
goto err;
while (oids && *oids) {
if ((nid = OBJ_txt2nid(*oids)) != NID_undef && (o = OBJ_nid2obj(nid)))
X509_EXTENSION *x = NULL;
ASN1_GENERALIZEDTIME *gt = NULL;
- if (!(gt = ASN1_GENERALIZEDTIME_new()))
+ if ((gt = ASN1_GENERALIZEDTIME_new()) == NULL)
goto err;
if (!(ASN1_GENERALIZEDTIME_set_string(gt, tim)))
goto err;
OCSP_SERVICELOC *sloc = NULL;
ACCESS_DESCRIPTION *ad = NULL;
- if (!(sloc = OCSP_SERVICELOC_new()))
+ if ((sloc = OCSP_SERVICELOC_new()) == NULL)
goto err;
- if (!(sloc->issuer = X509_NAME_dup(issuer)))
+ if ((sloc->issuer = X509_NAME_dup(issuer)) == NULL)
goto err;
- if (urls && *urls && !(sloc->locator = sk_ACCESS_DESCRIPTION_new_null()))
+ if (urls && *urls
+ && (sloc->locator = sk_ACCESS_DESCRIPTION_new_null()) == NULL)
goto err;
while (urls && *urls) {
- if (!(ad = ACCESS_DESCRIPTION_new()))
+ if ((ad = ACCESS_DESCRIPTION_new()) == NULL)
goto err;
- if (!(ad->method = OBJ_nid2obj(NID_ad_OCSP)))
+ if ((ad->method = OBJ_nid2obj(NID_ad_OCSP)) == NULL)
goto err;
- if (!(ad->location = GENERAL_NAME_new()))
+ if ((ad->location = GENERAL_NAME_new()) == NULL)
goto err;
- if (!(ia5 = ASN1_IA5STRING_new()))
+ if ((ia5 = ASN1_IA5STRING_new()) == NULL)
goto err;
if (!ASN1_STRING_set((ASN1_STRING *)ia5, *urls, -1))
goto err;
OCSP_CERTID *cid = NULL;
unsigned char md[EVP_MAX_MD_SIZE];
- if (!(cid = OCSP_CERTID_new()))
+ if ((cid = OCSP_CERTID_new()) == NULL)
goto err;
alg = cid->hashAlgorithm;
OCSPerr(OCSP_F_OCSP_CERT_ID_NEW, OCSP_R_UNKNOWN_NID);
goto err;
}
- if (!(alg->algorithm = OBJ_nid2obj(nid)))
+ if ((alg->algorithm = OBJ_nid2obj(nid)) == NULL)
goto err;
if ((alg->parameter = ASN1_TYPE_new()) == NULL)
goto err;
if (serialNumber) {
ASN1_INTEGER_free(cid->serialNumber);
- if (!(cid->serialNumber = ASN1_INTEGER_dup(serialNumber)))
+ if ((cid->serialNumber = ASN1_INTEGER_dup(serialNumber)) == NULL)
goto err;
}
return cid;
}
i = ASN1_STRING_length(rb->response);
- if (!(br = OCSP_response_get1_basic(o)))
+ if ((br = OCSP_response_get1_basic(o)) == NULL)
goto err;
rd = br->tbsResponseData;
l = ASN1_INTEGER_get(rd->version);
{
OCSP_RESPONSE *rsp = NULL;
- if (!(rsp = OCSP_RESPONSE_new()))
+ if ((rsp = OCSP_RESPONSE_new()) == NULL)
goto err;
if (!(ASN1_ENUMERATED_set(rsp->responseStatus, status)))
goto err;
if (!bs)
return rsp;
- if (!(rsp->responseBytes = OCSP_RESPBYTES_new()))
+ if ((rsp->responseBytes = OCSP_RESPBYTES_new()) == NULL)
goto err;
rsp->responseBytes->responseType = OBJ_nid2obj(NID_id_pkix_OCSP_basic);
if (!ASN1_item_pack
OCSP_CERTSTATUS *cs;
OCSP_REVOKEDINFO *ri;
- if (!rsp->tbsResponseData->responses &&
- !(rsp->tbsResponseData->responses = sk_OCSP_SINGLERESP_new_null()))
+ if (rsp->tbsResponseData->responses == NULL
+ && (rsp->tbsResponseData->responses
+ = sk_OCSP_SINGLERESP_new_null()) == NULL)
goto err;
- if (!(single = OCSP_SINGLERESP_new()))
+ if ((single = OCSP_SINGLERESP_new()) == NULL)
goto err;
if (!ASN1_TIME_to_generalizedtime(thisupd, &single->thisUpdate))
OCSP_CERTID_free(single->certId);
- if (!(single->certId = OCSP_CERTID_dup(cid)))
+ if ((single->certId = OCSP_CERTID_dup(cid)) == NULL)
goto err;
cs = single->certStatus;
OCSPerr(OCSP_F_OCSP_BASIC_ADD1_STATUS, OCSP_R_NO_REVOKED_TIME);
goto err;
}
- if (!(cs->value.revoked = ri = OCSP_REVOKEDINFO_new()))
+ if ((cs->value.revoked = ri = OCSP_REVOKEDINFO_new()) == NULL)
goto err;
if (!ASN1_TIME_to_generalizedtime(revtime, &ri->revocationTime))
goto err;
if (reason != OCSP_REVOKED_STATUS_NOSTATUS) {
- if (!(ri->revocationReason = ASN1_ENUMERATED_new()))
+ if ((ri->revocationReason = ASN1_ENUMERATED_new()) == NULL)
goto err;
if (!(ASN1_ENUMERATED_set(ri->revocationReason, reason)))
goto err;
int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert)
{
- if (!resp->certs && !(resp->certs = sk_X509_new_null()))
+ if (resp->certs == NULL
+ && (resp->certs = sk_X509_new_null()) == NULL)
return 0;
if (!sk_X509_push(resp->certs, cert))
if (flags & OCSP_RESPID_KEY) {
unsigned char md[SHA_DIGEST_LENGTH];
X509_pubkey_digest(signer, EVP_sha1(), md, NULL);
- if (!(rid->value.byKey = ASN1_OCTET_STRING_new()))
+ if ((rid->value.byKey = ASN1_OCTET_STRING_new()) == NULL)
goto err;
if (!(ASN1_OCTET_STRING_set(rid->value.byKey, md, SHA_DIGEST_LENGTH)))
goto err;
X509_NAME *iname;
int mdlen;
unsigned char md[EVP_MAX_MD_SIZE];
- if (!(dgst = EVP_get_digestbyobj(cid->hashAlgorithm->algorithm))) {
+ if ((dgst = EVP_get_digestbyobj(cid->hashAlgorithm->algorithm))
+ == NULL) {
OCSPerr(OCSP_F_OCSP_MATCH_ISSUERID,
OCSP_R_UNKNOWN_MESSAGE_DIGEST);
return -1;
PKCS8_PRIV_KEY_INFO *p8inf;
char buf[PEM_BUFSIZE];
int ret;
- if (!(p8inf = EVP_PKEY2PKCS8(x))) {
+
+ if ((p8inf = EVP_PKEY2PKCS8(x)) == NULL) {
PEMerr(PEM_F_DO_PK8PKEY, PEM_R_ERROR_CONVERTING_PRIVATE_KEY);
return 0;
}
{
BIO *bp;
int ret;
- if (!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
+
+ if ((bp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) {
PEMerr(PEM_F_DO_PK8PKEY_FP, ERR_R_BUF_LIB);
return (0);
}
{
BIO *bp;
EVP_PKEY *ret;
- if (!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
+
+ if ((bp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) {
PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_FP, ERR_R_BUF_LIB);
return NULL;
}
if (!read_lebn(&p, 20, &dsa->priv_key))
goto memerr;
/* Calculate public key */
- if (!(dsa->pub_key = BN_new()))
+ if ((dsa->pub_key = BN_new()) == NULL)
goto memerr;
- if (!(ctx = BN_CTX_new()))
+ if ((ctx = BN_CTX_new()) == NULL)
goto memerr;
if (!BN_mod_exp(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx))
-
goto memerr;
BN_CTX_free(ctx);
}
{
PKCS12_BAGS *bag;
PKCS12_SAFEBAG *safebag;
- if (!(bag = PKCS12_BAGS_new())) {
+
+ if ((bag = PKCS12_BAGS_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE);
return NULL;
}
PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE);
return NULL;
}
- if (!(safebag = PKCS12_SAFEBAG_new())) {
+ if ((safebag = PKCS12_SAFEBAG_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE);
return NULL;
}
PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8)
{
PKCS12_SAFEBAG *bag;
- if (!(bag = PKCS12_SAFEBAG_new())) {
+
+ if ((bag = PKCS12_SAFEBAG_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_MAKE_KEYBAG, ERR_R_MALLOC_FAILURE);
return NULL;
}
const EVP_CIPHER *pbe_ciph;
/* Set up the safe bag */
- if (!(bag = PKCS12_SAFEBAG_new())) {
+ if ((bag = PKCS12_SAFEBAG_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE);
return NULL;
}
PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk)
{
PKCS7 *p7;
- if (!(p7 = PKCS7_new())) {
+
+ if ((p7 = PKCS7_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE);
return NULL;
}
p7->type = OBJ_nid2obj(NID_pkcs7_data);
- if (!(p7->d.data = ASN1_OCTET_STRING_new())) {
+ if ((p7->d.data = ASN1_OCTET_STRING_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE);
return NULL;
}
PKCS7 *p7;
X509_ALGOR *pbe;
const EVP_CIPHER *pbe_ciph;
- if (!(p7 = PKCS7_new())) {
+
+ if ((p7 = PKCS7_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
return NULL;
}
char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag)
{
ASN1_TYPE *atype;
- if (!(atype = PKCS12_get_attr(bag, NID_friendlyName)))
+
+ if ((atype = PKCS12_get_attr(bag, NID_friendlyName)) == NULL)
return NULL;
if (atype->type != V_ASN1_BMPSTRING)
return NULL;
int keyidlen = -1;
/* Add user certificate */
- if (!(bag = PKCS12_x5092certbag(cert)))
+ if ((bag = PKCS12_x5092certbag(cert)) == NULL)
goto err;
/*
PKCS8_PRIV_KEY_INFO *p8 = NULL;
/* Make a PKCS#8 structure */
- if (!(p8 = EVP_PKEY2PKCS8(key)))
+ if ((p8 = EVP_PKEY2PKCS8(key)) == NULL)
goto err;
if (key_usage && !PKCS8_add_keyusage(p8, key_usage))
goto err;
return NULL;
}
- if (!(out = OPENSSL_malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx)))) {
+ if ((out = OPENSSL_malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx)))
+ == NULL) {
PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, ERR_R_MALLOC_FAILURE);
goto err;
}
ASN1_OCTET_STRING *oct = NULL;
unsigned char *in = NULL;
int inlen;
- if (!(oct = ASN1_OCTET_STRING_new())) {
+
+ if ((oct = ASN1_OCTET_STRING_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, ERR_R_MALLOC_FAILURE);
goto err;
}
PKCS12 *PKCS12_init(int mode)
{
PKCS12 *pkcs12;
- if (!(pkcs12 = PKCS12_new())) {
+
+ if ((pkcs12 = PKCS12_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE);
return NULL;
}
pkcs12->authsafes->type = OBJ_nid2obj(mode);
switch (mode) {
case NID_pkcs7_data:
- if (!(pkcs12->authsafes->d.data = ASN1_OCTET_STRING_new())) {
+ if ((pkcs12->authsafes->d.data = ASN1_OCTET_STRING_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE);
goto err;
}
int i, bagnid;
PKCS7 *p7;
- if (!(asafes = PKCS12_unpack_authsafes(p12)))
+ if ((asafes = PKCS12_unpack_authsafes(p12)) == NULL)
return 0;
for (i = 0; i < sk_PKCS7_num(asafes); i++) {
p7 = sk_PKCS7_value(asafes, i);
case NID_keyBag:
if (!pkey || *pkey)
return 1;
- if (!(*pkey = EVP_PKCS82PKEY(bag->value.keybag)))
+ if ((*pkey = EVP_PKCS82PKEY(bag->value.keybag)) == NULL)
return 0;
break;
case NID_pkcs8ShroudedKeyBag:
if (!pkey || *pkey)
return 1;
- if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen)))
+ if ((p8 = PKCS12_decrypt_skey(bag, pass, passlen)) == NULL)
return 0;
*pkey = EVP_PKCS82PKEY(p8);
PKCS8_PRIV_KEY_INFO_free(p8);
case NID_certBag:
if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate)
return 1;
- if (!(x509 = PKCS12_certbag2x509(bag)))
+ if ((x509 = PKCS12_certbag2x509(bag)) == NULL)
return 0;
if (lkid && !X509_keyid_set1(x509, lkid->data, lkid->length)) {
X509_free(x509);
iter = 1;
else
iter = ASN1_INTEGER_get(p12->mac->iter);
- if (!(md_type = EVP_get_digestbyobj(p12->mac->dinfo->algor->algorithm))) {
+ if ((md_type = EVP_get_digestbyobj(p12->mac->dinfo->algor->algorithm))
+ == NULL) {
PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_UNKNOWN_DIGEST_ALGORITHM);
return 0;
}
int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen,
const EVP_MD *md_type)
{
- if (!(p12->mac = PKCS12_MAC_DATA_new()))
+ if ((p12->mac = PKCS12_MAC_DATA_new()) == NULL)
return PKCS12_ERROR;
if (iter > 1) {
- if (!(p12->mac->iter = ASN1_INTEGER_new())) {
+ if ((p12->mac->iter = ASN1_INTEGER_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
return 0;
}
if (!saltlen)
saltlen = PKCS12_SALT_LEN;
p12->mac->salt->length = saltlen;
- if (!(p12->mac->salt->data = OPENSSL_malloc(saltlen))) {
+ if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) {
PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
return 0;
}
} else
memcpy(p12->mac->salt->data, salt, saltlen);
p12->mac->dinfo->algor->algorithm = OBJ_nid2obj(EVP_MD_type(md_type));
- if (!(p12->mac->dinfo->algor->parameter = ASN1_TYPE_new())) {
+ if ((p12->mac->dinfo->algor->parameter = ASN1_TYPE_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
return 0;
}
unsigned char mac[EVP_MAX_MD_SIZE];
unsigned int maclen;
- if (!(asafes = PKCS12_unpack_authsafes(p12)))
+ if ((asafes = PKCS12_unpack_authsafes(p12)) == NULL)
return 0;
- if (!(newsafes = sk_PKCS7_new_null()))
+ if ((newsafes = sk_PKCS7_new_null()) == NULL)
return 0;
for (i = 0; i < sk_PKCS7_num(asafes); i++) {
p7 = sk_PKCS7_value(asafes, i);
/* Repack safe: save old safe in case of error */
p12_data_tmp = p12->authsafes->d.data;
- if (!(p12->authsafes->d.data = ASN1_OCTET_STRING_new()))
+ if ((p12->authsafes->d.data = ASN1_OCTET_STRING_new()) == NULL)
goto saferr;
if (!PKCS12_pack_authsafes(p12, newsafes))
goto saferr;
if (!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen))
goto saferr;
- if (!(macnew = ASN1_OCTET_STRING_new()))
+ if ((macnew = ASN1_OCTET_STRING_new()) == NULL)
goto saferr;
if (!ASN1_OCTET_STRING_set(macnew, mac, maclen))
goto saferr;
if (M_PKCS12_bag_type(bag) != NID_pkcs8ShroudedKeyBag)
return 1;
- if (!(p8 = PKCS8_decrypt(bag->value.shkeybag, oldpass, -1)))
+ if ((p8 = PKCS8_decrypt(bag->value.shkeybag, oldpass, -1)) == NULL)
return 0;
if (!alg_get(bag->value.shkeybag->algor, &p8_nid, &p8_iter, &p8_saltlen))
return 0;
- if (!(p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen,
- p8_iter, p8)))
+ if ((p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen,
+ p8_iter, p8)) == NULL)
return 0;
X509_SIG_free(bag->value.shkeybag);
bag->value.shkeybag = p8new;
unsigned char *salt, int saltlen, int iter,
PKCS8_PRIV_KEY_INFO *p8inf)
{
- X509_SIG *p8 = NULL;
+ X509_SIG *p8;
X509_ALGOR *pbe;
- if (!(p8 = X509_SIG_new())) {
+ if ((p8 = X509_SIG_new()) == NULL) {
PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE);
goto err;
}
{
int ulen, i;
unsigned char *unitmp;
+
if (asclen == -1)
asclen = strlen(asc);
ulen = asclen * 2 + 2;
- if (!(unitmp = OPENSSL_malloc(ulen)))
+ if ((unitmp = OPENSSL_malloc(ulen)) == NULL)
return NULL;
for (i = 0; i < ulen - 2; i += 2) {
unitmp[i] = 0;
{
int asclen, i;
char *asctmp;
+
asclen = unilen / 2;
/* If no terminating zero allow for one */
if (!unilen || uni[unilen - 1])
asclen++;
uni++;
- if (!(asctmp = OPENSSL_malloc(asclen)))
+ if ((asctmp = OPENSSL_malloc(asclen)) == NULL)
return NULL;
for (i = 0; i < unilen; i += 2)
asctmp[i >> 1] = uni[i];
STACK_OF(X509_ALGOR) *cap)
{
ASN1_STRING *seq;
- if (!(seq = ASN1_STRING_new())) {
+
+ if ((seq = ASN1_STRING_new()) == NULL) {
PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP, ERR_R_MALLOC_FAILURE);
return 0;
}
const unsigned char *p;
cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities);
- if (!cap || (cap->type != V_ASN1_SEQUENCE))
+ if (cap == NULL || (cap->type != V_ASN1_SEQUENCE))
return NULL;
p = cap->value.sequence->data;
return (STACK_OF(X509_ALGOR) *)
{
X509_ALGOR *alg;
- if (!(alg = X509_ALGOR_new())) {
+ if ((alg = X509_ALGOR_new()) == NULL) {
PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE);
return 0;
}
alg->algorithm = OBJ_nid2obj(nid);
if (arg > 0) {
ASN1_INTEGER *nbit;
- if (!(alg->parameter = ASN1_TYPE_new())) {
+ if ((alg->parameter = ASN1_TYPE_new()) == NULL) {
PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE);
return 0;
}
- if (!(nbit = ASN1_INTEGER_new())) {
+ if ((nbit = ASN1_INTEGER_new()) == NULL) {
PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE);
return 0;
}
int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t)
{
- if (!t && !(t = X509_gmtime_adj(NULL, 0))) {
+ if (t == NULL && (t = X509_gmtime_adj(NULL, 0)) == NULL) {
PKCS7err(PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME,
ERR_R_MALLOC_FAILURE);
return 0;
ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk)
{
ASN1_TYPE *astype;
- if (!(astype = get_attribute(sk, NID_pkcs9_messageDigest)))
+ if ((astype = get_attribute(sk, NID_pkcs9_messageDigest)) == NULL)
return NULL;
return astype->value.octet_string;
}
X509_ATTRIBUTE *attr = NULL;
if (*sk == NULL) {
- *sk = sk_X509_ATTRIBUTE_new_null();
- if (*sk == NULL)
+ if ((*sk = sk_X509_ATTRIBUTE_new_null()) == NULL)
return 0;
new_attrib:
- if (!(attr = X509_ATTRIBUTE_create(nid, atrtype, value)))
+ if ((attr = X509_ATTRIBUTE_create(nid, atrtype, value)) == NULL)
return 0;
if (!sk_X509_ATTRIBUTE_push(*sk, attr)) {
X509_ATTRIBUTE_free(attr);
}
}
if (!j) { /* we need to add another algorithm */
- if (!(alg = X509_ALGOR_new())
- || !(alg->parameter = ASN1_TYPE_new())) {
+ if ((alg = X509_ALGOR_new()) == NULL
+ || (alg->parameter = ASN1_TYPE_new()) == NULL) {
X509_ALGOR_free(alg);
PKCS7err(PKCS7_F_PKCS7_ADD_SIGNER, ERR_R_MALLOC_FAILURE);
return (0);
int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md)
{
if (PKCS7_type_is_digest(p7)) {
- if (!(p7->d.digest->md->parameter = ASN1_TYPE_new())) {
+ if ((p7->d.digest->md->parameter = ASN1_TYPE_new()) == NULL) {
PKCS7err(PKCS7_F_PKCS7_SET_DIGEST, ERR_R_MALLOC_FAILURE);
return 0;
}
PKCS7 *p7;
int i;
- if (!(p7 = PKCS7_new())) {
+ if ((p7 = PKCS7_new()) == NULL) {
PKCS7err(PKCS7_F_PKCS7_SIGN, ERR_R_MALLOC_FAILURE);
return NULL;
}
{
BIO *p7bio;
int ret = 0;
- if (!(p7bio = PKCS7_dataInit(p7, NULL))) {
+ if ((p7bio = PKCS7_dataInit(p7, NULL)) == NULL) {
PKCS7err(PKCS7_F_PKCS7_FINAL, ERR_R_MALLOC_FAILURE);
return 0;
}
return NULL;
}
- if (!(si = PKCS7_add_signature(p7, signcert, pkey, md))) {
+ if ((si = PKCS7_add_signature(p7, signcert, pkey, md)) == NULL) {
PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER,
PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR);
return NULL;
goto err;
/* Add SMIMECapabilities */
if (!(flags & PKCS7_NOSMIMECAP)) {
- if (!(smcap = sk_X509_ALGOR_new_null())) {
+ if ((smcap = sk_X509_ALGOR_new_null()) == NULL) {
PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER, ERR_R_MALLOC_FAILURE);
goto err;
}
} else
tmpin = indata;
- if (!(p7bio = PKCS7_dataInit(p7, tmpin)))
+ if ((p7bio = PKCS7_dataInit(p7, tmpin)) == NULL)
goto err;
if (flags & PKCS7_TEXT) {
- if (!(tmpout = BIO_new(BIO_s_mem()))) {
+ if ((tmpout = BIO_new(BIO_s_mem())) == NULL) {
PKCS7err(PKCS7_F_PKCS7_VERIFY, ERR_R_MALLOC_FAILURE);
goto err;
}
return 0;
}
- if (!(signers = sk_X509_new_null())) {
+ if ((signers = sk_X509_new_null()) == NULL) {
PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS, ERR_R_MALLOC_FAILURE);
return NULL;
}
BIO *p7bio = NULL;
int i;
X509 *x509;
- if (!(p7 = PKCS7_new())) {
+ if ((p7 = PKCS7_new()) == NULL) {
PKCS7err(PKCS7_F_PKCS7_ENCRYPT, ERR_R_MALLOC_FAILURE);
return NULL;
}
return 0;
}
- if (!(tmpmem = PKCS7_dataDecode(p7, pkey, NULL, cert))) {
+ if ((tmpmem = PKCS7_dataDecode(p7, pkey, NULL, cert)) == NULL) {
PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_DECRYPT_ERROR);
return 0;
}
if (flags & PKCS7_TEXT) {
BIO *tmpbuf, *bread;
/* Encrypt BIOs can't do BIO_gets() so add a buffer BIO */
- if (!(tmpbuf = BIO_new(BIO_f_buffer()))) {
+ if ((tmpbuf = BIO_new(BIO_f_buffer())) == NULL) {
PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE);
BIO_free_all(tmpmem);
return 0;
}
- if (!(bread = BIO_push(tmpbuf, tmpmem))) {
+ if ((bread = BIO_push(tmpbuf, tmpmem)) == NULL) {
PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE);
BIO_free_all(tmpbuf);
BIO_free_all(tmpmem);
const unsigned char *p;
int pklen;
RSA *rsa = NULL;
+
if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, NULL, pubkey))
return 0;
- if (!(rsa = d2i_RSAPublicKey(NULL, &p, pklen))) {
+ if ((rsa = d2i_RSAPublicKey(NULL, &p, pklen)) == NULL) {
RSAerr(RSA_F_RSA_PUB_DECODE, ERR_R_RSA_LIB);
return 0;
}
const unsigned char **pder, int derlen)
{
RSA *rsa;
- if (!(rsa = d2i_RSAPrivateKey(NULL, pder, derlen))) {
+
+ if ((rsa = d2i_RSAPrivateKey(NULL, pder, derlen)) == NULL) {
RSAerr(RSA_F_OLD_RSA_PRIV_DECODE, ERR_R_RSA_LIB);
return 0;
}
if (strcmp(type, "rsa_mgf1_md") == 0) {
const EVP_MD *md;
- if (!(md = EVP_get_digestbyname(value))) {
+ if ((md = EVP_get_digestbyname(value)) == NULL) {
RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_INVALID_DIGEST);
return 0;
}
if (strcmp(type, "rsa_oaep_md") == 0) {
const EVP_MD *md;
- if (!(md = EVP_get_digestbyname(value))) {
+ if ((md = EVP_get_digestbyname(value)) == NULL) {
RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_INVALID_DIGEST);
return 0;
}
EVP_DigestFinal_ex(&ctxt, cu, NULL);
EVP_MD_CTX_cleanup(&ctxt);
- if (!(u = BN_bin2bn(cu, sizeof(cu), NULL)))
+ if ((u = BN_bin2bn(cu, sizeof(cu), NULL)) == NULL)
return NULL;
if (!BN_is_zero(u))
return u;
/* B = g**b + k*v */
- if (!BN_mod_exp(gb, g, b, N, bn_ctx) ||
- !(k = srp_Calc_k(N, g)) ||
- !BN_mod_mul(kv, v, k, N, bn_ctx) ||
- !BN_mod_add(B, gb, kv, N, bn_ctx)) {
+ if (!BN_mod_exp(gb, g, b, N, bn_ctx)
+ || (k = srp_Calc_k(N, g)) == NULL
+ || !BN_mod_mul(kv, v, k, N, bn_ctx)
+ || !BN_mod_add(B, gb, kv, N, bn_ctx)) {
BN_free(B);
B = NULL;
}
if (!BN_mod_exp(tmp, g, x, N, bn_ctx))
goto err;
- if (!(k = srp_Calc_k(N, g)))
+ if ((k = srp_Calc_k(N, g)) == NULL)
goto err;
if (!BN_mod_mul(tmp2, tmp, k, N, bn_ctx))
goto err;
if (!BN_mod_sub(tmp, B, tmp2, N, bn_ctx))
goto err;
-
if (!BN_mod_mul(tmp3, u, x, N, bn_ctx))
goto err;
if (!BN_mod_add(tmp2, a, tmp3, N, bn_ctx))
if (vb == NULL)
return NULL;
- if (!(vb->users_pwd = sk_SRP_user_pwd_new_null()) ||
- !(vb->gN_cache = sk_SRP_gN_cache_new_null())) {
+ if ((vb->users_pwd = sk_SRP_user_pwd_new_null()) == NULL
+ || (vb->gN_cache = sk_SRP_gN_cache_new_null()) == NULL) {
OPENSSL_free(vb);
return NULL;
}
if ((gN = OPENSSL_malloc(sizeof(*gN))) == NULL)
goto err;
- if (!(gN->id = BUF_strdup(pp[DB_srpid]))
- || !(gN->N =
- SRP_gN_place_bn(vb->gN_cache, pp[DB_srpverifier]))
- || !(gN->g = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpsalt]))
+ if ((gN->id = BUF_strdup(pp[DB_srpid])) == NULL
+ || (gN->N = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpverifier]))
+ == NULL
+ || (gN->g = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpsalt]))
+ == NULL
|| sk_SRP_gN_insert(SRP_gN_tab, gN, 0) == 0)
goto err;
goto err;
if (N) {
- if (!(len = t_fromb64(tmp, N)))
+ if ((len = t_fromb64(tmp, N)) == 0)
goto err;
N_bn = BN_bin2bn(tmp, len, NULL);
- if (!(len = t_fromb64(tmp, g)))
+ if ((len = t_fromb64(tmp, g)) == 0)
goto err;
g_bn = BN_bin2bn(tmp, len, NULL);
defgNid = "*";
s = BN_bin2bn(tmp2, SRP_RANDOM_SALT_LEN, NULL);
} else {
- if (!(len = t_fromb64(tmp2, *salt)))
+ if ((len = t_fromb64(tmp2, *salt)) == 0)
goto err;
s = BN_bin2bn(tmp2, len, NULL);
}
STACK_OF(X509_INFO) *allcerts = NULL;
int i;
- if (!(certs = BIO_new_file(file, "r")))
+ if ((certs = BIO_new_file(file, "r")) == NULL)
goto end;
-
- if (!(othercerts = sk_X509_new_null()))
+ if ((othercerts = sk_X509_new_null()) == NULL)
goto end;
+
allcerts = PEM_X509_INFO_read_bio(certs, NULL, NULL, NULL);
for (i = 0; i < sk_X509_INFO_num(allcerts); i++) {
X509_INFO *xi = sk_X509_INFO_value(allcerts, i);
BIO *key = NULL;
EVP_PKEY *pkey = NULL;
- if (!(key = BIO_new_file(file, "r")))
+ if ((key = BIO_new_file(file, "r")) == NULL)
goto end;
pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, (char *)pass);
end:
{
int ret = 0;
- if (!device)
+ if (device == NULL)
device = NCONF_get_string(conf, section, ENV_CRYPTO_DEVICE);
if (device && !TS_CONF_set_default_engine(device)) {
if (strcmp(name, "builtin") == 0)
return 1;
- if (!(e = ENGINE_by_id(name)))
+ if ((e = ENGINE_by_id(name)) == NULL)
goto err;
+
/* Enable the use of the NCipher HSM for forked children. */
if (strcmp(name, "chil") == 0)
ENGINE_ctrl(e, ENGINE_CTRL_CHIL_SET_FORKCHECK, 1, 0, 0);
{
int ret = 0;
X509 *cert_obj = NULL;
- if (!cert)
+
+ if (cert == NULL) {
cert = NCONF_get_string(conf, section, ENV_SIGNER_CERT);
- if (!cert) {
- TS_CONF_lookup_fail(section, ENV_SIGNER_CERT);
- goto err;
+ if (cert == NULL) {
+ TS_CONF_lookup_fail(section, ENV_SIGNER_CERT);
+ goto err;
+ }
}
- if (!(cert_obj = TS_CONF_load_cert(cert)))
+ if ((cert_obj = TS_CONF_load_cert(cert)) == NULL)
goto err;
if (!TS_RESP_CTX_set_signer_cert(ctx, cert_obj))
goto err;
{
int ret = 0;
STACK_OF(X509) *certs_obj = NULL;
- if (!certs)
- certs = NCONF_get_string(conf, section, ENV_CERTS);
- /* Certificate chain is optional. */
- if (!certs)
- goto end;
- if (!(certs_obj = TS_CONF_load_certs(certs)))
+
+ if (certs == NULL) {
+ /* Certificate chain is optional. */
+ if ((certs = NCONF_get_string(conf, section, ENV_CERTS)) == NULL)
+ goto end;
+ }
+ if ((certs_obj = TS_CONF_load_certs(certs)) == NULL)
goto err;
if (!TS_RESP_CTX_set_certs(ctx, certs_obj))
goto err;
TS_CONF_lookup_fail(section, ENV_SIGNER_KEY);
goto err;
}
- if (!(key_obj = TS_CONF_load_key(key, pass)))
+ if ((key_obj = TS_CONF_load_key(key, pass)) == NULL)
goto err;
if (!TS_RESP_CTX_set_signer_key(ctx, key_obj))
goto err;
TS_CONF_lookup_fail(section, ENV_DEFAULT_POLICY);
goto err;
}
- if (!(policy_obj = OBJ_txt2obj(policy, 0))) {
+ if ((policy_obj = OBJ_txt2obj(policy, 0)) == NULL) {
TS_CONF_invalid(section, ENV_DEFAULT_POLICY);
goto err;
}
int ret = 0;
int i;
STACK_OF(CONF_VALUE) *list = NULL;
- char *policies = NCONF_get_string(conf, section,
- ENV_OTHER_POLICIES);
+ char *policies = NCONF_get_string(conf, section, ENV_OTHER_POLICIES);
+
/* If no other policy is specified, that's fine. */
- if (policies && !(list = X509V3_parse_list(policies))) {
+ if (policies && (list = X509V3_parse_list(policies)) == NULL) {
TS_CONF_invalid(section, ENV_OTHER_POLICIES);
goto err;
}
CONF_VALUE *val = sk_CONF_VALUE_value(list, i);
const char *extval = val->value ? val->value : val->name;
ASN1_OBJECT *objtmp;
- if (!(objtmp = OBJ_txt2obj(extval, 0))) {
+
+ if ((objtmp = OBJ_txt2obj(extval, 0)) == NULL) {
TS_CONF_invalid(section, ENV_OTHER_POLICIES);
goto err;
}
int i;
STACK_OF(CONF_VALUE) *list = NULL;
char *digests = NCONF_get_string(conf, section, ENV_DIGESTS);
- if (!digests) {
+
+ if (digests == NULL) {
TS_CONF_lookup_fail(section, ENV_DIGESTS);
goto err;
}
- if (!(list = X509V3_parse_list(digests))) {
+ if ((list = X509V3_parse_list(digests)) == NULL) {
TS_CONF_invalid(section, ENV_DIGESTS);
goto err;
}
CONF_VALUE *val = sk_CONF_VALUE_value(list, i);
const char *extval = val->value ? val->value : val->name;
const EVP_MD *md;
- if (!(md = EVP_get_digestbyname(extval))) {
+
+ if ((md = EVP_get_digestbyname(extval)) == NULL) {
TS_CONF_invalid(section, ENV_DIGESTS);
goto err;
}
STACK_OF(CONF_VALUE) *list = NULL;
char *accuracy = NCONF_get_string(conf, section, ENV_ACCURACY);
- if (accuracy && !(list = X509V3_parse_list(accuracy))) {
+ if (accuracy && (list = X509V3_parse_list(accuracy)) == NULL) {
TS_CONF_invalid(section, ENV_ACCURACY);
goto err;
}
{
TS_RESP_CTX *ctx;
- if (!(ctx = OPENSSL_malloc(sizeof(*ctx)))) {
+ if ((ctx = OPENSSL_malloc(sizeof(*ctx))) == NULL) {
TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
}
int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy)
{
ASN1_OBJECT_free(ctx->default_policy);
- if (!(ctx->default_policy = OBJ_dup(def_policy)))
+ if ((ctx->default_policy = OBJ_dup(def_policy)) == NULL)
goto err;
return 1;
err:
ctx->certs = NULL;
if (!certs)
return 1;
- if (!(ctx->certs = X509_chain_up_ref(certs))) {
+ if ((ctx->certs = X509_chain_up_ref(certs)) == NULL) {
TSerr(TS_F_TS_RESP_CTX_SET_CERTS, ERR_R_MALLOC_FAILURE);
return 0;
}
ASN1_OBJECT *copy = NULL;
/* Create new policy stack if necessary. */
- if (!ctx->policies && !(ctx->policies = sk_ASN1_OBJECT_new_null()))
+ if (ctx->policies == NULL
+ && (ctx->policies = sk_ASN1_OBJECT_new_null()) == NULL)
goto err;
- if (!(copy = OBJ_dup(policy)))
+ if ((copy = OBJ_dup(policy)) == NULL)
goto err;
if (!sk_ASN1_OBJECT_push(ctx->policies, copy))
goto err;
int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md)
{
/* Create new md stack if necessary. */
- if (!ctx->mds && !(ctx->mds = sk_EVP_MD_new_null()))
+ if (ctx->mds == NULL
+ && (ctx->mds = sk_EVP_MD_new_null()) == NULL)
goto err;
/* Add the shared md, no copy needed. */
if (!sk_EVP_MD_push(ctx->mds, (EVP_MD *)md))
{
TS_RESP_CTX_accuracy_free(ctx);
- if (secs && (!(ctx->seconds = ASN1_INTEGER_new())
- || !ASN1_INTEGER_set(ctx->seconds, secs)))
+ if (secs
+ && ((ctx->seconds = ASN1_INTEGER_new()) == NULL
+ || !ASN1_INTEGER_set(ctx->seconds, secs)))
goto err;
- if (millis && (!(ctx->millis = ASN1_INTEGER_new())
- || !ASN1_INTEGER_set(ctx->millis, millis)))
+ if (millis
+ && ((ctx->millis = ASN1_INTEGER_new()) == NULL
+ || !ASN1_INTEGER_set(ctx->millis, millis)))
goto err;
- if (micros && (!(ctx->micros = ASN1_INTEGER_new())
- || !ASN1_INTEGER_set(ctx->micros, micros)))
+ if (micros
+ && ((ctx->micros = ASN1_INTEGER_new()) == NULL
+ || !ASN1_INTEGER_set(ctx->micros, micros)))
goto err;
return 1;
ASN1_UTF8STRING *utf8_text = NULL;
int ret = 0;
- if (!(si = TS_STATUS_INFO_new()))
+ if ((si = TS_STATUS_INFO_new()) == NULL)
goto err;
if (!ASN1_INTEGER_set(si->status, status))
goto err;
if (text) {
- if (!(utf8_text = ASN1_UTF8STRING_new())
+ if ((utf8_text = ASN1_UTF8STRING_new()) == NULL
|| !ASN1_STRING_set(utf8_text, text, strlen(text)))
goto err;
- if (!si->text && !(si->text = sk_ASN1_UTF8STRING_new_null()))
+ if (si->text == NULL
+ && (si->text = sk_ASN1_UTF8STRING_new_null()) == NULL)
goto err;
if (!sk_ASN1_UTF8STRING_push(si->text, utf8_text))
goto err;
int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure)
{
TS_STATUS_INFO *si = TS_RESP_get_status_info(ctx->response);
- if (!si->failure_info && !(si->failure_info = ASN1_BIT_STRING_new()))
+ if (si->failure_info == NULL
+ && (si->failure_info = ASN1_BIT_STRING_new()) == NULL)
goto err;
if (!ASN1_BIT_STRING_set_bit(si->failure_info, failure, 1))
goto err;
TS_RESP_CTX_init(ctx);
/* Creating the response object. */
- if (!(ctx->response = TS_RESP_new())) {
+ if ((ctx->response = TS_RESP_new()) == NULL) {
TSerr(TS_F_TS_RESP_CREATE_RESPONSE, ERR_R_MALLOC_FAILURE);
goto end;
}
/* Parsing DER request. */
- if (!(ctx->request = d2i_TS_REQ_bio(req_bio, NULL))) {
+ if ((ctx->request = d2i_TS_REQ_bio(req_bio, NULL)) == NULL) {
TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
"Bad request format or " "system error.");
TS_RESP_CTX_add_failure_info(ctx, TS_INFO_BAD_DATA_FORMAT);
goto end;
/* Checking acceptable policies. */
- if (!(policy = TS_RESP_get_policy(ctx)))
+ if ((policy = TS_RESP_get_policy(ctx)) == NULL)
goto end;
/* Creating the TS_TST_INFO object. */
- if (!(ctx->tst_info = TS_RESP_create_tst_info(ctx, policy)))
+ if ((ctx->tst_info = TS_RESP_create_tst_info(ctx, policy)) == NULL)
goto end;
/* Processing extensions. */
const ASN1_INTEGER *nonce;
GENERAL_NAME *tsa_name = NULL;
- if (!(tst_info = TS_TST_INFO_new()))
+ if ((tst_info = TS_TST_INFO_new()) == NULL)
goto end;
if (!TS_TST_INFO_set_version(tst_info, 1))
goto end;
goto end;
if (!TS_TST_INFO_set_msg_imprint(tst_info, ctx->request->msg_imprint))
goto end;
- if (!(serial = (*ctx->serial_cb) (ctx, ctx->serial_cb_data))
+ if ((serial = ctx->serial_cb(ctx, ctx->serial_cb_data)) == NULL
|| !TS_TST_INFO_set_serial(tst_info, serial))
goto end;
- if (!(*ctx->time_cb) (ctx, ctx->time_cb_data, &sec, &usec)
- || !(asn1_time = TS_RESP_set_genTime_with_precision(NULL,
- sec, usec,
- ctx->clock_precision_digits))
+ if (!ctx->time_cb(ctx, ctx->time_cb_data, &sec, &usec)
+ || (asn1_time =
+ TS_RESP_set_genTime_with_precision(NULL, sec, usec,
+ ctx->clock_precision_digits)) == NULL
|| !TS_TST_INFO_set_time(tst_info, asn1_time))
goto end;
/* Setting accuracy if needed. */
if ((ctx->seconds || ctx->millis || ctx->micros)
- && !(accuracy = TS_ACCURACY_new()))
+ && (accuracy = TS_ACCURACY_new()) == NULL)
goto end;
if (ctx->seconds && !TS_ACCURACY_set_seconds(accuracy, ctx->seconds))
/* Setting TSA name to subject of signer certificate. */
if (ctx->flags & TS_TSA_NAME) {
- if (!(tsa_name = GENERAL_NAME_new()))
+ if ((tsa_name = GENERAL_NAME_new()) == NULL)
goto end;
tsa_name->type = GEN_DIRNAME;
tsa_name->d.dirn =
}
/* Create a new PKCS7 signed object. */
- if (!(p7 = PKCS7_new())) {
+ if ((p7 = PKCS7_new()) == NULL) {
TSerr(TS_F_TS_RESP_SIGN, ERR_R_MALLOC_FAILURE);
goto err;
}
}
/* Add a new signer info. */
- if (!(si = PKCS7_add_signature(p7, ctx->signer_cert,
- ctx->signer_key, EVP_sha1()))) {
+ if ((si = PKCS7_add_signature(p7, ctx->signer_cert,
+ ctx->signer_key, EVP_sha1())) == NULL) {
TSerr(TS_F_TS_RESP_SIGN, TS_R_PKCS7_ADD_SIGNATURE_ERROR);
goto err;
}
* certificate id and optionally the certificate chain.
*/
certs = ctx->flags & TS_ESS_CERT_ID_CHAIN ? ctx->certs : NULL;
- if (!(sc = ESS_SIGNING_CERT_new_init(ctx->signer_cert, certs)))
+ if ((sc = ESS_SIGNING_CERT_new_init(ctx->signer_cert, certs)) == NULL)
goto err;
/* Add SigningCertificate signed attribute to the signer info. */
goto err;
/* Add the DER encoded tst_info to the PKCS7 structure. */
- if (!(p7bio = PKCS7_dataInit(p7, NULL))) {
+ if ((p7bio = PKCS7_dataInit(p7, NULL)) == NULL) {
TSerr(TS_F_TS_RESP_SIGN, ERR_R_MALLOC_FAILURE);
goto err;
}
int i;
/* Creating the ESS_CERT_ID stack. */
- if (!(sc = ESS_SIGNING_CERT_new()))
+ if ((sc = ESS_SIGNING_CERT_new()) == NULL)
goto err;
- if (!sc->cert_ids && !(sc->cert_ids = sk_ESS_CERT_ID_new_null()))
+ if (sc->cert_ids == NULL
+ && (sc->cert_ids = sk_ESS_CERT_ID_new_null()) == NULL)
goto err;
/* Adding the signing certificate id. */
- if (!(cid = ESS_CERT_ID_new_init(signcert, 0))
+ if ((cid = ESS_CERT_ID_new_init(signcert, 0)) == NULL
|| !sk_ESS_CERT_ID_push(sc->cert_ids, cid))
goto err;
/* Adding the certificate chain ids. */
for (i = 0; i < sk_X509_num(certs); ++i) {
X509 *cert = sk_X509_value(certs, i);
- if (!(cid = ESS_CERT_ID_new_init(cert, 1))
+ if ((cid = ESS_CERT_ID_new_init(cert, 1)) == NULL
|| !sk_ESS_CERT_ID_push(sc->cert_ids, cid))
goto err;
}
/* Recompute SHA1 hash of certificate if necessary (side effect). */
X509_check_purpose(cert, -1, 0);
- if (!(cid = ESS_CERT_ID_new()))
+ if ((cid = ESS_CERT_ID_new()) == NULL)
goto err;
if (!ASN1_OCTET_STRING_set(cid->hash, cert->sha1_hash,
sizeof(cert->sha1_hash)))
/* Setting the issuer/serial if requested. */
if (issuer_needed) {
/* Creating issuer/serial structure. */
- if (!cid->issuer_serial
- && !(cid->issuer_serial = ESS_ISSUER_SERIAL_new()))
+ if (cid->issuer_serial == NULL
+ && (cid->issuer_serial = ESS_ISSUER_SERIAL_new()) == NULL)
goto err;
/* Creating general name from the certificate issuer. */
- if (!(name = GENERAL_NAME_new()))
+ if ((name = GENERAL_NAME_new()) == NULL)
goto err;
name->type = GEN_DIRNAME;
- if (!(name->d.dirn = X509_NAME_dup(cert->cert_info->issuer)))
+ if ((name->d.dirn = X509_NAME_dup(cert->cert_info->issuer)) == NULL)
goto err;
if (!sk_GENERAL_NAME_push(cid->issuer_serial->issuer, name))
goto err;
ASN1_OCTET_STRING *octet_string = NULL;
/* Create new encapsulated NID_id_smime_ct_TSTInfo content. */
- if (!(ret = PKCS7_new()))
+ if ((ret = PKCS7_new()) == NULL)
goto err;
- if (!(ret->d.other = ASN1_TYPE_new()))
+ if ((ret->d.other = ASN1_TYPE_new()) == NULL)
goto err;
ret->type = OBJ_nid2obj(NID_id_smime_ct_TSTInfo);
- if (!(octet_string = ASN1_OCTET_STRING_new()))
+ if ((octet_string = ASN1_OCTET_STRING_new()) == NULL)
goto err;
ASN1_TYPE_set(ret->d.other, V_ASN1_OCTET_STRING, octet_string);
octet_string = NULL;
int len;
len = i2d_ESS_SIGNING_CERT(sc, NULL);
- if (!(pp = OPENSSL_malloc(len))) {
+ if ((pp = OPENSSL_malloc(len)) == NULL) {
TSerr(TS_F_ESS_ADD_SIGNING_CERT, ERR_R_MALLOC_FAILURE);
goto err;
}
p = pp;
i2d_ESS_SIGNING_CERT(sc, &p);
- if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set(seq, pp, len)) {
+ if ((seq = ASN1_STRING_new()) == NULL || !ASN1_STRING_set(seq, pp, len)) {
TSerr(TS_F_ESS_ADD_SIGNING_CERT, ERR_R_MALLOC_FAILURE);
goto err;
}
if (precision > TS_MAX_CLOCK_PRECISION_DIGITS)
goto err;
- if (!(tm = gmtime(&time_sec)))
+ if ((tm = gmtime(&time_sec)) == NULL)
goto err;
/*
*p++ = '\0';
/* Now call OpenSSL to check and set our genTime value */
- if (!asn1_time && !(asn1_time = ASN1_GENERALIZEDTIME_new()))
+ if (asn1_time == NULL
+ && (asn1_time = ASN1_GENERALIZEDTIME_new()) == NULL)
goto err;
if (!ASN1_GENERALIZEDTIME_set_string(asn1_time, genTime_str)) {
ASN1_GENERALIZEDTIME_free(asn1_time);
/* Set the embedded_status_text to the returned description. */
if (sk_ASN1_UTF8STRING_num(info->text) > 0
- && !(embedded_status_text = TS_get_status_text(info->text)))
+ && (embedded_status_text = TS_get_status_text(info->text)) == NULL)
return 0;
/* Filling in failure_text with the failure information. */
length += 1; /* separator character */
}
/* Allocate memory (closing '\0' included). */
- if (!(result = OPENSSL_malloc(length))) {
+ if ((result = OPENSSL_malloc(length)) == NULL) {
TSerr(TS_F_TS_GET_STATUS_TEXT, ERR_R_MALLOC_FAILURE);
return NULL;
}
*imprint = NULL;
/* Return the MD algorithm of the response. */
- if (!(*md_alg = X509_ALGOR_dup(md_alg_resp)))
+ if ((*md_alg = X509_ALGOR_dup(md_alg_resp)) == NULL)
goto err;
/* Getting the MD object. */
- if (!(md = EVP_get_digestbyobj((*md_alg)->algorithm))) {
+ if ((md = EVP_get_digestbyobj((*md_alg)->algorithm)) == NULL) {
TSerr(TS_F_TS_COMPUTE_IMPRINT, TS_R_UNSUPPORTED_MD_ALGORITHM);
goto err;
}
if (length < 0)
goto err;
*imprint_len = length;
- if (!(*imprint = OPENSSL_malloc(*imprint_len))) {
+ if ((*imprint = OPENSSL_malloc(*imprint_len)) == NULL) {
TSerr(TS_F_TS_COMPUTE_IMPRINT, ERR_R_MALLOC_FAILURE);
goto err;
}
/* Check all the alternative names. */
gen_names = X509_get_ext_d2i(signer, NID_subject_alt_name, NULL, &idx);
- while (gen_names != NULL
- && !(found = TS_find_name(gen_names, tsa_name) >= 0)) {
+ while (gen_names != NULL) {
+ found = TS_find_name(gen_names, tsa_name) >= 0;
+ if (found)
+ break;
/*
* Get the next subject alternative name, although there should be no
* more than one.
*/
GENERAL_NAMES_free(gen_names);
- gen_names = X509_get_ext_d2i(signer, NID_subject_alt_name,
- NULL, &idx);
+ gen_names = X509_get_ext_d2i(signer, NID_subject_alt_name, NULL, &idx);
}
GENERAL_NAMES_free(gen_names);
OPENSSL_assert(req != NULL);
if (ret)
TS_VERIFY_CTX_cleanup(ret);
- else if (!(ret = TS_VERIFY_CTX_new()))
+ else if ((ret = TS_VERIFY_CTX_new()) == NULL)
return NULL;
/* Setting flags. */
/* Setting policy. */
if ((policy = TS_REQ_get_policy_id(req)) != NULL) {
- if (!(ret->policy = OBJ_dup(policy)))
+ if ((ret->policy = OBJ_dup(policy)) == NULL)
goto err;
} else
ret->flags &= ~TS_VFY_POLICY;
/* Setting md_alg, imprint and imprint_len. */
imprint = TS_REQ_get_msg_imprint(req);
md_alg = TS_MSG_IMPRINT_get_algo(imprint);
- if (!(ret->md_alg = X509_ALGOR_dup(md_alg)))
+ if ((ret->md_alg = X509_ALGOR_dup(md_alg)) == NULL)
goto err;
msg = TS_MSG_IMPRINT_get_msg(imprint);
ret->imprint_len = ASN1_STRING_length(msg);
- if (!(ret->imprint = OPENSSL_malloc(ret->imprint_len)))
+ if ((ret->imprint = OPENSSL_malloc(ret->imprint_len)) == NULL)
goto err;
memcpy(ret->imprint, ASN1_STRING_data(msg), ret->imprint_len);
/* Setting nonce. */
if ((nonce = TS_REQ_get_nonce(req)) != NULL) {
- if (!(ret->nonce = ASN1_INTEGER_dup(nonce)))
+ if ((ret->nonce = ASN1_INTEGER_dup(nonce)) == NULL)
goto err;
} else
ret->flags &= ~TS_VFY_NONCE;
continue;
else {
buf->data[offset - 1] = '\0'; /* blat the '\n' */
- if (!(p = OPENSSL_malloc(add + offset)))
+ if ((p = OPENSSL_malloc(add + offset)) == NULL)
goto err;
offset = 0;
}
}
atype = stmp->type;
} else if (len != -1) {
- if (!(stmp = ASN1_STRING_type_new(attrtype)))
+ if ((stmp = ASN1_STRING_type_new(attrtype)) == NULL)
goto err;
if (!ASN1_STRING_set(stmp, data, len))
goto err;
*/
if (attrtype == 0)
return 1;
- if (!(ttmp = ASN1_TYPE_new()))
+ if ((ttmp = ASN1_TYPE_new()) == NULL)
goto err;
if ((len == -1) && !(attrtype & MBSTRING_FLAG)) {
if (!ASN1_TYPE_set1(ttmp, attrtype, data))
idx = X509_TRUST_get_by_id(id);
/* Need a new entry */
if (idx == -1) {
- if (!(trtmp = OPENSSL_malloc(sizeof(*trtmp)))) {
+ if ((trtmp = OPENSSL_malloc(sizeof(*trtmp))) == NULL) {
X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);
return 0;
}
if (trtmp->flags & X509_TRUST_DYNAMIC_NAME)
OPENSSL_free(trtmp->name);
/* dup supplied name */
- if (!(trtmp->name = BUF_strdup(name))) {
+ if ((trtmp->name = BUF_strdup(name)) == NULL) {
X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);
return 0;
}
/* If its a new entry manage the dynamic table */
if (idx == -1) {
- if (!trtable && !(trtable = sk_X509_TRUST_new(tr_cmp))) {
+ if (trtable == NULL
+ && (trtable = sk_X509_TRUST_new(tr_cmp)) == NULL) {
X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);
return 0;
}
NETSCAPE_SPKI *spki;
if (len <= 0)
len = strlen(str);
- if (!(spki_der = OPENSSL_malloc(len + 1))) {
+ if ((spki_der = OPENSSL_malloc(len + 1)) == NULL) {
X509err(X509_F_NETSCAPE_SPKI_B64_DECODE, ERR_R_MALLOC_FAILURE);
return NULL;
}
* If no anyPolicy node on this this level it can't appear on lower
* levels so end search.
*/
- if (!(anyptr = curr->anyPolicy))
+ if ((anyptr = curr->anyPolicy) == NULL)
break;
curr++;
for (j = 0; j < sk_X509_POLICY_NODE_num(curr->nodes); j++) {
}
}
- if (!(akeyid = AUTHORITY_KEYID_new()))
+ if ((akeyid = AUTHORITY_KEYID_new()) == NULL)
goto err;
if (isname) {
- if (!(gens = sk_GENERAL_NAME_new_null())
- || !(gen = GENERAL_NAME_new())
+ if ((gens = sk_GENERAL_NAME_new_null()) == NULL
+ || (gen = GENERAL_NAME_new()) == NULL
|| !sk_GENERAL_NAME_push(gens, gen)) {
X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE);
goto err;
GENERAL_NAMES *gens = NULL;
CONF_VALUE *cnf;
int i;
- if (!(gens = sk_GENERAL_NAME_new_null())) {
+
+ if ((gens = sk_GENERAL_NAME_new_null()) == NULL) {
X509V3err(X509V3_F_V2I_ISSUER_ALT, ERR_R_MALLOC_FAILURE);
return NULL;
}
goto err;
} else {
GENERAL_NAME *gen;
- if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf)))
+ if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL)
goto err;
sk_GENERAL_NAME_push(gens, gen);
}
GENERAL_NAME *gen;
X509_EXTENSION *ext;
int i;
+
if (ctx && (ctx->flags == CTX_TEST))
return 1;
if (!ctx || !ctx->issuer_cert) {
i = X509_get_ext_by_NID(ctx->issuer_cert, NID_subject_alt_name, -1);
if (i < 0)
return 1;
- if (!(ext = X509_get_ext(ctx->issuer_cert, i)) ||
- !(ialt = X509V3_EXT_d2i(ext))) {
+ if ((ext = X509_get_ext(ctx->issuer_cert, i)) == NULL
+ || (ialt = X509V3_EXT_d2i(ext)) == NULL) {
X509V3err(X509V3_F_COPY_ISSUER, X509V3_R_ISSUER_DECODE_ERROR);
goto err;
}
GENERAL_NAMES *gens = NULL;
CONF_VALUE *cnf;
int i;
- if (!(gens = sk_GENERAL_NAME_new_null())) {
+
+ if ((gens = sk_GENERAL_NAME_new_null()) == NULL) {
X509V3err(X509V3_F_V2I_SUBJECT_ALT, ERR_R_MALLOC_FAILURE);
return NULL;
}
goto err;
} else {
GENERAL_NAME *gen;
- if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf)))
+ if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL)
goto err;
sk_GENERAL_NAME_push(gens, gen);
}
X509_NAME_ENTRY_free(ne);
i--;
}
- if (!email || !(gen = GENERAL_NAME_new())) {
+ if (email == NULL || (gen = GENERAL_NAME_new()) == NULL) {
X509V3err(X509V3_F_COPY_EMAIL, ERR_R_MALLOC_FAILURE);
goto err;
}
GENERAL_NAMES *gens = NULL;
CONF_VALUE *cnf;
int i;
- if (!(gens = sk_GENERAL_NAME_new_null())) {
+
+ if ((gens = sk_GENERAL_NAME_new_null()) == NULL) {
X509V3err(X509V3_F_V2I_GENERAL_NAMES, ERR_R_MALLOC_FAILURE);
return NULL;
}
for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
cnf = sk_CONF_VALUE_value(nval, i);
- if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf)))
+ if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL)
goto err;
sk_GENERAL_NAME_push(gens, gen);
}
case GEN_RID:
{
ASN1_OBJECT *obj;
- if (!(obj = OBJ_txt2obj(value, 0))) {
+ if ((obj = OBJ_txt2obj(value, 0)) == NULL) {
X509V3err(X509V3_F_A2I_GENERAL_NAME, X509V3_R_BAD_OBJECT);
ERR_add_error_data(2, "value=", value);
goto err;
}
if (is_string) {
- if (!(gen->d.ia5 = ASN1_IA5STRING_new()) ||
+ if ((gen->d.ia5 = ASN1_IA5STRING_new()) == NULL ||
!ASN1_STRING_set(gen->d.ia5, (unsigned char *)value,
strlen(value))) {
X509V3err(X509V3_F_A2I_GENERAL_NAME, ERR_R_MALLOC_FAILURE);
{
char *objtmp = NULL, *p;
int objlen;
- if (!(p = strchr(value, ';')))
+
+ if ((p = strchr(value, ';')) == NULL)
return 0;
- if (!(gen->d.otherName = OTHERNAME_new()))
+ if ((gen->d.otherName = OTHERNAME_new()) == NULL)
return 0;
/*
* Free this up because we will overwrite it. no need to free type_id
* because it is static
*/
ASN1_TYPE_free(gen->d.otherName->value);
- if (!(gen->d.otherName->value = ASN1_generate_v3(p + 1, ctx)))
+ if ((gen->d.otherName->value = ASN1_generate_v3(p + 1, ctx)) == NULL)
return 0;
objlen = p - value;
objtmp = OPENSSL_malloc(objlen + 1);
{
int ret = 0;
STACK_OF(CONF_VALUE) *sk = NULL;
- X509_NAME *nm = NULL;
- if (!(nm = X509_NAME_new()))
+ X509_NAME *nm;
+
+ if ((nm = X509_NAME_new()) == NULL)
goto err;
sk = X509V3_get_section(ctx, value);
if (!sk) {
BASIC_CONSTRAINTS *bcons = NULL;
CONF_VALUE *val;
int i;
- if (!(bcons = BASIC_CONSTRAINTS_new())) {
+
+ if ((bcons = BASIC_CONSTRAINTS_new()) == NULL) {
X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS, ERR_R_MALLOC_FAILURE);
return NULL;
}
ASN1_BIT_STRING *bs;
int i;
BIT_STRING_BITNAME *bnam;
- if (!(bs = ASN1_BIT_STRING_new())) {
+ if ((bs = ASN1_BIT_STRING_new()) == NULL) {
X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, ERR_R_MALLOC_FAILURE);
return NULL;
}
X509_EXTENSION *ext;
STACK_OF(CONF_VALUE) *nval;
void *ext_struc;
+
if (ext_nid == NID_undef) {
X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_UNKNOWN_EXTENSION_NAME);
return NULL;
}
- if (!(method = X509V3_EXT_get_nid(ext_nid))) {
+ if ((method = X509V3_EXT_get_nid(ext_nid)) == NULL) {
X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_UNKNOWN_EXTENSION);
return NULL;
}
if (!ext_struc)
return NULL;
} else if (method->s2i) {
- if (!(ext_struc = method->s2i(method, ctx, value)))
+ if ((ext_struc = method->s2i(method, ctx, value)) == NULL)
return NULL;
} else if (method->r2i) {
if (!ctx->db || !ctx->db_meth) {
X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_NO_CONFIG_DATABASE);
return NULL;
}
- if (!(ext_struc = method->r2i(method, ctx, value)))
+ if ((ext_struc = method->r2i(method, ctx, value)) == NULL)
return NULL;
} else {
X509V3err(X509V3_F_DO_EXT_NCONF,
goto merr;
} else {
unsigned char *p;
+
ext_len = method->i2d(ext_struc, NULL);
- if (!(ext_der = OPENSSL_malloc(ext_len)))
+ if ((ext_der = OPENSSL_malloc(ext_len)) == NULL)
goto merr;
p = ext_der;
method->i2d(ext_struc, &p);
}
- if (!(ext_oct = ASN1_OCTET_STRING_new()))
+ if ((ext_oct = ASN1_OCTET_STRING_new()) == NULL)
goto merr;
ext_oct->data = ext_der;
ext_der = NULL;
X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc)
{
const X509V3_EXT_METHOD *method;
- if (!(method = X509V3_EXT_get_nid(ext_nid))) {
+
+ if ((method = X509V3_EXT_get_nid(ext_nid)) == NULL) {
X509V3err(X509V3_F_X509V3_EXT_I2D, X509V3_R_UNKNOWN_EXTENSION);
return NULL;
}
ASN1_OBJECT *obj = NULL;
ASN1_OCTET_STRING *oct = NULL;
X509_EXTENSION *extension = NULL;
- if (!(obj = OBJ_txt2obj(ext, 0))) {
+
+ if ((obj = OBJ_txt2obj(ext, 0)) == NULL) {
X509V3err(X509V3_F_V3_GENERIC_EXTENSION,
X509V3_R_EXTENSION_NAME_ERROR);
ERR_add_error_data(2, "name=", ext);
goto err;
}
- if (!(oct = ASN1_OCTET_STRING_new())) {
+ if ((oct = ASN1_OCTET_STRING_new()) == NULL) {
X509V3err(X509V3_F_V3_GENERIC_EXTENSION, ERR_R_MALLOC_FAILURE);
goto err;
}
STACK_OF(CONF_VALUE) *nval;
CONF_VALUE *val;
int i;
- if (!(nval = NCONF_get_section(conf, section)))
+
+ if ((nval = NCONF_get_section(conf, section)) == NULL)
return 0;
for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
val = sk_CONF_VALUE_value(nval, i);
- if (!(ext = X509V3_EXT_nconf(conf, ctx, val->name, val->value)))
+ if ((ext = X509V3_EXT_nconf(conf, ctx, val->name, val->value)) == NULL)
return 0;
if (ctx->flags == X509V3_CTX_REPLACE)
delete_ext(*sk, ext);
}
pol = policy_section(ctx, polsect, ia5org);
X509V3_section_free(ctx, polsect);
- if (!pol)
+ if (pol == NULL)
goto err;
} else {
- if (!(pobj = OBJ_txt2obj(cnf->name, 0))) {
+ if ((pobj = OBJ_txt2obj(cnf->name, 0)) == NULL) {
X509V3err(X509V3_F_R2I_CERTPOL,
X509V3_R_INVALID_OBJECT_IDENTIFIER);
X509V3_conf_err(cnf);
CONF_VALUE *cnf;
POLICYINFO *pol;
POLICYQUALINFO *qual;
- if (!(pol = POLICYINFO_new()))
+
+ if ((pol = POLICYINFO_new()) == NULL)
goto merr;
for (i = 0; i < sk_CONF_VALUE_num(polstrs); i++) {
cnf = sk_CONF_VALUE_value(polstrs, i);
if (strcmp(cnf->name, "policyIdentifier") == 0) {
ASN1_OBJECT *pobj;
- if (!(pobj = OBJ_txt2obj(cnf->value, 0))) {
+ if ((pobj = OBJ_txt2obj(cnf->value, 0)) == NULL) {
X509V3err(X509V3_F_POLICY_SECTION,
X509V3_R_INVALID_OBJECT_IDENTIFIER);
X509V3_conf_err(cnf);
pol->policyid = pobj;
} else if (!name_cmp(cnf->name, "CPS")) {
- if (!pol->qualifiers)
+ if (pol->qualifiers == NULL)
pol->qualifiers = sk_POLICYQUALINFO_new_null();
- if (!(qual = POLICYQUALINFO_new()))
+ if ((qual = POLICYQUALINFO_new()) == NULL)
goto merr;
if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual))
goto merr;
- if (!(qual->pqualid = OBJ_nid2obj(NID_id_qt_cps))) {
+ if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_cps)) == NULL) {
X509V3err(X509V3_F_POLICY_SECTION, ERR_R_INTERNAL_ERROR);
goto err;
}
- if (!(qual->d.cpsuri = ASN1_IA5STRING_new()))
+ if ((qual->d.cpsuri = ASN1_IA5STRING_new()) == NULL)
goto merr;
if (!ASN1_STRING_set(qual->d.cpsuri, cnf->value,
strlen(cnf->value)))
CONF_VALUE *cnf;
USERNOTICE *not;
POLICYQUALINFO *qual;
- if (!(qual = POLICYQUALINFO_new()))
+
+ if ((qual = POLICYQUALINFO_new()) == NULL)
goto merr;
- if (!(qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice))) {
+ if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice)) == NULL) {
X509V3err(X509V3_F_NOTICE_SECTION, ERR_R_INTERNAL_ERROR);
goto err;
}
- if (!(not = USERNOTICE_new()))
+ if ((not = USERNOTICE_new()) == NULL)
goto merr;
qual->d.usernotice = not;
for (i = 0; i < sk_CONF_VALUE_num(unot); i++) {
cnf = sk_CONF_VALUE_value(unot, i);
if (strcmp(cnf->name, "explicitText") == 0) {
- if (!(not->exptext = ASN1_VISIBLESTRING_new()))
+ if ((not->exptext = ASN1_VISIBLESTRING_new()) == NULL)
goto merr;
if (!ASN1_STRING_set(not->exptext, cnf->value,
strlen(cnf->value)))
} else if (strcmp(cnf->name, "organization") == 0) {
NOTICEREF *nref;
if (!not->noticeref) {
- if (!(nref = NOTICEREF_new()))
+ if ((nref = NOTICEREF_new()) == NULL)
goto merr;
not->noticeref = nref;
} else
NOTICEREF *nref;
STACK_OF(CONF_VALUE) *nos;
if (!not->noticeref) {
- if (!(nref = NOTICEREF_new()))
+ if ((nref = NOTICEREF_new()) == NULL)
goto merr;
not->noticeref = nref;
} else
for (i = 0; i < sk_CONF_VALUE_num(nos); i++) {
cnf = sk_CONF_VALUE_value(nos, i);
- if (!(aint = s2i_ASN1_INTEGER(NULL, cnf->name))) {
+ if ((aint = s2i_ASN1_INTEGER(NULL, cnf->name)) == NULL) {
X509V3err(X509V3_F_NREF_NOS, X509V3_R_INVALID_NUMBER);
goto err;
}
GENERAL_NAME *gen = NULL;
CONF_VALUE *cnf;
int i;
- if (!(crld = sk_DIST_POINT_new_null()))
+
+ if ((crld = sk_DIST_POINT_new_null()) == NULL)
goto merr;
for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
DIST_POINT *point;
goto merr;
}
} else {
- if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf)))
+ if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL)
goto err;
- if (!(gens = GENERAL_NAMES_new()))
+ if ((gens = GENERAL_NAMES_new()) == NULL)
goto merr;
if (!sk_GENERAL_NAME_push(gens, gen))
goto merr;
gen = NULL;
- if (!(point = DIST_POINT_new()))
+ if ((point = DIST_POINT_new()) == NULL)
goto merr;
if (!sk_DIST_POINT_push(crld, point)) {
DIST_POINT_free(point);
goto merr;
}
- if (!(point->distpoint = DIST_POINT_NAME_new()))
+ if ((point->distpoint = DIST_POINT_NAME_new()) == NULL)
goto merr;
point->distpoint->name.fullname = gens;
point->distpoint->type = 0;
CONF_VALUE *val;
int i;
- if (!(extku = sk_ASN1_OBJECT_new_null())) {
+ if ((extku = sk_ASN1_OBJECT_new_null()) == NULL) {
X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, ERR_R_MALLOC_FAILURE);
return NULL;
}
extval = val->value;
else
extval = val->name;
- if (!(objtmp = OBJ_txt2obj(extval, 0))) {
+ if ((objtmp = OBJ_txt2obj(extval, 0)) == NULL) {
sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free);
X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE,
X509V3_R_INVALID_OBJECT_IDENTIFIER);
char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5)
{
char *tmp;
+
if (!ia5 || !ia5->length)
return NULL;
- if (!(tmp = OPENSSL_malloc(ia5->length + 1))) {
+ if ((tmp = OPENSSL_malloc(ia5->length + 1)) == NULL) {
X509V3err(X509V3_F_I2S_ASN1_IA5STRING, ERR_R_MALLOC_FAILURE);
return NULL;
}
X509V3_R_INVALID_NULL_ARGUMENT);
return NULL;
}
- if (!(ia5 = ASN1_IA5STRING_new()))
+ if ((ia5 = ASN1_IA5STRING_new()) == NULL)
goto err;
if (!ASN1_STRING_set((ASN1_STRING *)ia5, (unsigned char *)str,
strlen(str))) {
ACCESS_DESCRIPTION *acc;
int i, objlen;
char *objtmp, *ptmp;
- if (!(ainfo = sk_ACCESS_DESCRIPTION_new_null())) {
+
+ if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
return NULL;
}
for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
cnf = sk_CONF_VALUE_value(nval, i);
- if (!(acc = ACCESS_DESCRIPTION_new())
+ if ((acc = ACCESS_DESCRIPTION_new()) == NULL
|| !sk_ACCESS_DESCRIPTION_push(ainfo, acc)) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
ERR_R_MALLOC_FAILURE);
ctmp.value = cnf->value;
if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0))
goto err;
- if (!(objtmp = OPENSSL_malloc(objlen + 1))) {
+ if ((objtmp = OPENSSL_malloc(objlen + 1)) == NULL) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
ERR_R_MALLOC_FAILURE);
goto err;
int X509V3_EXT_add(X509V3_EXT_METHOD *ext)
{
- if (!ext_list && !(ext_list = sk_X509V3_EXT_METHOD_new(ext_cmp))) {
+ if (ext_list == NULL
+ && (ext_list = sk_X509V3_EXT_METHOD_new(ext_cmp)) == NULL) {
X509V3err(X509V3_F_X509V3_EXT_ADD, ERR_R_MALLOC_FAILURE);
return 0;
}
const X509V3_EXT_METHOD *ext;
X509V3_EXT_METHOD *tmpext;
- if (!(ext = X509V3_EXT_get_nid(nid_from))) {
- X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS,
- X509V3_R_EXTENSION_NOT_FOUND);
+ if ((ext = X509V3_EXT_get_nid(nid_from)) == NULL) {
+ X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, X509V3_R_EXTENSION_NOT_FOUND);
return 0;
}
- if (!(tmpext = OPENSSL_malloc(sizeof(*tmpext)))) {
+ if ((tmpext = OPENSSL_malloc(sizeof(*tmpext))) == NULL) {
X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, ERR_R_MALLOC_FAILURE);
return 0;
}
ASN1_STRING *extvalue;
int extlen;
- if (!(method = X509V3_EXT_get(ext)))
+ if ((method = X509V3_EXT_get(ext)) == NULL)
return NULL;
extvalue = X509_EXTENSION_get_data(ext);
p = ASN1_STRING_data(extvalue);
return 1;
}
- if (!*x && !(*x = sk_X509_EXTENSION_new_null()))
+ if (*x == NULL
+ && (*x = sk_X509_EXTENSION_new_null()) == NULL)
return -1;
if (!sk_X509_EXTENSION_push(*x, ext))
return -1;
X509V3_conf_err(val);
return 0;
}
- if (!(*language = OBJ_txt2obj(val->value, 0))) {
+ if ((*language = OBJ_txt2obj(val->value, 0)) == NULL) {
X509V3err(X509V3_F_PROCESS_PCI_VALUE,
X509V3_R_INVALID_OBJECT_IDENTIFIER);
X509V3_conf_err(val);
POLICY_CONSTRAINTS *pcons = NULL;
CONF_VALUE *val;
int i;
- if (!(pcons = POLICY_CONSTRAINTS_new())) {
+
+ if ((pcons = POLICY_CONSTRAINTS_new()) == NULL) {
X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS, ERR_R_MALLOC_FAILURE);
return NULL;
}
CONF_VALUE *val;
int i;
- if (!(pmaps = sk_POLICY_MAPPING_new_null())) {
+ if ((pmaps = sk_POLICY_MAPPING_new_null()) == NULL) {
X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, ERR_R_MALLOC_FAILURE);
return NULL;
}
p = ASN1_STRING_data(extoct);
extlen = ASN1_STRING_length(extoct);
- if (!(method = X509V3_EXT_get(ext)))
+ if ((method = X509V3_EXT_get(ext)) == NULL)
return unknown_ext_print(out, p, extlen, flag, indent, 0);
if (method->it)
ext_str = ASN1_item_d2i(NULL, &p, extlen, ASN1_ITEM_ptr(method->it));
return unknown_ext_print(out, p, extlen, flag, indent, 1);
if (method->i2s) {
- if (!(value = method->i2s(method, ext_str))) {
+ if ((value = method->i2s(method, ext_str)) == NULL) {
ok = 0;
goto err;
}
}
#endif
} else if (method->i2v) {
- if (!(nval = method->i2v(method, ext_str, NULL))) {
+ if ((nval = method->i2v(method, ext_str, NULL)) == NULL) {
ok = 0;
goto err;
}
{
BIO *bio_tmp;
int ret;
- if (!(bio_tmp = BIO_new_fp(fp, BIO_NOCLOSE)))
+
+ if ((bio_tmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL)
return 0;
ret = X509V3_EXT_print(bio_tmp, ext, flag, indent);
BIO_free(bio_tmp);
idx = X509_PURPOSE_get_by_id(id);
/* Need a new entry */
if (idx == -1) {
- if (!(ptmp = OPENSSL_malloc(sizeof(*ptmp)))) {
+ if ((ptmp = OPENSSL_malloc(sizeof(*ptmp))) == NULL) {
X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE);
return 0;
}
/* If its a new entry manage the dynamic table */
if (idx == -1) {
- if (!xptable && !(xptable = sk_X509_PURPOSE_new(xp_cmp))) {
+ if (xptable == NULL
+ && (xptable = sk_X509_PURPOSE_new(xp_cmp)) == NULL) {
X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE);
return 0;
}
ASN1_OCTET_STRING *oct;
long length;
- if (!(oct = ASN1_OCTET_STRING_new())) {
+ if ((oct = ASN1_OCTET_STRING_new()) == NULL) {
X509V3err(X509V3_F_S2I_ASN1_OCTET_STRING, ERR_R_MALLOC_FAILURE);
return NULL;
}
- if (!(oct->data = string_to_hex(str, &length))) {
+ if ((oct->data = string_to_hex(str, &length)) == NULL) {
ASN1_OCTET_STRING_free(oct);
return NULL;
}
if (strcmp(str, "hash"))
return s2i_ASN1_OCTET_STRING(method, ctx, str);
- if (!(oct = ASN1_OCTET_STRING_new())) {
+ if ((oct = ASN1_OCTET_STRING_new()) == NULL) {
X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE);
return NULL;
}
int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen)
{
- ASN1_INTEGER *izone = NULL;
- if (!(izone = s2i_ASN1_INTEGER(NULL, zone))) {
+ ASN1_INTEGER *izone;
+
+ if ((izone = s2i_ASN1_INTEGER(NULL, zone)) == NULL) {
X509V3err(X509V3_F_SXNET_ADD_ID_ASC, X509V3_R_ERROR_CONVERTING_ZONE);
return 0;
}
int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user,
int userlen)
{
- ASN1_INTEGER *izone = NULL;
- if (!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) {
+ ASN1_INTEGER *izone;
+
+ if ((izone = ASN1_INTEGER_new()) == NULL
+ || !ASN1_INTEGER_set(izone, lzone)) {
X509V3err(X509V3_F_SXNET_ADD_ID_ULONG, ERR_R_MALLOC_FAILURE);
ASN1_INTEGER_free(izone);
return 0;
X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER, X509V3_R_USER_TOO_LONG);
return 0;
}
- if (!*psx) {
- if (!(sx = SXNET_new()))
+ if (*psx == NULL) {
+ if ((sx = SXNET_new()) == NULL)
goto err;
if (!ASN1_INTEGER_set(sx->version, 0))
goto err;
return 0;
}
- if (!(id = SXNETID_new()))
+ if ((id = SXNETID_new()) == NULL)
goto err;
if (userlen == -1)
userlen = strlen(user);
ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone)
{
- ASN1_INTEGER *izone = NULL;
+ ASN1_INTEGER *izone;
ASN1_OCTET_STRING *oct;
- if (!(izone = s2i_ASN1_INTEGER(NULL, zone))) {
+
+ if ((izone = s2i_ASN1_INTEGER(NULL, zone)) == NULL) {
X509V3err(X509V3_F_SXNET_GET_ID_ASC, X509V3_R_ERROR_CONVERTING_ZONE);
return NULL;
}
ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone)
{
- ASN1_INTEGER *izone = NULL;
+ ASN1_INTEGER *izone;
ASN1_OCTET_STRING *oct;
- if (!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) {
+
+ if ((izone = ASN1_INTEGER_new()) == NULL
+ || !ASN1_INTEGER_set(izone, lzone)) {
X509V3err(X509V3_F_SXNET_GET_ID_ULONG, ERR_R_MALLOC_FAILURE);
ASN1_INTEGER_free(izone);
return NULL;
{
CONF_VALUE *vtmp = NULL;
char *tname = NULL, *tvalue = NULL;
- if (name && !(tname = BUF_strdup(name)))
+
+ if (name && (tname = BUF_strdup(name)) == NULL)
goto err;
- if (value && !(tvalue = BUF_strdup(value)))
+ if (value && (tvalue = BUF_strdup(value)) == NULL)
goto err;
- if (!(vtmp = OPENSSL_malloc(sizeof(*vtmp))))
+ if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL)
goto err;
- if (!*extlist && !(*extlist = sk_CONF_VALUE_new_null()))
+ if (*extlist == NULL && (*extlist = sk_CONF_VALUE_new_null()) == NULL)
goto err;
vtmp->section = NULL;
vtmp->name = tname;
{
BIGNUM *bntmp = NULL;
char *strtmp = NULL;
+
if (!a)
return NULL;
- if (!(bntmp = ASN1_ENUMERATED_to_BN(a, NULL)) ||
- !(strtmp = BN_bn2dec(bntmp)))
+ if ((bntmp = ASN1_ENUMERATED_to_BN(a, NULL)) == NULL
+ || (strtmp = BN_bn2dec(bntmp)) == NULL)
X509V3err(X509V3_F_I2S_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE);
BN_free(bntmp);
return strtmp;
{
BIGNUM *bntmp = NULL;
char *strtmp = NULL;
+
if (!a)
return NULL;
- if (!(bntmp = ASN1_INTEGER_to_BN(a, NULL)) ||
- !(strtmp = BN_bn2dec(bntmp)))
+ if ((bntmp = ASN1_INTEGER_to_BN(a, NULL)) == NULL
+ || (strtmp = BN_bn2dec(bntmp)) == NULL)
X509V3err(X509V3_F_I2S_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
BN_free(bntmp);
return strtmp;
{
char *strtmp;
int ret;
+
if (!aint)
return 1;
- if (!(strtmp = i2s_ASN1_INTEGER(NULL, aint)))
+ if ((strtmp = i2s_ASN1_INTEGER(NULL, aint)) == NULL)
return 0;
ret = X509V3_add_value(name, strtmp, extlist);
OPENSSL_free(strtmp);
int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool)
{
char *btmp;
- if (!(btmp = value->value))
+
+ if ((btmp = value->value) == NULL)
goto err;
if (strcmp(btmp, "TRUE") == 0
|| strcmp(btmp, "true") == 0
int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint)
{
ASN1_INTEGER *itmp;
- if (!(itmp = s2i_ASN1_INTEGER(NULL, value->value))) {
+
+ if ((itmp = s2i_ASN1_INTEGER(NULL, value->value)) == NULL) {
X509V3_conf_err(value);
return 0;
}
const static char hexdig[] = "0123456789ABCDEF";
if (!buffer || !len)
return NULL;
- if (!(tmp = OPENSSL_malloc(len * 3 + 1))) {
+ if ((tmp = OPENSSL_malloc(len * 3 + 1)) == NULL) {
X509V3err(X509V3_F_HEX_TO_STRING, ERR_R_MALLOC_FAILURE);
return NULL;
}
X509V3err(X509V3_F_STRING_TO_HEX, X509V3_R_INVALID_NULL_ARGUMENT);
return NULL;
}
- if (!(hexbuf = OPENSSL_malloc(strlen(str) >> 1)))
+ if ((hexbuf = OPENSSL_malloc(strlen(str) >> 1)) == NULL)
goto err;
for (p = (unsigned char *)str, q = hexbuf; *p;) {
ch = *p++;
FILE *inf;
int i, count;
X509_EXTENSION *ext;
+
X509V3_add_standard_extensions();
ERR_load_crypto_strings();
if (!argv[1]) {
fprintf(stderr, "Usage v3prin cert.pem\n");
exit(1);
}
- if (!(inf = fopen(argv[1], "r"))) {
+ if ((inf = fopen(argv[1], "r")) == NULL) {
fprintf(stderr, "Can't open %s\n", argv[1]);
exit(1);
}
- if (!(cert = PEM_read_X509(inf, NULL, NULL))) {
+ if ((cert = PEM_read_X509(inf, NULL, NULL)) == NULL) {
fprintf(stderr, "Can't read certificate %s\n", argv[1]);
ERR_print_errors_fp(stderr);
exit(1);
goto err;
}
/* bind functions */
- if (!
- (p1 =
- (cl_engine_init *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F1))
-|| !(p2 = (cl_mod_exp *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F2))
-|| !(p3 = (cl_mod_exp_crt *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F3))
-|| !(p4 = (cl_rsa_mod_exp *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F4))
-|| !(p5 =
- (cl_rsa_priv_enc *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F5))
-|| !(p6 =
- (cl_rsa_priv_dec *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F6))
-|| !(p7 = (cl_rsa_pub_enc *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F7))
-|| !(p8 = (cl_rsa_pub_dec *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F8))
-|| !(p20 =
- (cl_rand_bytes *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F20))
-|| !(p30 = (cl_dsa_sign *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F30))
-|| !(p31 =
- (cl_dsa_verify *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F31))) {
+#define BINDIT(t, name) (t *)DSO_bind_func(cluster_labs_dso, name)
+ if ((p1 = (cl_engine_init, CLUSTER_LABS_F1)) == NULL
+ || (p2 = BINDIT(cl_mod_exp, CLUSTER_LABS_F2)) == NULL
+ || (p3 = BINDIT(cl_mod_exp_crt, CLUSTER_LABS_F3)) == NULL
+ || (p4 = BINDIT(cl_rsa_mod_exp, CLUSTER_LABS_F4)) == NULL
+ || (p5 = BINDIT(cl_rsa_priv_enc, CLUSTER_LABS_F5)) == NULL
+ || (p6 = BINDIT(cl_rsa_priv_dec, CLUSTER_LABS_F6)) == NULL
+ || (p7 = BINDIT(cl_rsa_pub_enc, CLUSTER_LABS_F7)) == NULL
+ || (p8 = BINDIT(cl_rsa_pub_dec, CLUSTER_LABS_F8)) == NULL
+ || (p20 = BINDIT(cl_rand_bytes, CLUSTER_LABS_F20)) == NULL
+ || (p30 = BINDIT(cl_dsa_sign, CLUSTER_LABS_F30)) == NULL
+ || (p31 = BINDIT(cl_dsa_verify, CLUSTER_LABS_F31)) == NULL) {
CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_DSO_FAILURE);
goto err;
}
goto err;
}
- if (!(p1 = DSO_bind_func(ibmca_dso, IBMCA_F1)) ||
- !(p2 = DSO_bind_func(ibmca_dso, IBMCA_F2)) ||
- !(p3 = DSO_bind_func(ibmca_dso, IBMCA_F3)) ||
- !(p4 = DSO_bind_func(ibmca_dso, IBMCA_F4)) ||
- !(p5 = DSO_bind_func(ibmca_dso, IBMCA_F5))) {
+ if ((p1 = DSO_bind_func(ibmca_dso, IBMCA_F1)) == NULL
+ || (p2 = DSO_bind_func(ibmca_dso, IBMCA_F2)) == NULL
+ || (p3 = DSO_bind_func(ibmca_dso, IBMCA_F3)) == NULL
+ || (p4 = DSO_bind_func(ibmca_dso, IBMCA_F4)) == NULL
+ || (p5 = DSO_bind_func(ibmca_dso, IBMCA_F5)) == NULL) {
IBMCAerr(IBMCA_F_IBMCA_INIT, IBMCA_R_DSO_FAILURE);
goto err;
}
/*
* Trying to load Function from the Library
*/
- if (!
- (ptr_1 =
- (t_zencod_bytes2bits *) DSO_bind_func(zencod_dso, ZENCOD_Fct_1))
-|| !(ptr_2 = (t_zencod_bits2bytes *) DSO_bind_func(zencod_dso, ZENCOD_Fct_2))
-|| !(ptr_3 = (t_zencod_new_number *) DSO_bind_func(zencod_dso, ZENCOD_Fct_3))
-|| !(ptr_4 = (t_zencod_init_number *) DSO_bind_func(zencod_dso, ZENCOD_Fct_4))
-|| !(ptr_exp_1 =
- (t_zencod_rsa_mod_exp *) DSO_bind_func(zencod_dso, ZENCOD_Fct_exp_1))
-|| !(ptr_exp_2 =
- (t_zencod_rsa_mod_exp_crt *) DSO_bind_func(zencod_dso, ZENCOD_Fct_exp_2))
-|| !(ptr_dsa_1 =
- (t_zencod_dsa_do_sign *) DSO_bind_func(zencod_dso, ZENCOD_Fct_dsa_1))
-|| !(ptr_dsa_2 =
- (t_zencod_dsa_do_verify *) DSO_bind_func(zencod_dso, ZENCOD_Fct_dsa_2))
-|| !(ptr_dh_1 =
- (t_zencod_dh_generate_key *) DSO_bind_func(zencod_dso, ZENCOD_Fct_dh_1))
-|| !(ptr_dh_2 =
- (t_zencod_dh_compute_key *) DSO_bind_func(zencod_dso, ZENCOD_Fct_dh_2))
-|| !(ptr_rand_1 =
- (t_zencod_rand_bytes *) DSO_bind_func(zencod_dso, ZENCOD_Fct_rand_1))
-|| !(ptr_math_1 =
- (t_zencod_math_mod_exp *) DSO_bind_func(zencod_dso, ZENCOD_Fct_math_1))
-|| !(ptr_0 = (t_zencod_test *) DSO_bind_func(zencod_dso, ZENCOD_Fct_0))
-|| !(ptr_md5_1 =
- (t_zencod_md5_init *) DSO_bind_func(zencod_dso, ZENCOD_Fct_md5_1))
-|| !(ptr_md5_2 =
- (t_zencod_md5_update *) DSO_bind_func(zencod_dso, ZENCOD_Fct_md5_2))
-|| !(ptr_md5_3 =
- (t_zencod_md5_do_final *) DSO_bind_func(zencod_dso, ZENCOD_Fct_md5_3))
-|| !(ptr_sha1_1 =
- (t_zencod_sha1_init *) DSO_bind_func(zencod_dso, ZENCOD_Fct_sha1_1))
-|| !(ptr_sha1_2 =
- (t_zencod_sha1_update *) DSO_bind_func(zencod_dso, ZENCOD_Fct_sha1_2))
-|| !(ptr_sha1_3 =
- (t_zencod_sha1_do_final *) DSO_bind_func(zencod_dso, ZENCOD_Fct_sha1_3))
-|| !(ptr_xdes_1 =
- (t_zencod_xdes_cipher *) DSO_bind_func(zencod_dso, ZENCOD_Fct_xdes_1))
-|| !(ptr_rc4_1 =
- (t_zencod_rc4_cipher *) DSO_bind_func(zencod_dso, ZENCOD_Fct_rc4_1))) {
-
+#define BINDIT(t, name) (t*)DSO_bindfunc(zencod_dso, name)
+ if ((ptr_1 = BINDIT(t_zencod_bytes2bits ZENCOD_Fct_1)) == NULL
+ || (ptr_2 = BINDIT(t_zencod_bits2bytes ZENCOD_Fct_2)) == NULL
+ || (ptr_3 = BINDIT(t_zencod_new_number ZENCOD_Fct_3)) == NULL
+ || (ptr_4 = BINDIT(t_zencod_init_number ZENCOD_Fct_4)) == NULL
+ || (ptr_exp_1 = BINDIT(t_zencod_rsa_mod_exp, ZENCOD_Fct_exp_1)) == NULL
+ || (ptr_exp_2 = BINDIT(t_zencod_rsa_mod_exp_crt, ZENCOD_Fct_exp_2)) == NULL
+ || (ptr_dsa_1 = BINDIT(t_zencod_dsa_do_sign, ZENCOD_Fct_dsa_1)) == NULL
+ || (ptr_dsa_2 = BINDIT(t_zencod_dsa_do_verify, ZENCOD_Fct_dsa_2)) == NULL
+ || (ptr_dh_1 = BINDIT(t_zencod_dh_generate_key, ZENCOD_Fct_dh_1)) == NULL
+ || (ptr_dh_2 = BINDIT(t_zencod_dh_compute_key, ZENCOD_Fct_dh_2)) == NULL
+ || (ptr_rand_1 = BINDIT(t_zencod_rand_bytes, ZENCOD_Fct_rand_1)) == NULL
+ || (ptr_math_1 = BINDIT(t_zencod_math_mod_exp, ZENCOD_Fct_math_1)) == NULL
+ || (ptr_0 = BINDIT(t_zencod_test, ZENCOD_Fct_0)) == NULL
+ || (ptr_md5_1 = BINDIT(t_zencod_md5_init, ZENCOD_Fct_md5_1)) == NULL
+ || (ptr_md5_2 = BINDIT(t_zencod_md5_update, ZENCOD_Fct_md5_2)) == NULL
+ || (ptr_md5_3 = BINDIT(t_zencod_md5_do_final, ZENCOD_Fct_md5_3)) == NULL
+ || (ptr_sha1_1 = BINDIT(t_zencod_sha1_init, ZENCOD_Fct_sha1_1)) == NULL
+ || (ptr_sha1_2 = BINDIT(t_zencod_sha1_update, ZENCOD_Fct_sha1_2)) == NULL
+ || (ptr_sha1_3 = BINDIT(t_zencod_sha1_do_final, ZENCOD_Fct_sha1_3)) == NULL
+ || (ptr_xdes_1 = BINDIT(t_zencod_xdes_cipher, ZENCOD_Fct_xdes_1)) == NULL
+ || (ptr_rc4_1 = BINDIT(t_zencod_rc4_cipher, ZENCOD_Fct_rc4_1)) == NULL) {
ZENCODerr(ZENCOD_F_ZENCOD_INIT, ZENCOD_R_DSO_FAILURE);
goto err;
}
return meth->dsa_do_sign(dgst, dlen, dsa);
}
- if (!(bn_s = BN_new()) || !(bn_r = BN_new())) {
+ if ((bn_s = BN_new()) == NULL || (bn_r = BN_new()) == NULL) {
ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_BAD_KEY_COMPONENTS);
goto FAILED;
}
goto FAILED;
}
- if (!(sig = DSA_SIG_new())) {
+ if ((sig = DSA_SIG_new()) == NULL) {
ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_REQUEST_FAILED);
goto FAILED;
}
bn_prv = dh->priv_key;
generate_x = 0;
} else {
- if (!(bn_prv = BN_new())) {
+ if ((bn_prv = BN_new()) == NULL) {
ENGINEerr(ZENCOD_F_ZENCOD_DH_GENERATE, ZENCOD_R_BN_EXPAND_FAIL);
goto FAILED;
}
/* Public key */
if (dh->pub_key)
bn_pub = dh->pub_key;
- else if (!(bn_pub = BN_new())) {
+ else if ((bn_pub = BN_new()) == NULL) {
ENGINEerr(ZENCOD_F_ZENCOD_DH_GENERATE, ZENCOD_R_BN_EXPAND_FAIL);
goto FAILED;
}
}
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
- if (!(fp = fopen(argv[1], "rb"))) {
+ if ((fp = fopen(argv[1], "rb")) == NULL) {
fprintf(stderr, "Error opening file %s\n", argv[1]);
exit(1);
}
exit(1);
}
PKCS12_free(p12);
- if (!(fp = fopen(argv[3], "w"))) {
+ if ((fp = fopen(argv[3], "w")) == NULL) {
fprintf(stderr, "Error opening file %s\n", argv[1]);
exit(1);
}
}
SSLeay_add_all_algorithms();
ERR_load_crypto_strings();
- if (!(fp = fopen(argv[1], "r"))) {
+ if ((fp = fopen(argv[1], "r")) == NULL) {
fprintf(stderr, "Error opening file %s\n", argv[1]);
exit(1);
}
ERR_print_errors_fp(stderr);
exit(1);
}
- if (!(fp = fopen(argv[4], "wb"))) {
+ if ((fp = fopen(argv[4], "wb")) == NULL) {
fprintf(stderr, "Error opening file %s\n", argv[1]);
ERR_print_errors_fp(stderr);
exit(1);
goto err;
}
BN_CTX_start(ctx);
- if (!(priv_key = EC_KEY_get0_private_key(ec))) {
+ if ((priv_key = EC_KEY_get0_private_key(ec)) == NULL) {
GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC, ERR_R_EC_LIB);
goto err;
}
if (!ec) {
return NULL;
}
- if (!(priv = EC_KEY_get0_private_key(ec)))
+ if ((priv = EC_KEY_get0_private_key(ec)) == NULL)
return NULL;
return (BIGNUM *)priv;
}
CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_DSO_FAILURE);
goto err;
}
+#define BINDIT(t, name) (t)DSO_bind_func(dso, name)
# ifndef OPENSSL_NO_RSA
- if (!(keyRecordRead = (F_KEYRECORDREAD)
- DSO_bind_func(dso, n_keyRecordRead)) ||
- !(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
- DSO_bind_func(dso, n_randomNumberGenerate)) ||
- !(digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)
- DSO_bind_func(dso, n_digitalSignatureGenerate)) ||
- !(digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)
- DSO_bind_func(dso, n_digitalSignatureVerify)) ||
- !(publicKeyExtract = (F_PUBLICKEYEXTRACT)
- DSO_bind_func(dso, n_publicKeyExtract)) ||
- !(pkaEncrypt = (F_PKAENCRYPT)
- DSO_bind_func(dso, n_pkaEncrypt)) || !(pkaDecrypt = (F_PKADECRYPT)
- DSO_bind_func(dso,
- n_pkaDecrypt)))
+ if ((keyRecordRead = BINDIT(F_KEYRECORDREAD, n_keyRecordRead)) == NULL
+ || (randomNumberGenerate = BINDIT(F_RANDOMNUMBERGENERATE, n_randomNumberGenerate)) == NULL
+ || (digitalSignatureGenerate = BINDIT(F_DIGITALSIGNATUREGENERATE, n_digitalSignatureGenerate)) == NULL
+ || (digitalSignatureVerify = BINDIT(F_DIGITALSIGNATUREVERIFY, n_digitalSignatureVerify)) == NULL
+ || (publicKeyExtract = BINDIT(F_PUBLICKEYEXTRACT, n_publicKeyExtract)) == NULL
+ || (pkaEncrypt = BINDIT(F_PKAENCRYPT, n_pkaEncrypt)) == NULL
+ || (pkaDecrypt = BINDIT(F_PKADECRYPT, n_pkaDecrypt)) == NULL)
{
CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_DSO_FAILURE);
goto err;
}
# else
- if (!(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
- DSO_bind_func(dso, n_randomNumberGenerate))) {
+ if ((randomNumberGenerate = BINDIT(F_RANDOMNUMBERGENERATE, n_randomNumberGenerate)) == NULL) {
CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_DSO_FAILURE);
goto err;
}
/* Attempt to load libaep.so. */
aep_dso = DSO_load(NULL, get_AEP_LIBNAME(), NULL, 0);
-
if (aep_dso == NULL) {
AEPHKerr(AEPHK_F_AEP_INIT, AEPHK_R_NOT_LOADED);
goto err;
}
- if (!(p1 = (t_AEP_ModExp *) DSO_bind_func(aep_dso, AEP_F1)) ||
- !(p2 = (t_AEP_ModExpCrt *) DSO_bind_func(aep_dso, AEP_F2)) ||
+#define BINDIT(t, name) (t *)DSO_bind_func(aep_dso, name)
+ if ((p1 = BINDIT(t_AEP_ModExp, AEP_F1)) == NULL
+ || (p2 = BINDIT(t_AEP_ModExpCrt, AEP_F2)) == NULL
# ifdef AEPRAND
- !(p3 = (t_AEP_GenRandom *) DSO_bind_func(aep_dso, AEP_F3)) ||
+ || (p3 = BINDIT(t_AEP_GenRandom, AEP_F3)) == NULL
# endif
- !(p4 = (t_AEP_Finalize *) DSO_bind_func(aep_dso, AEP_F4)) ||
- !(p5 = (t_AEP_Initialize *) DSO_bind_func(aep_dso, AEP_F5)) ||
- !(p6 = (t_AEP_OpenConnection *) DSO_bind_func(aep_dso, AEP_F6)) ||
- !(p7 = (t_AEP_SetBNCallBacks *) DSO_bind_func(aep_dso, AEP_F7)) ||
- !(p8 = (t_AEP_CloseConnection *) DSO_bind_func(aep_dso, AEP_F8))) {
+ || (p4 = BINDIT(t_AEP_Finalize, AEP_F4)) == NULL
+ || (p5 = BINDIT(t_AEP_Initialize, AEP_F5)) == NULL
+ || (p6 = BINDIT(t_AEP_OpenConnection, AEP_F6)) == NULL
+ || (p7 = BINDIT(t_AEP_SetBNCallBacks, AEP_F7)) == NULL
+ || (p8 = BINDIT(t_AEP_CloseConnection, AEP_F8)) == NULL) {
AEPHKerr(AEPHK_F_AEP_INIT, AEPHK_R_NOT_LOADED);
goto err;
}
ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_NOT_LOADED);
goto err;
}
- if (!
- (p1 =
- (tfnASI_GetHardwareConfig *) DSO_bind_func(atalla_dso, ATALLA_F1))
-|| !(p2 = (tfnASI_RSAPrivateKeyOpFn *) DSO_bind_func(atalla_dso, ATALLA_F2))
-|| !(p3 =
- (tfnASI_GetPerformanceStatistics *) DSO_bind_func(atalla_dso,
- ATALLA_F3))) {
+#define BINDIT(t, name) (t *)DSO_bind_func(atalla_dso, name)
+ if ((p1 = BINDIT(tfnASI_GetHardwareConfig, ATALLA_F1)) == NULL
+ || (p2 = BINDIT(tfnASI_RSAPrivateKeyOpFn, ATALLA_F2)) == NULL
+ || (p3 = BINDIT(tfnASI_GetPerformanceStatistics, ATALLA_F3)) == NULL) {
ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_NOT_LOADED);
goto err;
}
RSA_set_ex_data(rkey, rsa_capi_idx, key);
- if (!(ret = EVP_PKEY_new()))
+ if ((ret = EVP_PKEY_new()) == NULL)
goto memerr;
EVP_PKEY_assign_RSA(ret, rkey);
DSA_set_ex_data(dkey, dsa_capi_idx, key);
- if (!(ret = EVP_PKEY_new()))
+ if ((ret = EVP_PKEY_new()) == NULL)
goto memerr;
EVP_PKEY_assign_DSA(ret, dkey);
}
/* Create temp reverse order version of input */
- if (!(tmpbuf = OPENSSL_malloc(flen))) {
+ if ((tmpbuf = OPENSSL_malloc(flen)) == NULL) {
CAPIerr(CAPI_F_CAPI_RSA_PRIV_DEC, ERR_R_MALLOC_FAILURE);
return -1;
}
HWCRHKerr(HWCRHK_F_HWCRHK_INIT, HWCRHK_R_DSO_FAILURE);
goto err;
}
- if (!(p1 = (HWCryptoHook_Init_t *)
- DSO_bind_func(hwcrhk_dso, n_hwcrhk_Init)) ||
- !(p2 = (HWCryptoHook_Finish_t *)
- DSO_bind_func(hwcrhk_dso, n_hwcrhk_Finish)) ||
- !(p3 = (HWCryptoHook_ModExp_t *)
- DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExp)) ||
+
+#define BINDIT(t, name) (t *)DSO_bind_func(hwcrhk_dso, name)
+ if ((p1 = BINDIT(HWCryptoHook_Init_t, n_hwcrhk_Init)) == NULL
+ || (p2 = BINDIT(HWCryptoHook_Finish_t, n_hwcrhk_Finish)) == NULL
+ || (p3 = BINDIT(HWCryptoHook_ModExp_t, n_hwcrhk_ModExp)) == NULL
# ifndef OPENSSL_NO_RSA
- !(p4 = (HWCryptoHook_RSA_t *)
- DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSA)) ||
- !(p5 = (HWCryptoHook_RSALoadKey_t *)
- DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSALoadKey)) ||
- !(p6 = (HWCryptoHook_RSAGetPublicKey_t *)
- DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAGetPublicKey)) ||
- !(p7 = (HWCryptoHook_RSAUnloadKey_t *)
- DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAUnloadKey)) ||
+ || (p4 = BINDIT(HWCryptoHook_RSA_t, n_hwcrhk_RSA)) == NULL
+ || (p5 = BINDIT(HWCryptoHook_RSALoadKey_t, n_hwcrhk_RSALoadKey)) == NULL
+ || (p6 = BINDIT(HWCryptoHook_RSAGetPublicKey_t, n_hwcrhk_RSAGetPublicKey)) == NULL
+ || (p7 = BINDIT(HWCryptoHook_RSAUnloadKey_t, n_hwcrhk_RSAUnloadKey)) == NULL
# endif
- !(p8 = (HWCryptoHook_RandomBytes_t *)
- DSO_bind_func(hwcrhk_dso, n_hwcrhk_RandomBytes)) ||
- !(p9 = (HWCryptoHook_ModExpCRT_t *)
- DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExpCRT))) {
+ || (p8 = BINDIT(HWCryptoHook_RandomBytes_t, n_hwcrhk_RandomBytes)) == NULL
+ || (p9 = BINDIT(HWCryptoHook_ModExpCRT_t, n_hwcrhk_ModExpCRT)) == NULL) {
HWCRHKerr(HWCRHK_F_HWCRHK_INIT, HWCRHK_R_DSO_FAILURE);
goto err;
}
CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_NOT_LOADED);
goto err;
}
- if (!(p1 = (t_swAcquireAccContext *)
- DSO_bind_func(cswift_dso, CSWIFT_F1)) ||
- !(p2 = (t_swAttachKeyParam *)
- DSO_bind_func(cswift_dso, CSWIFT_F2)) ||
- !(p3 = (t_swSimpleRequest *)
- DSO_bind_func(cswift_dso, CSWIFT_F3)) ||
- !(p4 = (t_swReleaseAccContext *)
- DSO_bind_func(cswift_dso, CSWIFT_F4))) {
+
+#define BINDIT(t, name) (t *)DSO_bind_func(cswift_dso, name)
+ if ((p1 = BINDIT(t_swAcquireAccContext, CSWIFT_F1)) == NULL
+ || (p2 = BINDIT(t_swAttachKeyParam, CSWIFT_F2)) == NULL
+ || (p3 = BINDIT(t_swSimpleRequest *) DSO_bind_func(cswift_dso, CSWIFT_F3)) == NULL
+ || (p4 = BINDIT(t_swReleaseAccContext *) DSO_bind_func(cswift_dso, CSWIFT_F4)) == NULL) {
CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_NOT_LOADED);
goto err;
}
ENGINE_R_NOT_INITIALISED);
}
/* extract ref to private key */
- else if (!(hptr = RSA_get_ex_data(rsa, rsaHndidx))) {
+ else if ((hptr = RSA_get_ex_data(rsa, rsaHndidx)) == NULL) {
SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,
SUREWARE_R_MISSING_KEY_COMPONENTS);
goto err;
SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_SIGN, ENGINE_R_NOT_INITIALISED);
}
/* extract ref to private key */
- else if (!(hptr = RSA_get_ex_data(rsa, rsaHndidx))) {
+ else if ((hptr = RSA_get_ex_data(rsa, rsaHndidx)) == NULL) {
SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_SIGN,
SUREWARE_R_MISSING_KEY_COMPONENTS);
} else {
goto err;
}
/* extract ref to private key */
- else if (!(hptr = DSA_get_ex_data(dsa, dsaHndidx))) {
+ else if ((hptr = DSA_get_ex_data(dsa, dsaHndidx)) == NULL) {
SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,
SUREWARE_R_MISSING_KEY_COMPONENTS);
goto err;
goto err;
}
- if (!(p1 = (t_UBSEC_ubsec_bytes_to_bits *)
- DSO_bind_func(ubsec_dso, UBSEC_F1))
- || !(p2 = (t_UBSEC_ubsec_bits_to_bytes *)
- DSO_bind_func(ubsec_dso, UBSEC_F2))
- || !(p3 = (t_UBSEC_ubsec_open *)
- DSO_bind_func(ubsec_dso, UBSEC_F3))
- || !(p4 = (t_UBSEC_ubsec_close *)
- DSO_bind_func(ubsec_dso, UBSEC_F4))
+#define BINDIT(t, name) (t *)DSO_bind_func(ubsec_dso, name)
+ if ((p1 = BINDIT(t_UBSEC_ubsec_bytes_to_bits, UBSEC_F1)) == NULL
+ || (p2 = BINDIT(t_UBSEC_ubsec_bits_to_bytes, UBSEC_F2)) == NULL
+ || (p3 = BINDIT(t_UBSEC_ubsec_open, UBSEC_F3)) == NULL
+ || (p4 = BINDIT(t_UBSEC_ubsec_close, UBSEC_F4)) == NULL
# ifndef OPENSSL_NO_DH
- || !(p5 = (t_UBSEC_diffie_hellman_generate_ioctl *)
- DSO_bind_func(ubsec_dso, UBSEC_F5))
- || !(p6 = (t_UBSEC_diffie_hellman_agree_ioctl *)
- DSO_bind_func(ubsec_dso, UBSEC_F6))
+ || (p5 = BINDIT(t_UBSEC_diffie_hellman_generate_ioctl, UBSEC_F5)) == NULL
+ || (p6 = BINDIT(t_UBSEC_diffie_hellman_agree_ioctl, UBSEC_F6)) == NULL
# endif
/* #ifndef OPENSSL_NO_RSA */
- || !(p7 = (t_UBSEC_rsa_mod_exp_ioctl *)
- DSO_bind_func(ubsec_dso, UBSEC_F7))
- || !(p8 = (t_UBSEC_rsa_mod_exp_crt_ioctl *)
- DSO_bind_func(ubsec_dso, UBSEC_F8))
+ || (p7 = BINDIT(t_UBSEC_rsa_mod_exp_ioctl, UBSEC_F7)) == NULL
+ || (p8 = BINDIT(t_UBSEC_rsa_mod_exp_crt_ioctl, UBSEC_F8)) == NULL
/* #endif */
# ifndef OPENSSL_NO_DSA
- || !(p9 = (t_UBSEC_dsa_sign_ioctl *)
- DSO_bind_func(ubsec_dso, UBSEC_F9))
- || !(p10 = (t_UBSEC_dsa_verify_ioctl *)
- DSO_bind_func(ubsec_dso, UBSEC_F10))
+ || (p9 = BINDIT(t_UBSEC_dsa_sign_ioctl, UBSEC_F9)) == NULL
+ || (p10 = BINDIT(t_UBSEC_dsa_verify_ioctl, UBSEC_F10)) == NULL
# endif
- || !(p11 = (t_UBSEC_math_accelerate_ioctl *)
- DSO_bind_func(ubsec_dso, UBSEC_F11))
- || !(p12 = (t_UBSEC_rng_ioctl *)
- DSO_bind_func(ubsec_dso, UBSEC_F12))
- || !(p13 = (t_UBSEC_max_key_len_ioctl *)
- DSO_bind_func(ubsec_dso, UBSEC_F13))) {
+ || (p11 = BINDIT(t_UBSEC_math_accelerate_ioctl, UBSEC_F11)) == NULL
+ || (p12 = BINDIT(t_UBSEC_rng_ioctl, UBSEC_F12)) == NULL
+ || (p13 = BINDIT(t_UBSEC_max_key_len_ioctl, UBSEC_F13)) == NULL) {
UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
goto err;
}
char *ptr = (char *)profiles_string;
SRTP_PROTECTION_PROFILE *p;
- if (!(profiles = sk_SRTP_PROTECTION_PROFILE_new_null())) {
+ if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {
SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);
return 1;
# endif /* KRB5_MIT_OLD11 */
# ifdef KRB5CHECKAUTH
- if (!cklens && !(cklens = (size_t *)calloc(sizeof(int), n + 1)))
+ if (cklens == NULL
+ && (cklens = (size_t *)calloc(sizeof(int), n + 1)) == NULL)
return NULL;
for (i = 0; i < n; i++) {
conlen = (etype) ? 8 : 0;
- if (!cksumlens && !(cksumlens = populate_cksumlens()))
+ if (cksumlens NULL
+ && (cksumlens = populate_cksumlens()) == NULL)
return NULL;
for (i = 0; (cklen = cksumlens[i]) != 0; i++) {
test_auth = a + conlen + cklen;
}
param_len += i;
- if (!(s->srp_ctx.N = BN_bin2bn(p, i, NULL))) {
+ if ((s->srp_ctx.N = BN_bin2bn(p, i, NULL)) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
}
param_len += i;
- if (!(s->srp_ctx.g = BN_bin2bn(p, i, NULL))) {
+ if ((s->srp_ctx.g = BN_bin2bn(p, i, NULL)) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
}
param_len += i;
- if (!(s->srp_ctx.s = BN_bin2bn(p, i, NULL))) {
+ if ((s->srp_ctx.s = BN_bin2bn(p, i, NULL)) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
}
param_len += i;
- if (!(s->srp_ctx.B = BN_bin2bn(p, i, NULL))) {
+ if ((s->srp_ctx.B = BN_bin2bn(p, i, NULL)) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
}
param_len += i;
- if (!(rsa->n = BN_bin2bn(p, i, rsa->n))) {
+ if ((rsa->n = BN_bin2bn(p, i, rsa->n)) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
}
param_len += i;
- if (!(rsa->e = BN_bin2bn(p, i, rsa->e))) {
+ if ((rsa->e = BN_bin2bn(p, i, rsa->e)) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
}
param_len += i;
- if (!(dh->p = BN_bin2bn(p, i, NULL))) {
+ if ((dh->p = BN_bin2bn(p, i, NULL)) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
}
param_len += i;
- if (!(dh->g = BN_bin2bn(p, i, NULL))) {
+ if ((dh->g = BN_bin2bn(p, i, NULL)) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
}
param_len += i;
- if (!(dh->pub_key = BN_bin2bn(p, i, NULL))) {
+ if ((dh->pub_key = BN_bin2bn(p, i, NULL)) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
SSL_R_BAD_SRP_A_LENGTH);
goto f_err;
}
- if (!(s->srp_ctx.A = BN_bin2bn(p, i, NULL))) {
+ if ((s->srp_ctx.A = BN_bin2bn(p, i, NULL)) == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_BN_LIB);
goto err;
}
if (!SRP_Verify_A_mod_N(s->srp_ctx.A, s->srp_ctx.N))
goto err;
- if (!(u = SRP_Calc_u(s->srp_ctx.A, s->srp_ctx.B, s->srp_ctx.N)))
+ if ((u = SRP_Calc_u(s->srp_ctx.A, s->srp_ctx.B, s->srp_ctx.N)) == NULL)
goto err;
- if (!
- (K =
- SRP_Calc_server_key(s->srp_ctx.A, s->srp_ctx.v, u, s->srp_ctx.b,
- s->srp_ctx.N)))
+ if ((K = SRP_Calc_server_key(s->srp_ctx.A, s->srp_ctx.v, u, s->srp_ctx.b,
+ s->srp_ctx.N)) == NULL)
goto err;
tmp_len = BN_num_bytes(K);
if ((tmp = OPENSSL_malloc(tmp_len)) == NULL)
goto err;
BN_bn2bin(K, tmp);
- ret =
- s->method->ssl3_enc->generate_master_secret(s, master_key, tmp,
- tmp_len);
+ ret = s->method->ssl3_enc->generate_master_secret(s, master_key, tmp,
+ tmp_len);
err:
OPENSSL_clear_free(tmp, tmp_len);
BN_clear_free(K);
*/
if (SRP_Verify_B_mod_N(s->srp_ctx.B, s->srp_ctx.N) == 0)
goto err;
- if (!(u = SRP_Calc_u(s->srp_ctx.A, s->srp_ctx.B, s->srp_ctx.N)))
+ if ((u = SRP_Calc_u(s->srp_ctx.A, s->srp_ctx.B, s->srp_ctx.N)) == NULL)
goto err;
if (s->srp_ctx.SRP_give_srp_client_pwd_callback == NULL)
goto err;
s->srp_ctx.SRP_give_srp_client_pwd_callback(s,
s->srp_ctx.SRP_cb_arg)))
goto err;
- if (!(x = SRP_Calc_x(s->srp_ctx.s, s->srp_ctx.login, passwd)))
+ if ((x = SRP_Calc_x(s->srp_ctx.s, s->srp_ctx.login, passwd)) == NULL)
goto err;
- if (!
- (K =
- SRP_Calc_client_key(s->srp_ctx.N, s->srp_ctx.B, s->srp_ctx.g, x,
- s->srp_ctx.a, u)))
+ if ((K = SRP_Calc_client_key(s->srp_ctx.N, s->srp_ctx.B, s->srp_ctx.g, x,
+ s->srp_ctx.a, u)) == NULL)
goto err;
tmp_len = BN_num_bytes(K);
group_order_tests(group);
- if (!(P_160 = EC_GROUP_new(EC_GROUP_method_of(group))))
+ if ((P_160 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)
ABORT;
if (!EC_GROUP_copy(P_160, group))
ABORT;
group_order_tests(group);
- if (!(P_192 = EC_GROUP_new(EC_GROUP_method_of(group))))
+ if ((P_192 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)
ABORT;
if (!EC_GROUP_copy(P_192, group))
ABORT;
group_order_tests(group);
- if (!(P_224 = EC_GROUP_new(EC_GROUP_method_of(group))))
+ if ((P_224 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)
ABORT;
if (!EC_GROUP_copy(P_224, group))
ABORT;
group_order_tests(group);
- if (!(P_256 = EC_GROUP_new(EC_GROUP_method_of(group))))
+ if ((P_256 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)
ABORT;
if (!EC_GROUP_copy(P_256, group))
ABORT;
group_order_tests(group);
- if (!(P_384 = EC_GROUP_new(EC_GROUP_method_of(group))))
+ if ((P_384 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)
ABORT;
if (!EC_GROUP_copy(P_384, group))
ABORT;
group_order_tests(group);
- if (!(P_521 = EC_GROUP_new(EC_GROUP_method_of(group))))
+ if ((P_521 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)
ABORT;
if (!EC_GROUP_copy(P_521, group))
ABORT;
if (EC_GROUP_get_degree(group) != _degree) ABORT; \
fprintf(stdout, " ok\n"); \
group_order_tests(group); \
- if (!(_variable = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; \
+ if ((_variable = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL) ABORT; \
if (!EC_GROUP_copy(_variable, group)) ABORT; \
# ifndef OPENSSL_NO_EC2M