Lines Matching refs:session

53 static void close_ck_session(struct pkcs11_session *session);
71 struct handle_db *get_object_handle_db(struct pkcs11_session *session) in get_object_handle_db() argument
73 return &session->client->object_handle_db; in get_object_handle_db()
76 struct session_list *get_session_list(struct pkcs11_session *session) in get_session_list() argument
78 return &session->client->session_list; in get_session_list()
116 struct pkcs11_session *session = NULL; in unregister_client() local
124 TAILQ_FOREACH_SAFE(session, &client->session_list, link, next) in unregister_client()
125 close_ck_session(session); in unregister_client()
175 enum pkcs11_rc set_processing_state(struct pkcs11_session *session, in set_processing_state() argument
183 if (session->processing) in set_processing_state()
229 session->processing = proc; in set_processing_state()
536 struct pkcs11_session *session, bool readonly) in set_session_state() argument
552 assert(sess != session); in set_session_state()
554 if (sess->token == session->token) { in set_session_state()
583 session->state = state; in set_session_state()
600 struct pkcs11_session *session = NULL; in entry_ck_open_session() local
604 out->memref.size != sizeof(session->handle)) in entry_ck_open_session()
638 TAILQ_FOREACH(session, &client->session_list, link) in entry_ck_open_session()
639 if (pkcs11_session_is_so(session)) in entry_ck_open_session()
643 session = TEE_Malloc(sizeof(*session), TEE_MALLOC_FILL_ZERO); in entry_ck_open_session()
644 if (!session) in entry_ck_open_session()
647 session->handle = handle_get(&client->session_handle_db, session); in entry_ck_open_session()
648 if (!session->handle) { in entry_ck_open_session()
649 TEE_Free(session); in entry_ck_open_session()
653 session->token = token; in entry_ck_open_session()
654 session->client = client; in entry_ck_open_session()
656 LIST_INIT(&session->object_list); in entry_ck_open_session()
658 set_session_state(client, session, readonly); in entry_ck_open_session()
660 TAILQ_INSERT_HEAD(&client->session_list, session, link); in entry_ck_open_session()
662 session->token->session_count++; in entry_ck_open_session()
664 session->token->rw_session_count++; in entry_ck_open_session()
666 TEE_MemMove(out->memref.buffer, &session->handle, in entry_ck_open_session()
667 sizeof(session->handle)); in entry_ck_open_session()
669 DMSG("Open PKCS11 session %"PRIu32, session->handle); in entry_ck_open_session()
674 static void close_ck_session(struct pkcs11_session *session) in close_ck_session() argument
676 release_active_processing(session); in close_ck_session()
677 release_session_find_obj_context(session); in close_ck_session()
680 while (!LIST_EMPTY(&session->object_list)) in close_ck_session()
681 destroy_object(session, in close_ck_session()
682 LIST_FIRST(&session->object_list), true); in close_ck_session()
684 TAILQ_REMOVE(&session->client->session_list, session, link); in close_ck_session()
685 handle_put(&session->client->session_handle_db, session->handle); in close_ck_session()
687 session->token->session_count--; in close_ck_session()
688 if (pkcs11_session_is_read_write(session)) in close_ck_session()
689 session->token->rw_session_count--; in close_ck_session()
691 TEE_Free(session); in close_ck_session()
693 DMSG("Close PKCS11 session %"PRIu32, session->handle); in close_ck_session()
706 struct pkcs11_session *session = NULL; in entry_ck_close_session() local
713 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_ck_close_session()
720 close_ck_session(session); in entry_ck_close_session()
737 struct pkcs11_session *session = NULL; in entry_ck_close_all_sessions() local
758 TAILQ_FOREACH_SAFE(session, &client->session_list, link, next) in entry_ck_close_all_sessions()
759 if (session->token == token) in entry_ck_close_all_sessions()
760 close_ck_session(session); in entry_ck_close_all_sessions()
776 struct pkcs11_session *session = NULL; in entry_ck_session_info() local
786 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_ck_session_info()
793 info.slot_id = get_token_id(session->token); in entry_ck_session_info()
794 info.state = session->state; in entry_ck_session_info()
795 if (pkcs11_session_is_read_write(session)) in entry_ck_session_info()
800 DMSG("Get find on PKCS11 session %"PRIu32, session->handle); in entry_ck_session_info()
963 static enum pkcs11_rc set_pin(struct pkcs11_session *session, in set_pin() argument
967 struct ck_token *token = session->token; in set_pin()
975 if (!pkcs11_session_is_read_write(session)) in set_pin()
1038 struct pkcs11_session *session = NULL; in entry_ck_init_pin() local
1050 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_ck_init_pin()
1065 if (!pkcs11_session_is_so(session)) in entry_ck_init_pin()
1068 assert(session->token->db_main->flags & PKCS11_CKFT_TOKEN_INITIALIZED); in entry_ck_init_pin()
1070 IMSG("PKCS11 session %"PRIu32": init PIN", session->handle); in entry_ck_init_pin()
1072 return set_pin(session, pin, pin_size, PKCS11_CKU_USER); in entry_ck_init_pin()
1075 static enum pkcs11_rc check_so_pin(struct pkcs11_session *session, in check_so_pin() argument
1078 struct ck_token *token = session->token; in check_so_pin()
1133 static enum pkcs11_rc check_user_pin(struct pkcs11_session *session, in check_user_pin() argument
1136 struct ck_token *token = session->token; in check_user_pin()
1199 struct pkcs11_session *session = NULL; in entry_ck_set_pin() local
1213 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_ck_set_pin()
1236 if (!pkcs11_session_is_read_write(session)) in entry_ck_set_pin()
1239 if (pkcs11_session_is_so(session)) { in entry_ck_set_pin()
1240 if (!(session->token->db_main->flags & in entry_ck_set_pin()
1244 rc = check_so_pin(session, old_pin, old_pin_size); in entry_ck_set_pin()
1248 IMSG("PKCS11 session %"PRIu32": set PIN", session->handle); in entry_ck_set_pin()
1250 return set_pin(session, pin, pin_size, PKCS11_CKU_SO); in entry_ck_set_pin()
1253 if (!(session->token->db_main->flags & in entry_ck_set_pin()
1257 rc = check_user_pin(session, old_pin, old_pin_size); in entry_ck_set_pin()
1261 IMSG("PKCS11 session %"PRIu32": set PIN", session->handle); in entry_ck_set_pin()
1263 return set_pin(session, pin, pin_size, PKCS11_CKU_USER); in entry_ck_set_pin()
1266 static void session_login_user(struct pkcs11_session *session) in session_login_user() argument
1268 struct pkcs11_client *client = session->client; in session_login_user()
1272 if (sess->token != session->token) in session_login_user()
1282 static void session_login_so(struct pkcs11_session *session) in session_login_so() argument
1284 struct pkcs11_client *client = session->client; in session_login_so()
1288 if (sess->token != session->token) in session_login_so()
1298 static void session_logout(struct pkcs11_session *session) in session_logout() argument
1300 struct pkcs11_client *client = session->client; in session_logout()
1308 if (sess->token != session->token) in session_logout()
1311 release_active_processing(session); in session_logout()
1323 LIST_FOREACH(obj, &session->token->object_list, link) { in session_logout()
1324 handle = pkcs11_object2handle(obj, session); in session_logout()
1330 release_session_find_obj_context(session); in session_logout()
1346 struct pkcs11_session *session = NULL; in entry_ck_login() local
1360 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_ck_login()
1381 if (pkcs11_session_is_so(session)) in entry_ck_login()
1384 if (pkcs11_session_is_user(session)) in entry_ck_login()
1388 if (sess->token == session->token && in entry_ck_login()
1412 rc = check_so_pin(session, pin, pin_size); in entry_ck_login()
1414 session_login_so(session); in entry_ck_login()
1419 if (pkcs11_session_is_so(session)) in entry_ck_login()
1422 if (pkcs11_session_is_user(session)) in entry_ck_login()
1431 rc = check_user_pin(session, pin, pin_size); in entry_ck_login()
1433 session_login_user(session); in entry_ck_login()
1445 IMSG("PKCS11 session %"PRIu32": login", session->handle); in entry_ck_login()
1457 struct pkcs11_session *session = NULL; in entry_ck_logout() local
1467 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_ck_logout()
1474 if (pkcs11_session_is_public(session)) in entry_ck_logout()
1477 session_logout(session); in entry_ck_logout()
1479 IMSG("PKCS11 session %"PRIu32": logout", session->handle); in entry_ck_logout()
1527 struct pkcs11_session *session = NULL; in entry_ck_seed_random() local
1535 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_ck_seed_random()
1552 DMSG("PKCS11 session %"PRIu32": seed random", session->handle); in entry_ck_seed_random()
1568 struct pkcs11_session *session = NULL; in entry_ck_generate_random() local
1579 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_ck_generate_random()
1610 DMSG("PKCS11 session %"PRIu32": generate random", session->handle); in entry_ck_generate_random()