forked from wolfSSL/wolfssl
make inOutKeyType parameter mandatory for DecodeAsymKey_Assign
This commit is contained in:
@@ -35324,7 +35324,7 @@ int DecodeAsymKey_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (input == NULL || inOutIdx == NULL || inSz == 0 ||
|
if (input == NULL || inOutIdx == NULL || inSz == 0 ||
|
||||||
privKey == NULL || privKeyLen == NULL) {
|
privKey == NULL || privKeyLen == NULL || inOutKeyType == NULL) {
|
||||||
#ifdef WOLFSSL_ASN_TEMPLATE
|
#ifdef WOLFSSL_ASN_TEMPLATE
|
||||||
FREE_ASNGETDATA(dataASN, NULL);
|
FREE_ASNGETDATA(dataASN, NULL);
|
||||||
#endif
|
#endif
|
||||||
@@ -35345,7 +35345,6 @@ int DecodeAsymKey_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
if (GetAlgoId(input, inOutIdx, &oid, oidKeyType, inSz) < 0)
|
if (GetAlgoId(input, inOutIdx, &oid, oidKeyType, inSz) < 0)
|
||||||
return ASN_PARSE_E;
|
return ASN_PARSE_E;
|
||||||
|
|
||||||
if (inOutKeyType != NULL) {
|
|
||||||
/* If user supplies ANONk (0) key type, we want to auto-detect from
|
/* If user supplies ANONk (0) key type, we want to auto-detect from
|
||||||
* DER and copy it back to user */
|
* DER and copy it back to user */
|
||||||
if (*inOutKeyType == ANONk) {
|
if (*inOutKeyType == ANONk) {
|
||||||
@@ -35355,7 +35354,6 @@ int DecodeAsymKey_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
else if (oid != (word32)*inOutKeyType) {
|
else if (oid != (word32)*inOutKeyType) {
|
||||||
return ASN_PARSE_E;
|
return ASN_PARSE_E;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (GetOctetString(input, inOutIdx, &length, inSz) < 0)
|
if (GetOctetString(input, inOutIdx, &length, inSz) < 0)
|
||||||
return ASN_PARSE_E;
|
return ASN_PARSE_E;
|
||||||
@@ -35407,7 +35405,7 @@ int DecodeAsymKey_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* If user supplies an expected keyType (algorithm OID sum), attempt to
|
/* If user supplies an expected keyType (algorithm OID sum), attempt to
|
||||||
* process DER accordingly */
|
* process DER accordingly */
|
||||||
if (inOutKeyType != NULL && *inOutKeyType != 0) {
|
if (*inOutKeyType != ANONk) {
|
||||||
word32 oidSz;
|
word32 oidSz;
|
||||||
/* Explicit OID check - use expected type */
|
/* Explicit OID check - use expected type */
|
||||||
const byte* oidDerBytes = OidFromId((word32)*inOutKeyType,
|
const byte* oidDerBytes = OidFromId((word32)*inOutKeyType,
|
||||||
@@ -35434,7 +35432,7 @@ int DecodeAsymKey_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Store detected OID if requested */
|
/* Store detected OID if requested */
|
||||||
if (ret == 0 && inOutKeyType != NULL && *inOutKeyType == ANONk) {
|
if (ret == 0 && *inOutKeyType == ANONk) {
|
||||||
*inOutKeyType =
|
*inOutKeyType =
|
||||||
(int)dataASN[EDKEYASN_IDX_PKEYALGO_OID].data.oid.sum;
|
(int)dataASN[EDKEYASN_IDX_PKEYALGO_OID].data.oid.sum;
|
||||||
}
|
}
|
||||||
@@ -35513,7 +35511,7 @@ int DecodeAsymKeyPublic_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (input == NULL || inSz == 0 || inOutIdx == NULL ||
|
if (input == NULL || inSz == 0 || inOutIdx == NULL ||
|
||||||
pubKey == NULL || pubKeyLen == NULL) {
|
pubKey == NULL || pubKeyLen == NULL || inOutKeyType == NULL) {
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35527,7 +35525,6 @@ int DecodeAsymKeyPublic_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
if (GetObjectId(input, inOutIdx, &oid, oidKeyType, inSz) < 0)
|
if (GetObjectId(input, inOutIdx, &oid, oidKeyType, inSz) < 0)
|
||||||
return ASN_PARSE_E;
|
return ASN_PARSE_E;
|
||||||
|
|
||||||
if (inOutKeyType != NULL) {
|
|
||||||
/* If user supplies ANONk (0) key type, we want to auto-detect from
|
/* If user supplies ANONk (0) key type, we want to auto-detect from
|
||||||
* DER and copy it back to user */
|
* DER and copy it back to user */
|
||||||
if (*inOutKeyType == ANONk) {
|
if (*inOutKeyType == ANONk) {
|
||||||
@@ -35537,7 +35534,6 @@ int DecodeAsymKeyPublic_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
else if (oid != (word32)*inOutKeyType) {
|
else if (oid != (word32)*inOutKeyType) {
|
||||||
return ASN_PARSE_E;
|
return ASN_PARSE_E;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* key header */
|
/* key header */
|
||||||
ret = CheckBitString(input, inOutIdx, &length, inSz, 1, NULL);
|
ret = CheckBitString(input, inOutIdx, &length, inSz, 1, NULL);
|
||||||
@@ -35559,7 +35555,7 @@ int DecodeAsymKeyPublic_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* If user supplies an expected keyType (algorithm OID sum), attempt to
|
/* If user supplies an expected keyType (algorithm OID sum), attempt to
|
||||||
* process DER accordingly */
|
* process DER accordingly */
|
||||||
if (inOutKeyType != NULL && *inOutKeyType != ANONk) {
|
if (*inOutKeyType != ANONk) {
|
||||||
word32 oidSz;
|
word32 oidSz;
|
||||||
/* Explicit OID check - use expected type */
|
/* Explicit OID check - use expected type */
|
||||||
const byte* oidDerBytes = OidFromId((word32)*inOutKeyType,
|
const byte* oidDerBytes = OidFromId((word32)*inOutKeyType,
|
||||||
@@ -35581,7 +35577,7 @@ int DecodeAsymKeyPublic_Assign(const byte* input, word32* inOutIdx, word32 inSz,
|
|||||||
ret = ASN_PARSE_E;
|
ret = ASN_PARSE_E;
|
||||||
|
|
||||||
/* Store detected OID if requested */
|
/* Store detected OID if requested */
|
||||||
if (ret == 0 && inOutKeyType != NULL && *inOutKeyType == ANONk) {
|
if (ret == 0 && *inOutKeyType == ANONk) {
|
||||||
*inOutKeyType =
|
*inOutKeyType =
|
||||||
(int)dataASN[PUBKEYASN_IDX_ALGOID_OID].data.oid.sum;
|
(int)dataASN[PUBKEYASN_IDX_ALGOID_OID].data.oid.sum;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user