requested style changes

This commit is contained in:
MJSPollard
2018-07-19 11:05:56 -06:00
parent 42985d8250
commit 19dd08e191

View File

@@ -19780,7 +19780,7 @@ WOLFSSL_API int wolfSSL_sk_SSL_COMP_zero(WOLFSSL_STACK* st)
{ {
(void)st; (void)st;
WOLFSSL_STUB("wolfSSL_sk_SSL_COMP_zero"); WOLFSSL_STUB("wolfSSL_sk_SSL_COMP_zero");
//wolfSSL_set_options(ssl, SSL_OP_NO_COMPRESSION); /* wolfSSL_set_options(ssl, SSL_OP_NO_COMPRESSION); */
return WOLFSSL_FAILURE; return WOLFSSL_FAILURE;
} }
#endif #endif
@@ -27926,11 +27926,12 @@ WOLFSSL_RSA *wolfSSL_d2i_RSAPublicKey(WOLFSSL_RSA **r, const unsigned char **pp,
/* Converts an rsa private key from der format to an rsa structure. /* Converts an rsa private key from der format to an rsa structure.
Returns pointer to the rsa structure on succcess and NULL if error. */ Returns pointer to the rsa structure on succcess and NULL if error. */
WOLFSSL_RSA *wolfSSL_d2i_RSAPrivateKey(WOLFSSL_RSA **r, const unsigned char **derBuf, long derSz) WOLFSSL_RSA *wolfSSL_d2i_RSAPrivateKey(WOLFSSL_RSA **r,
const unsigned char **derBuf, long derSz)
{ {
WOLFSSL_RSA *rsa = NULL; WOLFSSL_RSA *rsa = NULL;
WOLFSSL_ENTER("d2i_RSAPrivateKey"); WOLFSSL_ENTER("wolfSSL_d2i_RSAPrivateKey");
/* check for bad functions arguments */ /* check for bad functions arguments */
if (derBuf == NULL) { if (derBuf == NULL) {
@@ -27942,8 +27943,8 @@ WOLFSSL_RSA *wolfSSL_d2i_RSAPrivateKey(WOLFSSL_RSA **r, const unsigned char **de
return NULL; return NULL;
} }
if(wolfSSL_RSA_LoadDer_ex(rsa, *derBuf, (int)derSz, WOLFSSL_RSA_LOAD_PRIVATE) if (wolfSSL_RSA_LoadDer_ex(rsa, *derBuf, (int)derSz,
!= WOLFSSL_SUCCESS){ WOLFSSL_RSA_LOAD_PRIVATE) != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("RSA_LoadDer failed"); WOLFSSL_MSG("RSA_LoadDer failed");
wolfSSL_RSA_free(rsa); wolfSSL_RSA_free(rsa);
rsa = NULL; rsa = NULL;
@@ -27951,6 +27952,7 @@ WOLFSSL_RSA *wolfSSL_d2i_RSAPrivateKey(WOLFSSL_RSA **r, const unsigned char **de
} }
if(r != NULL) if(r != NULL)
*r = rsa; *r = rsa;
return rsa; return rsa;
} }
@@ -27966,7 +27968,7 @@ int wolfSSL_i2d_RSAPrivateKey(WOLFSSL_RSA *rsa, unsigned char **pp)
int ret; int ret;
int i; int i;
WOLFSSL_ENTER("i2d_RSAPrivateKey"); WOLFSSL_ENTER("wolfSSL_i2d_RSAPrivateKey");
/* check for bad functions arguments */ /* check for bad functions arguments */
if ((rsa == NULL) || (pp == NULL)) { if ((rsa == NULL) || (pp == NULL)) {
@@ -27975,7 +27977,7 @@ int wolfSSL_i2d_RSAPrivateKey(WOLFSSL_RSA *rsa, unsigned char **pp)
} }
if ((ret = SetRsaInternal(rsa)) != WOLFSSL_SUCCESS) { if ((ret = SetRsaInternal(rsa)) != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("SetRsaInternal Failed"); WOLFSSL_MSG("SetRsaInternal() Failed");
return ret; return ret;
} }
@@ -27992,13 +27994,13 @@ int wolfSSL_i2d_RSAPrivateKey(WOLFSSL_RSA *rsa, unsigned char **pp)
/* RSA key to DER */ /* RSA key to DER */
if ((ret = wc_RsaKeyToDer((RsaKey *)rsa->internal, der, derMax)) < 0) { if ((ret = wc_RsaKeyToDer((RsaKey *)rsa->internal, der, derMax)) < 0) {
WOLFSSL_MSG("RsaKeyToDer failed"); WOLFSSL_MSG("wc_RsaKeyToDer() failed");
XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER);
der = NULL; der = NULL;
return ret; return ret;
} }
//ret is the size of the der buffer /* ret is the size of the der buffer */
for (i = 0; i < ret; i++) { for (i = 0; i < ret; i++) {
*(*pp + i) = *(der + i); *(*pp + i) = *(der + i);
} }
@@ -28852,7 +28854,7 @@ void* wolfSSL_GetDhAgreeCtx(WOLFSSL* ssl)
int wolfSSL_i2d_X509_NAME(WOLFSSL_X509_NAME* name, unsigned char** out) int wolfSSL_i2d_X509_NAME(WOLFSSL_X509_NAME* name, unsigned char** out)
{ {
CertName cName; CertName cName;
unsigned char buf[256]; //ASN_MAX_NAME unsigned char buf[256]; /* ASN_MAX_NAME */
int sz; int sz;
if (out == NULL || name == NULL) { if (out == NULL || name == NULL) {
@@ -31195,12 +31197,12 @@ int wolfSSL_BIO_new_bio_pair(WOLFSSL_BIO **bio1_p, size_t writebuf1,
} }
if (ret && writebuf1) { if (ret && writebuf1) {
if (!(ret = wolfSSL_BIO_set_write_buf_size(bio1, writebuf1))) { if (!(ret = wolfSSL_BIO_set_write_buf_size(bio1, writebuf1))) {
WOLFSSL_MSG("BIO_set_write_buf failed"); WOLFSSL_MSG("wolfSSL_BIO_set_write_buf() failure");
} }
} }
if (ret && writebuf2) { if (ret && writebuf2) {
if (!(ret = wolfSSL_BIO_set_write_buf_size(bio2, writebuf2))) { if (!(ret = wolfSSL_BIO_set_write_buf_size(bio2, writebuf2))) {
WOLFSSL_MSG("BIO_set_write_buf failed"); WOLFSSL_MSG("wolfSSL_BIO_set_write_buf() failure");
} }
} }
@@ -31245,7 +31247,7 @@ WOLFSSL_RSA* wolfSSL_d2i_RSAPrivateKey_bio(WOLFSSL_BIO *bio, WOLFSSL_RSA **out)
bioMemSz = wolfSSL_BIO_pending(bio); bioMemSz = wolfSSL_BIO_pending(bio);
if (bioMemSz <= 0) { if (bioMemSz <= 0) {
WOLFSSL_MSG("wolfSSL_BIO_pending failure"); WOLFSSL_MSG("wolfSSL_BIO_pending() failure");
return NULL; return NULL;
} }
@@ -31262,10 +31264,10 @@ WOLFSSL_RSA* wolfSSL_d2i_RSAPrivateKey_bio(WOLFSSL_BIO *bio, WOLFSSL_RSA **out)
return NULL; return NULL;
} }
//This function is used to get the total length of the rsa key. /* This function is used to get the total length of the rsa key. */
derLength = wolfSSL_i2d_RSAPrivateKey(key, &bufPtr); derLength = wolfSSL_i2d_RSAPrivateKey(key, &bufPtr);
//Write extra data back into bio object if necessary. /* Write extra data back into bio object if necessary. */
extraBioMemSz = (bioMemSz - derLength); extraBioMemSz = (bioMemSz - derLength);
if (extraBioMemSz > 0) { if (extraBioMemSz > 0) {
extraBioMem = XMALLOC(extraBioMemSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); extraBioMem = XMALLOC(extraBioMemSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
@@ -31273,7 +31275,8 @@ WOLFSSL_RSA* wolfSSL_d2i_RSAPrivateKey_bio(WOLFSSL_BIO *bio, WOLFSSL_RSA **out)
WOLFSSL_MSG("Malloc failure");; WOLFSSL_MSG("Malloc failure");;
XFREE((unsigned char*)extraBioMem, bio->heap, XFREE((unsigned char*)extraBioMem, bio->heap,
DYNAMIC_TYPE_TMP_BUFFER); DYNAMIC_TYPE_TMP_BUFFER);
XFREE((unsigned char*)bioMem, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE((unsigned char*)bioMem, bio->heap,
DYNAMIC_TYPE_TMP_BUFFER);
return NULL; return NULL;
} }
@@ -31282,12 +31285,13 @@ WOLFSSL_RSA* wolfSSL_d2i_RSAPrivateKey_bio(WOLFSSL_BIO *bio, WOLFSSL_RSA **out)
j++; j++;
} }
BIO_write(bio, extraBioMem, extraBioMemSz); wolfSSL_BIO_write(bio, extraBioMem, extraBioMemSz);
if (wolfSSL_BIO_pending(bio) <= 0) { if (wolfSSL_BIO_pending(bio) <= 0) {
WOLFSSL_MSG("Failed to write memory to bio"); WOLFSSL_MSG("Failed to write memory to bio");
XFREE((unsigned char*)extraBioMem, bio->heap, XFREE((unsigned char*)extraBioMem, bio->heap,
DYNAMIC_TYPE_TMP_BUFFER); DYNAMIC_TYPE_TMP_BUFFER);
XFREE((unsigned char*)bioMem, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE((unsigned char*)bioMem, bio->heap,
DYNAMIC_TYPE_TMP_BUFFER);
return NULL; return NULL;
} }
XFREE((unsigned char*)extraBioMem, bio->heap, XFREE((unsigned char*)extraBioMem, bio->heap,
@@ -31309,12 +31313,14 @@ Returns WOLFSSL_SUCCESS if no error, returns WOLFSSL_FAILURE otherwise.*/
int wolfSSL_CTX_use_certificate_ASN1(WOLFSSL_CTX *ctx, int derSz, int wolfSSL_CTX_use_certificate_ASN1(WOLFSSL_CTX *ctx, int derSz,
const unsigned char *der) const unsigned char *der)
{ {
WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_ASN1"); WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_ASN1()");
if (der != NULL && ctx != NULL) { if (der != NULL && ctx != NULL) {
if (wolfSSL_CTX_use_certificate_buffer(ctx, der, derSz, if (wolfSSL_CTX_use_certificate_buffer(ctx, der, derSz,
WOLFSSL_FILETYPE_ASN1) == WOLFSSL_SUCCESS) WOLFSSL_FILETYPE_ASN1) == WOLFSSL_SUCCESS) {
return WOLFSSL_SUCCESS; return WOLFSSL_SUCCESS;
} }
}
return WOLFSSL_FAILURE; return WOLFSSL_FAILURE;
} }
@@ -31329,7 +31335,7 @@ int wolfSSL_CTX_use_RSAPrivateKey(WOLFSSL_CTX* ctx, WOLFSSL_RSA* rsa)
unsigned char maxDerBuf[4096]; unsigned char maxDerBuf[4096];
unsigned char* key = NULL; unsigned char* key = NULL;
WOLFSSL_ENTER("wolfSSL_CTX_use_RSAPrivateKey"); WOLFSSL_ENTER("wolfSSL_CTX_use_RSAPrivateKey()");
if (ctx == NULL || rsa == NULL) { if (ctx == NULL || rsa == NULL) {
WOLFSSL_MSG("one or more inputs were NULL"); WOLFSSL_MSG("one or more inputs were NULL");
@@ -31338,13 +31344,13 @@ int wolfSSL_CTX_use_RSAPrivateKey(WOLFSSL_CTX* ctx, WOLFSSL_RSA* rsa)
key = maxDerBuf; key = maxDerBuf;
/* convert RSA struct to der encoded buffer and get the size */ /* convert RSA struct to der encoded buffer and get the size */
if ((derSize = wolfSSL_i2d_RSAPrivateKey(rsa, &key)) <= 0) { if ((derSize = wolfSSL_i2d_RSAPrivateKey(rsa, &key)) <= 0) {
WOLFSSL_MSG("wolfSSL_i2d_RSAPrivateKey failed"); WOLFSSL_MSG("wolfSSL_i2d_RSAPrivateKey() failure");
return WOLFSSL_FAILURE; return WOLFSSL_FAILURE;
} }
ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, (const unsigned char*)maxDerBuf, ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, (const unsigned char*)maxDerBuf,
derSize, SSL_FILETYPE_ASN1); derSize, SSL_FILETYPE_ASN1);
if (ret != WOLFSSL_SUCCESS) { if (ret != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("CTX_USE_PrivateKey_buffer() failure"); WOLFSSL_MSG("wolfSSL_CTX_USE_PrivateKey_buffer() failure");
return WOLFSSL_FAILURE; return WOLFSSL_FAILURE;
} }
return ret; return ret;
@@ -31375,7 +31381,7 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey_bio(WOLFSSL_BIO* bio,
memSz = wolfSSL_BIO_pending(bio); memSz = wolfSSL_BIO_pending(bio);
if (memSz <= 0) { if (memSz <= 0) {
WOLFSSL_MSG("wolfSSL_BIO_pending failure"); WOLFSSL_MSG("wolfSSL_BIO_pending() failure");
return NULL; return NULL;
} }
@@ -31388,12 +31394,12 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey_bio(WOLFSSL_BIO* bio,
if (wolfSSL_BIO_read(bio, (unsigned char*)mem, memSz) == memSz) { if (wolfSSL_BIO_read(bio, (unsigned char*)mem, memSz) == memSz) {
/* Determines key type and returns the new private EVP_PKEY object */ /* Determines key type and returns the new private EVP_PKEY object */
if ((key = wolfSSL_d2i_PrivateKey_EVP(NULL, &mem, (long)memSz)) == NULL) { if ((key = wolfSSL_d2i_PrivateKey_EVP(NULL, &mem, (long)memSz)) == NULL) {
WOLFSSL_MSG("d2i_PrivateKey_EVP() failure"); WOLFSSL_MSG("wolfSSL_d2i_PrivateKey_EVP() failure");
XFREE(mem, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); XFREE(mem, bio->heap, DYNAMIC_TYPE_TMP_BUFFER);
return NULL; return NULL;
} }
//Write extra data back into bio object if necessary. /* Write extra data back into bio object if necessary. */
derLength = key->pkey_sz; derLength = key->pkey_sz;
extraBioMemSz = (memSz - derLength); extraBioMemSz = (memSz - derLength);
if (extraBioMemSz > 0) { if (extraBioMemSz > 0) {
@@ -31411,7 +31417,7 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey_bio(WOLFSSL_BIO* bio,
j++; j++;
} }
BIO_write(bio, extraBioMem, extraBioMemSz); wolfSSL_BIO_write(bio, extraBioMem, extraBioMemSz);
if (wolfSSL_BIO_pending(bio) <= 0) { if (wolfSSL_BIO_pending(bio) <= 0) {
WOLFSSL_MSG("Failed to write memory to bio"); WOLFSSL_MSG("Failed to write memory to bio");
XFREE((unsigned char*)extraBioMem, bio->heap, XFREE((unsigned char*)extraBioMem, bio->heap,
@@ -31442,7 +31448,7 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey_EVP(WOLFSSL_EVP_PKEY** out,
const unsigned char* mem; const unsigned char* mem;
long memSz = inSz; long memSz = inSz;
WOLFSSL_ENTER("wolfSSL_d2i_PrivateKey_EVP"); WOLFSSL_ENTER("wolfSSL_d2i_PrivateKey_EVP()");
if (in == NULL || inSz < 0) { if (in == NULL || inSz < 0) {
WOLFSSL_MSG("Bad argument"); WOLFSSL_MSG("Bad argument");