forked from wolfSSL/wolfssl
touch up pkcs8 create function and test case warning
This commit is contained in:
@ -74557,6 +74557,7 @@ static int test_wc_GetPkcs8TraditionalOffset(void)
|
|||||||
ExpectIntGT(derSz = (int)XFREAD(der, 1, sizeof(der), file), 0);
|
ExpectIntGT(derSz = (int)XFREAD(der, 1, sizeof(der), file), 0);
|
||||||
if (file != XBADFILE)
|
if (file != XBADFILE)
|
||||||
XFCLOSE(file);
|
XFCLOSE(file);
|
||||||
|
file = XBADFILE; /* reset file to avoid warning of use after close */
|
||||||
|
|
||||||
/* valid case */
|
/* valid case */
|
||||||
inOutIdx = 0;
|
inOutIdx = 0;
|
||||||
|
@ -6897,6 +6897,7 @@ enum {
|
|||||||
PKCS8KEYASN_IDX_PKEY_ALGO_PARAM_SEQ,
|
PKCS8KEYASN_IDX_PKEY_ALGO_PARAM_SEQ,
|
||||||
#endif
|
#endif
|
||||||
PKCS8KEYASN_IDX_PKEY_DATA,
|
PKCS8KEYASN_IDX_PKEY_DATA,
|
||||||
|
PKCS8KEYASN_IDX_PKEY_ATTRIBUTES,
|
||||||
WOLF_ENUM_DUMMY_LAST_ELEMENT(PKCS8KEYASN_IDX)
|
WOLF_ENUM_DUMMY_LAST_ELEMENT(PKCS8KEYASN_IDX)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -7307,7 +7308,9 @@ int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz,
|
|||||||
*outSz = tmpSz + sz;
|
*outSz = tmpSz + sz;
|
||||||
return (int)(tmpSz + sz);
|
return (int)(tmpSz + sz);
|
||||||
#else
|
#else
|
||||||
DECL_ASNSETDATA(dataASN, pkcs8KeyASN_Length);
|
/* pkcs8KeyASN_Length-1, the -1 is because we are not adding the optional
|
||||||
|
* set of attributes */
|
||||||
|
DECL_ASNSETDATA(dataASN, pkcs8KeyASN_Length-1);
|
||||||
int sz = 0;
|
int sz = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
word32 keyIdx = 0;
|
word32 keyIdx = 0;
|
||||||
@ -7328,7 +7331,7 @@ int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz,
|
|||||||
ret = ASN_PARSE_E;
|
ret = ASN_PARSE_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
CALLOC_ASNSETDATA(dataASN, pkcs8KeyASN_Length, ret, NULL);
|
CALLOC_ASNSETDATA(dataASN, pkcs8KeyASN_Length-1, ret, NULL);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* Only support default PKCS #8 format - v0. */
|
/* Only support default PKCS #8 format - v0. */
|
||||||
@ -7354,7 +7357,7 @@ int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz,
|
|||||||
SetASN_Buffer(&dataASN[PKCS8KEYASN_IDX_PKEY_DATA], key, keySz);
|
SetASN_Buffer(&dataASN[PKCS8KEYASN_IDX_PKEY_DATA], key, keySz);
|
||||||
|
|
||||||
/* Get the size of the DER encoding. */
|
/* Get the size of the DER encoding. */
|
||||||
ret = SizeASN_Items(pkcs8KeyASN, dataASN, pkcs8KeyASN_Length, &sz);
|
ret = SizeASN_Items(pkcs8KeyASN, dataASN, pkcs8KeyASN_Length-1, &sz);
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* Always return the calculated size. */
|
/* Always return the calculated size. */
|
||||||
@ -7367,7 +7370,7 @@ int wc_CreatePKCS8Key(byte* out, word32* outSz, byte* key, word32 keySz,
|
|||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
/* Encode PKCS #8 key into buffer. */
|
/* Encode PKCS #8 key into buffer. */
|
||||||
SetASN_Items(pkcs8KeyASN, dataASN, pkcs8KeyASN_Length, out);
|
SetASN_Items(pkcs8KeyASN, dataASN, pkcs8KeyASN_Length-1, out);
|
||||||
ret = sz;
|
ret = sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user