SEP Profile

1. Add session cache index to CYASSL structure.
2. Add accessor for cache index in CYASSL structure.
3. Add copy function for session cache item.
This commit is contained in:
John Safranek 2013-07-28 17:11:22 -07:00
parent 505b1a8a67
commit 1357cdb0e4
3 changed files with 42 additions and 0 deletions

View File

@ -1823,6 +1823,9 @@ struct CYASSL {
#endif
#ifdef HAVE_NETX
NetX_Ctx nxCtx; /* NetX IO Context */
#endif
#ifdef SESSION_INDEX
int sessionIndex; /* Session's location in the cache. */
#endif
CYASSL_ALERT_HISTORY alert_history;
};

View File

@ -247,6 +247,11 @@ CYASSL_API void CyaSSL_flush_sessions(CYASSL_CTX *ctx, long tm);
CYASSL_API int CyaSSL_SetServerID(CYASSL* ssl, const unsigned char*,
int, int);
#ifdef SESSION_INDEX
CYASSL_API int CyaSSL_GetSessionIndex(CYASSL* ssl);
CYASSL_API int CyaSSL_GetSessionAtIndex(int index, CYASSL_SESSION* session);
#endif
typedef int (*VerifyCallback)(int, CYASSL_X509_STORE_CTX*);
typedef int (*pem_password_cb)(char*, int, int, void*);

View File

@ -4532,6 +4532,9 @@ int AddSession(CYASSL* ssl)
return BAD_MUTEX_ERROR;
idx = SessionCache[row].nextIdx++;
#ifdef SESSION_INDEX
ssl->sessionIndex = (row << 4) | idx;
#endif
XMEMCPY(SessionCache[row].Sessions[idx].masterSecret,
ssl->arrays->masterSecret, SECRET_LEN);
@ -4587,6 +4590,37 @@ int AddSession(CYASSL* ssl)
}
#ifdef SESSION_INDEX
int CyaSSL_GetSessionIndex(CYASSL* ssl)
{
return ssl->sessionIndex;
}
int CyaSSL_GetSessionAtIndex(int index, CYASSL_SESSION* session)
{
int row, col, result = SSL_FAILURE;
row = index >> 4;
col = index & 0x0F;
if (LockMutex(&session_mutex) != 0)
return BAD_MUTEX_ERROR;
if (row < SESSION_ROWS && col < SessionCache[row].totalCount) {
XMEMCPY(session,
&SessionCache[row].Sessions[col], sizeof(CYASSL_SESSION));
result = SSL_SUCCESS;
}
if (UnLockMutex(&session_mutex) != 0)
return BAD_MUTEX_ERROR;
return result;
}
#endif
#ifdef SESSION_STATS
CYASSL_API