PKI/ASN.1 23

RSA ๊ฐœ์ธํ‚ค ํŠน์„ฑ

RSA ํ‚ค ์Œ์—์„œ ๊ฐœ์ธํ‚ค ํŒŒ์ผ์„ ์•Œ์•„ ๋ณด์ž์ผ๋ฐ˜์ ์œผ๋กœ ๊ฐœ์ธํ‚ค๋Š” ์•”ํ˜ธํ™” ๋˜์–ด ์žˆ์ง€๋งŒ ์•”ํ˜ธํ™” ๋˜์ง€ ์•Š์€ ํ˜•์‹์€ PKCS#1 ์—์„œ ์ •์˜ ๋œ ํ˜•์‹์„ ๊ฐ€์ง€๊ณ  ๋งŒ๋“ค์–ด์ ธ์žˆ๋‹ค.๋ณดํ†ต RSA ์—ฐ์‚ฐ์—์„œ ์‚ฌ์šฉ ๋˜๋Š” ํ‚ค ๊ฐ’์€ n, e, d ์ด๋‹ค.์—ฌ๊ธฐ์„œ ๋ณดํ†ต (n, d) ๊ฐ’์ด ๊ฐœ์ธํ‚ค ์ด๊ณ  (n, e) ๊ฐ’์„ ๊ณต๊ฐœํ‚ค๋กœ ํ”ํžˆ๋“ค ๋งํ•œ๋‹ค.๊ทธ๋Ÿผ PKCS#1 ํ˜•์‹์˜ ๊ฐœ์ธํ‚ค๋ฅผ BerEditor๋กœ ๋ณด๋ฉด ๋‹ค์Œ ๊ทธ๋ฆผ๊ณผ ๊ฐ™๋‹ค.๋ณดํ†ต ๊ฐœ์ธํ‚ค ํŒŒ์ผ์—๋Š” ๊ฐœ์ธํ‚ค์™€ ๊ณต๊ฐœํ‚ค ๊ฐ’์ด ๋ชจ๋‘ ๋“ค์–ด๊ฐ€ ์žˆ๋Š”๋ฐ์™œ n, e, d ๊ฐ’ ์™œ์— ๋‹ค๋ฅธ ๊ฐ’์ด ๋” ์žˆ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.์ด ๊ฐ’๋“ค์€ PKCS#1 ์— ์ •์˜ ๋œ ASN.1 ๊ฐ’์„ ์ฐธ์กฐ ํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.RSA ๊ฐœ์ธํ‚ค ASN.1 RSAPrivateKey ::= SEQUENCE { version ..

PKI/ASN.1 2024.05.31

ECDSA ์ธ์ฆ์„œ ๊ณต๊ฐœํ‚ค ๊ฐ’์— 0x04 ๊ฐ€ ์•ž์— ๋ถ™๋Š” ์ด์œ 

์ผ๋ฐ˜์ ์œผ๋กœ ECDSA ๊ณต๊ฐœํ‚ค๋ฅผ ์ธ์ฆ์„œ์—์„œ ๊ฐ’์„ ์ฝ์–ด ๋ณด๋ฉด ํ•ญ์ƒ ์ฒซ ๋ฐ”์ดํŠธ๊ฐ€ 0x04 ๊ฐ’์œผ๋กœ ์‹œ์ž‘ ํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ECDSA ๊ณต๊ฐœํ‚ค ๊ฒฝ์šฐ ๋ณดํ†ต P-256 ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด 64 ๋ฐ”์ดํŠธ ๊ธธ์ด์–ด์•ผ ํ•˜๋Š”๋ฐ 0x04 ๊ฐ€ ๋ถ™์Œ์œผ๋กœ 65 ๋ฐ”์ดํŠธ๊ฐ€ ๋œ๋‹ค. ์œ„ ๊ทธ๋ฆผ์—์„œ 03 42 00 04 ... ์ด๋ ‡๊ฒŒ ์ง„ํ–‰ ํ•˜๋Š”๋ฐ 03 ์€ BitString ์ด๊ตฌ 42 ๋Š” 66 ๋ฐ”์ดํŠธ์ด๊ตฌ 00 ์€ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๋น„ํŠธ ๊ฐœ์ˆ˜์ด๊ตฌ 04 ๋ถ€ํ„ฐ ๊ณต๊ฐœํ‚ค ๊ฐ’์ด๋‹ค ์ฆ‰ ์ด๋ ‡๊ฒŒ 04 ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋Ÿผ ์ด 0x04 ๊ฐ’์˜ ์˜๋ฏธ๋Š” ๋ฌด์—‡์ธ๊ฐ€? ์ด ๋‚ด์šฉ์— ๋Œ€ํ•ด์„œ๋Š” RFC5480 ๋ฌธ์„œ์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋‚ด์šฉ์ด ๋‚˜์˜จ๋‹ค. o The first octet of the OCTET STRING indicates whether the key is comp..

PKI/ASN.1 2023.10.13

CER( Canonical Encoding Rules ) ์˜ ํŠน์„ฑ (DER๊ณผ ๋น„๊ต)

์ผ๋ฐ˜์ ์œผ๋กœ BER๊ณผ DER ์€ PKI ์—์„œ ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค. ํŠนํžˆ DER ์€ BER์˜ ์„œ๋ธŒ์…‹์œผ๋กœ ์ข€๋” ๋ช…ํ™•ํžˆ ๊ฐ’์„ ์ œํ•œ ํ•˜์˜€๋‹ค๊ณ  ๋ณด๋ฉด ๋œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  DER ๊ณผ ๋‹ค๋ฅธ ๋˜๋‹ค๋ฅธ BER ์˜ ์„œ๋ธŒ์…‹์ธ CER ์ด์žˆ๋‹ค. ๊ทธ๋Ÿผ CER์ด ๋ฌด์—‡์ธ์ง€ DER๊ณผ ์ฐจ์ด์ ์„ ์•Œ์•„๋ณด์ž CER ํŠน์„ฑ ๋ชจ๋“  ์œ ํšจํ•œ CER ์ธ์ฝ”๋”ฉ์ด ์œ ํšจํ•œ BER ์ธ์ฝ”๋”ฉ์ด๋ผ๋Š” ์ ์—์„œ BER๊ณผ ์œ ์‚ฌํ•˜๋‹ค. BER์€ ๋Œ€๋ถ€๋ถ„์˜ ๊ฐ’์„ ์ธ์ฝ”๋”ฉํ•˜๋Š” ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์„ ํ—ˆ์šฉํ•˜๋Š” ๋ฐ˜๋ฉด, CER์€ ์ฃผ์–ด์ง„ ๊ฐ’์— ๋Œ€ํ•ด ์ด๋Ÿฌํ•œ ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜๋งŒ ํ—ˆ์šฉํ•œ๋‹ค๊ณ  ๊ทœ์ •ํ•ฉ๋‹ˆ๋‹ค (์˜ˆ: BER์€ BOOLEAN์˜ ๊ฒฝ์šฐ 00 ๊ฐ’์ด FALSE์ด๊ณ  0์ด ์•„๋‹Œ ๊ฐ’์€ TRUE๋ผ๊ณ  ๋งํ•˜์ง€๋งŒ CER์€ 00์€ FALSE์ด๊ณ  FF๋Š” TRUE์ด๋ฉฐ ๊ฐ’ 01-FE๋Š” ๊ฑฐ์ง“์ž„์„ ๋‚˜ํƒ€๋‚ด๋‹ค) DER์€ ์ฃผ์–ด์ง„ ๊ฐ’์„ ์ธ์ฝ”๋”ฉํ•˜๋Š” ๋‹จ์ผ ๋ฐฉ๋ฒ•..

PKI/ASN.1 2023.06.30

ASN.1 ์ธ์ฝ”๋”ฉ ๋ฐฉ์‹

ASN.1(Abstract Syntax Notation One)์€ ๋ฐ์ดํ„ฐ ํ‘œํ˜„ ํ˜•์‹์˜ ๊ทœ์น™์„ ์ •์˜ํ•˜๊ธฐ ์œ„ํ•œ ํ‘œ๊ธฐ๋ฒ•์ด๋‹ค. ASN.1 ์ธ์ฝ”๋”ฉ์€ ์ผ๋ฐ˜์ ์œผ๋กœ ๋ฐ”์ดํŠธ ์ŠคํŠธ๋ฆผ์œผ๋กœ ํ‘œํ˜„๋˜๋ฉฐ ์ธ์ฝ”๋”ฉ ํ˜•์‹์€ ๋ฐ์ดํ„ฐ์˜ ํฌ๊ธฐ๋ฅผ ์ตœ์†Œํ™”ํ•˜๊ณ , ๋‹ค์–‘ํ•œ ํ”Œ๋žซํผ๊ณผ ์–ธ์–ด ๊ฐ„์— ๋ฐ์ดํ„ฐ๋ฅผ ์ƒํ˜ธ ์ „ํ™˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•œ๋‹ค. ASN.1 ์ธ์ฝ”๋”ฉ์—๋Š” ๋‹ค์–‘ํ•œ ํ˜•์‹์ด ์žˆ๋Š”๋ฐ BER( Basic Encoding Rules ), PER (Packed Encoding Rules), CER (Canonical Encoding Rules) DER (Distingushed Encoding Rules ) OER, XER, JER ๋“ฑ์ด ์žˆ๋‹ค. ๊ทธ๋Ÿผ ๊ฐ๊ฐ์˜ ์ธ์ฝ”๋”ฉ ํŠน์ง•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. ์ด๊ธ€์€ oss.com ์— ์žˆ๋Š” ์ •๋ณด๋ฅผ ์ฐธ๊ณ  ํ•˜์˜€๋‹ค [์ฐธ๊ณ ์ž๋ฃŒ] BER DER CER..

PKI/ASN.1 2023.06.29

ASN.1 ์˜คํ”ˆ์†Œ์Šค ์ปดํŒŒ์ผ๋Ÿฌ asn1c ์‚ฌ์šฉ๋ฒ•

ASN.1 ์ •๋ณด๋ฅผ ๊ฐ€์ง€๊ณ  ๊ฐœ๋ฐœ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ASN.1 ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ์‹ค์ œ๋กœ ์ƒ์šฉ ๋ฒ„์ „์˜ ์ปดํŒŒ์ผ๋Ÿฌ๋Š” ๋ผ์ด์„ผ์Šค ๋น„์šฉ์ด ๋น„์‹ธ๋‹ค ์—ฌ๊ธฐ์„œ๋Š” ํ˜„์žฌ ๋ฌด๋ฃŒ๋กœ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์˜คํ”ˆ์†Œ์Šค์ธ asn1c ๊ธฐ๋ณธ ์‚ฌ์šฉ๋ฒ•์ด๋‹ค. ํ•ด๋‹น ํˆด์˜ ํ™ˆํŽ˜์ด์ง€์—์„œ ๊ด€๋ จ ์„ค๋ช…๊ณผ GitHub ์—์„œ ์†Œ์Šค๋ฅผ ๋‹ค์šด ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋Ÿผ asn1c ์— ๋Œ€ํ•ด ์‚ฌ์šฉ๋ฒ•์„ ์•Œ์•„๋ณด์ž. ASN1C ์„ค์น˜ asn1c ๋ฅผ ์†Œ์ŠคํŒŒ์ผ์„ ํ’€์–ด ๋ณด์ž ํ˜„์žฌ ๋‹ค์šด ๋ฒ„์ „์€ 0.9.28 ๋ฒ„์ „์ด๋‹ค. tar zxvf asn1c-0.9.28.tar.gz cd asn1c-0.9.28 ./configure make make install ์„ค์น˜๋Š” ๊ฐ„๋‹จํžˆ ํ•œ๋‹ค. ์ฐธ๊ณ ๋กœ make install ์€ root ๊ถŒํ•œ์ด ํ•„์š”ํ•˜๋‹ค. root ๊ถŒํ•œ์ด ์•„๋‹ˆ๋ผ๋ฉด sudo make install ์„ ํ•ด์ฃผ๋ฉด ๋œ๋‹ค...

PKI/ASN.1 2023.05.09

ECDSA ๊ฐœ์ธํ‚ค ASN.1 ํ˜•์‹

์ด๋ฒˆ์—๋Š” ECDSA ์•Œ๊ณ ๋ฆฌ์ฆ˜์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฐœ์ธํ‚ค ํฌ๋งท์— ๋Œ€ํ•ด ์•Œ์•„ ๋ณด์ž ๋จผ์ € ECDSA ๊ฐœ์ธํ‚ค ํฌ๋งท์€ RFC5915 ์— ์ •์˜ ๋˜์–ด ์žˆ๋‹ค. ASN.1 ํ˜•์‹ ECPrivateKey { iso(1) identified-organization(3) dod(6) internet(1) security(5) mechanisms(5) pkix(7) id-mod(0) id-mod-ecprivateKey(65) } DEFINITIONS EXPLICIT TAGS ::= BEGIN -- EXPORTS ALL; IMPORTS -- FROM New PKIX ASN.1 [RFC5912] ECParameters, NamedCurve FROM PKIXAlgs-2009 { iso(1) identified-organization(3) d..

PKI/ASN.1 2023.05.02

Distinguished Encoding Rules

BER๊ณผ ๋น„์Šทํ•˜๋‚˜ BER์— ๋ช‡ ๊ฐ€์ง€ ์ œ์•ฝ์‚ฌํ•ญ์„ ๊ฐ€์ง DER ์ œ์•ฝ์‚ฌํ•ญ Length Octets · ์ตœ์†Œ์˜ octets ์ˆ˜ ์•ˆ์—์„œ definite form length๋ฅผ ์‚ฌ์šฉ BIT STRING, OCTET STRING · Constructed form์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Œ BOOLEAN value · TRUE์ด๋ฉด ๋ชจ๋“  8bits ๊ฐ’์€ 1 (0xFF) BIT STRING · ๋งˆ์ง€๋ง‰ octet์˜ ์‚ฌ์šฉ๋˜์ง€ ์•Š๋Š” bit๋Š” ‘0’์œผ๋กœ ์„ค์ • · tailing 0 bits๋Š” ์ธ์ฝ”๋”ฉ ํ•˜์ง€ ์•Š์Œ · 1bit๋„ ๊ฐ’์œผ๋กœ ๊ฐ€์ง€์ง€ ์•Š์œผ๋ฉด, “03 01 00”์œผ๋กœ ์ธ์ฝ”๋”ฉ ํ•จ Time · ์˜๋ฏธ์—†์ด ๋”ฐ๋ผ์˜ค๋Š” 0์€ ์ธ์ฝ”๋”ฉ ํ•˜์ง€ ์•Š์Œ · UTCTime์ผ ๊ฒฝ์šฐ, ์†Œ์ˆ˜์  ์ดํ•˜๊ฐ€ ์—†์œผ๋ฉด ‘.’ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Œ · GeneralizedTime์ผ ๊ฒฝ์šฐ,..

PKI/ASN.1 2022.11.07