PKI/Geneal Infomation

๊ฐœ์ธํ‚ค ์•”ํ˜ธํ™”ํ•˜๋Š” ๋‘๊ฐ€์ง€ ํ‘œ์ค€ ๊ธฐ์ˆ ( PKCS#8, PKCS#12)

JayKim๐Ÿ™‚ 2024. 1. 29. 11:45

PKI ์‹œ์Šคํ…œ์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•˜๊ฒŒ ๊ด€๋ฆฌ ๋˜์–ด์•ผ ํ•˜๋Š”๊ฒƒ์ด ๊ฐœ์ธํ‚ค์ด๋‹ค.
๊ทธ๋ž˜์„œ ๊ฐœ์ธํ‚ค๋Š” ์•”ํ˜ธํ™”๋ฅผ ํ•ด์„œ ๋ณด๊ด€ํ•˜๋Š”๊ฒƒ์ด ์ผ๋ฐ˜์ ์ด๋‹ค.
๋ฌผ๋ก  ์ข€๋” ์•ˆ์ „ํ•˜๊ฒŒ ๋ณด๊ด€ํ•˜๊ธฐ ์œ„ํ•ด HSM ์žฅ์น˜๋ฅผ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ๋‹ค.

๊ทธ๋Ÿฌ๋ฉด ์ด ๊ฐœ์ธํ‚ค๋ฅผ ์•”ํ˜ธํ™”์— ์‚ฌ์šฉ๋˜๋Š” ๋‘๊ฐ€์ง€ ๊ธฐ์ˆ  ํ‘œ์ค€์ด ์žˆ๋‹ค.
๊ทธ ๋‘๊ฐ€์ง€ ๊ธฐ์ˆ  ํ‘œ์ค€์ด PKIX ์—์„œ PKCS#8 ๊ณผ PKCS#12 ๋‘๊ฐ€์ง€ ๊ธฐ์ˆ ์ด ์žˆ๋‹ค.

๊ทธ๋Ÿผ PKCS#8 ๊ณผ PKCS#12 ์— ๋Œ€ํ•ด์„œ ์•Œ์•„ ๋ณด์ž

PKCS#8

PKCS#8 ์€ ๊ฐœ์ธํ‚ค ๋งŒ์„ ์•”ํ˜ธํ™” ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ ๋˜๋Š” ํ‘œ์ค€ ๊ธฐ์ˆ ์ด๋‹ค [ RFC5208 ]
๊ฐœ์ธํ‚ค ์•”ํ˜ธ๋ฅผ ์œ„ํ•ด์„œ PrivateKeyInfo ์™€ EncryptedPrivateKeyInfo ๋‘๊ฐ€์ง€ ASN.1 ํ˜•์‹์ด ์‚ฌ์šฉ๋œ๋‹ค.
๋จผ์ € ๊ฐœ์ธํ‚ค๋ฅผ ์•”ํ˜ธํ™” ํ•˜๊ธฐ ์ „์— PrivateKeyInfo ํ˜•์‹์œผ๋กœ ๊ฐœ์ธํ‚ค ๊ฐ’์„ ๋งŒ๋“ค๊ณ  ์ด ๊ฐ’์„ PKCS#5 ์˜ ์•”ํ˜ธํ™” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜์—ฌ
์•”ํ˜ธํ™” ํ•œํ›„ ์ €์žฅํ•˜๋Š”๊ฒƒ์ด EncryptedPrivateKeyInfo ํ˜•์‹์œผ๋กœ ์ €์žฅ์„ ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

์ฆ‰ EncryptedPrivateKeyInfo ์—์„œ EncryptedData ๊ฐ’์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š”๊ฒƒ์ด PrivateKeyInfo ์˜ ๊ฐ’์„ ์•”ํ˜ธํ™” ํ•˜์—ฌ ๋งŒ๋“ค์–ด์ง€๋Š” ๊ฐ’์ด๋‹ค.
์ผ๋ฐ˜์ ์œผ๋กœ ์ €์žฅํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋Š” ๊ฐœ์ธํ‚ค ์•”ํ˜ธํ™”๋Š” EncryptedPrivateKeyInfo ํ˜•์‹์„ ์‚ฌ์šฉํ•œ๋‹ค.

Private-Key Information Syntax

      PrivateKeyInfo ::= SEQUENCE {
        version                   Version,
        privateKeyAlgorithm       PrivateKeyAlgorithmIdentifier,
        privateKey                PrivateKey,
        attributes           [0]  IMPLICIT Attributes OPTIONAL }

      Version ::= INTEGER

      PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier

      PrivateKey ::= OCTET STRING

      Attributes ::= SET OF Attribute

Encrypted Private-Key Information Syntax

      EncryptedPrivateKeyInfo ::= SEQUENCE {
        encryptionAlgorithm  EncryptionAlgorithmIdentifier,
        encryptedData        EncryptedData }

      EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier

      EncryptedData ::= OCTET STRING

PEM ์—์„œ Encrypted Private Key ๋Š” "BEGIN ENCRYPTED PRIVATE KEY" ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ €์žฅ์ด ๋˜๋‹ˆ ์ด๋ ‡๊ฒŒ ํ—ค๋”๊ฐ€ ์žˆ๋Š” ๊ฐœ์ธํ‚ค๋Š” PKCS#8 ์˜ ์•”ํ˜ธํ™”๋œ ํ‚ค๋กœ ๋ณด๋ฉด ๋œ๋‹ค.

์•„๋ž˜ ๊ทธ๋ฆผ์—์„œ ๋ณด๋ฉด OctetString ์˜์—ญ์˜ ๊ฐ’์ด PrivateKeyInfo ์˜ ์•”ํ˜ธํ™”๋œ ๋ฐ์ดํƒ€ ๊ฐ’์ด๋‹ค.

PKCS#8 EncryptedPrivateKeyInfo Raw ๋ฐ์ดํƒ€

๊ทธ๋Ÿผ PKCS#8 ํ˜•์‹์˜ RSA ํŒŒ์ผ์„ OpenSSL ๋ช…๋ น์–ด๋กœ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ๋Š” ์•„๋ž˜ ๊ธ€์„ ์ฐธ์กฐ ํ•˜์ž

[OpenSSL] RSA ๊ฐœ์ธํ‚ค (PrivateKey) ์ƒ์„ฑ ๋ช…๋ น์–ด

PKCS#12

PKCS#12๋Š” ์‚ฌ์‹ค ๊ฐœ์ธํ‚ค ๋งŒ์„ ์œ„ํ•œ๊ฒƒ์ด ์•„๋‹ˆ๋ฆฌ ๋ณดํ†ต ์ธ์ฆ์„œ์™€ ์ธ์ฆ์„œ ๊ฒฝ๋กœ๊ฒ€์ฆ์— ํ•„์š”ํ•œ ์ฒด์ธ ๊นŒ์ง€ ๋ชจ๋‘ ์ €์žฅ์„ ์œ„ํ•œ ๊ธฐ์ˆ  ํ‘œ์ค€์ด๋‹ค[RFC7292].
์ฆ‰ CA, Root ์ธ์ฆ์„œ๋“ฑ ์‹ ๋ขฐ ์ฒด์ธ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ ๋ชจ๋“  ์š”์†Œ๋ฅผ ํ•˜๋‚˜์˜ ํŒŒ์ผ๋กœ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•œ ํ˜•์‹์ธ ๊ฒƒ์ด๋‹ค.

PKCS#12 ๋Š” Personal Information Exchange Syntax ๋กœ์„œ ํ™•์žฅ์ž๋ฅผ PFX ๋˜๋Š” p12 ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค.
์ฆ‰ PFX ๋Š” Personal Information Exchange ์˜ ์•ฝ์ž์ด๋‹ค.

์ผ๋ฐ˜์ ์œผ๋กœ๋Š” ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์€ ๊ฐœ์ธํ‚ค์™€ ๊ฐœ์ธํ‚ค์— ๋งž๋Š” ์ธ์ฆ์„œ๋ฅผ ๊ฐ™์ด ํ•˜๋‚˜์˜ ํŒŒ์ผ๋กœ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค.

PFX PDU Syntax

   PFX ::= SEQUENCE {
       version     INTEGER {v3(3)}(v3,...),
       authSafe    ContentInfo,
       macData     MacData OPTIONAL
   }

   MacData ::= SEQUENCE {
       mac         DigestInfo,
       macSalt     OCTET STRING,
       iterations  INTEGER DEFAULT 1
       -- Note: The default is for historical reasons and its
       --       use is deprecated.
   }

   AuthenticatedSafe ::= SEQUENCE OF ContentInfo
       -- Data if unencrypted
       -- EncryptedData if password-encrypted
       -- EnvelopedData if public key-encrypted

์•„๋ž˜ ๊ทธ๋ฆผ์„ ๋ณด๋ฉด Content-specific[0] ์˜์—ญ์— ๊ฐœ์ธํ‚ค์™€ ์ธ์ฆ์„œ ์ •๋ณด๋“ค์ด ์ €์žฅ์ด ๋œ๋‹ค.

PKCS#12 Raw ๋ฐ์ดํƒ€

๊ทธ๋Ÿผ PKCS#12 ํ˜•์‹์˜ ํŒŒ์ผ์„ OpenSSL ๋ช…๋ น์–ด๋กœ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ๋Š” ์•„๋ž˜ ๊ธ€์„ ์ฐธ์กฐ ํ•˜์ž

[OpenSSL] PKCS#12 (PFX) ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ ๋ช…๋ น์–ด

๋งˆ๋ฌด๋ฆฌ

๋ณดํ†ต ๊ฐœ์ธํ‚ค๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ์ €์žฅํ•˜๊ณ  ์‚ฌ์šฉํ•  ๋•Œ๋Š” PKCS#8 ์˜ ์•”ํ˜ธํ™” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜์—ฌ ์ €์žฅ์„ ํ•˜๊ณ 
๊ฐœ์ธํ‚ค์™€ ์ธ์ฆ์„œ๋ฅผ ๊ฐ™์ด ์ „๋‹ฌ ํ•˜๊ฑฐ๋‚˜ ๊ฐ€์ ธ์˜ฌ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๊ธฐ์ˆ ์ด PKCS#12 ์ด๋‹ค. ์ฆ‰ PFX ํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.