Merge branch 'master' of https://github.com/lchristina26/wolfssl into leah-master

This commit is contained in:
toddouska
2015-02-16 13:43:36 -08:00
6 changed files with 63 additions and 39 deletions

View File

@@ -6351,9 +6351,7 @@ static int DoAlert(WOLFSSL* ssl, byte* input, word32* inOutIdx, int* type,
WOLFSSL_MSG(" close notify");
ssl->options.closeNotify = 1;
}
if (!ssl->options.sentNotify) {
WOLFSSL_ERROR(*type);
}
WOLFSSL_ERROR(*type);
if (ssl->keys.encryptionOn) {
if (*inOutIdx + ssl->keys.padSz > totalSz)
return BUFFER_E;
@@ -7751,9 +7749,7 @@ startScr:
while (ssl->buffers.clearOutputBuffer.length == 0) {
if ( (ssl->error = ProcessReply(ssl)) < 0) {
if (!ssl->options.sentNotify) {
WOLFSSL_ERROR(ssl->error);
}
WOLFSSL_ERROR(ssl->error);
if (ssl->error == ZERO_RETURN) {
WOLFSSL_MSG("Zero return, no more data coming");
return 0; /* no more data coming */

View File

@@ -917,6 +917,7 @@ int wolfSSL_recv(WOLFSSL* ssl, void* data, int sz, int flags)
/* SSL_SUCCESS on ok */
int wolfSSL_shutdown(WOLFSSL* ssl)
{
byte tmp;
WOLFSSL_ENTER("SSL_shutdown()");
if (ssl == NULL)
@@ -937,23 +938,26 @@ int wolfSSL_shutdown(WOLFSSL* ssl)
}
ssl->options.sentNotify = 1; /* don't send close_notify twice */
WOLFSSL_LEAVE("SSL_shutdown()", ssl->error);
return 0;
if (ssl->options.closeNotify)
return 1;
else
return 0;
}
/* call wolfSSL_shutdown again for bidirectional shudown */
if (ssl->options.sentNotify && !ssl->options.closeNotify) {
ssl->error = ReceiveData(ssl, 0, 0, 0);
ssl->error = wolfSSL_read(ssl, &tmp, 0);
if (ssl->error < 0) {
WOLFSSL_ERROR(ssl->error);
return SSL_FATAL_ERROR;
}
WOLFSSL_LEAVE("SSL_shutdown()", ssl->error);
ssl->error = SSL_ERROR_SYSCALL; /* simulate OpenSSL behavior */
if(ssl->options.closeNotify)
return SSL_SUCCESS;
}
WOLFSSL_LEAVE("SSL_shutdown()", ssl->error);
ssl->error = SSL_ERROR_SYSCALL; /* simulate OpenSSL behavior */
return SSL_SUCCESS;
return SSL_FATAL_ERROR;
}

View File

@@ -3887,10 +3887,4 @@ static int AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in,
#endif /* HAVE_FIPS */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* NO_AES */

View File

@@ -3179,30 +3179,49 @@ int rsa_test(void)
wc_RsaInitCavium(&key, CAVIUM_DEV_ID);
#endif
ret = wc_InitRsaKey(&key, 0);
if (ret != 0) return -39;
if (ret != 0) {
free(tmp);
return -39;
}
ret = wc_RsaPrivateKeyDecode(tmp, &idx, &key, (word32)bytes);
if (ret != 0) return -41;
if (ret != 0) {
free(tmp);
return -41;
}
ret = wc_InitRng(&rng);
if (ret != 0) return -42;
if (ret != 0) {
free(tmp);
return -42;
}
ret = wc_RsaPublicEncrypt(in, inLen, out, sizeof(out), &key, &rng);
if (ret < 0) return -43;
if (ret < 0) {
free(tmp);
return -43;
}
ret = wc_RsaPrivateDecrypt(out, ret, plain, sizeof(plain), &key);
if (ret < 0) return -44;
if (memcmp(plain, in, inLen)) return -45;
if (ret < 0) {
free(tmp);
return -44;
}
if (memcmp(plain, in, inLen)) {
free(tmp);
return -45;
}
ret = wc_RsaSSL_Sign(in, inLen, out, sizeof(out), &key, &rng);
if (ret < 0) return -46;
if (ret < 0) {
free(tmp);
return -46;
}
memset(plain, 0, sizeof(plain));
ret = wc_RsaSSL_Verify(out, ret, plain, sizeof(plain), &key);
if (ret < 0) return -47;
if (memcmp(plain, in, ret)) return -48;
if (ret < 0) {
free(tmp);
return -47;
}
if (memcmp(plain, in, ret)) {
free(tmp);
return -48;
}
#if defined(WOLFSSL_MDK_ARM)
#define sizeof(s) strlen((char *)(s))
#endif
@@ -3215,8 +3234,10 @@ int rsa_test(void)
bytes = sizeof_client_cert_der_2048;
#else
file2 = fopen(clientCert, "rb");
if (!file2)
if (!file2) {
free(tmp);
return -49;
}
bytes = fread(tmp, 1, FOURK_BUF, file2);
fclose(file2);

View File

@@ -1800,7 +1800,7 @@ static INLINE const char* mymktemp(char *tempfn, int len, int num)
static const char alphanum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
RNG rng;
int out;
byte out;
if (tempfn == NULL || len < 1 || num < 1 || len <= num) {
printf("Bad input\n");

View File

@@ -28,6 +28,10 @@
#include <stdlib.h>
#include <wolfssl/wolfcrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void *(*wolfSSL_Malloc_cb)(size_t size);
typedef void (*wolfSSL_Free_cb)(void *ptr);
typedef void *(*wolfSSL_Realloc_cb)(void *ptr, size_t size);
@@ -43,5 +47,10 @@ WOLFSSL_API void* wolfSSL_Malloc(size_t size);
WOLFSSL_API void wolfSSL_Free(void *ptr);
WOLFSSL_API void* wolfSSL_Realloc(void *ptr, size_t size);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* WOLFSSL_MEMORY_H */