0c1d965624f95f53a0c527b9a1ca967e.ppt
- Количество слайдов: 79
Key Managemnet 소프트웨어공학 실험실 김경태, 전은아, 민병도 Computer Network Lab. 1
목 차 q소 개 q Keys q Key Generators와 Translators q Key Agreement q The Identity Key Management Paradigm q The Key. Store Key Management Paradigm q결 론 Computer Network Lab. 2
소 개 q 배경: 개인정보의 보호를 위하여 암호 키 사용하게 되었고, 따라서 암호 키의 관리 문제가 나타남. Sun은 키 관리를 위한 인터페이스와 클래스를 제공(JDK). JDK class와interface가 키를 관리하고 표현하는데 사용 q구성 The Identity Key Management Paradigm Computer Network Lab. Keys Key Generators Key Translators Key Agreement The Key. Store Key Management Paradigm 3
Keys(1/3) 인터페이스 java. security. Key 클래스 java. security. Key. Pair Public String get. Algorithm() public Public. Key get. Public() Public byte[] get. Encoded() public Pivate. Key get. Private() Public String get. Format() java. security. Public. Key java. security. Private. Key javax. crypto 인터페이스 javax. crypto. Secret. Key Computer Network Lab. 4
Keys(2/3) q java. security. Key 인터페이스 - 모든 키의 공통적 기능을 정의하는 인터페이스 § 메소드 public String get. Algorithm() - 키에서 사용된 암호 알고리즘 리턴 (예: DSA, MD 5, RSA 등) public byte[] get. Encoded() - 암호화된 값 리턴 ( 암호화는 바이트 배열에 키 값을 적용) public String get. Format() - 암호화에 사용된 키 포맷의 이름 리턴(예: X. 509, PKCS#8) q java. crypto. Securet. Key 인터페이스 - 비밀 키에 사용되는 인터페이스 (개인 또는 세션 키) Computer Network Lab. 5
Keys(3/3) q JDK 인터 페이스(타입의 안정성과 키 확인) v java. security. Public. Key - 공개 키에 사용되는 인터페이스 v java. security. Private. Key - 개인 키에 사용되는 인터페이스 q JDK 클래스 v public Key. Pair(Public. Key public. Key, Private. Key private. Key) - 공개 키와 개인 키로 이루어지는 키 쌍 생성 Ø 메소드 : public Public. Key get. Public() - 공개 키 리턴 public Private. Key get. Private() - 개인 키 리턴 Computer Network Lab. 6
Key Generator(1/6) : 암호 키 생성( 암호키: 키 또는 키 쌍) q 암호 키 생성 단계 1. 사용하기를 원하는 알고리즘에 대한 키 Generator 객체 획득 2. 키 genetator 초기화 3. 키 또는 키 쌍의 생성을 key generator에게 요청 클래스 java. security. Key. Pair. Generator Public abstract void initialize(int strength, Secure. Random random) Public void initialize(int strength) Public abstract Key. Pair gen. Key. Pair() Computer Network Lab. 7
Key Generator(2/6) 클래스 javax. crypto. Key. Generator Public final void init(Secure. Random random)* Public final void init(int strength) Public final void init(int strength, Secure. Random random) Public final Secret. Key generate. Key( ) Computer Network Lab. 8
Key Generator(3/6) q Key. Pair. Generator 클래스 : java. security. Key. Pair. Generator-공개 키와 개인 키 쌍을 생성하고 Key. Pair로 리턴. v Generator 객체를 get. Instance() 메소드에 알고리즘의 종류를 명시하는 문자열 인수를 적용함으로 생성 Ex) Key. Pair. Generator kpg = Key. Pair. Generator. get. Instance(“El. Gamal”) -알고리즘을 발견하지 못할시 No. Such. Algorithm. Exception 동작 v Generator 초기화 메소드 public abstract void initialize(int strength, Secure. Random random) : 보안강도(실제로 키가 차지하는 비트 수)와 난수로 초기화 public void initialize(int strength) : 보안 강도로 초기화 Computer Network Lab. 9
Key Generator(4/6) v 키 생성 메소드 Public abstract Key. Pair gen. Key. Pair() : 이전의 initialze()에서 명시된 강도와 랜덤 비트 소스를 사용하여 key pair를 생성 Ex) Key. Pair. Generator kpg = Key. Pair. Generator. get. Instance(“DSA”); kpg. initialize(1024); key. Pair pair = kpg. gen. Key. Pair(); Computer Network Lab. 10
Key Generator(5/6) q Key. Generator 클래스 : 대칭 암호에서의 하나의 키 생성. 따라서 JCE는 jvax. crypto. Key. Generator라는 랜덤한 하나의 키를 생성하는 클래스 포함 v Generator 객체 획득 Ø Key. Generator kg = Key. Generator. get. Instance(“DES”) v 초기화 메소드 ØPublic final void init(Secure. Random random)* : 난수 사용하여 Key. Generator을 초기화 ØPublic final void init(int strength) : 보안 강도 사용 ØPublic final void init(int strength, Secure. Random random) : 보안 강도와 난수 사용 Computer Network Lab. 11
Key Generator(6/6) v 키 생성 메소드 ØPublic final Secret. Key generate. Key() : 새로운 랜덤 Secret. Key를 생성 Ex) Key. Generator kg = Key. Generator. get. Instance (“DES”); Kg. init(new Secure. Random()); Secret. Key key = kg. generate. Key(); Computer Network Lab. 12
Algorithm-Specific Initialization(1/2) : Java. security. Key. Pair. Generator와 javax. crypto. Key. Generatorsms Algorithm-Specific Initialization의 개념을 지원 - 사용하는 알고리즘에 대한 정해진 파라메터를 사용가능 q Java. security. Key. Pair. Generator는 Algorithm-Specific Initialization을 위한 하나의 메소드 포함 Public void initialize(Algorithm. Parameter. Spec params) throws Invalid. Algorithm. Parameter. Exception : 만일 Algorithm. Parameter. Spec 객체가 인정되지 않는다면, 예외처리 Computer Network Lab. 13
Algorithm-Specific Initialization(2/2) q javax. crypto. Key. Generator는 Algorithm-Specific Initialization을 위한 두 개의 메소드 포함 Public final void init(Algorithm. Parameter. Spec params) throws Invalid. Algorithm. Parameter. Exception : 만일 Algorithm. Parameter. Spec 객체가 인정되지 않는다면, 예외처리 Public final void init(Algorithm. Parameter. Spec params, Secure. Random random) throws Invalid. Algorithm. Parameter. Exception : 만일 Algorithm. Parameter. Spec 객체가 인정되지 않는다면, 예외처리 Computer Network Lab. 14
Key Translator(1/8) q Problem) 디스크에서의 키 저장, 네트워크에서의 키 전송 Solution) 바이트 열 단위로 키 저장 또는 전송 바이트 열과 vice versa로 Key 객체 변환 q 클래스를 사용하여 객체 변환 Class javax. crypto. spec. Secret. Key. Spec java. crypto. Secret. Key. Factory javax. security. Key. Factory Computer Network Lab. 15
Key Translator(2/8) q. Secret. Key. Spec : javax. crypto. spec. Secret. Key. Spec 클래스는 비밀 키의 바이트 열을 변환하는 가장 간단한 방법. 두 개의 생성자를 가지고 있슴. v pubic Secret. Key. Spec(byte[] key, String algorithm) : 제공된 바이트 열을을 사용하여 Secret. Key. Spec을 생성. Key에 알고리즘 제공. v pubic Secret. Key. Spec(byte[] key, int offset, int len, String algorithm) : 제공된 바이트 배열의 Offset에서 시작하는 len 바이트들을 사용하여 Secret. Key. Spec을 생성. 제공된 알고리즘 가짐. 예제) Secure. Random sr = new Secure. Random(); Byte[] key. Byte = new byte[20]; Sr. next. Bytes(key. Bytes); Secret. Key key = new Secret. Key. Spec (key. Bytes, “Hmac. SHA 1”); Computer Network Lab. 16
Key Translator(3/8) q Secret. Key. Factory 클래스 : java. crypto. Secret. Key. Factory 클래스는 get. Instance() 함수를 이용하여 Secret. Key. Factory를 생성. 두 개의 생성자 가짐. v pubic static final Secret. Key. Factory get. Instance(String algorithm) throws No. Such. Algorithm. Exception : 주어진 알고리즘을 사용하여 새로운 Secret. Key. Factory 생성 알고리즘 이름(예: DES)이 대칭 암호 알고리즘 이름과 일치해야함 v pubic static final Secret. Key. Factory get. Instance(String algorithm, String provider) throws No. Such. Algorithm. Exception, No. Such. Provider. Exception : 알고리즘과 제공자를 사용하여, 새로운 Secret. Key. Factory 생성 -Secret. Key. Factory를 가지고 있다면, Key. Spec와 Secret. Key사에서의 key translate가 자유롭다 Computer Network Lab. 17
Key Translator(4/8) q. From things to keys : Secret. Key에서 Key. Spec로의 translate는 Secret. Factory의 generator. Secret() 함수를 사용한다 v pubic final Secret. Key generate. Secret(Key. Spec key. Spec) throws Invalid. Key. Sepc. Exception : key. Spec의 정보를 사용하여, Secret. Key 생성. 만일 Key. Spec이 인정되 지 않는다면, 예외처리 Ex) DES 키 생성 pubic Secret. Key make. DESKey(byte[] input, int offset) throws No. Such. Algorithm. Exception, Invalid. Key. Sepc. Exception, Invalid. Key. Spec. Exception { Secret. Key. Factory des. Factory = Secret. Key. Factory. get. Instance(“DES”); Key. Spec spec = new DESKey. Spec(input, offset); Return des. Factory. generate. Secret (spec); } Computer Network Lab. 18
Key Translator(5/8) q make. DESKey() 함수의 단계 1. DES 키를 위한 키 요소의 획득. Secret. Key. get. Instance()를 사용 2. Key. Spec은 제공된 바이트 열로부터 DES 키 데이터 표시 생성 3. Key. Spec로부터의 Secret. Key 생성. generate. Secret()를 사용 q예외사항 v get. Instance()함수 -No. Such. Algorithm. Exception vgenerator. Secret()함수 -Invalid. Key. Exception (정확하지 않은 키 길이 전달) vgenerator. Secret()함수 -Invalid. Key. Spec. Exception(Key. Spec에서 불인정) Computer Network Lab. 19
Key Translator(6/8) q From keys to things : Secret. Factory 는 Secret. Key로부터 Key. Spec 생성하는 방법 소유 v Public final Key. Spec get. Key. Spec(Secret. Key key, Class key. Spec) throws Invalid. Key. Spec. Exception : 주어진 Secret. Key로 부터 Key. Spec 생성. key. Spec 파라메터는 리턴 되는 객체의 형태 결정 Ex) public byte[] make. Bytes. From. DESKey(Secret. Key key) throws No. Such. Algorithm. Exception, Invalid. Key. Sepc. Exception { Secret. Key. Factory des. Factory = Secret. Key. Factory. get. Instance(“DES”); Key. Spec spec = (DESKey. Spec) des. Factory. get. Key(key, DESKey. Spec. class); return spec. get. Key(); } Computer Network Lab. 20
Key Translator(7/8) q. Key. Factory 클래스 : Java. security. Key. Factory 클래스는 Secret. Key. Factory와 유사. 공개키와 개인키에 적용 v. Public static final Key. Factory get. Instance(String algorithm) throws No. Such. Algrithm. Exception : 주어진 알고리즘을 사용하여 새로운 Key. Factory 생성에 사용 : 알고리즘 이름은 비대칭 알고리즘 이름이거나 서명알고리즘(예: DSA)으로 해야함 v. Public static final Key. Factory get. Instance(String algorithm, String provider) throws No. Such. Algrithm. Exception, No. Such. Provider. Exception : 제공된 제공자의 이름을 구현에 사용하여, 새로운 Key. Factory생성 Computer Network Lab. 21
Key Translator(8/8) q Public. Key 또는 Privatekey는 Key. Spec으로 부터의 변환에 generate. Public()와 generate. Private()메소드 사용 v Public final Public. Key generate. Public(Key. Spec key. Spec) throws Invalid. Key. Spec. Exception : 지정된 Key. Spec을 Public. Key 생성에 사용 : 만일 Key. Spec이 Key. Factory에 인정되지 않으면, 예외처리 v Public final Private. Key generate. Private(Key. Spec key. Spec) throws Invalid. Key. Spec. Exception : 지정된 Key. Spec을 개인키 생성에 사용 q Key. Factory는 공개키와 개인키를 동시에 조정하는 get. Key. Spec()을 갖는다 v Public final Key. Spec get. Key. Spec(Key key, Class key. Spec) throws Invalid. Key. Spec. Exception : 지정된 키로 부터 Key. Spec 생성 Computer Network Lab. 22
Key Agreement(1/7) : 두 개 이상의부분에 동일한 secret 값을 소유하게 하는 프로토콜 세션 키에서도 사용 q Diffie-Hellman -가장 널리 사용 됨 - 1976년경 발표 q 특징 : 비안전 채널 사용(예: 인터넷) 인증에는 사용하지 못함 직접적인 키 전송을 하지 않는다 사용자가 n일시, n-1 데이타 교환 필요 q Notation - p : prime number - x m, x r : random number - y = g x mod p Computer Network Lab. - g: primitive mod p - y m, y r : public key x - km= g r x m mod p xm x = yr mod p = ymrmod p 23
Key Agreement(2/7) 1. p와 g 선택. 가입자에게 배포 2. x 선택. y 계산 3. m m ym로빈에게 Marian 전송 Robin 2. x r선택. yr 계산 3. yr 마리안에게 전송 x 4. 동일한 k m g r x m = mod xm p x = yr mod p = ymrmod p 소유 Computer Network Lab. 24
Key Agreement(3/7) q Javax. crypto. Key. Agreement : Javax. crypto. Key. Agreement는 키 agreement 프로토콜을 캡슐화 : Sun. JCE는 Diffie-Hellman이 기반이되된 Key. Agreemnet 제공 q Key. Agreement 객체 획득을 위하여, get. Instance()메소드 사용 v Public static final Key. Agreement get. Instance(String algorithm) throws Nosuch. Algorithm. Exception : 주어진 알고리즘을 사용하여 새로운 Key. Agreement생성 v Public static final Key. Agreement get. Instance(String algorithm, String provider) throws Nosuch. Algorithm. Exception, No. Such. Provider. Exception : 주어진 제공자의 이름으로, 새로운 Key. Agreement 생성 Computer Network Lab. 25
Key Agreement(4/7) q Key. Agreement 초기화 메소드 v. Public final void init (Key key) throws Invalid. Key. Exception : 제공된 키를 사용하여 Key. Agreement 초기화 : 올바른 키 형태가 아니라면 예외처리 발생 v. Public final void init (Key key, Secure. Random random) throws Invalid. Key. Exception : 제공된 키와 난수로 Key. Agreement 초기화 v. Public final void init (Key key, Algorithm. Parameter. Spec params) throws Invalid. Key. Exception, Invalid. Algorithm. Parameter. Exception : 제공된 키와 Algorithm. Parameter. Spec으로 Key. Agreement 초기화 v. Public final void init (Key key, Algorithm. Parameter. Spec params, Secure. Random random) throws Invalid. Key. Exception, Invalid. Algorithm. Parameter. Exception : 제공된 키, Algorithm. Parameter. Spec, Secure. Random로 Key. Agreement 초기화 Computer Network Lab. 26
Key Agreement(5/7) q Public final Key do. Phase (Key key, boolean last. Phase) throws Invalid. Key. Exception, Illegal. State. Exception : 공개 키 값 리턴. last. Phase는 키 agreement가 수행되기 시작한 마 지막 단계 지시 q Secret 값 추출 v Public final byte[] generate. Secret() throws Illegal. State. Exception : secret 값 리턴. Key. Agreement의 모든 단계 미실행시, 예외처리 v Public final init generate. Secret(byte[] shared. Secret, int offset) throws Illegal. State. Exception, Short. Buffer. Exception : offset에서 시작한 배열에 secret 값 write. 배열 길이 불충분시 예외처리 v Public final init generate. Secret(String algorithm) throws Invalid. Key. Exception, Illegal. State. Exception, No. Such. Algorithm. Exception : 주어진 알고리즘으로 Secret. Key에 대한 secret 값 리턴 Computer Network Lab. 27
Key Agreement(6/7) q. SKIP (Simple Key Internet Protocol) Diffie-Hellman 사용 세션 키 사용 로컬 네트워크와 VPN(Virtual Private Key)에서 사용 키 크기에 따른 세가지 다른 베이스와 모듈 제공 q SKIP 베이스와 모듈 값을 위한 클래스를 정의 클래스 { String // 16진법으로 모듈 값을 표시하기 위하여 스트링 정의 모듈 // Big. Integer을 이용하여 모듈 값 생성 베이스 // 베이스 값 생성 저장 // DHParamter. Spec에 모듈과 베이스 값 저장 } Computer Network Lab. 28
Key Agreement(7/7) 서버 1. Key Pair 생성 2. 네트워크 연결 wait 3. 공개 키 수신 클라이언트 1. Key Pair 생성 2. 명령 라인에 host IP와 포트 입력하여 네트워크 연결. 공개 키 전송 4. Key. Factory를 이용 키 재구성 3. 공개키 수신 5. 자신의 공개키 전송 4. Key. Factory를 이용 키 재구성 6. Secret 값 계산 5. Secret 값 계산 7. Secret 값 출력 6. Secret 값 출력 Computer Network Lab. 29
목 차 1. Identity Key Management 의 정의 2. Key Holders - Principal - Identity - Signer - Identity. Scope 4. Key. Manager 구현 Computer Network Lab. 30
The Identity Key Management Paradigm • Identity Key Management 란? – JDK 1. 1에서 java. security. Identity 클래스를 사용한 키관리 * JDK 1. 2 에서는 Keystore-based Key Management 로 바뀜 – 구성 • Identity ; 공개키와 관련정보들을 포함 • Signer ; 공개키와 개인키, 그리고 관련정보들을 포함 • Identity. Scope ; Identity 의 그룹을 표시하며 Identity 객체를 가짐 Computer Network Lab. 31
The Identity Key Management Paradigm Identity Scope (Marian’s computer) Identity Scope (Merry Men) Signer (Marian) Identity (Will) Identity (Tuck) 공개키 기타 정보들 공개키 개인키 기타 정보들 공개키 기타 정보들 Identity (Sheriff) Identity (Robin) 공개키 기타 정보들 Figure : Identity-based key management Computer Network Lab. 32
Java. security For the Identity Key Management Interface Principal Method Identity Constructor identity() identity(String name, Identity. Scope scope) Method get. Public. Key() set. Pulic. Key(Publickey key) add. Certificate(Certificate certificate) remove. Certificate(Certificate certificate) Certificate[] get. Certificates() get. Name() Class Signer Identity. Scope Computer Network Lab. Constructor Signer() Signer(String name, Identity. Scope scope) Method get. Private. Key() set. Key. Pair(Key. Pair pari) Constructor identity. Scope() identity. Scope(String name, Identity. Scope scope) Method add. Identity(Identity identity) remove. Identity(Identity identity) get. Identity(String name) get. Identity(Public. Key key) get. Identity(Principal principal) size() identites() 33
Key Holder • Principal 인터페이스 – Identity 는 java. security. principal 인터페이스로 구현 – Principal 은 단순히 이름을 가져온다 – Method • public abstract String get. Name(); Computer Network Lab. 34
Key Holder • Identity 클래스 – 실제 세계의 실체들(사람이나 조직같은)을 표현 – 키의 소유자 확인 – 이름, 공개키를 증명하는 증명서 포함 – Constructor • public Identity (String name); • public Identity (String name, Identity. Scope scope) throws Key. Management. Exception; Computer Network Lab. 35
Key Holder – Method ( 공개키 관리 ) • public Public. Key get. Public. Key (); • public void set. Public. Key (Public. Key key) throws Key. Management. Exception; ( 증명서 관리 ) • public void add. Certificate (Certificate certificate) throws Key. Management. Exception; • public void remove. Certificate (Certificate certificate) throws Key. Management. Exception; • public Certificate[] get. Certificates (); Computer Network Lab. 36
Key Holder • Signer 클래스 – 개인키 관리를 위해 추가로 제공되는 서브클래스 – Method • public Private. Key get. Private. Key (); • public final void set. Key. Pair (Key. Pair pair) throws Invalid. Parameter. Exception Key. Exception; Computer Network Lab. 37
Key Holder • Identity. Scope – – Identity의 그룹을 표시 Identity의 객체 저장 Identity의 Scope라는 개념을 제시 Identity. Scope 자체가 Identity로 다른 Scope에 속할수 있다 – 공개키, 인증서를 가질수 있다 – Identity 로 부터 상속 받은 클래스이므로 Signer 일수 없다 Computer Network Lab. 38
Key Holder – Method ( Identity 관리 ) • public abstract void add. Identity (Identity identity) throws Key. Management. Exception; • public abstract void remove. Identity (Identity identity) throws Key. Management. Exception; • public abstract int size (); • public abstract Enumeration identites (); • public abstract Identity get. Identity (String name); • public abstract Identity get. Identity (Public. Key key); • public Identity get. Identity (Principal principal); Computer Network Lab. 39
Key. Manager • Key 와 Identity 관리 클래스의 구현 – – – java Key. Manager -c keyfile signer algorithm strength java Key. Manager -e keyfile idname outfile java Key. Manager -i keyfile infile java Key. Manager -r keyfile idname java Key. Manager -l keyfile Computer Network Lab. 40
Key. Manager • 구현된 함수들 – Constructor protected Key. Manager(String name, Key. Pair pair) { super(name); try { set. Public. Key(pair. get. Public()); } catch (Key. Management. Exception kme) {} m. Private. Key = pair. get. Private(); m. Identities = new Hashtable(); } Computer Network Lab. 41
Key. Manager – Name 의 Identity 획득 public synchronized Identity get. Identity(String name) { Enumeration e = m. Identities. elements(); while (e. has. More. Elements()) { Identity i = (Identity)e. next. Element(); if (i. get. Name(). equals(name)) return i; } return null; } public Identity get. Identity(Public. Key key) { return (Identity)m. Identities. get(key); Computer Network Lab. } 42
Key. Manager – Identity 추가 public synchronized void add. Identity(Identity identity) throws Key. Management. Exception { if(m. Identities. contains(identity)) throw new Key. Management. Exception("This Key. Manager already contains " + identity. get. Name() + ". "); if(m. Identities. contains. Key(identity. get. Public. Key())) throw new Key. Management. Exception("This Key. Manager already contains "+ identity. get. Name() + "'s key. "); m. Identities. put(identity. get. Public. Key(), identity); } Computer Network Lab. 43
Key. Manager – Identity 삭제 public synchronized void remove. Identity(Identity identity) throws Key. Management. Exception { Public. Key key = identity. get. Public. Key(); if(m. Identities. contains. Key(key)) m. Identities. remove(key); else throw new Key. Management. Exception("This Key. Manager does not contain "+ identity. get. Name() + ". "); } Computer Network Lab. 44
Key. Manager – 키 획득 public synchronized Public. Key get. Public. Key(String name) { if(name. equals(get. Name())) return get. Public. Key(); return get. Identity(name). get. Public. Key(); } public Private. Key get. Private. Key() { return m. Private. Key; } Computer Network Lab. 45
Key. Manager – Identity 추가 public void add. Identity(String name, Public. Key key) throws Key. Management. Exception { Identity i = new Key. Manager. Identity(name); i. set. Public. Key(key); add. Identity(i); } Computer Network Lab. 46
Key. Manager – 인스턴스 획득 public static Key. Manager get. Instance(String file) throws IOException, Class. Not. Found. Exception { Object. Input. Stream in = new Object. Input. Stream(new File. Input. Stream(file)); Key. Manager km = (Key. Manager)in. read. Object(); in. close(); km. m. Key. File = file; return km; } Computer Network Lab. 47
Key. Manager – Key. Manager 생성 public static Key. Manager create(String file, String name, Key. Pair pair) { Key. Manager km = new Key. Manager(name, pair); km. m. Key. File = file; return km; } Computer Network Lab. 48
Key. Manager – 저장 public synchronized void save() { try { Object. Output. Stream out = new Object. Output. Stream(new File. Output. Stream(m. Key. File)); out. write. Object(this); out. close(); } catch (Exception e) { System. out. println("Key. Manager. save: " + e. to. String()); } } Computer Network Lab. 49
Key. Manager – Key. Manger. Identity private static class Key. Manager. Identity extends Identity { public Key. Manager. Identity(String name) { super(name); } } Computer Network Lab. 50
Key. Manager • Main 함수 java Key. Manager -c keyfile signer algorithm strength if (option. index. Of("c") != -1) { if (args. length < 5) { usage(); return; } String signer = args[2]; String algorithm = args[3]; int strength = Number. Format. get. Instance(). parse(args[4]). int. Value(); System. out. println("Initializing the Key. Pair. Generatro. . . "); Key. Pair. Generator kpg = Key. Pair. Generator. get. Instance(algorithm); kpg. initialize(strength); System. out. println("Generating the key pair. . . "); Key. Pair pair = kpg. gen. Key. Pair(); Key. Manager km = create(keyfile, signer, pair); km. save(); System. out. println("Done. "); } Computer Network Lab. 51
Key. Manager java Key. Manager -e keyfile idname outfile else if (option. index. Of("e") != -1) { if(args. length < 4) {usage(); return; } String idname = args[2]; String outfile = args[3]; Key. Manager km = get. Instance(keyfile); Object. Output. Stream out = new Object. Output. Stream(new File. Output. Stream(outfile)); Public. Key key = km. get. Public. Key(idname); out. write. Object(key); out. close(); System. out. println("done. "); } Computer Network Lab. 52
Key. Manager java Key. Manager -i keyfile infile else if (option. index. Of("i") != -1) { if (args. length < 3) { usage(); return; } String infile = args[2]; Key. Manager km = get. Instance(keyfile); Object. Input. Stream in = new Object. Input. Stream(new File. Input. Stream(infile)); String idname = (String)in. read. Object(); Public. Key key = (Public. Key)in. read. Object(); in. close(); km. add. Identity(idname, key); km. save(); System. out. println("Done. "); } Computer Network Lab. 53
Key. Manager java Key. Manager -r keyfile idname else if (option. index. Of("r") != -1) { if (args. length < 3) { usage(); return; } String idname = args[2]; Key. Manager km = get. Instance(keyfile); Identity i = km. get. Identity(idname); km. remove. Identity(i); km. save(); System. out. println("done. "); } Computer Network Lab. 54
Key. Manager java Key. Manager -l keyfile else if (option. index. Of("1") != -1) { if (args. length < 2) { usage(); return; } Key. Manager km = get. Instance(keyfile); System. out. println("Key. Manager contents of " + keyfile + ": "); System. out. println(" public and private key for " + km. get. Name()); Enumeration e = km. identities(); while (e. has. More. Elements()) { Identity i = (Identity)e. next. Element(); System. out. println(" public key for " + i. get. Name()); } Computer Network Lab. 55
목 차 1. 일반 사항 2. Key. Store 개요 2. 1 Key. Store 구성 2. 2 Key. Store 기능들 2. 3 Key. Store 메소드 설명 3. keytool 개요 3. 1 Keytool 기능들 3. 2 Keytool 기능 설명 4. 요 약 Computer Network Lab. 56
1. 일반 사항 n JDK 1. 2 API l 1. 1에서 제공하던 고급기능과 Public-key Encryption을 더욱 확장, 보안기 능 제공 l JDK 1. 1의 키 관리는 identity-based이며, 1. 2는 java. security. Key. Store 기반 으로 새로운 메소드를 제공 n Key. Store : Private Key와 Public Key, Certificates를 보유하는 handy box 로 한 사람을 증명하기 위하여 요구되는 모든 정보를 포함. l 당신을 다른 이들에게 증명할 필요가 있다. -->서명데이터 개인키 사용, 공개키와 인증서 제공 l 사람들이 합법적임을 확신하도록 만들 필요가 있다. n 키관리 요구사항 l 하나의 개인/공개키 쌍보다 더 많이 소유할 수 있으므로 관리가 요구됨 Computer Network Lab. 57
2. Key. Store 개요 n 두개의 엔트리 형태를 포함 l 개인키 엔트리(Private key entry) Ø 공개키와 매핑되어 일치하는 인증서와 연계된 개인키를 포함. --> 다른 데이터를 서명하고 암호 분배하는데 유용 l 신용 증명 엔트리(trusted certificate entry) Ø 당신이 사실임(신용)을 증명하는 것을 포함한다. Ø 이는 보안 정책 유틸리티, Policytool, 신용 코드 서명자에 대한 보 안 정책 정의와 연계되어 사용될 수 있다. l 별칭들(aliases) 또는 짧은 이름으로 조직 l 엔트리들은 alias, Hashtable 또는 Properties 객체 작업과 유사한 메소드를 사용하여 저장되거나 검출. Computer Network Lab. 58
2. 1 Key. Store 구성 l 두개의 키쌍 엔트리 : 애플릿 서명과 email 메시지들을 서명 l 세개의 서로 다른 인증체인 : Will과 Tuck 그리고 Robin에게 일치하는 인 증 체인 (Marian을 아는 사람들이, 그들의 공개키와 조합하여 사용) l 각 엔트리의 식별 : alias인 “Code. Keys” 또는 “Will. Scarlet” 에 의하여 식 별한다. 세개의 서로 다른 인증체인 Key. Store(Marian’s computer) Code. Keys Will. Scarlet Friar. Tuck Public. Key Private. Key Certificates Certificate Email. Keys Robin. Hood Public. Key Private. Key Certificates 두개의 키쌍 엔트리 Certificate (그림 5 -2) Key. Store 기반 키관리 Computer Network Lab. 59
2. 2 Key. Store 기능들 n n n Getting(획득) Loading and saving(로딩과 저장) Adding private key entries (개인키 엔트리 추가) Adding trusted certificate entry(신용 인증 엔트리 추가) Retrieving entries(엔트리 검출) Computer Network Lab. 60
키관리 및 인증서 발급/ 증명 Flow 인증기관 공개키 및 인증서 등록관리 공개키 등록, CSR/인증서 요구 등록 개인/공개키 생성자, 인증서 작성자. . . Identity -based Singer, Identity. . . 공개키기반 데이터 전송 공개키 분배 공개키 및 인증서 요구 공개키 사용자, 인증서 사용자. . . Key. Store -based. . . Code. Keys, Email. Keys, Certificate. . . 키관리 패러다임 Computer Network Lab. 61
2. 3 Key. Store 메소드 설명(1) n Getting l Key. Store는 abstract class로 get. Instance(); 를 사용하여 실 제적인subclass 얻는다. Public static final Key. Store get. Instance() throws Key. Store. Exception • 이 메소드는 Key. Store 인스턴스를 리턴 l Key. Store의 get. Instance() 메소드는 Key. Store의 subclass를 어떻게 생성할 것인가를 결정하는데 java. security 소유 파일의 라인으로 사용한다. l 만일 라인이 손실된다면, get. Instance()로 기본 Key. Store 구현, sun. security. tools. Java. Key. Store을 사용한다. Computer Network Lab. 62
2. 3 Key. Store 메소드 설명(2) n Loading과 saving l loading과 saving을 지원, passphrase(password)를 통하여 데이터의 무결성 검사 수행 후 저장 public abstract void store(Output. Stream stream, String password) throws IOException, No. Such. Algotithm. Exception, Certificate. Exception l 무결성 검사는 적절하게 구현되었는지, 키 저장 데이터에 속여진 것이 없 다면 일부 보장을 제공하지만 중요하다. 가장 단순한 경우는 키 저장에 따르는 Key. Store의 메시지 다이제스트를 저장한다. l 로딩하였을 때 Key. Store’s 데이터를 기반한 메시지 다이제스트를 최근에 계산된 저장 메시지 다이제스트와 비교할 수 있다. 결과 다이제스트 값을 Key. Store에 저장된다. l 로딩될 때 동일한 비밀번호가 동일한 다이제스트 값을 생성하기 위하여 필요하다. 만일 두 다이제스트 값이 일치하지 않는다면, 비밀번호를 다르 게 사용하였거나 Key. Store데이터가 변경된 것이다. Computer Network Lab. 63
2. 3 Key. Store 메소드 설명(3) n Adding private key entries (개인키 엔트리 추가) l 당신이 가진 키쌍을 Key. Store로 추가하기를 원하는 것이다. l 공개키와 대응되는 개인키와 인증체인을 추가 l 공개키에 포함된 본인서명 인증을 가지고 있다면 인증체인을 추가 Public abstract void set. Key. Entry(String alias, Private. Key key, String passphrase, Certificate[] chain) throws Key. Store. Exception Ø String passphrase(subclass 구현에 따르며, 적절히 지정) Brain-dead protection : 단순스킴, Key. Store 저장시 평문에 passphase와 개 인키를 저장, ㅔpassphrase로 키복구 가능 Weak encryption : passphrase와 개인키가 결함, 스크램블링에 의해 개인키 암호화. 캐주얼 스누피와 아마추어 해커 방지 Computer Network Lab. 64
2. 3 Key. Store 메소드 설명(4) Strong encryption : 가장 좋은 해결책으로 passphrase기반 암호화에 사용됨. (제 7장 참조) 이 스킴에서 passphrase는 세션키를 생성하기 위해 사용되고, 세션키는 대칭 암호에 사용되며, 이는 Key. Store로 저장되기 전에 초기 개 인키를 암호화하기 위해 사용된다. 암호화 알고리즘에 따라서 이는 개인 키를 숨기기에 가장 효과적일 수 있다. l 일찍이 보아 왔던 것 store()와 load()에 대한 passphrase의 사용 과는 다름. 여기서 passphrase 메소드는 전체 키 저장 데이터의 무결성을 보장한다. Computer Network Lab. 65
2. 3 Key. Store 메소드 설명(5) n Adding trused certificate entry(신용 인증 엔트리 추가) l set. Certificate. Entry()를 사용하여 Key. Store로 인증을 추가 Public abstract set. Certificate. Entry(String alias certificate Exception) • 이 메소드는 주어진 인증서와 함께 alias가 추가된다. • 만일 alias가 이미 존재한다면 최근의 인증서는 새로운 것으로 대 체된다. l 당신은 모든 인증 체인에 추가할 수 없다. 만일 당신이 누군가 의 공개키와 일치하는 인증 체인을 수신한다면, 당신은 신용 인증 엔트리로 체인에 각 인증서를 추가할 수 있다. Computer Network Lab. 66
2. 3 Key. Store 메소드 설명(6) n Retrieving entries(엔트리 검출) l 다른 사람들의 공개키에 포함하는 인증서들을 보유함. l Get 메소드로 검출 Public abstract Private. Key get. Private. Key(String alias, String passphrase) throws No. Such. Algorithm. Exception, Unrecoverable. Key. Exception l 당신은 alias와 관련된 개인키를 검출하기 위하여 이 메소드 를 사용할 수 있다. 주어진 passphrase는 개인키를 적용하여 보호(protection)하는 것을 취소(undo)하기 위해 사용된다. Computer Network Lab. 67
3. keytool 개요 n Keytool은 java. security. Key. Store 클래스에 대한 명령 라인 인터페이스이다. l Key. Store 개념 Ø 개인키, 공개키와 인증에 대한 단순 database이며, 엔트리는 alias으로 식별 및 참조한다. Ø 기본적으로 Key. Stores는 hard disk에 파일로 저장, 하나의 파일 이 Key. Store로 적합 n keytool 활용(기본 구현으로 변화될 것임) Ø Key. Store는 파일 다수개를 관리하는데 사용될 수 있다. Ø 만약 당신이 keytool을 사용할 때 Key. Store 파일을 명시하지 않 았다면 사전 설정된 파일이 사용, Ø 이 는. key. Store파 일 로 불 리 게 되 며 HOMEDRIVE와 HOMEPATH 환경변수에 의해 결정된 디렉토리에 놓여진다. 또는. key. Store 는 JDK 설치디렉토리에 위치한다. Computer Network Lab. 68
3. 1 keytool 기능들 n Creating a key pair(키쌍 생성) n Ubiquitous options and defaults (어디서나 있는 옵션과 기본설정) n Inspecting the Key. Store (키 저장 면밀검사) n Generating a CSR(Certificate Signing Request 생성) n Importing certificates (인증서 불러오기) n Other options (다른 옵션들) n Changing the default Key. Store class (기본설정 키 저장 클래스 변경) Computer Network Lab. 69
3. 2 Keytool 기능설명(1) n Creating a key pair(키쌍 생성) l 당신은 –genkey 명령 옵션을 사용하여 키쌍을 생성 C: keytool –genkey –alias Jonathan –keyalg DSA –keysize 1024 –dname “CN=Jonathan Knudsen, OU=Technical Publications, O=O’Reilly & Associates, C=US” –keypass buendia –storepass buendia C: - dname Ø 이 엔트리는 뚜렷한 이름(DN: distinguished name)*을 명시(선택적으로 사 용가능) ÕCN(공용 이름) : 당신의 이름 ÕOU(조직 단위) 당신이 속하는 당신 조직의 부서 ÕO(조직) : 당신의 조직 ÕL(위치) : 통상, 시 ÕS(정부) : 정부 또는 주 ÕC(나라) : 나라 Computer Network Lab. 70
3. 2 Keytool 기능설명(2) - keypass Ø 이 단계는 새로운 키쌍의 개인키를 보호하기 위해 사용된다. 주) 누구든지 당신의 어깨 넘어로 비밀번호를 볼 수 있을 것이다. 추 가적으로 Key. Store 구현에 적용될 실질적인 보호를 당신은 사용 하여야 한다. - storepass Ø 이 passphrase는 전체 키 저장의 무결성을 보장한다. 때문에 새로 운 키 저장을 생성하기 위하여 –genkey 옵션을 사용하며, 이 옵션 으로 Key. Store의 passphrase를 설정한다. 이후에 Key. Store에 따른 동작은 동일한 passphrase 타이프를 요구한다. Computer Network Lab. 71
3. 2 Keytool 기능설명(3) n Ubiquitous options and defaults (어디서나 있는 옵션과 기본설정) l keytool의 다양한 옵션들은 어느 명령어와 함께 사용할 수 있 다. 이것들은 –keystore, -storepass, 그리고 –v가 있다. l keytool은 당신이 필요로 하는 것 여러 경우에 있어서, 옵션을 잃어버리더라도 기본설정이 있어서 관대하다. 만일 없다면, keytool은 당신이 잃어버린 정보를 즉시 알려 줄 것이다. <표 5 -1> keytool 옵션들의 기본설정 값 Computer Network Lab. 72
3. 2 Keytool 기능설명(4) n Inspecting the Key. Store (키 저장 면밀검사) l Key. Store의 내용을 보기 위하여 –list 명령을 사용한다. C: keytool –list –storepass buendia Your Key. Store contains 1 entry: jonathan, Mon Jan 12 16: 59 EST 1998, Key. Entry, Certificate MD 5 56: E 0: FD: 24: 13: 6 c: 51: C 0: D 9: 57: B 4: 33: 7 F: 79: A 8: a 4 Fingerprint: C: l –v 옵션을 –list와 함께 사용한다면, 당신은 더 많은 상세 정보를 출력 l 궁극적으로 하나의 Key. Store 엔트리를 보기 위하여 –alias옵션을 사용. C: keytool –list –alias Jonathan –storepass buendia Computer Network Lab. 73
3. 2 Keytool 기능설명(5) n Generating a CSR(인증 서명 요구서 생성) 실제적인 인증서를 얻기 위하여, 당신은 CSR 생성을 요구하면, 인증 기관 (CA)에 의해 서명된다. (signed) CSR은 당신에 관한 공개키와 정보를 포함하는 특별한 파일임 이는 당신의 개인키로 서명된다. 당신이 CSR을 CA로 송부할때, CA는 당신의 신원(identity)를 검사하고 CSR 의 권한 부여를 증명(Authenticity)하기 위하여 노력할 것이다. 그리고 당신의 인증함을 알리고, CA의 Private key로 서명하여, 당신의 공개 키를 확인(verifies)한다. l CSR을 생성하기 위하여 -csr 명령을 선택적으로 사용한 예제 C: keytool -csr -alias Jonathan -file Jonathan. csr -keypass buendia -storepass buendia -v Certification request stored in file <Jonathan. csr>. Submit this to your certificate authority. C: type Jonathan. csr (base 64 data 출력결과 page 88 참조) Computer Network Lab. 74
3. 2 Keytool 기능설명(6) n Importing certificates (인증서 불러오기) l Key. Store로 인증서를 불러오는 두 가지 이유가 존재한다. Ø 첫번째 경우, 당신은 CSR에 대한 응답으로 CA로부터 인증서를 수 신할 수 있다. 이 경우에 당신의 CSR을 생성하기 위하여 사용한 개 인키 엔트리로 인증관계를 요구할 것이다. Ø 두번째 경우, 그 밖의 다른 사람의 trusted certificate entry를 만들기 위 하여 인증서를 불러온다. l 다른 경우 keytool의 –import 명령 옵션 사용 Ø keytool은 RFC 1421에서 기술된 것과 같이 “printable encoding”에 대 해, 어떻게 X. 509 인증서를 Import하는지를 안다. 이 포맷은 header line과 footer line이 있으며, body는 base 64 data이다. (base 64에 관한 좀 더 상세한 정보는 제 1장과 부록B를 참조한다. ) --> (base 64 data 출력결 과 page 88 참조) Computer Network Lab. 75
3. 2 Keytool 기능설명(7) n Other options (다른 옵션들 ) -selfcert : 개인키 엔트리에 대한 자신의 서명 인증을 keytool로 재생성, 개인키 엔트리를 별도의 이름(Distinguished Name)으로 변경, 옵션은 <표 5 -2>의 –genkey와 같이 대부분의 동일한 옵션들을 허용 -export : 파일에 인증서를 보관(save)하기 위해 내보낸다. 엔트리를 명시 하기 위하여 –alias 옵션을 사용, 출력 파일을 명시하기 위하여 –file 옵 션을 사용한다. -printcert : 파일에 포함된 인증서에 관한 정보를 출력한다. 단순하게 파 일 이름을 명시하는 것은 –file을 사용한다. 이 명령은 Key. Store 데이 터를 사용하거나 변경하지 않는다. -keyclone : 개인키 키저장 엔트리를 복사한다. -alias, -dest, -keypass, -new 옵션들을 허용한다. Computer Network Lab. 76
3. 2 Keytool 기능설명(8) -storepasswd : 키 저장에 대한 비밀번호를 변경한다. 모든 다른 명령들과 같이 초기 키저장 비밀번호를 –storepass를 사용하여 새로 명시한다. 새로운 키저장 비밀번호는 –new 옵션을 사용하여 명시한다. -keypasswd : 키 저장에서 개인키 엔트리에 대한 비밀번호를 변경한다. 이는 <표 5 -4>에서 나열한 옵션들을 사용한다. -delete : 키 저장으로부터 엔트리 제거(remove). 엔트리를 명시하기 위해 –alias 옵션을 사용한다. -help : 이 명령 옵션은 모든 keytool의 옵션들의 리스트를 출력한다. Computer Network Lab. 77
3. 2 Keytool 기능설명(9) n Changing the default Key. Store class (기본설정 키 저장 클래스 변경) l 기본설정 keytool은 sun. security. tools. Java. Key. Store을 사용하여 작성한 다. 만일 당신이 자신만의 Key. Store 구현을 write 한다면, 당신은 당신 의 키와 인증서들을 관리하기 위하여 keytool을 사용할 수 있다. 당신 은 JDK 설치 디렉토리 밑의 lib/security를 찾고, java. security파일의 한 라인을 변경이 필요하다. Key. Store=sun. security. tools. Java. Key. Store l 만일 당신의 Key. Store oreilly. jonathan. security. Super. Duper. Key. Store로 구현한다면, 예제와 같이 변경이 요구된다. Key. Store=oreilly. jonathan. security. Super. Duper. Key. Store Computer Network Lab. 78
4. 요 약 n 본 5장을 통하여, Key 관리에 기본개념을 분석함 n 키생성, 분배, 동의, identity-based, Key. Store-based의 각 단 계의 개념과 프로그램을 파악 n 키관리 및 인증서 발급/증명 Flow 참조(7쪽) Computer Network Lab. 79
0c1d965624f95f53a0c527b9a1ca967e.ppt