file_cpy = app_malloc(mem_len, file);
i = 0;
- while(e < length) {
+ while (e < length) {
const char c = file[e];
if (c == '\n') {
file_cpy[i++] = '\\';
*/
if (app_libctx == NULL) {
if (!app_provider_load(NULL, "null")) {
- opt_printf_stderr( "Failed to create null provider\n");
+ opt_printf_stderr("Failed to create null provider\n");
return NULL;
}
app_libctx = OSSL_LIB_CTX_new();
char *p;
int last, ret = 1;
- for ( ; ; ) {
+ for (;;) {
last = 0;
for (p = name; *p != '\0' && *p != LIST_SEPARATOR_CHAR; p++)
continue;
static const char *format2string(int format)
{
- switch(format) {
+ switch (format) {
case FORMAT_PEM:
return "PEM";
case FORMAT_ASN1:
ERR_print_errors(bio_err);
BIO_printf(bio_err,
"%s: Error adding %s name attribute \"/%s=%s\"\n",
- opt_getprog(), desc, typestr ,valstr);
+ opt_getprog(), desc, typestr, valstr);
goto err;
}
}
# include <floss.h(floss_write)>
# endif
# endif
-int raw_write_stdout(const void *buf,int siz)
+int raw_write_stdout(const void *buf, int siz)
{
- return write(fileno(stdout),(void*)buf,siz);
+ return write(fileno(stdout), (void*)buf, siz);
}
#else
# if defined(__TANDEM)
#include <openssl/cmp.h>
#include <openssl/err.h>
#include <openssl/cmperr.h>
-
+
/* the context for the CMP mock server */
typedef struct
{
return;
}
- BIO_printf(bio, "---\nAcceptable %s certificate CA names\n",cs);
+ BIO_printf(bio, "---\nAcceptable %s certificate CA names\n", cs);
for (i = 0; i < sk_X509_NAME_num(sk); i++) {
X509_NAME_print_ex(bio, sk_X509_NAME_value(sk, i), 0, get_nameopt());
BIO_write(bio, "\n", 1);
} SPTB;
# ifdef TERM_SOCK_TEST
-\f
+
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
}
# endif
-\f
+
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
return TERM_SOCK_SUCCESS;
}
-\f
+
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
sin.sin_port = LocalHostPort ;
status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof(sin));
- if (status < 0 ) {
+ if (status < 0) {
LogMessage ("CreateSocketPair: connect () - %d", errno);
sys$cantim (&sptb, 0);
sys$cancel (TcpAcceptChan);
return (0) ;
}
-\f
+
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
return;
}
-\f
+
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
return status;
}
-\f
+
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
for (i = 0; i < (int)len; ++i)
BIO_printf(out, "%02X", buf[i]);
if (outfile == NULL)
- BIO_printf(out,"\n");
+ BIO_printf(out, "\n");
}
ret = 0;
OCSP_copy_nonce(bs, req);
mctx = EVP_MD_CTX_new();
- if ( mctx == NULL || !EVP_DigestSignInit(mctx, &pkctx, rmd, NULL, rkey)) {
+ if (mctx == NULL || !EVP_DigestSignInit(mctx, &pkctx, rmd, NULL, rkey)) {
*resp = OCSP_response_create(OCSP_RESPONSE_STATUS_INTERNALERROR, NULL);
goto end;
}
OPENSSL_strlcat(out_buf, ascii_salt, sizeof(out_buf));
/* assert "$5$rounds=999999999$......salt......" */
- if (strlen(out_buf) > 3 + 17 * rounds_custom + salt_len )
+ if (strlen(out_buf) > 3 + 17 * rounds_custom + salt_len)
goto err;
md = EVP_MD_CTX_new();
goto end;
}
mbuf = app_malloc(filesize, "oneshot sign/verify buffer");
- switch(pkey_op) {
+ switch (pkey_op) {
case EVP_PKEY_OP_VERIFY:
buf_len = BIO_read(in, mbuf, filesize);
if (buf_len != filesize) {
goto end;
}
- switch(pkey_op) {
+ switch (pkey_op) {
case EVP_PKEY_OP_VERIFY:
for (;;) {
buf_len = BIO_read(in, tbuf, TBUF_MAXSIZE);
goto end;
}
- if (!make_REQ(req, pkey, fsubj, multirdn, !gen_x509, chtype)){
+ if (!make_REQ(req, pkey, fsubj, multirdn, !gen_x509, chtype)) {
BIO_printf(bio_err, "Error making certificate request\n");
goto end;
}
if (!noservername && (servername != NULL || dane_tlsa_domain == NULL)) {
if (servername == NULL) {
- if(host == NULL || is_dNS_name(host))
+ if (host == NULL || is_dNS_name(host))
servername = (host == NULL) ? "localhost" : host;
}
if (servername != NULL && !SSL_set_tlsext_host_name(con, servername)) {
BIO_printf(bio_err, "RENEGOTIATING\n");
SSL_renegotiate(con);
cbuf_len = 0;
- } else if (!c_ign_eof && (cbuf[0] == 'K' || cbuf[0] == 'k' )
+ } else if (!c_ign_eof && (cbuf[0] == 'K' || cbuf[0] == 'k')
&& cmdletters) {
BIO_printf(bio_err, "KEYUPDATE\n");
SSL_key_update(con,
if ((*ctx)->expect_file_generations) {
char *p = (*ctx)->entry_name + strlen((*ctx)->entry_name);
- while(p > (*ctx)->entry_name && isdigit(p[-1]))
+ while (p > (*ctx)->entry_name && isdigit(p[-1]))
p--;
if (p > (*ctx)->entry_name && p[-1] == ';')
p[-1] = '\0';
#if 1
static void prefetch256(const void *table)
{
- volatile unsigned long *t=(void *)table,ret;
+ volatile unsigned long *t = (void *)table, ret;
unsigned long sum;
int i;
/* 32 is common least cache-line size */
- for (sum=0,i=0;i<256/sizeof(t[0]);i+=32/sizeof(t[0])) sum ^= t[i];
+ for (sum = 0, i = 0; i < 256/sizeof(t[0]); i += 32/sizeof(t[0]))
+ sum ^= t[i];
ret = sum;
}
ARIA_ADD_ROUND_KEY(rk, reg0, reg1, reg2, reg3);
rk++;
- while(Nr -= 2){
+ while (Nr -= 2) {
ARIA_SUBST_DIFF_EVEN(reg0, reg1, reg2, reg3);
ARIA_ADD_ROUND_KEY(rk, reg0, reg1, reg2, reg3);
rk++;
{
int ret = 0; /* Assume failure */
- switch(family) {
+ switch (family) {
case AF_INET:
#ifdef AF_INET6
case AF_INET6:
he_fallback_address = INADDR_ANY;
if (host == NULL) {
he = &he_fallback;
- switch(lookup_type) {
+ switch (lookup_type) {
case BIO_LOOKUP_CLIENT:
he_fallback_address = INADDR_LOOPBACK;
break;
/* The easiest way to create a linked list from an
array is to start from the back */
- for(addrlistp = he->h_addr_list; *addrlistp != NULL;
- addrlistp++)
+ for (addrlistp = he->h_addr_list; *addrlistp != NULL;
+ addrlistp++)
;
- for(addresses = addrlistp - he->h_addr_list;
- addrlistp--, addresses-- > 0; ) {
+ for (addresses = addrlistp - he->h_addr_list;
+ addrlistp--, addresses-- > 0; ) {
if (!addrinfo_wrap(he->h_addrtype, socktype,
*addrlistp, he->h_length,
se->s_port, &tmp_bai))
inc 16,%o1
addxcc %g3,%g4,%g3
st %g3,[%o0+4]
-
+
ld [%o1-4],%g3
ld [%o2+12],%g4
inc 16,%o2
inc 16,%o1
subxcc %g3,%g4,%g4
st %g4,[%o0+4]
-
+
ld [%o1-4],%g3
ld [%o2+12],%g4
inc 16,%o2
addxcc c_2,t_2,c_2 !=
st c_1,rp(6) !r[6]=c1;
st c_2,rp(7) !r[7]=c2;
-
+
ret
restore %g0,%g0,%o0
addxcc c_2,t_2,c_2 !=
st c_1,rp(6) !r[6]=c1;
st c_2,rp(7) !r[7]=c2;
-
+
ret
restore %g0,%g0,%o0
inc 16,%o1
addccc %g1,%g2,%g1
stuw %g1,[%o0+4]
-
+
inc 16,%o2
addccc %g3,%g4,%g3
stuw %g3,[%o0+8]
srlx t_1,32,c_12 !=
stuw t_1,rp(6) !r[6]=c1;
stuw c_12,rp(7) !r[7]=c2;
-
+
ret
restore %g0,%g0,%o0
srlx t_1,32,c_12
stuw t_1,rp(6) !r[6]=c1;
stuw c_12,rp(7) !r[7]=c2;
-
+
ret
restore %g0,%g0,%o0
BN_set_flags(p1, BN_FLG_CONSTTIME);
/* Find the first odd number >= Xp1 that is probably prime */
- for(;;) {
+ for (;;) {
i++;
BN_GENCB_call(cb, 0, i);
/* MR test with trial division */
}
msg = OSSL_CMP_MSG_new(libctx, propq);
- if (msg == NULL){
+ if (msg == NULL) {
ERR_raise(ERR_LIB_CMP, ERR_R_MALLOC_FAILURE);
return NULL;
}
{
const char *alg = NULL;
- switch(keylen) {
+ switch (keylen) {
case 16:
alg = "AES-128-WRAP";
break;
base = 16, str++;
}
- while((digit = todigit(*str++)) < base)
+ while ((digit = todigit(*str++)) < base)
ret = ret * base + digit;
return ret;
static variant_char *ossl_strchr(const variant_char *str, char srch)
{ variant_char c;
- while((c = *str)) {
+ while ((c = *str)) {
if (c == srch)
return (variant_char *)str;
str++;
* We have a curve defined by a Weierstrass equation
* y^2 + x*y = x^3 + a*x^2 + b.
* <=> x^3 + a*x^2 + x*y + b + y^2 = 0
- * <=> ((x + a) * x + y ) * x + b + y^2 = 0
+ * <=> ((x + a) * x + y) * x + b + y^2 = 0
*/
if (!BN_GF2m_add(lh, point->X, group->a))
goto err;
if (ecbits <= 0)
goto err;
- sz = (ecbits + 7 ) / 8;
+ sz = (ecbits + 7) / 8;
if (!OSSL_PARAM_BLD_push_BN_pad(tmpl,
OSSL_PKEY_PARAM_PRIV_KEY,
priv_key, sz))
point_conversion_form_t genform;
if (group == NULL) {
- ERR_raise(ERR_LIB_EC,EC_R_PASSED_NULL_PARAMETER);
+ ERR_raise(ERR_LIB_EC, EC_R_PASSED_NULL_PARAMETER);
return 0;
}
/*
* The bottom 128 bit of the exponent are processed with fixed 4-bit window
*/
- for(i = 0; i < 32; i++) {
+ for (i = 0; i < 32; i++) {
/* expLo - the low 128 bits of the exponent we use (ord(p256) - 2),
* split into nibbles */
static const unsigned char expLo[32] = {
/*-
* Apply randomization of EC point projective coordinates:
*
- * (X, Y ,Z ) = (lambda^2*X, lambda^3*Y, lambda*Z)
- * lambda = [1,group->field)
+ * (X, Y, Z) = (lambda^2*X, lambda^3*Y, lambda*Z)
+ * lambda = [1, group->field)
*
*/
int ossl_ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p,
{
if (IS25519(pkey->ameth->pkey_id)) {
return X25519_BITS;
- } else if(ISX448(pkey->ameth->pkey_id)) {
+ } else if (ISX448(pkey->ameth->pkey_id)) {
return X448_BITS;
} else {
return ED448_BITS;
ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
return -2;
}
- switch(ctx->operation) {
+ switch (ctx->operation) {
case EVP_PKEY_OP_ENCRYPT:
if (ctx->pmeth->encrypt_init == NULL)
return 1;
if (!enc || !cctx->aes.ccm.tag_set)
return 0;
- if(arg < cctx->aes.ccm.m)
+ if (arg < cctx->aes.ccm.m)
return 0;
memcpy(ptr, cctx->aes.ccm.kmac_param.icv.b, cctx->aes.ccm.m);
EVP_CIPHER_CTX_get_key_length(ctx) * 8,
EVP_CIPHER_CTX_get_cipher_data(ctx));
if (ret < 0) {
- ERR_raise(ERR_LIB_EVP,EVP_R_ARIA_KEY_SETUP_FAILED);
+ ERR_raise(ERR_LIB_EVP, EVP_R_ARIA_KEY_SETUP_FAILED);
return 0;
}
return 1;
const unsigned char *iv, int enc)
{
int ret;
- EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX,ctx);
+ EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX, ctx);
if (!iv && !key)
return 1;
CRYPTO_gcm128_init(&gctx->gcm, &gctx->ks,
(block128_f) ossl_aria_encrypt);
if (ret < 0) {
- ERR_raise(ERR_LIB_EVP,EVP_R_ARIA_KEY_SETUP_FAILED);
+ ERR_raise(ERR_LIB_EVP, EVP_R_ARIA_KEY_SETUP_FAILED);
return 0;
}
static int aria_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
{
- EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX,c);
+ EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX, c);
switch (type) {
case EVP_CTRL_INIT:
case EVP_CTRL_COPY:
{
EVP_CIPHER_CTX *out = ptr;
- EVP_ARIA_GCM_CTX *gctx_out = EVP_C_DATA(EVP_ARIA_GCM_CTX,out);
+ EVP_ARIA_GCM_CTX *gctx_out = EVP_C_DATA(EVP_ARIA_GCM_CTX, out);
if (gctx->gcm.key) {
if (gctx->gcm.key != &gctx->ks)
return 0;
static int aria_gcm_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
- EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX,ctx);
+ EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX, ctx);
int rv = -1;
/* Encrypt/decrypt must be performed in place */
static int aria_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
- EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX,ctx);
+ EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX, ctx);
/* If not set up, return error */
if (!gctx->key_set)
const unsigned char *iv, int enc)
{
int ret;
- EVP_ARIA_CCM_CTX *cctx = EVP_C_DATA(EVP_ARIA_CCM_CTX,ctx);
+ EVP_ARIA_CCM_CTX *cctx = EVP_C_DATA(EVP_ARIA_CCM_CTX, ctx);
if (!iv && !key)
return 1;
CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L,
&cctx->ks, (block128_f) ossl_aria_encrypt);
if (ret < 0) {
- ERR_raise(ERR_LIB_EVP,EVP_R_ARIA_KEY_SETUP_FAILED);
+ ERR_raise(ERR_LIB_EVP, EVP_R_ARIA_KEY_SETUP_FAILED);
return 0;
}
cctx->str = NULL;
static int aria_ccm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
{
- EVP_ARIA_CCM_CTX *cctx = EVP_C_DATA(EVP_ARIA_CCM_CTX,c);
+ EVP_ARIA_CCM_CTX *cctx = EVP_C_DATA(EVP_ARIA_CCM_CTX, c);
switch (type) {
case EVP_CTRL_INIT:
case EVP_CTRL_COPY:
{
EVP_CIPHER_CTX *out = ptr;
- EVP_ARIA_CCM_CTX *cctx_out = EVP_C_DATA(EVP_ARIA_CCM_CTX,out);
+ EVP_ARIA_CCM_CTX *cctx_out = EVP_C_DATA(EVP_ARIA_CCM_CTX, out);
if (cctx->ccm.key) {
if (cctx->ccm.key != &cctx->ks)
return 0;
static int aria_ccm_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
- EVP_ARIA_CCM_CTX *cctx = EVP_C_DATA(EVP_ARIA_CCM_CTX,ctx);
+ EVP_ARIA_CCM_CTX *cctx = EVP_C_DATA(EVP_ARIA_CCM_CTX, ctx);
CCM128_CONTEXT *ccm = &cctx->ccm;
/* Encrypt/decrypt must be performed in place */
static int aria_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
- EVP_ARIA_CCM_CTX *cctx = EVP_C_DATA(EVP_ARIA_CCM_CTX,ctx);
+ EVP_ARIA_CCM_CTX *cctx = EVP_C_DATA(EVP_ARIA_CCM_CTX, ctx);
CCM128_CONTEXT *ccm = &cctx->ccm;
/* If not set up, return error */
const unsigned char *iv, int enc)
{
int ret, mode;
- EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);
+ EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY, ctx);
ret = Camellia_set_key(key, EVP_CIPHER_CTX_get_key_length(ctx) * 8,
&dat->ks);
static int camellia_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
- EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);
+ EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY, ctx);
if (dat->stream.cbc)
(*dat->stream.cbc) (in, out, len, &dat->ks, ctx->iv,
{
size_t bl = EVP_CIPHER_CTX_get_block_size(ctx);
size_t i;
- EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);
+ EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY, ctx);
if (len < bl)
return 1;
static int camellia_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
- EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);
+ EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY, ctx);
int num = EVP_CIPHER_CTX_get_num(ctx);
CRYPTO_ofb128_encrypt(in, out, len, &dat->ks, ctx->iv, &num, dat->block);
static int camellia_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
- EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);
+ EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY, ctx);
int num = EVP_CIPHER_CTX_get_num(ctx);
CRYPTO_cfb128_encrypt(in, out, len, &dat->ks, ctx->iv, &num,
static int camellia_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
- EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);
+ EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY, ctx);
int num = EVP_CIPHER_CTX_get_num(ctx);
CRYPTO_cfb128_8_encrypt(in, out, len, &dat->ks, ctx->iv, &num,
static int camellia_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, size_t len)
{
- EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);
+ EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY, ctx);
if (EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS)) {
int num = EVP_CIPHER_CTX_get_num(ctx);
{
int snum = EVP_CIPHER_CTX_get_num(ctx);
unsigned int num;
- EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY,ctx);
+ EVP_CAMELLIA_KEY *dat = EVP_C_DATA(EVP_CAMELLIA_KEY, ctx);
if (snum < 0)
return 0;
{
EVP_CHACHA_AEAD_CTX *actx = aead_data(ctx);
- switch(type) {
+ switch (type) {
case EVP_CTRL_INIT:
if (actx == NULL)
actx = ctx->cipher_data
const unsigned char *in, size_t inl)
{
BLOCK_CIPHER_ecb_loop()
- IDEA_ecb_encrypt(in + i, out + i, &EVP_C_DATA(EVP_IDEA_KEY,ctx)->ks);
+ IDEA_ecb_encrypt(in + i, out + i, &EVP_C_DATA(EVP_IDEA_KEY, ctx)->ks);
return 1;
}
enc = 1;
}
if (enc)
- IDEA_set_encrypt_key(key, &EVP_C_DATA(EVP_IDEA_KEY,ctx)->ks);
+ IDEA_set_encrypt_key(key, &EVP_C_DATA(EVP_IDEA_KEY, ctx)->ks);
else {
IDEA_KEY_SCHEDULE tmp;
IDEA_set_encrypt_key(key, &tmp);
- IDEA_set_decrypt_key(&tmp, &EVP_C_DATA(EVP_IDEA_KEY,ctx)->ks);
+ IDEA_set_decrypt_key(&tmp, &EVP_C_DATA(EVP_IDEA_KEY, ctx)->ks);
OPENSSL_cleanse((unsigned char *)&tmp, sizeof(IDEA_KEY_SCHEDULE));
}
return 1;
static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
{
- SEED_set_key(key, &EVP_C_DATA(EVP_SEED_KEY,ctx)->ks);
+ SEED_set_key(key, &EVP_C_DATA(EVP_SEED_KEY, ctx)->ks);
return 1;
}
{
if (app_pkey_methods == NULL) {
app_pkey_methods = sk_EVP_PKEY_METHOD_new(pmeth_cmp);
- if (app_pkey_methods == NULL){
+ if (app_pkey_methods == NULL) {
ERR_raise(ERR_LIB_EVP, ERR_R_MALLOC_FAILURE);
return 0;
}
for (p = params; p->key != NULL; p++) {
/* Check the ctx actually understands this parameter */
- if (OSSL_PARAM_locate_const(settable, p->key) == NULL )
+ if (OSSL_PARAM_locate_const(settable, p->key) == NULL)
return -2;
}
}
const OSSL_PARAM *gettable = EVP_PKEY_CTX_gettable_params(ctx);
const OSSL_PARAM *p;
- for (p = params; p->key != NULL; p++ ) {
+ for (p = params; p->key != NULL; p++) {
/* Check the ctx actually understands this parameter */
- if (OSSL_PARAM_locate_const(gettable, p->key) == NULL )
+ if (OSSL_PARAM_locate_const(gettable, p->key) == NULL)
return -2;
}
}
/* find q */
for (;;) {
- if(!BN_GENCB_call(cb, 0, m++))
+ if (!BN_GENCB_call(cb, 0, m++))
goto err;
/* A.1.1.2 Step (5) : generate seed with size seed_len */
* A.1.1.3 Step (10)
* n = floor(L / hash_outlen) - 1
*/
- n = (L - 1 ) / (mdsize << 3);
+ n = (L - 1) / (mdsize << 3);
/* Calculate 2^(L-1): Used in step A.1.1.2 Step (11.3) */
if (!BN_lshift(test, BN_value_one(), L - 1))
*res = FFC_CHECK_Q_MISMATCH;
goto err;
}
- if(!BN_GENCB_call(cb, 2, 0))
+ if (!BN_GENCB_call(cb, 2, 0))
goto err;
- if(!BN_GENCB_call(cb, 3, 0))
+ if (!BN_GENCB_call(cb, 3, 0))
goto err;
memcpy(seed_tmp, seed, seedlen);
n = OPENSSL_realloc(lh->b,
(unsigned int)(sizeof(OPENSSL_LH_NODE *) * lh->pmax));
if (n == NULL) {
- /* fputs("realloc error in lhash",stderr); */
+ /* fputs("realloc error in lhash", stderr); */
lh->error++;
return;
}
}
bag->type = OBJ_nid2obj(type);
- switch(vtype) {
+ switch (vtype) {
case V_ASN1_OCTET_STRING:
{
ASN1_OCTET_STRING *strtmp = ASN1_OCTET_STRING_new();
safebag->value.bag = bag;
safebag->type = OBJ_nid2obj(NID_secretBag);
return safebag;
-
+
err:
PKCS12_BAGS_free(bag);
return NULL;
sigaction(SIGILL, &ill_act, &ill_oact);
#ifndef OSSL_IMPLEMENT_GETAUXVAL
- if (sigsetjmp(ill_jmp,1) == 0) {
+ if (sigsetjmp(ill_jmp, 1) == 0) {
OPENSSL_fpu_probe();
OPENSSL_ppccap_P |= PPC_FPU;
++*needed;
return;
}
- if(*remain == 1)
+ if (*remain == 1)
**buf = '\0';
else
**buf = ch;
if (*remain == 0)
return;
- if(*remain < len + 1)
+ if (*remain < len + 1)
len = *remain - 1;
- if(len > 0) {
+ if (len > 0) {
strncpy(*buf, str, len);
*buf += len;
*remain -= len;
}
- if(len < olen && *remain == 1) {
+ if (len < olen && *remain == 1) {
**buf = '\0';
++*buf;
--*remain;
socket_transport_name_get(AF_UNIX, current_transport, 20);
- if (strcmp(current_transport,transport) == 0)
+ if (strcmp(current_transport, transport) == 0)
return socket(family, type, protocol);
/* set the requested socket transport */
if (socket_transport_name_set(AF_UNIX, transport))
return -1;
- socket_rc = socket(family,type,protocol);
+ socket_rc = socket(family, type, protocol);
/* set mode back to what it was */
if (socket_transport_name_set(AF_UNIX, current_transport))
setbuf(fp, NULL);
/* Try to connect */
- for ( ; ; ) {
+ for (;;) {
if (connect(fd, (struct sockaddr *)&addr, i) == 0)
break;
# ifdef EISCONN
# pragma environment restore
#endif
- for ( ; ; ) {
+ for (;;) {
if (bytes > 0)
n = (bytes <= RAND_LOAD_BUF_SIZE) ? (int)bytes : RAND_BUF_SIZE;
else
n = RAND_LOAD_BUF_SIZE;
i = fread(buf, 1, n, in);
#ifdef EINTR
- if (ferror(in) && errno == EINTR){
+ if (ferror(in) && errno == EINTR) {
clearerr(in);
if (i == 0)
continue;
return 0;
}
} else if (pss == NULL) {
- if (BIO_puts(bp,"(INVALID PSS PARAMETERS)\n") <= 0)
+ if (BIO_puts(bp, "(INVALID PSS PARAMETERS)\n") <= 0)
return 0;
return 1;
}
if (numbers == NULL)
return 0;
- for (i = 0; names[i] != NULL; i++){
+ for (i = 0; names[i] != NULL; i++) {
p = OSSL_PARAM_locate_const(params, names[i]);
if (p != NULL) {
BIGNUM *tmp = NULL;
return 0;
}
} else {
- switch(mdnid) {
+ switch (mdnid) {
/* List of all supported RSA digests */
case NID_sha1:
case NID_sha224:
if (!ossl_bn_rsa_fips186_4_gen_prob_primes(rsa->p, Xpo, p1, p2, Xp, Xp1, Xp2,
nbits, e, ctx, cb))
goto err;
- for(;;) {
+ for (;;) {
/* (Step 5) Generate q, Xq*/
if (!ossl_bn_rsa_fips186_4_gen_prob_primes(rsa->q, Xqo, q1, q2, Xq, Xq1,
Xq2, nbits, e, ctx, cb))
printf(++i % 16 && i != sizeof(out) ? " " : "\n");
}
- if (memcmp(out,result,sizeof(out))) {
- fprintf(stderr,"failure\n");
+ if (memcmp(out, result, sizeof(out))) {
+ fprintf(stderr, "failure\n");
return 1;
} else {
- fprintf(stderr,"success\n");
+ fprintf(stderr, "success\n");
return 0;
}
}
if (eckey == NULL
|| (group = EC_KEY_get0_group(eckey)) == NULL
|| (priv_key = EC_KEY_get0_private_key(eckey)) == NULL
- || (order = EC_GROUP_get0_order(group)) == NULL ) {
+ || (order = EC_GROUP_get0_order(group)) == NULL) {
ERR_raise(ERR_LIB_SM2, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
if (N_bn_alloc == NULL)
goto err;
N_bn = N_bn_alloc;
- if ((len = t_fromb64(tmp, sizeof(tmp) ,g)) <= 0)
+ if ((len = t_fromb64(tmp, sizeof(tmp), g)) <= 0)
goto err;
g_bn_alloc = BN_bin2bn(tmp, len, NULL);
if (g_bn_alloc == NULL)
if (loader_ctx == NULL) {
OSSL_STORE_LOADER_free(fetched_loader);
fetched_loader = NULL;
- } else if(!loader_set_params(fetched_loader, loader_ctx,
- params, propq)) {
+ } else if (!loader_set_params(fetched_loader, loader_ctx,
+ params, propq)) {
(void)fetched_loader->p_close(loader_ctx);
OSSL_STORE_LOADER_free(fetched_loader);
fetched_loader = NULL;
goto bad_policy;
}
cache->anyPolicy = data;
- } else if (sk_X509_POLICY_DATA_find(cache->data, data) >=0 ) {
+ } else if (sk_X509_POLICY_DATA_find(cache->data, data) >=0) {
ret = -1;
goto bad_policy;
} else if (!sk_X509_POLICY_DATA_push(cache->data, data)) {
if (tree) {
if (tree->extra_data == NULL)
tree->extra_data = sk_X509_POLICY_DATA_new_null();
- if (tree->extra_data == NULL){
+ if (tree->extra_data == NULL) {
ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE);
goto node_error;
}
|| BIO_printf(bp, "\n") <= 0)
goto err;
}
- if (namingAuthority->namingAuthorityUrl != NULL ) {
+ if (namingAuthority->namingAuthorityUrl != NULL) {
if (BIO_printf(bp, "%*s namingAuthorityUrl: ", ind, "") <= 0
|| ASN1_STRING_print(bp, namingAuthority->namingAuthorityUrl) <= 0
|| BIO_printf(bp, "\n") <= 0)
#include <openssl/asn1t.h>
#include <openssl/x509v3.h>
-ASN1_SEQUENCE(PROXY_POLICY) =
- {
- ASN1_SIMPLE(PROXY_POLICY,policyLanguage,ASN1_OBJECT),
- ASN1_OPT(PROXY_POLICY,policy,ASN1_OCTET_STRING)
+ASN1_SEQUENCE(PROXY_POLICY) = {
+ ASN1_SIMPLE(PROXY_POLICY, policyLanguage, ASN1_OBJECT),
+ ASN1_OPT(PROXY_POLICY, policy, ASN1_OCTET_STRING)
} ASN1_SEQUENCE_END(PROXY_POLICY)
IMPLEMENT_ASN1_FUNCTIONS(PROXY_POLICY)
-ASN1_SEQUENCE(PROXY_CERT_INFO_EXTENSION) =
- {
- ASN1_OPT(PROXY_CERT_INFO_EXTENSION,pcPathLengthConstraint,ASN1_INTEGER),
- ASN1_SIMPLE(PROXY_CERT_INFO_EXTENSION,proxyPolicy,PROXY_POLICY)
+ASN1_SEQUENCE(PROXY_CERT_INFO_EXTENSION) = {
+ ASN1_OPT(PROXY_CERT_INFO_EXTENSION, pcPathLengthConstraint, ASN1_INTEGER),
+ ASN1_SIMPLE(PROXY_CERT_INFO_EXTENSION, proxyPolicy, PROXY_POLICY)
} ASN1_SEQUENCE_END(PROXY_CERT_INFO_EXTENSION)
IMPLEMENT_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION)
return 0;
case X509_TRUST_UNTRUSTED:
default:
- switch(ctx->error) {
+ switch (ctx->error) {
case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
case X509_V_ERR_CERT_NOT_YET_VALID:
case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp);
ASN1_SEQUENCE(X509_REVOKED) = {
- ASN1_EMBED(X509_REVOKED,serialNumber, ASN1_INTEGER),
- ASN1_SIMPLE(X509_REVOKED,revocationDate, ASN1_TIME),
- ASN1_SEQUENCE_OF_OPT(X509_REVOKED,extensions, X509_EXTENSION)
+ ASN1_EMBED(X509_REVOKED, serialNumber, ASN1_INTEGER),
+ ASN1_SIMPLE(X509_REVOKED, revocationDate, ASN1_TIME),
+ ASN1_SEQUENCE_OF_OPT(X509_REVOKED, extensions, X509_EXTENSION)
} ASN1_SEQUENCE_END(X509_REVOKED)
static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r);
char *digest_value=NULL;
int j;
- input = BIO_new_fd( fileno(stdin), 1 );
+ input = BIO_new_fd(fileno(stdin), 1);
if (input == NULL) {
fprintf(stderr, "BIO_new_fd() for stdin returned NULL\n");
goto cleanup;
* The algorithm name is case insensitive.
* See providers(7) for details about algorithm fetching
*/
- md = EVP_MD_fetch( library_context, "SHA3-512", NULL );
+ md = EVP_MD_fetch(library_context, "SHA3-512", NULL);
if (md == NULL) {
fprintf(stderr, "EVP_MD_fetch did not find SHA3-512.\n");
goto cleanup;
goto cleanup;
}
/* set our bio_digest BIO to digest data */
- if (BIO_set_md(bio_digest,md) != 1) {
+ if (BIO_set_md(bio_digest, md) != 1) {
fprintf(stderr, "BIO_set_md failed.\n");
goto cleanup;
}
* We will use BIO chaining so that as we read, the digest gets updated
* See the man page for BIO_push
*/
- BIO *reading = BIO_push( bio_digest, input );
-
- while( BIO_read(reading, buffer, sizeof(buffer)) > 0 )
+ BIO *reading = BIO_push(bio_digest, input);
+
+ while (BIO_read(reading, buffer, sizeof(buffer)) > 0)
;
/*-
fprintf(stderr, "BIO_gets(bio_digest) failed\n");
goto cleanup;
}
- for (j=0; j<digest_size; j++) {
+ for (j = 0; j < digest_size; j++) {
fprintf(stdout, "%02x", (unsigned char)digest_value[j]);
}
fprintf(stdout, "\n");
result = 0;
-
+
cleanup:
if (result != 0)
ERR_print_errors_fp(stderr);
int main(void)
{
int result = 1;
- BIO *input = BIO_new_fd( fileno(stdin), 1 );
+ BIO *input = BIO_new_fd(fileno(stdin), 1);
if (input != NULL) {
result = demonstrate_digest(input);
static unsigned char pbkdf2_salt[] = {
'N', 'a', 'C', 'l'
};
-
+
/*
* The iteration parameter can be variable or hard coded. The disadvantage with
* hard coding them is that they cannot easily be adjusted for future
* now, as bind_aflag can only be called by one thread at a
* time.
*/
- for(i = 0; i < OSSL_NELEM(afalg_cipher_nids); i++) {
+ for (i = 0; i < OSSL_NELEM(afalg_cipher_nids); i++) {
if (afalg_aes_cbc(afalg_cipher_nids[i]) == NULL) {
AFALGerr(AFALG_F_BIND_AFALG, AFALG_R_INIT_FAILED);
return 0;
static int free_cbc(void)
{
short unsigned int i;
- for(i = 0; i < OSSL_NELEM(afalg_cipher_nids); i++) {
+ for (i = 0; i < OSSL_NELEM(afalg_cipher_nids); i++) {
EVP_CIPHER_meth_free(cbc_handle[i]._hidden);
cbc_handle[i]._hidden = NULL;
}
/* Setup RSA_METHOD */
rsa_capi_idx = RSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
ossl_rsa_meth = RSA_PKCS1_OpenSSL();
- if ( !RSA_meth_set_pub_enc(capi_rsa_method,
+ if (!RSA_meth_set_pub_enc(capi_rsa_method,
RSA_meth_get_pub_enc(ossl_rsa_meth))
|| !RSA_meth_set_pub_dec(capi_rsa_method,
RSA_meth_get_pub_dec(ossl_rsa_meth))
/* Setup DSA Method */
dsa_capi_idx = DSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
ossl_dsa_meth = DSA_OpenSSL();
- if ( !DSA_meth_set_sign(capi_dsa_method, capi_dsa_do_sign)
+ if (!DSA_meth_set_sign(capi_dsa_method, capi_dsa_do_sign)
|| !DSA_meth_set_verify(capi_dsa_method,
DSA_meth_get_verify(ossl_dsa_meth))
|| !DSA_meth_set_finish(capi_dsa_method, capi_dsa_free)
fprintf (stderr, "Cipher %s, NID=%d, /dev/crypto info: id=%d, ",
name ? name : "unknown", cipher_data[i].nid,
cipher_data[i].devcryptoid);
- if (cipher_driver_info[i].status == DEVCRYPTO_STATUS_NO_CIOCGSESSION ) {
+ if (cipher_driver_info[i].status == DEVCRYPTO_STATUS_NO_CIOCGSESSION) {
fprintf (stderr, "CIOCGSESSION (session open call) failed\n");
continue;
}
if (ret <= 0)
return ret;
- switch(type) {
+ switch (type) {
case EVP_CTRL_AEAD_GET_TAG:
/* Always give the same tag */
memset(ptr, 0, EVP_GCM_TLS_TAG_LEN);
*/
CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new_ex(OSSL_LIB_CTX *libctx,
const char *propq);
-
+
/*
* The same as CT_POLICY_EVAL_CTX_new_ex() but the default library
* context and property query string is used.
size_t ossl_prov_get_nonce(PROV_CTX *prov_ctx, unsigned char **pout,
size_t min_len, size_t max_len,
- const void *salt,size_t salt_len)
+ const void *salt, size_t salt_len)
{
if (c_get_nonce == NULL)
return 0;
{ OSSL_FUNC_CIPHER_FINAL, (void (*)(void))chacha20_final },
{ OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))chacha20_cipher},
{ OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void))chacha20_get_params },
- { OSSL_FUNC_CIPHER_GETTABLE_PARAMS,(void (*)(void))chacha20_gettable_params },
+ { OSSL_FUNC_CIPHER_GETTABLE_PARAMS, (void (*)(void))chacha20_gettable_params },
{ OSSL_FUNC_CIPHER_GET_CTX_PARAMS, (void (*)(void))chacha20_get_ctx_params },
{ OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS,
(void (*)(void))chacha20_gettable_ctx_params },
size_t pad, i;
size_t len = *buflen;
- if(len != blocksize) {
+ if (len != blocksize) {
ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
return 0;
}
/* Free the blob allocated during key_to_paramstring_fn */
static void free_asn1_data(int type, void *data)
{
- switch(type) {
+ switch (type) {
case V_ASN1_OBJECT:
ASN1_OBJECT_free(data);
break;
if (p != NULL
&& !OSSL_PARAM_set_utf8_string(p, pdhctx->kdf_md == NULL
? ""
- : EVP_MD_get0_name(pdhctx->kdf_md))){
+ : EVP_MD_get0_name(pdhctx->kdf_md))) {
return 0;
}
if (p != NULL
&& !OSSL_PARAM_set_utf8_string(p, pectx->kdf_md == NULL
? ""
- : EVP_MD_get0_name(pectx->kdf_md))){
+ : EVP_MD_get0_name(pectx->kdf_md))) {
return 0;
}
}
if ((group = EC_KEY_get0_group(pecdhctx->k)) == NULL
- || (cofactor = EC_GROUP_get0_cofactor(group)) == NULL )
+ || (cofactor = EC_GROUP_get0_cofactor(group)) == NULL)
return 0;
/*
return 0;
if ((p = OSSL_PARAM_locate_const(params, OSSL_KDF_PARAM_SALT)) != NULL)
- if (!kdf_pbkdf1_set_membuf(&ctx->salt, &ctx->salt_len,p))
+ if (!kdf_pbkdf1_set_membuf(&ctx->salt, &ctx->salt_len, p))
return 0;
if ((p = OSSL_PARAM_locate_const(params, OSSL_KDF_PARAM_ITER)) != NULL)
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH);
return 0;
}
- if (!pbkdf2_set_membuf(&ctx->salt, &ctx->salt_len,p))
+ if (!pbkdf2_set_membuf(&ctx->salt, &ctx->salt_len, p))
return 0;
}
return 0;
if ((p = OSSL_PARAM_locate_const(params, OSSL_KDF_PARAM_SALT)) != NULL)
- if (!pkcs12kdf_set_membuf(&ctx->salt, &ctx->salt_len,p))
+ if (!pkcs12kdf_set_membuf(&ctx->salt, &ctx->salt_len, p))
return 0;
if ((p = OSSL_PARAM_locate_const(params, OSSL_KDF_PARAM_PKCS12_ID)) != NULL)
return 0;
if ((p = OSSL_PARAM_locate_const(params, OSSL_KDF_PARAM_SALT)) != NULL) {
- if (!pvk_set_membuf(&ctx->salt, &ctx->salt_len,p))
+ if (!pvk_set_membuf(&ctx->salt, &ctx->salt_len, p))
return 0;
}
ecbits = EC_GROUP_order_bits(ecg);
if (ecbits <= 0)
goto err;
- sz = (ecbits + 7 ) / 8;
+ sz = (ecbits + 7) / 8;
if (!ossl_param_build_set_bn_pad(tmpl, params,
OSSL_PKEY_PARAM_PRIV_KEY,
memcpy(out, vtmp, outlen);
OPENSSL_cleanse(vtmp, hash->blocklen);
break;
- } else if(!EVP_DigestFinal(ctx, out, NULL)) {
+ } else if (!EVP_DigestFinal(ctx, out, NULL)) {
return 0;
}
if (outlen == 0)
return 1;
memcpy(hash->vtmp, hash->V, drbg->seedlen);
- for(;;) {
+ for (;;) {
if (!EVP_DigestInit_ex(hash->ctx, ossl_prov_digest_md(&hash->digest),
NULL)
|| !EVP_DigestUpdate(hash->ctx, hash->vtmp, drbg->seedlen))
/* Get wall clock time, take 8 bits. */
clock_gettime(CLOCK_REALTIME, &ts);
v = (unsigned char)(ts.tv_nsec & 0xFF);
- ossl_rand_pool_add(pool, arg, &v, sizeof(v) , 2);
+ ossl_rand_pool_add(pool, arg, &v, sizeof(v), 2);
}
return ossl_rand_pool_entropy_available(pool);
}
uint32_t status;
uint32_t efn;
IOSB iosb;
- $DESCRIPTOR(SYSDEVICE,"SYS$SYSDEVICE:");
+ $DESCRIPTOR(SYSDEVICE, "SYS$SYSDEVICE:");
if ((status = sys$getdviw(EFN$C_ENF, 0, &SYSDEVICE, DVI_items,
0, 0, 0, 0, 0)) != SS$_NORMAL) {
RANDOM_NUM_GEN_STATUS status = randStatus();
if ((status == RANDOM_NUM_GEN_ENOUGH_ENTROPY)
- || (status == RANDOM_NUM_GEN_MAX_ENTROPY) ) {
+ || (status == RANDOM_NUM_GEN_MAX_ENTROPY)) {
result = randBytes(buffer, bytes_needed);
if (result == OK)
ossl_rand_pool_add_end(pool, bytes_needed, 8 * bytes_needed);
const char *mdname, const char *mgf1_mdname,
int mdnid)
{
- switch(prsactx->pad_mode) {
+ switch (prsactx->pad_mode) {
case RSA_NO_PADDING:
if (mdname != NULL || mdnid != NID_undef) {
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE);
static int rsa_pss_compute_saltlen(PROV_RSA_CTX *ctx)
{
int saltlen = ctx->saltlen;
-
+
if (saltlen == RSA_PSS_SALTLEN_DIGEST) {
saltlen = EVP_MD_get_size(ctx->md);
} else if (saltlen == RSA_PSS_SALTLEN_AUTO || saltlen == RSA_PSS_SALTLEN_MAX) {
return NULL;
}
- switch(ctx->pad_mode) {
+ switch (ctx->pad_mode) {
case RSA_PKCS1_PADDING:
ret = ossl_DER_w_algorithmIdentifier_MDWithRSAEncryption(&pkt, -1,
ctx->mdnid);
i = do_dtls1_write(s, SSL3_RT_ALERT, &buf[0], sizeof(buf), 0, &written);
if (i <= 0) {
s->s3.alert_dispatch = 1;
- /* fprintf( stderr, "not done with alert\n" ); */
+ /* fprintf(stderr, "not done with alert\n"); */
} else {
(void)BIO_flush(s->wbio);
const SSL_CIPHER *cp;
int reverse = 0;
- OSSL_TRACE_BEGIN(TLS_CIPHER){
+ OSSL_TRACE_BEGIN(TLS_CIPHER) {
BIO_printf(trc_out,
"Applying rule %d with %08x/%08x/%08x/%08x/%08x %08x (%d)\n",
rule, alg_mkey, alg_auth, alg_enc, alg_mac, min_tls,
retval = 1;
l = rule_str;
- for ( ; ; ) {
+ for (;;) {
ch = *l;
if (ch == '\0')
SSL_COMP_get_compression_methods();
#endif
ssl_sort_cipher_list();
- OSSL_TRACE(INIT,"ossl_init_ssl_base: SSL_add_ssl_module()\n");
+ OSSL_TRACE(INIT, "ossl_init_ssl_base: SSL_add_ssl_module()\n");
/*
* We ignore an error return here. Not much we can do - but not that bad
* either. We can still safely continue.
const char *ssl_protocol_to_string(int version)
{
- switch(version)
+ switch (version)
{
case TLS1_3_VERSION:
return "TLSv1.3";
}
#ifndef OPENSSL_NO_PSK
- if(sess == NULL
+ if (sess == NULL
&& s->psk_server_callback != NULL
&& idlen <= PSK_MAX_IDENTITY_LEN) {
char *pskid = NULL;
return 0;
}
- if (EVP_PKEY_encrypt_init(pkey_ctx) <= 0 ) {
+ if (EVP_PKEY_encrypt_init(pkey_ctx) <= 0) {
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
goto err;
};
s->s3.send_connection_binding = 0;
/* Check what signalling cipher-suite values were received. */
if (scsvs != NULL) {
- for(i = 0; i < sk_SSL_CIPHER_num(scsvs); i++) {
+ for (i = 0; i < sk_SSL_CIPHER_num(scsvs); i++) {
c = sk_SSL_CIPHER_value(scsvs, i);
if (SSL_CIPHER_get_id(c) == SSL3_CK_SCSV) {
if (s->renegotiate) {
}
/* check whether cipher is known */
- if(!ossl_assert(cipher != NULL))
+ if (!ossl_assert(cipher != NULL))
goto err;
if (!derive_secret_key_and_iv(s, which & SSL3_CC_WRITE, md, cipher,
# endif
while ((o = opt_next()) != OPT_EOF) {
- switch(o) {
+ switch (o) {
case OPT_PRINT:
print_test_data();
return 1;
static int do_test_bio_cipher(const EVP_CIPHER* cipher, int idx)
{
- switch(idx)
+ switch (idx)
{
case 0:
return do_bio_cipher(cipher, KEY, NULL);
static int test_gf2m_mod(void)
{
- BIGNUM *a = NULL, *b[2] = {NULL,NULL}, *c = NULL, *d = NULL, *e = NULL;
+ BIGNUM *a = NULL, *b[2] = {NULL, NULL}, *c = NULL, *d = NULL, *e = NULL;
int i, j, st = 0;
if (!TEST_ptr(a = BN_new())
static int test_gf2m_sqr(void)
{
- BIGNUM *a = NULL, *b[2] = {NULL,NULL}, *c = NULL, *d = NULL;
+ BIGNUM *a = NULL, *b[2] = {NULL, NULL}, *c = NULL, *d = NULL;
int i, j, st = 0;
if (!TEST_ptr(a = BN_new())
static int test_gf2m_modinv(void)
{
- BIGNUM *a = NULL, *b[2] = {NULL,NULL}, *c = NULL, *d = NULL;
+ BIGNUM *a = NULL, *b[2] = {NULL, NULL}, *c = NULL, *d = NULL;
int i, j, st = 0;
if (!TEST_ptr(a = BN_new())
static int test_gf2m_moddiv(void)
{
- BIGNUM *a = NULL, *b[2] = {NULL,NULL}, *c = NULL, *d = NULL;
+ BIGNUM *a = NULL, *b[2] = {NULL, NULL}, *c = NULL, *d = NULL;
BIGNUM *e = NULL, *f = NULL;
int i, j, st = 0;
static int test_gf2m_modexp(void)
{
- BIGNUM *a = NULL, *b[2] = {NULL,NULL}, *c = NULL, *d = NULL;
+ BIGNUM *a = NULL, *b[2] = {NULL, NULL}, *c = NULL, *d = NULL;
BIGNUM *e = NULL, *f = NULL;
int i, j, st = 0;
static int test_gf2m_modsqrt(void)
{
- BIGNUM *a = NULL, *b[2] = {NULL,NULL}, *c = NULL, *d = NULL;
+ BIGNUM *a = NULL, *b[2] = {NULL, NULL}, *c = NULL, *d = NULL;
BIGNUM *e = NULL, *f = NULL;
int i, j, st = 0;
static int test_gf2m_modsolvequad(void)
{
- BIGNUM *a = NULL, *b[2] = {NULL,NULL}, *c = NULL, *d = NULL;
+ BIGNUM *a = NULL, *b[2] = {NULL, NULL}, *c = NULL, *d = NULL;
BIGNUM *e = NULL;
int i, j, s = 0, t, st = 0;
# define BOTTOM_BIT_NOTOUCH 0
if (!TEST_true(BN_rand(n, bytes * 8, TOP_BIT_ON, BOTTOM_BIT_NOTOUCH)))
goto err;
- if (!TEST_int_eq(BN_num_bytes(n),A) bytes
+ if (!TEST_int_eq(BN_num_bytes(n), A) bytes
|| TEST_int_eq(BN_bn2bin(n, reference), bytes))
goto err;
/* Empty buffer should fail. */
if (!TEST_true(SSL_CTX_set_max_proto_version(ctx, 0)))
goto end;
- switch(currtest) {
+ switch (currtest) {
case TEST_SET_SESSION_TICK_DATA_VER_NEG:
#if !defined(OPENSSL_NO_TLS1_3) && defined(OPENSSL_NO_TLS1_2)
/* TLSv1.3 is enabled and TLSv1.2 is disabled so can't do this test */
const char *op_name, size_t a, size_t b,
int is_true)
{
- if (is_true && !TEST_size_t_eq(op(a,b), CONSTTIME_TRUE_S))
+ if (is_true && !TEST_size_t_eq(op(a, b), CONSTTIME_TRUE_S))
return 0;
- if (!is_true && !TEST_uint_eq(op(a,b), CONSTTIME_FALSE_S))
+ if (!is_true && !TEST_uint_eq(op(a, b), CONSTTIME_FALSE_S))
return 0;
return 1;
}
}
argc = test_get_argument_count();
- switch(argc) {
+ switch (argc) {
case 0:
is_fips = 0;
bad_fips = 0;
if (!TEST_ptr(priv_key = BN_bin2bn(td->xB, td->xB_len, NULL))
|| !TEST_ptr(pub_key = BN_bin2bn(td->yB, td->yB_len, NULL))
- || !TEST_true( DH_set0_key(dhB, pub_key, priv_key)))
+ || !TEST_true(DH_set0_key(dhB, pub_key, priv_key)))
goto bad_err;
priv_key = pub_key = NULL;
goto err;
/* create two `EVP_PKEY`s from the `EC_KEY`s */
- if(!TEST_ptr(pkey1 = EVP_PKEY_new())
+ if (!TEST_ptr(pkey1 = EVP_PKEY_new())
|| !TEST_int_eq(EVP_PKEY_assign_EC_KEY(pkey1, eckey1), 1))
goto err;
eckey1 = NULL; /* ownership passed to pkey1 */
- if(!TEST_ptr(pkey2 = EVP_PKEY_new())
+ if (!TEST_ptr(pkey2 = EVP_PKEY_new())
|| !TEST_int_eq(EVP_PKEY_assign_EC_KEY(pkey2, eckey2), 1))
goto err;
eckey2 = NULL; /* ownership passed to pkey2 */
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13
};
- if (tst == 0 ) {
+ if (tst == 0) {
if (!TEST_ptr(pkey = load_example_rsa_key()))
goto out;
} else if (tst == 1) {
if (nullprov != NULL && idx < 6)
return TEST_skip("Test does not support a non-default library context");
- switch(idx) {
+ switch (idx) {
case 0:
type = EVP_aes_128_cbc();
/* FALLTHROUGH */
if (lgcyprov == NULL && idx < 3)
return TEST_skip("Test requires legacy provider to be loaded");
- switch(idx) {
+ switch (idx) {
case 0:
type = EVP_CIPHER_fetch(testctx, "des-cbc", testpropq);
ref_iv = cbc_state_des;
static int evp_init_seq_set_iv(EVP_CIPHER_CTX *ctx, const EVP_INIT_TEST_st *t)
{
int res = 0;
-
+
if (t->ivlen != 0) {
if (!TEST_true(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, t->ivlen, NULL)))
goto err;
if (testctx != NULL)
return 1;
- switch(idx) {
+ switch (idx) {
case 0:
case 6:
id = EVP_PKEY_RSA;
return ret;
}
-static int test_kdfs_same( EVP_KDF *kdf1, EVP_KDF *kdf2)
+static int test_kdfs_same(EVP_KDF *kdf1, EVP_KDF *kdf2)
{
/* Fast path in case the two are the same algorithm pointer */
if (kdf1 == kdf2)
in += in_len - 1;
in_len = 1;
}
- if (in_len > 0 ) {
+ if (in_len > 0) {
if (!EVP_CipherUpdate(ctx, tmp + out_misalign + tmplen, &chunklen,
in, 1))
goto err;
goto end;
}
- if ((rv = EVP_PKEY_eq(pair->privk, pair->pubk)) != 1 ) {
- if ( 0 == rv ) {
+ if ((rv = EVP_PKEY_eq(pair->privk, pair->pubk)) != 1) {
+ if (0 == rv) {
t->err = "KEYPAIR_MISMATCH";
- } else if ( -1 == rv ) {
+ } else if (-1 == rv) {
t->err = "KEYPAIR_TYPE_MISMATCH";
- } else if ( -2 == rv ) {
+ } else if (-2 == rv) {
t->err = "UNSUPPORTED_KEY_COMPARISON";
} else {
TEST_error("Unexpected error in key comparison");
}
klist = &public_keys;
} else if (strcmp(pp->key, "PrivateKeyRaw") == 0
- || strcmp(pp->key, "PublicKeyRaw") == 0 ) {
+ || strcmp(pp->key, "PublicKeyRaw") == 0) {
char *strnid = NULL, *keydata = NULL;
unsigned char *keybin;
size_t keylen;
* The handshake succeeds once both peers have succeeded. If one peer
* errors out, we also let the other peer retry (and presumably fail).
*/
- for(;;) {
+ for (;;) {
if (client_turn) {
do_connect_step(test_ctx, &client, phase);
status = handshake_status(client.status, server.status,
attr_obj = X509_ATTRIBUTE_get0_object(attr);
OBJ_obj2txt(attr_txt, 100, attr_obj, 0);
- while(p_attr->oid != NULL) {
+ while (p_attr->oid != NULL) {
/* Find a matching attribute type */
if (strcmp(p_attr->oid, attr_txt) == 0) {
if (!TEST_int_eq(X509_ATTRIBUTE_count(attr), 1))
if (method_tls_dump == NULL) {
method_tls_dump = BIO_meth_new(BIO_TYPE_TLS_DUMP_FILTER,
"TLS dump filter");
- if ( method_tls_dump == NULL
+ if (method_tls_dump == NULL
|| !BIO_meth_set_write(method_tls_dump, tls_dump_write)
|| !BIO_meth_set_read(method_tls_dump, tls_dump_read)
|| !BIO_meth_set_puts(method_tls_dump, tls_dump_puts)
thispkt->type = type;
}
- for(i = 0; (looppkt = sk_MEMPACKET_value(ctx->pkts, i)) != NULL; i++) {
+ for (i = 0; (looppkt = sk_MEMPACKET_value(ctx->pkts, i)) != NULL; i++) {
/* Check if we found the right place to insert this packet */
if (looppkt->num > thispkt->num) {
if (sk_MEMPACKET_insert(ctx->pkts, thispkt, i) == 0)
{
int flags;
- flags = fcntl(fd,F_GETFL,0);
+ flags = fcntl(fd, F_GETFL, 0);
if (flags == -1)
return flags;
flags = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
if (set_nb(afd) == -1)
goto out;
- while (sfd == -1 || !cfd_connected ) {
+ while (sfd == -1 || !cfd_connected) {
sfd = accept(afd, NULL, 0);
if (sfd == -1 && errno != EAGAIN)
goto out;
if (A.data != NULL)
CRYPTO_gcm128_aad(&ctx, A.data, A.size);
if (P.data != NULL)
- if (!TEST_int_ge(CRYPTO_gcm128_encrypt( &ctx, P.data, out, P.size), 0))
+ if (!TEST_int_ge(CRYPTO_gcm128_encrypt(&ctx, P.data, out, P.size), 0))
return 0;
if (!TEST_false(CRYPTO_gcm128_finish(&ctx, T.data, 16))
|| (C.data != NULL
const char *urifmt;
char uri[PATH_MAX];
- switch(idx) {
+ switch (idx) {
#ifndef OPENSSL_NO_DH
case 0:
type = "DH";
|| !TEST_ptr(params_blt = OSSL_PARAM_BLD_to_param(bld)))
goto err;
- switch(tstid) {
+ switch (tstid) {
case 0:
params = params_blt;
break;
data2_size))
|| !TEST_ptr(params_blt = OSSL_PARAM_BLD_to_param(bld)))
goto err;
- switch(tstid) {
+ switch (tstid) {
case 0:
params = params_blt;
break;
if (!TEST_ptr(bld))
goto err;
-
+
for (i = 0; i < n; i++) {
names[i][0] = 'A' + (i / 26) - 1;
names[i][1] = 'a' + (i % 26) - 1;
params[n++] = OSSL_PARAM_construct_octet_ptr("octptr", &vp, 0);
params[n] = OSSL_PARAM_construct_end();
- switch(tstid) {
+ switch (tstid) {
case 0:
p = params;
break;
goto err;
/* Match the return size to avoid trailing garbage bytes */
cp->data_size = cp->return_size;
- if(!TEST_true(OSSL_PARAM_get_BN(cp, &bn2))
+ if (!TEST_true(OSSL_PARAM_get_BN(cp, &bn2))
|| !TEST_BN_eq(bn, bn2))
goto err;
ret = 1;
static int test_single_key_with_attrs(void)
{
PKCS12_BUILDER *pb = new_pkcs12_builder("1keyattrs.p12");
-
+
/* Generate/encode */
start_pkcs12(pb);
static int test_cert_key_with_attrs_and_mac(void)
{
PKCS12_BUILDER *pb = new_pkcs12_builder("1cert1key.p12");
-
+
/* Generate/encode */
start_pkcs12(pb);
static int test_cert_key_encrypted_content(void)
{
PKCS12_BUILDER *pb = new_pkcs12_builder("1cert1key_enc.p12");
-
+
/* Generate/encode */
start_pkcs12(pb);
{
PKCS12_BUILDER *pb = new_pkcs12_builder("1secret.p12");
int custom_nid = get_custom_oid();
-
+
/* Generate/encode */
start_pkcs12(pb);
{
PKCS12_BUILDER *pb = new_pkcs12_builder("multi_contents.p12");
int custom_nid = get_custom_oid();
-
+
/* Generate/encode */
start_pkcs12(pb);
|| !TEST_ptr(dummyprov = OSSL_PROVIDER_load(libctx, "dummy-prov")))
goto err;
- switch(tst) {
+ switch (tst) {
case 0:
decoder = OSSL_DECODER_fetch(libctx, "DUMMY", NULL);
if (!TEST_ptr(decoder))
{
int st_connect = 0, st_accept = 0;
- while(!st_connect || !st_accept) {
+ while (!st_connect || !st_accept) {
if (!st_connect) {
if (BIO_do_connect(client) <= 0) {
if (!BIO_should_retry(client))
PACKET pkt, pkt2, pkt3;
unsigned int MFL_code = 0, type = 0;
- if (!TEST_uint_gt( len = BIO_get_mem_data( bio, (char **) &data ), 0 ) )
+ if (!TEST_uint_gt(len = BIO_get_mem_data(bio, (char **) &data), 0))
goto end;
memset(&pkt, 0, sizeof(pkt));
memset(&pkt3, 0, sizeof(pkt3));
if (!TEST_long_gt(len, 0)
- || !TEST_true( PACKET_buf_init( &pkt, data, len ) )
+ || !TEST_true(PACKET_buf_init(&pkt, data, len))
/* Skip the record header */
|| !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH)
/* Skip the handshake message header */
if (method_tls_corrupt == NULL) {
method_tls_corrupt = BIO_meth_new(BIO_TYPE_CUSTOM_FILTER,
"TLS corrupt filter");
- if ( method_tls_corrupt == NULL
+ if (method_tls_corrupt == NULL
|| !BIO_meth_set_write(method_tls_corrupt, tls_corrupt_write)
|| !BIO_meth_set_read(method_tls_corrupt, tls_corrupt_read)
|| !BIO_meth_set_puts(method_tls_corrupt, tls_corrupt_puts)
goto end;
}
for (i = 0; i < n_exfinds; i++)
- if (!TEST_int_eq(sk_sint_find_ex(s, &exfinds[i].value), exfinds[i].ex)){
+ if (!TEST_int_eq(sk_sint_find_ex(s, &exfinds[i].value), exfinds[i].ex)) {
TEST_info("int sorted find_ex absent %d", i);
goto end;
}
if (method_watchccs == NULL) {
method_watchccs = BIO_meth_new(BIO_TYPE_WATCHCCS_FILTER,
"Watch CCS filter");
- if ( method_watchccs == NULL
+ if (method_watchccs == NULL
|| !BIO_meth_set_write(method_watchccs, watchccs_write)
|| !BIO_meth_set_read(method_watchccs, watchccs_read)
|| !BIO_meth_set_puts(method_watchccs, watchccs_puts)
} else {
badccs = 1;
}
- } else if(rectype == SSL3_RT_APPLICATION_DATA) {
+ } else if (rectype == SSL3_RT_APPLICATION_DATA) {
if (bio == s_to_c_fbio)
sappdataseen = 1;
else
int ok = 0;
if (!TEST_ptr(ui_method =
- UI_UTIL_wrap_read_pem_callback( test_pem_password_cb, 0))
+ UI_UTIL_wrap_read_pem_callback(test_pem_password_cb, 0))
|| !TEST_ptr(ui = UI_new_method(ui_method)))
goto err;