150 likes | 464 Views
Java - Security. 발표자 : 황영덕 발표일 : 2003-09-23 WMLAB. 차례. Model APIs. Java 1.2 Security Model. History. J2SE 1.3 Platform: Security Support for RSA signatures Interoperate with Netscape signtool Interoperate with VeriSign certificates Support X.520 attributes( 파기 )
E N D
Java - Security 발표자 : 황영덕 발표일 : 2003-09-23 WMLAB
차례 • Model • APIs
History • J2SE 1.3 Platform: Security • Support for RSA signatures • Interoperate with Netscape signtool • Interoperate with VeriSign certificates • Support X.520 attributes(파기) • JAAS 1.0(Java Authentication and Authorization Service API) • JCE 1.2.1(Java Cryptography extensions) • JSSE 1.0.1 (Java Secure Socket Extensions) • Standard socket APIs for SSL and TLS
Etc. Fig. JSSE 1.0.1 Fig. CertPath Fig. Kerberos
Java Cryptography Architecture (java.security) • (1) MessageDigest Class • SHA-1, MD5, MD2, SHA-256, SHA-384, SHA-512 • (2) Signature Class • MD2withRSA, MD5withRSA, SHA1withDSA, SHA1withRSA • (3) AlgorithmParameters Class • (4) AlgorithmParameterSpec Class • (5) Key Interface • (6) PrivateKey, PublicKey Interface • (7) KeyFactory Class • DSA, RSA, DiffieHellman • (8) KeyPairGenerator Class • (9) SecureRandom Class • SHA1PRNG • (10) CertificateFactory Class • X.509
Javax.crypto • (1) Cipher Class • AES, Blowfish, DES, DESede, PBEWith<Digest>And<암호화>, PBEWith<유사난수함수>And<암호화>, RC2, RC4, RC5, RSA • (2) KeyGenerator Class • AES, Blowfish, DES, DESede, HmacMD5, HmacSHA1 • (3) SecretKeyFactory Class • AES, DES, DESede, PBEWith<다이제스트>And<암호화>, PBEWith<유사난수함수>And<암호화> • (4) Mac Class • HmacMD5, HmacSHA1, PBEWith<MAC알고리즘>
제한없는 암호화의 사용 • 기본 포함된 암호화 정책은 미국의 수출 규제 정책에 따라 제한적 알고리즘만 제공 • 수출규제 정책이 완화되어 일부 강력한 알고리즘을 사용할 수 있는 정책파일을 별도로 다운로드하여야한다. • Jce_policy-1_4_1.zip • US_export_policy.jar • Local_policy.jar • $(JRE_HOME)\lib\Security 디렉토리의 있는 정책파일을 대체하면 된다.
암호화 키 관리 • 암호화 키를 안전하게 저장하고 보호함. • Keystore • 구현 방식에 따라 JKS, JCEKS, PKCS12 • 기본: JKS • Sun의 JCE : JCEKS(3DES기반) • Public final void load(InputStream, char[] password) • Public final void store(OutputStream, char[] password) • Keytool 유틸리티 • -genkey : 키를 생성하여 키스토어에 저장한다. • -import : 인증서 혹은 인증서 체인을 가져와 키스토어에 저장한다. • -selfcert : 자체 서명한 인증서를 생성하여 키스토어에 저장한다. • -certreq : 인증서 서명 요청을 생성하여 키스토어에 저장한다. • -storepasswd : 무결성 검사하는데 사용되는 패스워드 변경 • -keypasswd : 개인키를 보호하는 패스워드 변경
SSL(SecureSocketLayer) • TLS(Transport Layer Security)로 이름이 변경되어 인터넷 표준이됨. • JSSE(Java Secure Socket Extension) • SSL규약을 준수하는 자바 보안 소켓 확장 • 기능 • 서버인증 : 공개키 알고리즘을 사용하여 서버의 인증서가 유효한지 등을 검사하여 서버를 인증한다. • 클라이언트 인증 : 서버가 클라이언트를 인증. 특별한 경우가 아니면 생략 • 암호화된 연결 : 서로 주고받는 데이터의 암호화
JSSE API • Javax.net.ssl • (1) KeyManagerFactory Class • 자신의 키를 관리하는데 사용 • (2) TrustManagerFactory Class • 상대방 키를 관리하는데 사용 • (3) SSL Context Class • 상단의 두객체들의 보안 난수 객체를 사용하여 SSLServerSocketFactory 와 SSLSocketFactory 객체를 생성
public class SecretWriting { public static void main (String[] args) throws Exception { … // Key를 얻거나 생성한다 Key key; try { ObjectInputStream in = new ObjectInputStream (new FileInputStream("SecretKey.ser")); key = (Key) in.readObject(); in.close(); } catch (FileNotFoundException fnfe) { KeyGenerator generator = KeyGenerator.getInstance("DES"); generator.init(new SecureRandom()); key = generator.generateKey(); ObjectOutputStream out = new ObjectOutputStream (new FileOutputStream("SecretKey.ser")); out.close(); } // Cipher 객체를 얻는다 Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); // 문자열을 암호화하거나 복호화 한다 … cipher.init(Cipher.ENCRYPT_MODE, key); … BASE64Encoder encoder = new BASE64Encoder(); //RFC1521 … cipher.init(Cipher.DECRYPT_MODE, key); BASE64Decoder decoder = new BASE64Decoder(); }