mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 20:54:41 +02:00
Remove do/while(0) loop in wc_PKCS7_DecodeEncryptedKeyPackage(); use if-else if chain
This commit is contained in:
@@ -14888,41 +14888,30 @@ WOLFSSL_API int wc_PKCS7_DecodeEncryptedKeyPackage(wc_PKCS7 * pkcs7,
|
|||||||
word32 contentType = 0;
|
word32 contentType = 0;
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
||||||
do {
|
|
||||||
if (pkiMsg == NULL) {
|
if (pkiMsg == NULL) {
|
||||||
ret = BAD_FUNC_ARG;
|
ret = BAD_FUNC_ARG;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expect a SEQUENCE header to start the EncryptedKeyPackage
|
/* Expect a SEQUENCE header to start the EncryptedKeyPackage
|
||||||
* ContentInfo. */
|
* ContentInfo. */
|
||||||
if (GetSequence_ex(pkiMsg, &pkiIndex, &length, pkiMsgSz, 1) < 0) {
|
else if (GetSequence_ex(pkiMsg, &pkiIndex, &length, pkiMsgSz, 1) < 0) {
|
||||||
ret = ASN_PARSE_E;
|
ret = ASN_PARSE_E;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Validate the EncryptedKeyPackage OBJECT IDENTIFIER. */
|
/* Validate the EncryptedKeyPackage OBJECT IDENTIFIER. */
|
||||||
if (wc_GetContentType(pkiMsg, &pkiIndex, &contentType, pkiMsgSz) < 0) {
|
else if (wc_GetContentType(pkiMsg, &pkiIndex, &contentType, pkiMsgSz) < 0) {
|
||||||
ret = ASN_PARSE_E;
|
ret = ASN_PARSE_E;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else if (contentType != ENCRYPTED_KEY_PACKAGE) {
|
||||||
if (contentType != ENCRYPTED_KEY_PACKAGE) {
|
|
||||||
WOLFSSL_MSG("PKCS#7 input not of type EncryptedKeyPackage");
|
WOLFSSL_MSG("PKCS#7 input not of type EncryptedKeyPackage");
|
||||||
ret = PKCS7_OID_E;
|
ret = PKCS7_OID_E;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expect content [0] tag */
|
/* Expect content [0] tag */
|
||||||
if (GetASNHeader(pkiMsg, ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED,
|
else if (GetASNHeader(pkiMsg, ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED,
|
||||||
&pkiIndex, &length, pkiMsgSz) < 0) {
|
&pkiIndex, &length, pkiMsgSz) < 0) {
|
||||||
ret = ASN_PARSE_E;
|
ret = ASN_PARSE_E;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for an EncryptedKeyPackage explicit CHOICE [0] tag, indicating
|
/* Check for an EncryptedKeyPackage explicit CHOICE [0] tag, indicating
|
||||||
* an EnvelopedData subtype. */
|
* an EnvelopedData subtype. */
|
||||||
if (GetASNHeader(pkiMsg, ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED,
|
else if (GetASNHeader(pkiMsg, ASN_CONTEXT_SPECIFIC | ASN_CONSTRUCTED,
|
||||||
&pkiIndex, &length, pkiMsgSz) >= 0) {
|
&pkiIndex, &length, pkiMsgSz) >= 0) {
|
||||||
/* An explicit CHOICE [0] tag was found. pkiIndex now should point
|
/* An explicit CHOICE [0] tag was found. pkiIndex now should point
|
||||||
* to the EnvelopedData ContentInfo object within the
|
* to the EnvelopedData ContentInfo object within the
|
||||||
@@ -14940,7 +14929,6 @@ WOLFSSL_API int wc_PKCS7_DecodeEncryptedKeyPackage(wc_PKCS7 * pkcs7,
|
|||||||
ret = ASN_PARSE_E;
|
ret = ASN_PARSE_E;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} while(0);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user