mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-03-07 01:24:03 +01:00
Merge pull request #1637 from ghoso/openssl_compat201805
OpenSSL Compatibility APIs 2018/06
This commit is contained in:
@@ -407,7 +407,7 @@ static const bench_alg bench_other_opt[] = {
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_MDK_ARM)
|
||||
extern FILE * wolfSSL_fopen(const char *fname, const char *mode);
|
||||
extern XFILE wolfSSL_fopen(const char *fname, const char *mode);
|
||||
#define fopen wolfSSL_fopen
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2688,9 +2688,9 @@ int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz,
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
(void)tmpIdx;
|
||||
(void)curveOID;
|
||||
(void)oidSz;
|
||||
(void)tmpIdx;
|
||||
(void)keySz;
|
||||
(void)heap;
|
||||
|
||||
@@ -4083,6 +4083,48 @@ static int GetKey(DecodedCert* cert)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
|
||||
WOLFSSL_LOCAL int OBJ_sn2nid(const char *sn)
|
||||
{
|
||||
static const struct {
|
||||
const char *sn;
|
||||
int nid;
|
||||
} sn2nid[] = {
|
||||
{WOLFSSL_COMMON_NAME, NID_commonName},
|
||||
{WOLFSSL_COUNTRY_NAME, NID_countryName},
|
||||
{WOLFSSL_LOCALITY_NAME, NID_localityName},
|
||||
{WOLFSSL_STATE_NAME, NID_stateOrProvinceName},
|
||||
{WOLFSSL_ORG_NAME, NID_organizationName},
|
||||
{WOLFSSL_ORGUNIT_NAME, NID_organizationalUnitName},
|
||||
{WOLFSSL_EMAIL_ADDR, NID_emailAddress},
|
||||
{NULL, -1}};
|
||||
|
||||
int i;
|
||||
WOLFSSL_ENTER("OBJ_osn2nid");
|
||||
#ifdef HAVE_ECC
|
||||
/* Nginx uses this OpenSSL string. */
|
||||
if (XSTRNCMP(sn, "prime256v1", 10) == 0)
|
||||
sn = "SECP256R1";
|
||||
if (XSTRNCMP(sn, "secp384r1", 10) == 0)
|
||||
sn = "SECP384R1";
|
||||
/* find based on name and return NID */
|
||||
for (i = 0; i < ecc_sets[i].size; i++) {
|
||||
if (XSTRNCMP(sn, ecc_sets[i].name, ECC_MAXNAME) == 0) {
|
||||
return ecc_sets[i].id;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for(i=0; sn2nid[i].sn != NULL; i++) {
|
||||
if(XSTRNCMP(sn, sn2nid[i].sn, XSTRLEN(sn2nid[i].sn)) == 0) {
|
||||
return sn2nid[i].nid;
|
||||
}
|
||||
}
|
||||
|
||||
return NID_undef;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* process NAME, either issuer or subject */
|
||||
static int GetName(DecodedCert* cert, int nameType)
|
||||
{
|
||||
@@ -4563,6 +4605,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->cnLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], WOLFSSL_COMMON_NAME, 4);
|
||||
dName->cnNid = OBJ_sn2nid((const char *)WOLFSSL_COMMON_NAME);
|
||||
idx += 4;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->cnIdx], dName->cnLen);
|
||||
@@ -4572,6 +4615,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->snLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], WOLFSSL_SUR_NAME, 4);
|
||||
dName->snNid = OBJ_sn2nid((const char *)WOLFSSL_SUR_NAME);
|
||||
idx += 4;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->snIdx], dName->snLen);
|
||||
@@ -4581,6 +4625,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->cLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], WOLFSSL_COUNTRY_NAME, 3);
|
||||
dName->cNid = OBJ_sn2nid((const char *)WOLFSSL_COUNTRY_NAME);
|
||||
idx += 3;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->cIdx], dName->cLen);
|
||||
@@ -4590,6 +4635,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->lLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], WOLFSSL_LOCALITY_NAME, 3);
|
||||
dName->lNid = OBJ_sn2nid((const char *)WOLFSSL_LOCALITY_NAME);
|
||||
idx += 3;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->lIdx], dName->lLen);
|
||||
@@ -4599,6 +4645,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->stLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], WOLFSSL_STATE_NAME, 4);
|
||||
dName->stNid = OBJ_sn2nid((const char *)WOLFSSL_STATE_NAME);
|
||||
idx += 4;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->stIdx], dName->stLen);
|
||||
@@ -4608,6 +4655,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->oLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], WOLFSSL_ORG_NAME, 3);
|
||||
dName->oNid = OBJ_sn2nid((const char *)WOLFSSL_ORG_NAME);
|
||||
idx += 3;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->oIdx], dName->oLen);
|
||||
@@ -4617,6 +4665,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->ouLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], WOLFSSL_ORGUNIT_NAME, 4);
|
||||
dName->ouNid = OBJ_sn2nid((const char *)WOLFSSL_ORGUNIT_NAME);
|
||||
idx += 4;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->ouIdx], dName->ouLen);
|
||||
@@ -4626,6 +4675,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->emailLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], "/emailAddress=", 14);
|
||||
dName->emailNid = OBJ_sn2nid((const char *)"/emailAddress=");
|
||||
idx += 14;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->emailIdx], dName->emailLen);
|
||||
@@ -4646,6 +4696,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->uidLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], "/UID=", 5);
|
||||
dName->uidNid = OBJ_sn2nid((const char *)"/UID=");
|
||||
idx += 5;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->uidIdx], dName->uidLen);
|
||||
@@ -4655,6 +4706,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||
if (dName->serialLen != 0) {
|
||||
dName->entryCount++;
|
||||
XMEMCPY(&dName->fullName[idx], WOLFSSL_SERIAL_NUMBER, 14);
|
||||
dName->serialNid = OBJ_sn2nid((const char *)WOLFSSL_SERIAL_NUMBER);
|
||||
idx += 14;
|
||||
XMEMCPY(&dName->fullName[idx],
|
||||
&cert->source[dName->serialIdx], dName->serialLen);
|
||||
|
||||
@@ -733,30 +733,33 @@ void wc_ERR_print_errors_fp(XFILE fp)
|
||||
{
|
||||
WOLFSSL_ENTER("wc_ERR_print_errors_fp");
|
||||
|
||||
if (wc_LockMutex(&debug_mutex) != 0) {
|
||||
WOLFSSL_MSG("Lock debug mutex failed");
|
||||
}
|
||||
else {
|
||||
/* free all nodes from error queue and print them to file */
|
||||
if (wc_LockMutex(&debug_mutex) != 0)
|
||||
{
|
||||
struct wc_error_queue* current;
|
||||
struct wc_error_queue* next;
|
||||
WOLFSSL_MSG("Lock debug mutex failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* free all nodes from error queue and print them to file */
|
||||
{
|
||||
struct wc_error_queue *current;
|
||||
struct wc_error_queue *next;
|
||||
|
||||
current = (struct wc_error_queue*)wc_errors;
|
||||
while (current != NULL) {
|
||||
next = current->next;
|
||||
fprintf(fp, "%s\n", current->error);
|
||||
XFREE(current, current->heap, DYNAMIC_TYPE_LOG);
|
||||
current = next;
|
||||
current = (struct wc_error_queue *)wc_errors;
|
||||
while (current != NULL)
|
||||
{
|
||||
next = current->next;
|
||||
fprintf(fp, "%s\n", current->error);
|
||||
XFREE(current, current->heap, DYNAMIC_TYPE_LOG);
|
||||
current = next;
|
||||
}
|
||||
|
||||
/* set global pointers to match having been freed */
|
||||
wc_errors = NULL;
|
||||
wc_last_node = NULL;
|
||||
}
|
||||
|
||||
/* set global pointers to match having been freed */
|
||||
wc_errors = NULL;
|
||||
wc_last_node = NULL;
|
||||
wc_UnLockMutex(&debug_mutex);
|
||||
}
|
||||
|
||||
wc_UnLockMutex(&debug_mutex);
|
||||
}
|
||||
}
|
||||
#endif /* !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) */
|
||||
|
||||
|
||||
@@ -409,7 +409,7 @@ static void myFipsCb(int ok, int err, const char* hash)
|
||||
#elif defined(WOLFSSL_CERT_EXT)
|
||||
static byte gTestMemory[140000];
|
||||
#elif defined(USE_FAST_MATH) && !defined(ALT_ECC_SIZE)
|
||||
static byte gTestMemory[130000];
|
||||
static byte gTestMemory[150000];
|
||||
#else
|
||||
static byte gTestMemory[80000];
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user