Skip to content

Commit

Permalink
Merge pull request #8077 from douzzer/20241015-C89-pedantic-fixes
Browse files Browse the repository at this point in the history
20241015-C89-pedantic-fixes
  • Loading branch information
SparkiDev authored Oct 16, 2024
2 parents 4fd33b6 + ffc0721 commit db6a2cc
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 126 deletions.
10 changes: 5 additions & 5 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -20858,7 +20858,7 @@ static const ASNItem subjDirAttrASN[] = {
enum {
SUBJDIRATTRASN_IDX_SEQ = 0,
SUBJDIRATTRASN_IDX_OID,
SUBJDIRATTRASN_IDX_SET,
SUBJDIRATTRASN_IDX_SET
};

/* Number of items in ASN.1 template for BasicConstraints. */
Expand Down Expand Up @@ -23526,9 +23526,9 @@ typedef struct DecodeInstr {
/* Tag expected. */
byte tag;
/* Operation to perform: step in or go over */
byte op:1;
WC_BITFIELD op:1;
/* ASN.1 item is optional. */
byte optional:1;
WC_BITFIELD optional:1;
} DecodeInstr;

/* Step into ASN.1 item. */
Expand Down Expand Up @@ -40761,7 +40761,7 @@ enum {
HOLDER_IDX_ISSUERSERIAL_SEQ,
HOLDER_IDX_GN_SEQ,
HOLDER_IDX_SERIAL_INT,
HOLDER_IDX_GN_SEQ_OPT1,
HOLDER_IDX_GN_SEQ_OPT1
};

/* Number of items in ASN template for an X509 Acert. */
Expand Down Expand Up @@ -40885,7 +40885,7 @@ static const ASNItem AttCertIssuerASN[] =
};

enum {
ATTCERTISSUER_IDX_GN_SEQ,
ATTCERTISSUER_IDX_GN_SEQ
};

/* Number of items in ASN template for an X509 Acert. */
Expand Down
20 changes: 10 additions & 10 deletions wolfcrypt/src/pkcs7.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ struct PKCS7State {
word32 peakUsed; /* most bytes used for struct at any one time */
word32 peakRead; /* most bytes used by read buffer */
#endif
byte multi:1; /* flag for if content is in multiple parts */
byte flagOne:1;
byte detached:1; /* flag to indicate detached signature is present */
byte noContent:1;/* indicates content isn't included in bundle */
byte degenerate:1;
byte indefLen:1; /* flag to indicate indef-length encoding used */
WC_BITFIELD multi:1; /* flag for if content is in multiple parts */
WC_BITFIELD flagOne:1;
WC_BITFIELD detached:1; /* flag to indicate detached signature is present */
WC_BITFIELD noContent:1;/* indicates content isn't included in bundle */
WC_BITFIELD degenerate:1;
WC_BITFIELD indefLen:1; /* flag to indicate indef-length encoding used */
};


Expand Down Expand Up @@ -1523,7 +1523,7 @@ typedef struct ESD {
wc_HashAlg hash;
enum wc_HashType hashType;
byte contentDigest[WC_MAX_DIGEST_SIZE + 2]; /* content only + ASN.1 heading */
byte contentDigestSet:1;
WC_BITFIELD contentDigestSet:1;
byte contentAttribsDigest[WC_MAX_DIGEST_SIZE];
byte encContentDigest[MAX_ENCRYPTED_KEY_SZ];

Expand Down Expand Up @@ -6829,9 +6829,9 @@ typedef struct WC_PKCS7_KARI {
word32 sharedInfoSz; /* size of ECC-CMS-SharedInfo encoded */
byte ukmOwner; /* do we own ukm buffer? 1:yes, 0:no */
byte direction; /* WC_PKCS7_ENCODE | WC_PKCS7_DECODE */
byte decodedInit : 1; /* indicates decoded was initialized */
byte recipKeyInit : 1; /* indicates recipKey was initialized */
byte senderKeyInit : 1; /* indicates senderKey was initialized */
WC_BITFIELD decodedInit:1; /* indicates decoded was initialized */
WC_BITFIELD recipKeyInit:1; /* indicates recipKey was initialized */
WC_BITFIELD senderKeyInit:1; /* indicates senderKey was initialized */
} WC_PKCS7_KARI;


Expand Down
8 changes: 4 additions & 4 deletions wolfssl/wolfcrypt/aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ struct Aes {
byte over;
byte aOver;
byte cOver;
byte gcmKeySet:1;
byte nonceSet:1;
byte ctrSet:1;
WC_BITFIELD gcmKeySet:1;
WC_BITFIELD nonceSet:1;
WC_BITFIELD ctrSet:1;
#endif
byte isAllocated:1; /* flag indicates if structure was allocated */
WC_BITFIELD isAllocated:1; /* flag indicates if structure was allocated */
#ifdef WC_DEBUG_CIPHER_LIFECYCLE
void *CipherLifecycleTag; /* used for dummy allocation and initialization,
* trackable by sanitizers.
Expand Down
95 changes: 48 additions & 47 deletions wolfssl/wolfcrypt/asn.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ typedef struct ASNItem {
/* BER/DER tag to expect. */
byte tag;
/* Whether the ASN.1 item is constructed. */
byte constructed:1;
WC_BITFIELD constructed:1;
/* Whether to parse the header only or skip data. If
* ASNSetData.data.buffer.data is supplied then this option gets
* overwritten and the child nodes get ignored. */
byte headerOnly:1;
WC_BITFIELD headerOnly:1;
/* Whether ASN.1 item is optional.
* - 0 means not optional
* - 1 means is optional
Expand Down Expand Up @@ -1273,8 +1273,9 @@ enum Extensions_Sum {
#ifdef WOLFSSL_DUAL_ALG_CERTS
SUBJ_ALT_PUB_KEY_INFO_OID = 186, /* 2.5.29.72 subject alt public key info */
ALT_SIG_ALG_OID = 187, /* 2.5.29.73 alt sig alg */
ALT_SIG_VAL_OID = 188 /* 2.5.29.74 alt sig val */
ALT_SIG_VAL_OID = 188, /* 2.5.29.74 alt sig val */
#endif
WOLF_ENUM_DUMMY_LAST_ELEMENT(Extensions_Sum)
};

enum CertificatePolicy_Sum {
Expand Down Expand Up @@ -1941,63 +1942,63 @@ struct DecodedCert {
int criticalExt;

/* Option Bits */
byte subjectCNStored : 1; /* have we saved a copy we own */
byte extSubjKeyIdSet : 1; /* Set when the SKID was read from cert */
byte extAuthKeyIdSet : 1; /* Set when the AKID was read from cert */
WC_BITFIELD subjectCNStored:1; /* have we saved a copy we own */
WC_BITFIELD extSubjKeyIdSet:1; /* Set when the SKID was read from cert */
WC_BITFIELD extAuthKeyIdSet:1; /* Set when the AKID was read from cert */
#ifndef IGNORE_NAME_CONSTRAINTS
byte extNameConstraintSet : 1;
WC_BITFIELD extNameConstraintSet:1;
#endif
byte isCA : 1; /* CA basic constraint true */
byte pathLengthSet : 1; /* CA basic const path length set */
byte weOwnAltNames : 1; /* altNames haven't been given to copy */
byte extKeyUsageSet : 1;
byte extExtKeyUsageSet : 1; /* Extended Key Usage set */
WC_BITFIELD isCA:1; /* CA basic constraint true */
WC_BITFIELD pathLengthSet:1; /* CA basic const path length set */
WC_BITFIELD weOwnAltNames:1; /* altNames haven't been given to copy */
WC_BITFIELD extKeyUsageSet:1;
WC_BITFIELD extExtKeyUsageSet:1; /* Extended Key Usage set */
#ifdef HAVE_OCSP
byte ocspNoCheckSet : 1; /* id-pkix-ocsp-nocheck set */
#endif
byte extCRLdistSet : 1;
byte extAuthInfoSet : 1;
byte extBasicConstSet : 1;
byte extPolicyConstSet : 1;
byte extPolicyConstRxpSet : 1; /* requireExplicitPolicy set */
byte extPolicyConstIpmSet : 1; /* inhibitPolicyMapping set */
byte extSubjAltNameSet : 1;
byte inhibitAnyOidSet : 1;
byte selfSigned : 1; /* Indicates subject and issuer are same */
WC_BITFIELD ocspNoCheckSet:1; /* id-pkix-ocsp-nocheck set */
#endif
WC_BITFIELD extCRLdistSet:1;
WC_BITFIELD extAuthInfoSet:1;
WC_BITFIELD extBasicConstSet:1;
WC_BITFIELD extPolicyConstSet:1;
WC_BITFIELD extPolicyConstRxpSet:1; /* requireExplicitPolicy set */
WC_BITFIELD extPolicyConstIpmSet:1; /* inhibitPolicyMapping set */
WC_BITFIELD extSubjAltNameSet:1;
WC_BITFIELD inhibitAnyOidSet:1;
WC_BITFIELD selfSigned:1; /* Indicates subject and issuer are same */
#ifdef WOLFSSL_SEP
byte extCertPolicySet : 1;
#endif
byte extCRLdistCrit : 1;
byte extAuthInfoCrit : 1;
byte extBasicConstCrit : 1;
byte extPolicyConstCrit : 1;
byte extSubjAltNameCrit : 1;
byte extAuthKeyIdCrit : 1;
WC_BITFIELD extCertPolicySet:1;
#endif
WC_BITFIELD extCRLdistCrit:1;
WC_BITFIELD extAuthInfoCrit:1;
WC_BITFIELD extBasicConstCrit:1;
WC_BITFIELD extPolicyConstCrit:1;
WC_BITFIELD extSubjAltNameCrit:1;
WC_BITFIELD extAuthKeyIdCrit:1;
#ifndef IGNORE_NAME_CONSTRAINTS
byte extNameConstraintCrit : 1;
WC_BITFIELD extNameConstraintCrit:1;
#endif
byte extSubjKeyIdCrit : 1;
byte extKeyUsageCrit : 1;
byte extExtKeyUsageCrit : 1;
WC_BITFIELD extSubjKeyIdCrit:1;
WC_BITFIELD extKeyUsageCrit:1;
WC_BITFIELD extExtKeyUsageCrit:1;
#ifdef WOLFSSL_SUBJ_DIR_ATTR
byte extSubjDirAttrSet : 1;
WC_BITFIELD extSubjDirAttrSet:1;
#endif
#ifdef WOLFSSL_SUBJ_INFO_ACC
byte extSubjInfoAccSet : 1;
WC_BITFIELD extSubjInfoAccSet:1;
#endif
#ifdef WOLFSSL_DUAL_ALG_CERTS
byte extSapkiSet : 1;
byte extAltSigAlgSet : 1;
byte extAltSigValSet : 1;
WC_BITFIELD extSapkiSet:1;
WC_BITFIELD extAltSigAlgSet:1;
WC_BITFIELD extAltSigValSet:1;
#endif /* WOLFSSL_DUAL_ALG_CERTS */
#ifdef WOLFSSL_SEP
byte extCertPolicyCrit : 1;
WC_BITFIELD extCertPolicyCrit:1;
#endif
#ifdef WOLFSSL_CERT_REQ
byte isCSR : 1; /* Do we intend on parsing a CSR? */
WC_BITFIELD isCSR:1; /* Do we intend on parsing a CSR? */
#endif
#ifdef HAVE_RPK
byte isRPK : 1; /* indicate the cert is Raw-Public-Key cert in RFC7250 */
WC_BITFIELD isRPK:1; /* indicate the cert is Raw-Public-Key cert in RFC7250 */
#endif
#ifdef WC_ASN_UNKNOWN_EXT_CB
wc_UnknownExtCallback unknownExtCallback;
Expand Down Expand Up @@ -2034,7 +2035,7 @@ struct Signer {
word32 keyOID; /* key type */
word16 keyUsage;
byte maxPathLen;
byte selfSigned : 1;
WC_BITFIELD selfSigned:1;
const byte* publicKey;
int nameLen;
char* name; /* common name */
Expand Down Expand Up @@ -2572,10 +2573,10 @@ struct OcspEntry
byte* rawCertId; /* raw bytes of the CertID */
int rawCertIdSize; /* num bytes in raw CertID */
/* option bits - using 32-bit for alignment */
word32 ownStatus:1; /* do we need to free the status
WC_BITFIELD ownStatus:1; /* do we need to free the status
* response list */
word32 isDynamic:1; /* was dynamically allocated */
word32 used:1; /* entry used */
WC_BITFIELD isDynamic:1; /* was dynamically allocated */
WC_BITFIELD used:1; /* entry used */
};

/* TODO: Long-term, it would be helpful if we made this struct and other OCSP
Expand Down
32 changes: 16 additions & 16 deletions wolfssl/wolfcrypt/asn_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ typedef struct EncryptedInfo {
char name[NAME_SZ]; /* cipher name, such as "DES-CBC" */
byte iv[IV_SZ]; /* salt or encrypted IV */

word16 set:1; /* if encryption set */
WC_BITFIELD set:1; /* if encryption set */
#endif
} EncryptedInfo;

Expand All @@ -347,7 +347,7 @@ typedef struct WOLFSSL_ASN1_INTEGER {

unsigned char* data;
unsigned int dataMax; /* max size of data buffer */
unsigned int isDynamic:1; /* flag for if data pointer dynamic (1 is yes 0 is no) */
WC_BITFIELD isDynamic:1; /* flag for if data pointer dynamic (1 is yes 0 is no) */

int length; /* Length of DER encoding. */
int type; /* ASN.1 type. Includes negative flag. */
Expand Down Expand Up @@ -549,13 +549,13 @@ typedef struct Cert {
void* decodedCert; /* internal DecodedCert allocated from heap */
byte* der; /* Pointer to buffer of current DecodedCert cache */
void* heap; /* heap hint */
byte basicConstSet:1; /* Indicator for when Basic Constraint is set */
WC_BITFIELD basicConstSet:1; /* Indicator for when Basic Constraint is set */
#ifdef WOLFSSL_ALLOW_ENCODING_CA_FALSE
byte isCaSet:1; /* Indicator for when isCA is set */
WC_BITFIELD isCaSet:1; /* Indicator for when isCA is set */
#endif
byte pathLenSet:1; /* Indicator for when path length is set */
WC_BITFIELD pathLenSet:1; /* Indicator for when path length is set */
#ifdef WOLFSSL_ALT_NAMES
byte altNamesCrit:1; /* Indicator of criticality of SAN extension */
WC_BITFIELD altNamesCrit:1; /* Indicator of criticality of SAN extension */
#endif
} Cert;

Expand Down Expand Up @@ -937,9 +937,9 @@ typedef struct _wc_CertPIV {
word32 signedNonceSz; /* Identiv Only */

/* flags */
word16 compression:2;
word16 isX509:1;
word16 isIdentiv:1;
WC_BITFIELD compression:2;
WC_BITFIELD isX509:1;
WC_BITFIELD isIdentiv:1;
} wc_CertPIV;

WOLFSSL_API int wc_ParseCertPIV(wc_CertPIV* cert, const byte* buf, word32 totalSz);
Expand Down Expand Up @@ -1007,7 +1007,7 @@ enum Asn1PrintOpt {
/* Don't show text representations of primitive types. */
ASN1_PRINT_OPT_SHOW_NO_TEXT,
/* Don't show dump text representations of primitive types. */
ASN1_PRINT_OPT_SHOW_NO_DUMP_TEXT,
ASN1_PRINT_OPT_SHOW_NO_DUMP_TEXT
};

/* ASN.1 print options. */
Expand All @@ -1019,17 +1019,17 @@ typedef struct Asn1PrintOptions {
/* Number of spaces to indent for each change in depth. */
word8 indent;
/* Draw branches instead of indenting. */
word8 draw_branch:1;
WC_BITFIELD draw_branch:1;
/* Show raw data of primitive types as octets. */
word8 show_data:1;
WC_BITFIELD show_data:1;
/* Show header data as octets. */
word8 show_header_data:1;
WC_BITFIELD show_header_data:1;
/* Show the wolfSSL OID value for OBJECT_ID. */
word8 show_oid:1;
WC_BITFIELD show_oid:1;
/* Don't show text representations of primitive types. */
word8 show_no_text:1;
WC_BITFIELD show_no_text:1;
/* Don't show dump text representations of primitive types. */
word8 show_no_dump_text:1;
WC_BITFIELD show_no_dump_text:1;
} Asn1PrintOptions;

/* ASN.1 item data. */
Expand Down
2 changes: 1 addition & 1 deletion wolfssl/wolfcrypt/chacha20_poly1305.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ typedef struct ChaChaPoly_Aead {
word32 dataLen;

byte state;
byte isEncrypt:1;
WC_BITFIELD isEncrypt:1;
} ChaChaPoly_Aead;


Expand Down
6 changes: 3 additions & 3 deletions wolfssl/wolfcrypt/curve25519.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ struct curve25519_key {
#endif

/* bit fields */
byte pubSet:1;
byte privSet:1;
byte isAllocated:1; /* flag indicates if structure was allocated */
WC_BITFIELD pubSet:1;
WC_BITFIELD privSet:1;
WC_BITFIELD isAllocated:1; /* flag indicates if structure was allocated */
};

enum {
Expand Down
4 changes: 2 additions & 2 deletions wolfssl/wolfcrypt/curve448.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ struct curve448_key {
#endif

/* bit fields */
byte pubSet:1;
byte privSet:1;
WC_BITFIELD pubSet:1;
WC_BITFIELD privSet:1;
};

enum {
Expand Down
6 changes: 3 additions & 3 deletions wolfssl/wolfcrypt/ecc.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ struct ecc_point {
#if defined(WOLFSSL_SMALL_STACK_CACHE) && !defined(WOLFSSL_ECC_NO_SMALL_STACK)
ecc_key* key;
#endif
byte isAllocated:1;
WC_BITFIELD isAllocated:1;
};

/* ECC Flags */
Expand Down Expand Up @@ -590,12 +590,12 @@ struct ecc_key {
mp_int* sign_k;
#else
mp_int sign_k[1];
byte sign_k_set:1;
WC_BITFIELD sign_k_set:1;
#endif
#endif
#if defined(WOLFSSL_ECDSA_DETERMINISTIC_K) || \
defined(WOLFSSL_ECDSA_DETERMINISTIC_K_VARIANT)
byte deterministic:1;
WC_BITFIELD deterministic:1;
enum wc_HashType hashType;
#endif

Expand Down
Loading

0 comments on commit db6a2cc

Please sign in to comment.