Manual/OpenSSL 20

[OpenSSL] ECDH ํ‚ค ์œ ๋„ (Derive Key) ๋ช…๋ น์–ด

OpenSSL ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ด ECDH ๊ณต์œ  ํ‚ค๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์ž ECDH ๊ฐ’์„ ์ƒ์„ฑ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋‘ ์Œ์˜ ECDSA ์šฉ ํ‚ค ์Œ์ด ํ•„์š”ํ•˜๋‹ค. ํ‚ค ์Œ์˜ ์ด๋ฆ„์„ alice ์™€ bob ์ด๋ผ๋Š” ์ด๋ฆ„ ์œผ๋กœ ๋งŒ๋“ค์–ด ๋ณด์ž ๊ทธ๋Ÿผ ECDH ๊ณต์œ  ํ‚ค๋ฅผ ๋งŒ๋“ ๋Š”๊ฒƒ์€ alice ์˜ ๊ฐœ์ธํ‚ค์™€ Bob์˜ ๊ณต์œ ํ‚ค๋ฅผ ์ด์šฉํ•ด์„œ ๋งŒ๋“ค๊ณ  ๋˜ bob์˜ ๊ฐœ์ธํ‚ค์™€ alice ์˜ ๊ณต์œ ํ‚ค๋ฅผ ๊ฐ€์ง€๊ณ  ๋งŒ๋“ค๊ฒŒ ๋˜๋Š”๋ฐ ์ด๋•Œ ์„œ๋กœ ๋งŒ๋“  ๊ณต์œ ํ‚ค ๊ฐ’์ด ๊ฐ™์€ ๊ฐ’์ด ๋‚˜์˜ค๊ฒŒ ๋˜๋Š” ๊ฒƒ์ด๋‹ค. Alice ECDSA ์šฉ ํ‚ค ์Œ ๋งŒ๋“ค๊ธฐ // ECDSA ์šฉ alice์˜ ๊ฐœ์ธํ‚ค ๋งŒ๋“ค๊ธฐ openssl genpkey -out alice.pem -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -pkeyopt ec_param_enc:named_curve..

Manual/OpenSSL 2024.04.03

[OpenSSL] DSA ํ‚ค ์Œ ๋งŒ๋“ค๊ธฐ

DSA ํ‚ค ์Œ์„ ๋งŒ๋“ค๊ธฐ๋ฅผ ํ•˜๋ ค๋ฉด ์šฐ์„  DSA ํŒŒ๋ผ๋ฏธํ„ฐ ์ƒ์„ฑ ํ›„ DSA ํ‚ค ์Œ์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. ๋จผ์ € DSA ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ƒ์„ฑ ํ•˜์ž openssl dsaparam -out dsaparam.pem 2048 ์ƒ์„ฑ ๋œ DSA ํŒŒ๋ผ๋ฏธํ„ฐ -----BEGIN DSA PARAMETERS----- MIICKQKCAQEAz3b/DxqaD6NWa0q23jg3SJ8B/IPycYm7YClyMEh7OIqUhr0cckxm +JosmcqD/S+vEHraQFCF05shdWVjDiY1eyxCo6S9NOgmkDsUTLHFI/5lw4Kf+cum dd4FkMljKmSDybymg1NOggwVMQjbJ4LYS+35nktjLwGIWxo06Jjzt20AYCWpRkJo JmLX1x2dtua1BFgdhhWinxlPNRNLVtLTcLtPgx16TuYP9N..

Manual/OpenSSL 2023.07.04

[OpenSSL] EdDSA ์•Œ๊ณ ๋ฆฌ์ฆ˜ Ed25519 Ed448 ํ‚ค ์ƒ์„ฑ

EdDSA ( Edwards-Curve Digital Signature Algorithm ) ์˜ ์•ฝ์ž๋กœ ECC ์ฒ˜๋Ÿผ ๋””์ง€ํ„ธ ์„œ๋ช…์šฉ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. ECDSA์— ๋น„ํ•˜๋ฉด ์—ฐ์‚ฐ ์†๋„๊ฐ€ ECDSA ๋ณด๋‹ค๋Š” ์กฐ๊ธˆ ๋น ๋ฅธ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค. ํ˜„์žฌ EdDSA ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ECDSA ๋ณด๋‹ค๋Š” ๋„๋ฆฌ ์‚ฌ์šฉ๋˜์ง€๋Š” ์•Š์ง€๋งŒ ์ ์  ๋Š˜์–ด๋‚˜๊ณ  ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค. EdDSA ์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๋Š” Curve ๊ฐ€ Ed25519 ์™€ Ed448 ์ด๋‹ค. ๊ทธ๋Ÿผ OpenSSL ๋ช…๋ น์–ด๋กœ ed25519์™€ ed448 ํ‚ค ์Œ์„ ๋งŒ๋“ค์–ด ๋ณด์ž. ed25519 ๊ฐœ์ธํ‚ค ์ƒ์„ฑ openssl genpkey -algorithm ed25519 -out private.pem ed25519 ๊ฐœ์ธํ‚ค ๊ฒฐ๊ณผ -----BEGIN PRIVATE KEY----- MC4CAQAwBQYDK2VwBCIEIJ..

Manual/OpenSSL 2023.06.14

[OpenSSL] ca ๋ช…๋ น์–ด

์ด ๋ช…๋ น์–ด๋Š” CA ํ”„๋กœ๊ทธ๋žจ ๊ธฐ๋Šฅ์„ ํ•˜๋Š” ๋ช…๋ น์–ด์ด๋‹ค. https://www.openssl.org/docs/man3.0/man1/openssl-ca.html ์ •๋ณด๋ฅผ ์ฐธ๊ณ  ํ•จ CA ๊ธฐ๋Šฅ์„ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์„ค์ • ํŒŒ์ผ์˜ ํ™˜๊ฒฝ์— ๋งž๋Š” ๋ฐ์ดํƒ€๊ฐ€ ์žˆ์–ด์•ผ ํ•œ๋‹ค. openssl.cnf ์„ค์ • #################################################################### [ ca ] default_ca = CA_default # The default ca section #################################################################### [ CA_default ] dir = ./demoCA # Where everything is ..

Manual/OpenSSL 2023.05.24

[OpenSSL] crl ๋ช…๋ น์–ด

์ด ๋ช…๋ น์–ด๋Š” CRL ํŒŒ์ผ์„ DER ๋˜๋Š” PEM ํ˜•์‹์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ ๋ช…๋ น์–ด ์ด๋‹ค https://www.openssl.org/docs/man3.0/man1/openssl-crl.html ์ฐธ์กฐ ํ•˜์˜€๋‹ค. PEM ํ˜•์‹์˜ CRL ํŒŒ์ผ์„ DER ๋กœ ๋ฐ”๊พธ๊ธฐ openssl crl -in crl.pem -outform DER -out crl.der CRL ํŒŒ์ผ ์ •๋ณด ๋ณด๊ธฐ openssl crl -in crl.der -text -noout CRL ํŒŒ์ผ ์ •๋ณด ๋ณด๊ธฐ ๊ฒฐ๊ณผ ertificate Revocation List (CRL): Version 2 (0x1) Signature Algorithm: sha256WithRSAEncryption Issuer: C = KR, ST = Korea, O = TEST, CN = CA Last ..

Manual/OpenSSL 2023.05.21

[OpenSSL] x509 ๋ช…๋ น์–ด

์ด๋ช…๋ น์–ด๋Š” ๋‹ค์–‘ํ•œ ๋ชฉ์ ์œผ๋กœ ์ธ์ฆ์„œ๋ฅผ ๋‹ค๋ฃจ๋Š” ๋ช…๋ น์–ด์ด๋‹ค. https://www.openssl.org/docs/man3.0/man1/openssl-x509.html ์ด ์„ค๋ช…์„œ๋ฅผ ์ฐธ์กฐ ํ•ด์„œ ๋งŒ๋“ค์—ˆ๋‹ค. PEM ํ˜•์‹์˜ ์ธ์ฆ์„œ ์ •๋ณด ๋ณด๊ธฐ ์ถœ๋ ฅ openssl x509 -text -noout -in test_cert.crtDER ํ˜•์‹์˜ ์ธ์ฆ์„œ ์ •๋ณด ๋ณด๊ธฐ ๊ฒฐ๊ณผ openssl x509 -inform der -noout -text -in test_cert.der๊ฒฐ๊ณผ ํ™”๋ฉด Certificate: Data: Version: 3 (0x2) Serial Number: 53:14:62:20:a1:a5:29:73 Signature Algorithm: ecdsa-with-SHA256 Issuer: C = KR, O = Ranix, OU..

Manual/OpenSSL 2023.05.20

[OpenSSL] pkeyutl ๋ช…๋ น์–ด

์ด ๋ช…๋ น์–ด๋Š” ๊ณต๊ฐœํ‚ค ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์‹คํ–‰ ๋ช…๋ น์–ด์ด๋‹ค. ์ด ๋ฌธ์„œ๋Š” https://www.openssl.org/docs/man3.0/man1/openssl-pkeyutl.html ์ฐธ์กฐ ํ•˜์—ฌ ๋งŒ๋“ค์—ˆ๋‹ค. ๊ฐœ์ธํ‚ค๋ฅผ ์ด์šฉ ์ „์ž ์„œ๋ช… ์ƒ์„ฑ ์ด๋•Œ ์ž…๋ ฅ ๊ฐ’์€ ํ•ด์‰ฌ ๊ฐ’์ด์–ด์•ผ ํ•œ๋‹ค( ์›๋ฌธ ์•„๋‹˜ ) openssl pkeyutl -sign in data.txt -inkey rsa_key.pem -out sig์ƒ์„ฑ๋œ sig ๊ฐ’์€ ์ „์ž ์„œ๋ช… ๋ฐ”์ด๋„ˆ๋ฆฌ ๊ฐ’์ด๋‹ค. (ASN.1 ๋””์ฝ”๋”ฉ ์•ˆ๋จ ) ์„œ๋ช… ๋ฐ์ดํƒ€ ๊ฒ€์ฆ ์ž…๋ ฅ๋œ ์„œ๋ช… ๊ฒ€์ฆ openssl pkeyutl -verify -in data.txt -sigfile sig -inkey rsa_key.pem ๋ณต๊ตฌ ์„œ๋ช… ๊ฒ€์ฆ ์ด ๊ธฐ๋Šฅ์€ ์„œ๋ช… ๊ฒ€์ฆํ•˜๊ณ  ์„œ๋ช…์— ์‚ฌ์šฉ๋œ ํ•ด์‰ฌ ๊ฐ’์„ ๋ณต๊ตฌ ํ•ด์ฃผ๋Š” ๋ช…๋ น์–ด ์ด๋‹ค. o..

Manual/OpenSSL 2023.05.19

[OpenSSL] asn1parse ๋ช…๋ น์–ด

OpenSSL ์—์„œ asn1 ์ธ์ฝ”๋”ฉ ๋””์ฝ”๋”ฉ ๋ช…๋ น์–ด ์‚ฌ์šฉ๋ฒ•์„ ์•Œ์•„ ๋ณด์ž ํ•ด๋‹น ๊ธฐ๋Šฅ์— ๋Œ€ํ•œ ๋ฌธ์„œ ํŽ˜์ด์ง€๋Š” ๋ฉ”๋‰ด์–ผ์„ ์ฐธ๊ณ  ํ•˜์—ฌ ๋งŒ๋“ค์—ˆ๋‹ค. asn1parse ๋ช…๋ น์–ด๋กœ ๊ฐ„๋‹จํžˆ ๋ฌธ์ž ์ธ์ฝ”๋”ฉ/๋””์ฝ”๋”ฉ์„ ํ• ์ˆ˜ ์žˆ๊ณ  ๋ณต์žกํ•œ ๋ฐ์ดํƒ€๋Š” ์„ค์ •์„ ์ด์šฉํ•ด ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ASN.1 PEM ํ˜•์‹ ํŒŒ์‹ฑ ํ•ด์„œ ๋ณด๊ธฐ openssl asn1parse -in file.pem ASN1 DER ํ˜•์‹ ํŒŒ์ผ ๋ณด๊ธฐ openssl asn1parse -inform DER -in file.der UTF8String ๋ฌธ์ž ์ƒ์„ฑํ•˜๊ธฐ openssl asn1parse -genstr "UTF8:Hello world" ๊ฒฐ๊ณผ ๊ฐ’ 0:d=0 hl=2 l= 11 prim: UTF8STRING :Hello world UTF8String DER ํŒŒ์ผ๋กœ ์ƒ์„ฑํ•˜๊ธฐ o..

Manual/OpenSSL 2023.05.15

[OpenSSL] MAC ( Message Authentication Code ) ๋ช…๋ น์–ด

๋ฉ”์„ธ์ง€ ์ธ์ฆ ์ฝ”๋“œ๋ผ๋Š” MAC ๊ธฐ๋Šฅ์„ OpenSSL ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ด ๊ตฌํ•ด ๋ณด์ž ์‚ฌ์‹ค MAC ๊ฐ’์„ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด ๋ฐฉ์‹์€ ์—ฌ๋Ÿฌ๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ๋Š” Hash๋ฅผ ์‚ฌ์šฉํ•˜๋Š” HMAC๊ณผ Cipher-based MAC ์ธ CMAC์ด ๊ฐ€์žฅ ๋Œ€ํ‘œ์ ์ด๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋ธ”๋ก ์•”ํ˜ธ์—์„œ ์‚ฌ์šฉ๋˜๋Š” GCM ๋ชจ๋“œ๋ฅผ ์ด์šฉํ•œ GMAC ๋“ฑ์ด ์žˆ๋‹ค. ์ด ๋ช…๋ น์–ด์— ๋Œ€ํ•œ ๋ฉ”๋‰ด์–ผ์„ ์ฐธ๊ณ  ํ•˜์—ฌ ๋งŒ๋“ค์—ˆ๋‹ค. HMAC-SHA1 MAC openssl mac -digest SHA1 -macopt hexkey:000102030405060708090A0B0C0D0E0F10111213 -in msg.bin HMAC HMAC ์ง€์› ๋ชฉ๋ก ํ™•์ธ openssl list -digest-commands HMAC ์ง€์› ๋ชฉ๋ก ๊ฒฐ๊ณผ ํ™”๋ฉด blake2b512 blake2s256 md..

Manual/OpenSSL 2023.05.10

[OpenSSL] Message Digest ( Hash function ) ๋ช…๋ น์–ด

Message Digest๋Š” ์ž„์˜์˜ ๊ธธ์ด๋ฅผ ๋‹จ๋ฐฉํ–ฅ ํ•ด์‰ฌ ํ•จ์ˆ˜์— ์ ์šฉํ•˜์—ฌ ์ผ์ •ํ•œ ๊ธธ์ด๋กœ ์ƒ์„ฑ๋œ ๋น„ํŠธ์—ด์ด๋‹ค. ์ฆ‰ ํ•ด์‰ฌ์˜ ๊ฒฐ๊ณผ ๊ฐ’์œผ๋กœ ๋ณด๋ฉด ๋œ๋‹ค. ํ•ด์‰ฌ ํ•จ์ˆ˜ ์ฆ‰ ํ•ด์‰ฌ ๋ผ๊ณ  ๋งํ•˜๋Š” ์ž„์˜์˜ ๊ธธ์ด๋ฅผ ๊ฐ–๋Š” ๋ฐ์ดํƒ€์— ๋Œ€ํ•ด ๊ณ ์ •๋œ ๊ธธ์ด๋กœ ๋ฐ์ดํƒ€๋ฅผ ๋งคํ•‘ํ•˜๋Š” ๋‹จ๋ฐฉํ–ฅ ํ•จ์ˆ˜๋ฅผ ๋งํ•œ๋‹ค. OpenSSL ์„ ์ด์šฉํ•ด ํ•ด์‰ฌ ํ•จ์ˆ˜ ๊ธฐ๋Šฅ์„ ์ด์šฉํ•ด Message Digest ๊ฐ’์„ ๊ตฌํ•ด ๋ณด์ž. ์—ฌ๊ธฐ์„œ ์ž‘์„ฑํ•œ ๊ธฐ๋Šฅ์€ ๋ฉ”๋‰ด์–ผ ๋ฌธ์„œ๋ฅผ ์ฐธ์กฐ ํ•˜์—ฌ ๋งŒ๋“ค์—ˆ๋‹ค. ๋จผ์ € ์ง€์› ํ•˜๋Š” ๋ฉ”์„ธ์ง€ ๋‹ค์ด์ œ์ŠคํŠธ ๋ชฉ๋ก์„ ํ™•์ธ ํ•˜์ž openssl dgst -list Supported digests: -blake2b512 -blake2s256 -md5 -md5-sha1 -ripemd -ripemd160 -rmd160 -sha1 -sha224 -sha256 -sha3-224 -..

Manual/OpenSSL 2023.05.08