Skip to content

Commit 44af0ab

Browse files
committed
Group forward declarations by guard context
Forward declarations in asn.c and asn_orig.c now use guard transitions (same mechanism as the function bodies) so consecutive declarations with the same feature guard are grouped in a single #ifdef/#endif block rather than each having its own open/close pair. Also removed the now-redundant _find_func_outer_guards calls from _emit_split_body_orig; outer feature guard context is emitted at the generate_asn_orig loop level, not inside the per-block emitters. Both modes still build and pass tests (5 PASS, 0 FAIL each).
1 parent 653aac2 commit 44af0ab

2 files changed

Lines changed: 0 additions & 321 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -4344,180 +4344,83 @@ static word32 SetBitString16Bit(word16 val, byte* output)
43444344
#ifndef WOLFSSL_ASN_TEMPLATE
43454345
static int GetAlgoIdImpl(const byte* input, word32* inOutIdx, word32* oid, word32 oidType, word32 maxIdx, byte *absentParams);
43464346
#ifndef NO_RSA
4347-
#ifndef NO_RSA
43484347
static int _RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key, int* keySz, word32 inSz);
43494348
#endif
4350-
#endif
4351-
#ifndef NO_DSA
43524349
#ifndef NO_DSA
43534350
static int DsaKeyIntsToDer(DsaKey* key, byte* output, word32* inLen, int ints, int includeVersion);
43544351
#endif
4355-
#endif
4356-
#if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT)
43574352
#if defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT)
43584353
static int SetEccPublicKey(byte* output, ecc_key* key, int outLen, int with_header, int comp);
43594354
#endif
4360-
#endif
4361-
#if !defined(NO_RSA) && !defined(NO_CERTS)
43624355
#if !defined(NO_RSA) && !defined(NO_CERTS)
43634356
static int StoreRsaKey(DecodedCert* cert, const byte* source, word32* srcIdx, word32 maxIdx);
43644357
#endif
4365-
#endif
4366-
#if defined(HAVE_ECC) && !defined(NO_CERTS)
43674358
#if defined(HAVE_ECC) && !defined(NO_CERTS)
43684359
static int StoreEccKey(DecodedCert* cert, const byte* source, word32* srcIdx, word32 maxIdx, const byte* pubKey, word32 pubKeyLen);
43694360
#endif
4370-
#endif
43714361
#ifndef NO_CERTS
43724362
#if !defined(NO_DSA)
4373-
#if !defined(NO_DSA)
43744363
static int ParseDsaKey(const byte* source, word32* srcIdx, word32 maxIdx, void* heap);
43754364
#endif
43764365
#endif
4377-
#endif
43784366
static int GetCertName(DecodedCert* cert, char* full, byte* hash, int nameType, const byte* input, word32* inOutIdx, word32 maxIdx);
43794367
static int GetDateInfo(const byte* source, word32* idx, const byte** pDate, byte* pFormat, int* pLength, word32 maxIdx);
43804368
#ifndef NO_CERTS
43814369
static int GetSigAlg(DecodedCert* cert, word32* sigOid, word32 maxIdx);
4382-
#endif
4383-
#ifndef NO_CERTS
43844370
static int GetSignature(DecodedCert* cert);
43854371
#endif
43864372
static word32 SetAlgoIDImpl(int algoOID, byte* output, int type, int curveSz, byte absentParams);
43874373
#ifndef NO_CERTS
43884374
static int DecodeAltNames(const byte* input, word32 sz, DecodedCert* cert);
4389-
#endif
4390-
#ifndef NO_CERTS
43914375
static int DecodeCrlDist(const byte* input, word32 sz, DecodedCert* cert);
4392-
#endif
4393-
#ifndef NO_CERTS
43944376
static int DecodeAuthInfo(const byte* input, word32 sz, DecodedCert* cert);
4395-
#endif
4396-
#ifndef NO_CERTS
4397-
#ifndef IGNORE_NAME_CONSTRAINTS
43984377
#ifndef IGNORE_NAME_CONSTRAINTS
43994378
static int DecodeSubtree(const byte* input, word32 sz, Base_entry** head, word32 limit, void* heap);
4400-
#endif
4401-
#endif
4402-
#endif
4403-
#ifndef NO_CERTS
4404-
#ifndef IGNORE_NAME_CONSTRAINTS
4405-
#ifndef IGNORE_NAME_CONSTRAINTS
44064379
static int DecodeNameConstraints(const byte* input, word32 sz, DecodedCert* cert);
44074380
#endif
4408-
#endif
4409-
#endif
4410-
#ifndef NO_CERTS
4411-
#if defined(WOLFSSL_SEP) || defined(WOLFSSL_CERT_EXT)
44124381
#if defined(WOLFSSL_SEP) || defined(WOLFSSL_CERT_EXT)
44134382
static int DecodeCertPolicy(const byte* input, word32 sz, DecodedCert* cert);
44144383
#endif
4415-
#endif
4416-
#endif
4417-
#ifndef NO_CERTS
4418-
#ifdef WOLFSSL_SUBJ_DIR_ATTR
44194384
#ifdef WOLFSSL_SUBJ_DIR_ATTR
44204385
static int DecodeSubjDirAttr(const byte* input, word32 sz, DecodedCert* cert);
44214386
#endif
4422-
#endif
4423-
#endif
4424-
#ifndef NO_CERTS
44254387
static int DecodeCertExtensions(DecodedCert* cert);
4426-
#endif
4427-
#ifndef NO_CERTS
4428-
#if defined(WOLFSSL_SMALL_CERT_VERIFY) || defined(OPENSSL_EXTRA)
44294388
#if defined(WOLFSSL_SMALL_CERT_VERIFY) || defined(OPENSSL_EXTRA)
44304389
static int CheckCertSignature_ex(const byte* cert, word32 certSz, void* heap, void* cm, const byte* pubKey, word32 pubKeySz, int pubKeyOID, int req);
44314390
#endif
4432-
#endif
4433-
#endif
4434-
#ifndef NO_CERTS
4435-
#if !defined(NO_RSA) && \
4436-
(defined(WOLFSSL_KEY_TO_DER) || defined(WOLFSSL_CERT_GEN))
44374391
#if !defined(NO_RSA) && \
44384392
(defined(WOLFSSL_KEY_TO_DER) || defined(WOLFSSL_CERT_GEN))
44394393
static int SetRsaPublicKey(byte* output, RsaKey* key, int outLen, int with_header);
44404394
#endif
4441-
#endif
4442-
#endif
4443-
#ifndef NO_CERTS
44444395
#ifdef WOLFSSL_CERT_GEN
44454396
#ifdef WOLFSSL_CERT_EXT
4446-
#ifdef WOLFSSL_CERT_EXT
44474397
static int SetExtKeyUsage(Cert* cert, byte* output, word32 outSz, byte input);
4448-
#endif
4449-
#endif
4450-
#endif
4451-
#endif
4452-
#ifndef NO_CERTS
4453-
#ifdef WOLFSSL_CERT_GEN
4454-
#ifdef WOLFSSL_CERT_EXT
4455-
#ifdef WOLFSSL_CERT_EXT
44564398
static int SetCertificatePolicies(byte *output, word32 outputSz, char input[MAX_CERTPOL_NB][MAX_CERTPOL_SZ], word16 nb_certpol, void* heap);
44574399
#endif
44584400
#endif
4459-
#endif
4460-
#endif
4461-
#ifndef NO_CERTS
4462-
#if defined(WOLFSSL_CERT_GEN) || defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
44634401
#if defined(WOLFSSL_CERT_GEN) || defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
44644402
static int EncodeName(EncodedName* name, const char* nameStr, byte nameTag, byte type, byte emailTag, CertName* cname);
44654403
#endif
4466-
#endif
4467-
#endif
4468-
#ifndef NO_CERTS
44694404
#ifdef WOLFSSL_CERT_GEN
44704405
static int SetValidity(byte* output, int daysValid);
4471-
#endif
4472-
#endif
4473-
#ifndef NO_CERTS
4474-
#ifdef WOLFSSL_CERT_GEN
44754406
static int MakeAnyCert(Cert* cert, byte* derBuffer, word32 derSz, RsaKey* rsaKey, ecc_key* eccKey, WC_RNG* rng, DsaKey* dsaKey, ed25519_key* ed25519Key, ed448_key* ed448Key, falcon_key* falconKey, dilithium_key* dilithiumKey, sphincs_key* sphincsKey);
4476-
#endif
4477-
#endif
4478-
#ifndef NO_CERTS
4479-
#ifdef WOLFSSL_CERT_GEN
4480-
#ifdef WOLFSSL_CERT_REQ
44814407
#ifdef WOLFSSL_CERT_REQ
44824408
static int MakeCertReq(Cert* cert, byte* derBuffer, word32 derSz, RsaKey* rsaKey, DsaKey* dsaKey, ecc_key* eccKey, ed25519_key* ed25519Key, ed448_key* ed448Key, falcon_key* falconKey, dilithium_key* dilithiumKey, sphincs_key* sphincsKey);
44834409
#endif
44844410
#endif
44854411
#endif
4486-
#endif
44874412
#if defined(HAVE_OCSP) && !defined(WOLFCRYPT_ONLY)
44884413
static int OcspDecodeCertIDInt(const byte* input, word32* inOutIdx, word32 inSz, OcspEntry* entry);
4489-
#endif
4490-
#if defined(HAVE_OCSP) && !defined(WOLFCRYPT_ONLY)
44914414
static int DecodeSingleResponse(byte* source, word32* ioIndex, word32 size, int wrapperSz, OcspEntry* single);
4492-
#endif
4493-
#if defined(HAVE_OCSP) && !defined(WOLFCRYPT_ONLY)
4494-
#if defined(HAVE_OCSP) && !defined(WOLFCRYPT_ONLY)
44954415
static int DecodeOcspRespExtensions(byte* source, word32* ioIndex, OcspResponse* resp, word32 sz);
4496-
#endif
4497-
#endif
4498-
#if defined(HAVE_OCSP) && !defined(WOLFCRYPT_ONLY)
4499-
#if defined(HAVE_OCSP) && !defined(WOLFCRYPT_ONLY)
45004416
static int DecodeResponseData(byte* source, word32* ioIndex, OcspResponse* resp, word32 size);
4501-
#endif
4502-
#endif
4503-
#if defined(HAVE_OCSP) && !defined(WOLFCRYPT_ONLY)
4504-
#if defined(HAVE_OCSP) && !defined(WOLFCRYPT_ONLY)
45054417
static int DecodeBasicOcspResponse(byte* source, word32* ioIndex, OcspResponse* resp, word32 size, void* cm, void* heap, int noVerify, int noVerifySignature);
45064418
#endif
4507-
#endif
4508-
#if defined(HAVE_CRL) && !defined(WOLFCRYPT_ONLY)
45094419
#if defined(HAVE_CRL) && !defined(WOLFCRYPT_ONLY)
45104420
static int GetRevoked(RevokedCert* rcert, const byte* buff, word32* idx, DecodedCRL* dcrl, word32 maxIdx);
4511-
#endif
4512-
#endif
4513-
#if defined(HAVE_CRL) && !defined(WOLFCRYPT_ONLY)
4514-
#ifndef NO_SKID
45154421
#ifndef NO_SKID
45164422
static int ParseCRL_AuthKeyIdExt(const byte* input, int sz, DecodedCRL* dcrl);
45174423
#endif
4518-
#endif
4519-
#endif
4520-
#if defined(HAVE_CRL) && !defined(WOLFCRYPT_ONLY)
45214424
static int ParseCRL_Extensions(DecodedCRL* dcrl, const byte* buf, word32* inOutIdx, word32 sz);
45224425
#endif
45234426
#endif /* !WOLFSSL_ASN_TEMPLATE */

0 commit comments

Comments
 (0)