๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ–ฅ๏ธ Linux

OpenSSL docs ์ •๋ฆฌ (์—…๋ฐ์ดํŠธ ์˜ˆ์ •)

OPENSSL_malloc

- ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น, ONENSSL_free์™€ ๊ฐ™์ด ์‚ฌ์šฉ

 

 

CRYPTO_num_locks

- ์ตœ๋Œ€ ์ฒ˜๋ฆฌ๊ฐ€๋Šฅํ•œ mutex ๊ฐœ์ˆ˜

- mutex ๊ด€๋ จํ•˜์—ฌ int ํ˜• ์ƒ์ˆ˜๋ฅผ ๋ฐ˜ํ™˜, ์ด๋งŒํผ์„ ์ฒ˜๋ฆฌ ํ•  ์ˆ˜ ์žˆ์–ด์•ผํ•จ

- OpenSSL-1.0.1j ๊ธฐ์ค€์œผ๋กœ 41์ž„

- openssl/crypto/lock.c ์†Œ์Šค์—์„œ ํ™•์ธ ๊ฐ€๋Šฅ

- ๋‹ค์ค‘ ์Šค๋ ˆ๋“œ๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ์ถฉ๋Œ ํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ lock ์‚ฌ์šฉ

 

 

CRYPTO_THREADID_set_callback

- ์ฃผ์–ด์ง„ lock type๊ณผ ์ž ๊ธˆ ํ•ด์ œ ์—ฌ๋ถ€(mode)๋กœ ํ•ด๋‹น lock๋ฅผ ๊ด€๋ฆฌํ•ด์คŒ

- ํ˜„์žฌ ์‹คํ–‰ ์ค‘์ธ ์Šค๋ ˆ๋“œ์˜ tid ๋ณ„๋กœ ๋“ฑ๋กํ•ด์„œ ๊ด€๋ฆฌ ํ•จ

→ CRYPTO_THREADID_set_numeric์„ ์‚ฌ์šฉํ•œ ์ฝœ๋ฐฑ์„ ๋“ฑ๋ก

- ์ฝœ๋ฐฑ ๋“ฑ๋ก ํ•˜์ง€ ์•Š์œผ๋ฉด ๊ธฐ๋ณธ ๊ตฌํ˜„์œผ๋กœ ์‚ฌ์šฉ๋จ

 

 

CRYPTO_THREADID_set_numeric

- ์ฝœ๋ฐฑ ๋“ฑ๋กํ•  ๋•Œ ์‚ฌ์šฉ

- thread id์™€ pthread_self() ๋‘๊ฐœ๋ฅผ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ๋„ฃ์–ด์คŒ

 

 

CRYPTO_set_locking_callback

- ๋ชจ๋“  SSL ๋ฒ„์ „์—์„œ ์‚ฌ์šฉ๊ฐ€๋Šฅ

- mode & CRYPTO_LOCK ์ด๋ฉด n ๋ฒˆ์งธ ์ž ๊ธˆ์„ ์„ค์ •

 

 

OpenSSL_add_all_algorithms

- OpenSSL์€ ์—ฌ๋Ÿฌ ์•”ํ˜ธํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์“ฐ๋Š”๋ฐ, all์ด๋ฉด ๋‹ค ์“ฐ๊ฒ ๋‹ค๋Š” ๋œป

- ๊ทธ๋ฐ–์— _all_digests/_all_ciphers ๋“ฑ๋“ฑ์ด ์žˆ์Œ

 

 

SSL_load_error_strings

- libcrypto์™€ libssl์— ๋Œ€ํ•œ ์—๋Ÿฌ ๋ฌธ์ž์—ด์„ ๋“ฑ๋ก ํ•จ

- error:[error code]:[library name]:[function name]:[reason string]

 

 

SSL_library_init

- ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ SSL/TLS ์•”ํ˜ธ ๋ฐ Digest๋ฅผ ๋“ฑ๋ก

- ์ดˆ๊ธฐํ™” ํ•  ๋•Œ ์‹œ์ž‘ํ•˜๋ฉด ๋จ

- ๋ณดํ†ต ์‚ฌ์šฉ์‹œ์— SSL_load_error_strings๋ž‘ ๊ฐ™์ด ๋งŽ์ด ์‚ฌ์šฉ ํ•จ

- ํ•ญ์ƒ "1"์„ ๋ฐ˜ํ™˜ํ•˜๋‹ˆ๊นŒ ๋ฐ˜ํ™˜ ๊ฐ’ ๋ฒ„๋ ค๋„ ๋จ

 

SSL_CTX_new

- TLS/SSL ๋˜๋Š” DTLS ์‚ฌ์šฉ ์—ฐ๊ฒฐ์„ ์„ค์ •ํ•˜๊ธฐ ์œ„ํ•œ ํ”„๋ ˆ์ž„์›Œํฌ๋กœ ์ƒˆ SSL_CTX ๊ฐœ์ฒด๋ฅผ ์ƒ์„ฑ

 

SSL_new

- SSL_CTX_new๋กœ ์ƒ์„ฑํ•œ context ๊ฐ์ฒด๋ฅผ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ์„ค์ •

- TLS/SSL connection์„ ์œ„ํ•œ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•จ

- SSL_CTX_new → SSL_new → SSL_connect ์ˆœ

 

SSL_set_fd(ssl ๊ฐ์ฒด, fd)

- ํŒŒ์ผ ์„ค๋ช…์ž fd๋ฅผ TLS/SSL(์•”ํ˜ธํ™”)๋ฅผ ํ•˜๊ธฐ ์œ„ํ•œ ์ž…๋ ฅ/์ถœ๋ ฅ ๊ธฐ๋Šฅ์œผ๋กœ ์„ค์ •

 

SSL_connect

- ์„œ๋ฒ„์™€์˜ TLS/SSL ํ•ธ๋“œ์…ฐ์ดํฌ๋ฅผ ์‹œ์ž‘ํ•จ
- ๊ธฐ๋ณธ BIO ๋ฅผ ์„ค์ •ํ•˜์—ฌ ํ†ต์‹  ์ฑ„๋„์ด ์ด๋ฏธ ์„ค์ •๋˜๊ณ  SSL ์— ํ• ๋‹น๋˜์–ด ์žˆ์–ด์•ผ ํ•จ

 

SSL_get_peer_certificate

- ํ”ผ์–ด๊ฐ€ ์ œ์‹œํ•œ X509 ์ธ์ฆ์„œ์— ๋Œ€ํ•œ ํฌ์ธํ„ฐ๋ฅผ ๋ฐ˜ํ™˜

- ์—†์œผ๋ฉด NULL 

 


์ฐธ๊ณ ์ž๋ฃŒ

 

http://blog.purewell.biz/2014/11/openssl-supports-multi-threading.html

 

OpenSSL supports Multi-threading

Purewell's personal blog

blog.purewell.biz