forked from wolfSSL/wolfssl
fix indentation -- no code changed.
This commit is contained in:
160
src/ssl.c
160
src/ssl.c
@@ -1292,9 +1292,9 @@ int CyaSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff,
|
|||||||
if (pass) {
|
if (pass) {
|
||||||
info->ctx = CyaSSL_CTX_new(CyaSSLv23_client_method());
|
info->ctx = CyaSSL_CTX_new(CyaSSLv23_client_method());
|
||||||
if (info->ctx == NULL) {
|
if (info->ctx == NULL) {
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1773,11 +1773,11 @@ int CyaSSL_Init(void)
|
|||||||
|
|
||||||
#ifndef NO_CERTS
|
#ifndef NO_CERTS
|
||||||
|
|
||||||
/* Remove PEM header/footer, convert to ASN1, store any encrypted data
|
/* Remove PEM header/footer, convert to ASN1, store any encrypted data
|
||||||
info->consumed tracks of PEM bytes consumed in case multiple parts */
|
info->consumed tracks of PEM bytes consumed in case multiple parts */
|
||||||
int PemToDer(const unsigned char* buff, long longSz, int type,
|
int PemToDer(const unsigned char* buff, long longSz, int type,
|
||||||
buffer* der, void* heap, EncryptedInfo* info, int* eccKey)
|
buffer* der, void* heap, EncryptedInfo* info, int* eccKey)
|
||||||
{
|
{
|
||||||
char header[PEM_LINE_LEN];
|
char header[PEM_LINE_LEN];
|
||||||
char footer[PEM_LINE_LEN];
|
char footer[PEM_LINE_LEN];
|
||||||
char* headerEnd;
|
char* headerEnd;
|
||||||
@@ -1797,8 +1797,8 @@ int CyaSSL_Init(void)
|
|||||||
if (type == CERT_TYPE || type == CA_TYPE) {
|
if (type == CERT_TYPE || type == CA_TYPE) {
|
||||||
XSTRNCPY(header, "-----BEGIN CERTIFICATE-----", sizeof(header));
|
XSTRNCPY(header, "-----BEGIN CERTIFICATE-----", sizeof(header));
|
||||||
XSTRNCPY(footer, "-----END CERTIFICATE-----", sizeof(footer));
|
XSTRNCPY(footer, "-----END CERTIFICATE-----", sizeof(footer));
|
||||||
dynamicType = (type == CA_TYPE) ? DYNAMIC_TYPE_CA :
|
dynamicType = (type == CA_TYPE) ? DYNAMIC_TYPE_CA
|
||||||
DYNAMIC_TYPE_CERT;
|
: DYNAMIC_TYPE_CERT;
|
||||||
} else if (type == CERTREQ_TYPE) {
|
} else if (type == CERTREQ_TYPE) {
|
||||||
XSTRNCPY(header, "-----BEGIN CERTIFICATE REQUEST-----",
|
XSTRNCPY(header, "-----BEGIN CERTIFICATE REQUEST-----",
|
||||||
sizeof(header));
|
sizeof(header));
|
||||||
@@ -1870,7 +1870,7 @@ int CyaSSL_Init(void)
|
|||||||
return SSL_BAD_FILE;
|
return SSL_BAD_FILE;
|
||||||
|
|
||||||
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
|
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
|
||||||
{
|
{
|
||||||
/* remove encrypted header if there */
|
/* remove encrypted header if there */
|
||||||
char encHeader[] = "Proc-Type";
|
char encHeader[] = "Proc-Type";
|
||||||
char* line = XSTRNSTR(headerEnd, encHeader, PEM_LINE_LEN);
|
char* line = XSTRNSTR(headerEnd, encHeader, PEM_LINE_LEN);
|
||||||
@@ -1910,7 +1910,7 @@ int CyaSSL_Init(void)
|
|||||||
newline++;
|
newline++;
|
||||||
headerEnd = newline;
|
headerEnd = newline;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* OPENSSL_EXTRA || HAVE_WEBSERVER */
|
#endif /* OPENSSL_EXTRA || HAVE_WEBSERVER */
|
||||||
|
|
||||||
/* find footer */
|
/* find footer */
|
||||||
@@ -1974,16 +1974,16 @@ int CyaSSL_Init(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* process the buffer buff, legnth sz, into ctx of format and type
|
/* process the buffer buff, legnth sz, into ctx of format and type
|
||||||
used tracks bytes consumed, userChain specifies a user cert chain
|
used tracks bytes consumed, userChain specifies a user cert chain
|
||||||
to pass during the handshake */
|
to pass during the handshake */
|
||||||
static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
|
static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff,
|
||||||
long sz, int format, int type, CYASSL* ssl,
|
long sz, int format, int type, CYASSL* ssl,
|
||||||
long* used, int userChain)
|
long* used, int userChain)
|
||||||
{
|
{
|
||||||
buffer der; /* holds DER or RAW (for NTRU) */
|
buffer der; /* holds DER or RAW (for NTRU) */
|
||||||
int ret;
|
int ret;
|
||||||
int dynamicType = 0;
|
int dynamicType = 0;
|
||||||
@@ -2031,9 +2031,9 @@ int CyaSSL_Init(void)
|
|||||||
if (format == SSL_FILETYPE_PEM) {
|
if (format == SSL_FILETYPE_PEM) {
|
||||||
ret = PemToDer(buff, sz, type, &der, heap, info, &eccKey);
|
ret = PemToDer(buff, sz, type, &der, heap, info, &eccKey);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
XFREE(der.buffer, heap, dynamicType);
|
XFREE(der.buffer, heap, dynamicType);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -2043,11 +2043,11 @@ int CyaSSL_Init(void)
|
|||||||
|
|
||||||
/* we may have a user cert chain, try to consume */
|
/* we may have a user cert chain, try to consume */
|
||||||
if (userChain && type == CERT_TYPE && info->consumed < sz) {
|
if (userChain && type == CERT_TYPE && info->consumed < sz) {
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
byte staticBuffer[1]; /* force heap usage */
|
byte staticBuffer[1]; /* force heap usage */
|
||||||
#else
|
#else
|
||||||
byte staticBuffer[FILE_BUFFER_SIZE]; /* tmp chain buffer */
|
byte staticBuffer[FILE_BUFFER_SIZE]; /* tmp chain buffer */
|
||||||
#endif
|
#endif
|
||||||
byte* chainBuffer = staticBuffer;
|
byte* chainBuffer = staticBuffer;
|
||||||
byte* shrinked = NULL; /* shrinked to size chainBuffer
|
byte* shrinked = NULL; /* shrinked to size chainBuffer
|
||||||
* or staticBuffer */
|
* or staticBuffer */
|
||||||
@@ -2061,12 +2061,11 @@ int CyaSSL_Init(void)
|
|||||||
CYASSL_MSG("Growing Tmp Chain Buffer");
|
CYASSL_MSG("Growing Tmp Chain Buffer");
|
||||||
bufferSz = (word32)(sz - consumed);
|
bufferSz = (word32)(sz - consumed);
|
||||||
/* will shrink to actual size */
|
/* will shrink to actual size */
|
||||||
chainBuffer = (byte*)XMALLOC(bufferSz, heap,
|
chainBuffer = (byte*)XMALLOC(bufferSz, heap, DYNAMIC_TYPE_FILE);
|
||||||
DYNAMIC_TYPE_FILE);
|
|
||||||
if (chainBuffer == NULL) {
|
if (chainBuffer == NULL) {
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
XFREE(der.buffer, heap, dynamicType);
|
XFREE(der.buffer, heap, dynamicType);
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
@@ -2109,9 +2108,9 @@ int CyaSSL_Init(void)
|
|||||||
CYASSL_MSG(" Error in Cert in Chain");
|
CYASSL_MSG(" Error in Cert in Chain");
|
||||||
if (dynamicBuffer)
|
if (dynamicBuffer)
|
||||||
XFREE(chainBuffer, heap, DYNAMIC_TYPE_FILE);
|
XFREE(chainBuffer, heap, DYNAMIC_TYPE_FILE);
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
XFREE(der.buffer, heap, dynamicType);
|
XFREE(der.buffer, heap, dynamicType);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -2145,9 +2144,9 @@ int CyaSSL_Init(void)
|
|||||||
XFREE(chainBuffer, heap, DYNAMIC_TYPE_FILE);
|
XFREE(chainBuffer, heap, DYNAMIC_TYPE_FILE);
|
||||||
|
|
||||||
if (shrinked == NULL) {
|
if (shrinked == NULL) {
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
XFREE(der.buffer, heap, dynamicType);
|
XFREE(der.buffer, heap, dynamicType);
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
@@ -2156,9 +2155,9 @@ int CyaSSL_Init(void)
|
|||||||
else { /* ASN1 (DER) or RAW (NTRU) */
|
else { /* ASN1 (DER) or RAW (NTRU) */
|
||||||
der.buffer = (byte*) XMALLOC(sz, heap, dynamicType);
|
der.buffer = (byte*) XMALLOC(sz, heap, dynamicType);
|
||||||
if (!der.buffer) {
|
if (!der.buffer) {
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
return MEMORY_ERROR;
|
return MEMORY_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2237,9 +2236,9 @@ int CyaSSL_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
XFREE(der.buffer, heap, dynamicType);
|
XFREE(der.buffer, heap, dynamicType);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -2262,8 +2261,7 @@ int CyaSSL_Init(void)
|
|||||||
else if (type == CERT_TYPE) {
|
else if (type == CERT_TYPE) {
|
||||||
if (ssl) {
|
if (ssl) {
|
||||||
if (ssl->buffers.weOwnCert && ssl->buffers.certificate.buffer)
|
if (ssl->buffers.weOwnCert && ssl->buffers.certificate.buffer)
|
||||||
XFREE(ssl->buffers.certificate.buffer, heap,
|
XFREE(ssl->buffers.certificate.buffer, heap, dynamicType);
|
||||||
dynamicType);
|
|
||||||
ssl->buffers.certificate = der;
|
ssl->buffers.certificate = der;
|
||||||
ssl->buffers.weOwnCert = 1;
|
ssl->buffers.weOwnCert = 1;
|
||||||
}
|
}
|
||||||
@@ -2292,7 +2290,7 @@ int CyaSSL_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type == PRIVATEKEY_TYPE && format != SSL_FILETYPE_RAW) {
|
if (type == PRIVATEKEY_TYPE && format != SSL_FILETYPE_RAW) {
|
||||||
#ifndef NO_RSA
|
#ifndef NO_RSA
|
||||||
if (!eccKey) {
|
if (!eccKey) {
|
||||||
/* make sure RSA key can be used */
|
/* make sure RSA key can be used */
|
||||||
RsaKey key;
|
RsaKey key;
|
||||||
@@ -2301,10 +2299,10 @@ int CyaSSL_Init(void)
|
|||||||
ret = InitRsaKey(&key, 0);
|
ret = InitRsaKey(&key, 0);
|
||||||
if (ret != 0) return ret;
|
if (ret != 0) return ret;
|
||||||
if (RsaPrivateKeyDecode(der.buffer,&idx,&key,der.length) != 0) {
|
if (RsaPrivateKeyDecode(der.buffer,&idx,&key,der.length) != 0) {
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
/* could have DER ECC (or pkcs8 ecc), no easy way to tell */
|
/* could have DER ECC (or pkcs8 ecc), no easy way to tell */
|
||||||
eccKey = 1; /* so try it out */
|
eccKey = 1; /* so try it out */
|
||||||
#endif
|
#endif
|
||||||
if (!eccKey) {
|
if (!eccKey) {
|
||||||
FreeRsaKey(&key);
|
FreeRsaKey(&key);
|
||||||
return SSL_BAD_FILE;
|
return SSL_BAD_FILE;
|
||||||
@@ -2315,8 +2313,8 @@ int CyaSSL_Init(void)
|
|||||||
}
|
}
|
||||||
FreeRsaKey(&key);
|
FreeRsaKey(&key);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
if (!rsaKey) {
|
if (!rsaKey) {
|
||||||
/* make sure ECC key can be used */
|
/* make sure ECC key can be used */
|
||||||
word32 idx = 0;
|
word32 idx = 0;
|
||||||
@@ -2334,7 +2332,7 @@ int CyaSSL_Init(void)
|
|||||||
if (ssl)
|
if (ssl)
|
||||||
ssl->options.haveStaticECC = 1;
|
ssl->options.haveStaticECC = 1;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_ECC */
|
#endif /* HAVE_ECC */
|
||||||
}
|
}
|
||||||
else if (type == CERT_TYPE) {
|
else if (type == CERT_TYPE) {
|
||||||
DecodedCert cert;
|
DecodedCert cert;
|
||||||
@@ -2362,20 +2360,18 @@ int CyaSSL_Init(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
if (ctx)
|
if (ctx)
|
||||||
ctx->pkCurveOID = cert.pkCurveOID;
|
ctx->pkCurveOID = cert.pkCurveOID;
|
||||||
if (ssl)
|
if (ssl)
|
||||||
ssl->pkCurveOID = cert.pkCurveOID;
|
ssl->pkCurveOID = cert.pkCurveOID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FreeDecodedCert(&cert);
|
FreeDecodedCert(&cert);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SSL_SUCCESS;
|
return SSL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* CA PEM file for verification, may have multiple/chain certs to process */
|
/* CA PEM file for verification, may have multiple/chain certs to process */
|
||||||
@@ -2437,20 +2433,20 @@ int CyaSSL_CertManagerVerifyBuffer(CYASSL_CERT_MANAGER* cm, const byte* buff,
|
|||||||
|
|
||||||
if (format == SSL_FILETYPE_PEM) {
|
if (format == SSL_FILETYPE_PEM) {
|
||||||
int eccKey = 0; /* not used */
|
int eccKey = 0; /* not used */
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
EncryptedInfo* info;
|
EncryptedInfo* info;
|
||||||
#else
|
#else
|
||||||
EncryptedInfo info[1];
|
EncryptedInfo info[1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
|
info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
|
||||||
DYNAMIC_TYPE_TMP_BUFFER);
|
DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
info->set = 0;
|
info->set = 0;
|
||||||
info->ctx = NULL;
|
info->ctx = NULL;
|
||||||
@@ -2461,9 +2457,9 @@ int CyaSSL_CertManagerVerifyBuffer(CYASSL_CERT_MANAGER* cm, const byte* buff,
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
InitDecodedCert(cert, der.buffer, der.length, cm->heap);
|
InitDecodedCert(cert, der.buffer, der.length, cm->heap);
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
InitDecodedCert(cert, (byte*)buff, (word32)sz, cm->heap);
|
InitDecodedCert(cert, (byte*)buff, (word32)sz, cm->heap);
|
||||||
@@ -2774,7 +2770,8 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
XFCLOSE(file);
|
XFCLOSE(file);
|
||||||
if (dynamic) XFREE(myBuffer, heapHint, DYNAMIC_TYPE_FILE);
|
if (dynamic)
|
||||||
|
XFREE(myBuffer, heapHint, DYNAMIC_TYPE_FILE);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -2903,7 +2900,8 @@ int CyaSSL_CertManagerVerify(CYASSL_CERT_MANAGER* cm, const char* fname,
|
|||||||
ret = CyaSSL_CertManagerVerifyBuffer(cm, myBuffer, sz, format);
|
ret = CyaSSL_CertManagerVerifyBuffer(cm, myBuffer, sz, format);
|
||||||
|
|
||||||
XFCLOSE(file);
|
XFCLOSE(file);
|
||||||
if (dynamic) XFREE(myBuffer, cm->heap, DYNAMIC_TYPE_FILE);
|
if (dynamic)
|
||||||
|
XFREE(myBuffer, cm->heap, DYNAMIC_TYPE_FILE);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -3418,7 +3416,8 @@ static int CyaSSL_SetTmpDH_file_wrapper(CYASSL_CTX* ctx, CYASSL* ssl,
|
|||||||
}
|
}
|
||||||
|
|
||||||
XFCLOSE(file);
|
XFCLOSE(file);
|
||||||
if (dynamic) XFREE(myBuffer, ctx->heap, DYNAMIC_TYPE_FILE);
|
if (dynamic)
|
||||||
|
XFREE(myBuffer, ctx->heap, DYNAMIC_TYPE_FILE);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -5686,11 +5685,11 @@ int CyaSSL_set_compression(CYASSL* ssl)
|
|||||||
because of SSL_write behavior and because front adds may be small */
|
because of SSL_write behavior and because front adds may be small */
|
||||||
int CyaSSL_writev(CYASSL* ssl, const struct iovec* iov, int iovcnt)
|
int CyaSSL_writev(CYASSL* ssl, const struct iovec* iov, int iovcnt)
|
||||||
{
|
{
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
byte staticBuffer[1]; /* force heap usage */
|
byte staticBuffer[1]; /* force heap usage */
|
||||||
#else
|
#else
|
||||||
byte staticBuffer[FILE_BUFFER_SIZE];
|
byte staticBuffer[FILE_BUFFER_SIZE];
|
||||||
#endif
|
#endif
|
||||||
byte* myBuffer = staticBuffer;
|
byte* myBuffer = staticBuffer;
|
||||||
int dynamic = 0;
|
int dynamic = 0;
|
||||||
int sending = 0;
|
int sending = 0;
|
||||||
@@ -8387,13 +8386,13 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format)
|
|||||||
|
|
||||||
if (format == SSL_FILETYPE_PEM) {
|
if (format == SSL_FILETYPE_PEM) {
|
||||||
int ecc = 0;
|
int ecc = 0;
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
EncryptedInfo* info;
|
EncryptedInfo* info;
|
||||||
#else
|
#else
|
||||||
EncryptedInfo info[1];
|
EncryptedInfo info[1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
|
info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
|
||||||
DYNAMIC_TYPE_TMP_BUFFER);
|
DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
@@ -8402,7 +8401,7 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format)
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
info->set = 0;
|
info->set = 0;
|
||||||
info->ctx = NULL;
|
info->ctx = NULL;
|
||||||
@@ -8419,9 +8418,9 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
der.buffer = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_CERT);
|
der.buffer = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_CERT);
|
||||||
@@ -9782,31 +9781,28 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format)
|
|||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
|
|
||||||
#ifdef FORTRESS
|
#ifdef FORTRESS
|
||||||
int CyaSSL_cmp_peer_cert_to_file(CYASSL* ssl, const char *fname)
|
int CyaSSL_cmp_peer_cert_to_file(CYASSL* ssl, const char *fname)
|
||||||
{
|
{
|
||||||
int ret = SSL_FATAL_ERROR;
|
int ret = SSL_FATAL_ERROR;
|
||||||
|
|
||||||
CYASSL_ENTER("CyaSSL_cmp_peer_cert_to_file");
|
CYASSL_ENTER("CyaSSL_cmp_peer_cert_to_file");
|
||||||
if (ssl != NULL && fname != NULL)
|
if (ssl != NULL && fname != NULL)
|
||||||
{
|
{
|
||||||
XFILE file = XBADFILE;
|
#ifdef CYASSL_SMALL_STACK
|
||||||
long sz = 0;
|
EncryptedInfo* info;
|
||||||
#ifdef CYASSL_SMALL_STACK
|
|
||||||
byte staticBuffer[1]; /* force heap usage */
|
byte staticBuffer[1]; /* force heap usage */
|
||||||
#else
|
#else
|
||||||
|
EncryptedInfo info[1];
|
||||||
byte staticBuffer[FILE_BUFFER_SIZE];
|
byte staticBuffer[FILE_BUFFER_SIZE];
|
||||||
#endif
|
#endif
|
||||||
byte* myBuffer = staticBuffer;
|
byte* myBuffer = staticBuffer;
|
||||||
int dynamic = 0;
|
int dynamic = 0;
|
||||||
CYASSL_CTX* ctx = ssl->ctx;
|
XFILE file = XBADFILE;
|
||||||
buffer fileDer;
|
long sz = 0;
|
||||||
int eccKey = 0;
|
int eccKey = 0;
|
||||||
|
CYASSL_CTX* ctx = ssl->ctx;
|
||||||
CYASSL_X509* peer_cert = &ssl->peerCert;
|
CYASSL_X509* peer_cert = &ssl->peerCert;
|
||||||
#ifdef CYASSL_SMALL_STACK
|
buffer fileDer;
|
||||||
EncryptedInfo* info;
|
|
||||||
#else
|
|
||||||
EncryptedInfo info[1];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
file = XFOPEN(fname, "rb");
|
file = XFOPEN(fname, "rb");
|
||||||
if (file == XBADFILE)
|
if (file == XBADFILE)
|
||||||
@@ -9822,13 +9818,13 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format)
|
|||||||
dynamic = 1;
|
dynamic = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
|
info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL,
|
||||||
DYNAMIC_TYPE_TMP_BUFFER);
|
DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (info == NULL)
|
if (info == NULL)
|
||||||
ret = MEMORY_E;
|
ret = MEMORY_E;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
info->set = 0;
|
info->set = 0;
|
||||||
info->ctx = ctx;
|
info->ctx = ctx;
|
||||||
@@ -9848,9 +9844,9 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
XFREE(fileDer.buffer, ctx->heap, DYNAMIC_TYPE_CERT);
|
XFREE(fileDer.buffer, ctx->heap, DYNAMIC_TYPE_CERT);
|
||||||
@@ -9861,7 +9857,7 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user