Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit number of sessions #710

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ AC_DEFINE_UNQUOTED(
[4],
[Minimum PIN length]
)
AC_DEFINE_UNQUOTED(
[MAX_SESSION_COUNT],
[16],
[Maximum session count]
)
AC_DEFINE_UNQUOTED(
[DEFAULT_SOFTHSM2_CONF],
["$default_softhsm2_conf"],
Expand Down
4 changes: 2 additions & 2 deletions src/lib/session_mgr/SessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "SessionManager.h"
#include "log.h"
#include "config.h"

// Constructor
SessionManager::SessionManager()
Expand Down Expand Up @@ -82,8 +83,7 @@ CK_RV SessionManager::openSession
// Can not open a Read-Only session when in SO mode
if ((flags & CKF_RW_SESSION) == 0 && token->isSOLoggedIn()) return CKR_SESSION_READ_WRITE_SO_EXISTS;

// TODO: Do we want to check for maximum number of sessions?
// return CKR_SESSION_COUNT
if (sessions.size() == MAX_SESSION_COUNT) return CKR_SESSION_COUNT;

// Create the session
bool rwSession = ((flags & CKF_RW_SESSION) == CKF_RW_SESSION) ? true : false;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/slot_mgr/Token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ CK_RV Token::getTokenInfo(CK_TOKEN_INFO_PTR info)
info->ulRwSessionCount = CK_UNAVAILABLE_INFORMATION;

info->ulMaxRwSessionCount = CK_EFFECTIVELY_INFINITE;
info->ulMaxSessionCount = CK_EFFECTIVELY_INFINITE;
info->ulMaxSessionCount = MAX_SESSION_COUNT;
info->ulMaxPinLen = MAX_PIN_LEN;
info->ulMinPinLen = MIN_PIN_LEN;
info->ulTotalPublicMemory = CK_UNAVAILABLE_INFORMATION;
Expand Down