PKI/HSM

[PKCS#11] CK_SESSION_INFO ๊ตฌ์กฐ์ฒด ์„ค๋ช…

JayKim๐Ÿ™‚ 2024. 1. 4. 15:34

PKCS#11 API ๋ฅผ ์‚ฌ์šฉ์—์„œ ํ˜„์žฌ ์—ฐ๊ฒฐ ์ƒํƒœ ์ •๋ณด๋ฅผ ํ™•์ธ ํ•˜๊ธฐ ์œ„ํ•œ ๊ตฌ์กฐ์ฒด๊ฐ€ ์žˆ๋‹ค.
์ฆ‰ ํ˜„์žฌ ์„ธ์…˜์— ๋Œ€ํ•œ ๊ตฌ์กฐ์ฒด ์ •๋ณด๋ฅผ ํ™•์ธ ํ•˜๊ธฐ ์œ„ํ•œ ๊ตฌ์กฐ์ฒด๊ฐ€ CK_SESSION_INFO ๊ตฌ์กฐ์ฒด ์ด๋‹ค.

CK_SESSION_INFO ์ •์˜

typedef struct CK_SESSION_INFO {
 CK_SLOT_ID slotID;
 CK_STATE state;
 CK_FLAGS flags;
 CK_ULONG ulDeviceError;
} CK_SESSION_INFO;

์ด ์ •๋ณด๋ฅผ ์–ป๊ธฐ ์œ„ํ•œ API ๊ฐ€ C_GetSessionInfo ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•œ๋‹ค.
๊ฐ๊ฐ์˜ ๊ตฌ์กฐ์ฒด ์ •๋ณด์˜ ์ •์˜๋ฅผ ๋ณด๋ฉด

  • slotID : ํ† ์ปจ ์ธํ„ฐํŽ˜์ด์Šค ์Šฌ๋กฏ์˜ ID
  • state : ์„ธ์…˜์— ๋Œ€ํ•œ ์ƒํƒœ
  • flags : ๋น„ํŠธ ํ”Œ๋ž˜๊ทธ๋กœ CKF_RW_SESSION ๊ณผ CKF_SERIAL_SESSION ์—ฌ๋ถ€๋ฅผ ๋‚˜ํƒ€๋‚ด๋‹ค.
    ( ์ฆ‰ ์ฝ๊ธฐ ์ „์šฉ ๋˜๋Š” ์ฝ๊ณ  ์“ฐ๊ธฐ ์„ธ์…˜์„ ๋น„ํŠธ ํ”Œ๋ž˜๊ทธ ์ •๋ณด )
  • ulDeviceError : ์žฅ์น˜์—์„œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ์‹œ ์—๋Ÿฌ ์ •๋ณด๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค

์ฐธ๊ณ ๋กœ flags ๋Š” ๋น„ํŠธ ์…‹ํŒ…์ด๋กœ ์ค‘๋ณต ์ƒํƒœ๋ฅผ ๋‚˜ํƒ€์ง€๋งŒ state ๋Š” ๋‹จ์ผ ์ƒํƒœ๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค.

state ๊ฐ’์˜ ์ข…๋ฅ˜

#define CKS_RO_PUBLIC_SESSION   0UL
#define CKS_RO_USER_FUNCTIONS   1UL
#define CKS_RW_PUBLIC_SESSION   2UL
#define CKS_RW_USER_FUNCTIONS   3UL
#define CKS_RW_SO_FUNCTIONS     4UL

์ด๋ ‡๊ฒŒ 4๊ฐ€์ง€ ์ƒํƒœ ๊ฐ’์ด ์กด์žฌํ•œ๋‹ค.

  • CKS_RO_PUBLIC_SESSION : C_OpenSession ์—์„œ CKF_SERIAL_SESSON ํ”Œ๋ž˜๊ทธ๋กœ ์—ฐ ์ƒํƒœ
  • CKS_RW_PUBLIC_SESSION : C_OpenSession ์—์„œ CKF_SERIAL_SESSION | CKF_RW_SESSION ํ”Œ๋ž˜๊ทธ๋กœ ์—ฐ ์ƒํƒœ
  • CKS_RO_USER_FUNCTIONS : CKS_RO_PUBLIC_SESSION ์œผ๋กœ ์—ฐ๊ฒฐ๋œ ์„ธ์…˜์— C_Login ์„ User ํƒ€์ž…์œผ๋กœ ํ•œ ์ƒํƒœ
  • CKS_RW_USER_FUNCTIONS : CKS_RW_PUBLIC_SESSION ์œผ๋กœ ์—ฐ๊ฒฐ๋œ ์„ธ์…˜์— C_Login ์„ User ํƒ€์ž…์œผ๋กœ ํ•œ ์ƒํƒœ
  • CKS_RW_SO_FUNCTIONS : CKS_RW_PUBLIC_SESSION ์œผ๋กœ ์—ฐ๊ฒฐ ๋œ ์„ธ์…˜์— C_Login ์„ SO ํƒ€์ž…์œผ๋กœ ํ•œ ์ƒํƒœ

์ฐธ๊ณ ) CKF_SERIAL_SESSION ์€ C_OpenSession ์—์„œ ๋””ํดํŠธ๋กœ ์„ค์ •์ด ๋˜์–ด์•ผ ํ•œ๋‹ค.
์ฆ‰ CKF_RW_SESSION ๋‹จ๋…์œผ๋กœ๋Š” ์“ธ ์ˆ˜ ์—†๋‹ค.
CKS_RW_SO_FUNCTIONS ๋Š” CKS_RO_PUBLIC_SESSION ์—์„œ๋Š” ์‚ฌ์šฉ ํ•  ์ˆ˜ ์—†๋‹ค.
์ฆ‰ SO ๊ฒฝ์šฐ๋Š” ์ฝ๊ธฐ ์ „์šฉ์€ ์‚ฌ์šฉ ํ•˜์ง€ ์•Š๋Š”๋‹ค.

CK_SESSION_INFO ํŠน์„ฑ

์ด ๊ตฌ์กฐ์ฒด์—์„œ flags ์˜ ์ •๋ณด๋Š” C_OpenSession ์œผ๋กœ ์„ค์ • ํ•˜๊ณ  C_CloseSession ์œผ๋กœ ๊ฐ’์„ ์ง€์šฐ๊ฒŒ ๋œ๋‹ค.
๊ทธ๋ฆฌ๊ณ  state ์ •๋ณด๋Š” C_OpenSession ๊ณผ C_Login ์„ ํ†ตํ•˜์—ฌ ๋งŒ๋“ค์–ด์ง„ ๊ฐ’์ด๊ตฌ
๊ฐ’์˜ ์ƒํƒœ ์ œ๊ฑฐ๋Š” C_Logout ๊ณผ C_CloseSession ์œผ๋กœ ์ด๋ฃจ์–ด ์ง„๋‹ค.

๋งˆ๋ฌด๋ฆฌ

CK_SESSION_INFO ๋Š” ์‚ฌ์‹ค HSM ์žฅ์น˜์˜ ์ธ์ฆ ์ƒํƒœ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค.
์ด ๊ตฌ์กฐ์ฒด์˜ ์ •๋ณด๋ฅผ ํ™•์ธ ํ•˜์—ฌ ํ˜„์žฌ ์žฅ์น˜ ์—ฐ๊ฒฐ ์ƒํƒœ ์ •๋ณด๋ฅผ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.