Xây dựng hệ thống quản lý chứng chỉ số sử dụng công nghệ IAIK và SSL

120 35 0
Xây dựng hệ thống quản lý chứng chỉ số sử dụng công nghệ IAIK và SSL

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

ĐẠI HỌC CÔNG NGHỆ ĐẠI HỌC QUỐC GIA HÀ NỘI VŨ VĂN TRIỆU XÂY DỰNG HỆ THỐNG QUẢN LÝ CHỨNG CHỈ SỔ SỬ DỤNG CÔNG NGHỆ IAIK VÀ SSL LUẬN VĂN TH.S CÔNG NGHỆ THÔNG TIN Ngưới hướng dẫn:PGS.TS Trịnh Nhật Tiến Hà Nội 2007 MỤC LỤC LỜI CẢM ƠN CÁC THUẬT NGỮ VIẾT TẮT MỞ ĐẦU Chương CÁC KHÁI NIỆM CƠ BẢN 10 1.1 HỆ MÃ HÓA KHÓA ĐỐI XỨNG (Symmetric Key Cryptosystems) 10 1.1.3 Hệ mã hóa RC2 14 1.1.4 Hệ mã hóa RC4 18 1.1.5 Hệ mã hóa IDEA 19 1.1.6 Giao thức trao đổi khóa 22 1.2 HỆ MÃ HĨA KHĨA CƠNG KHAI 24 1.2.1 Khái niệm mã hóa cơng khai 24 1.2.2 Hệ mã hóa RSA 28 1.2.3 Các vấn đề liên quan đến hệ mã hóa RSA 30 1.3 GIAO THỨC SSL 32 1.3.1 Giới thiệu giao thức SSL 32 1.3.2 Vị trí tầng giao thức SSL 33 1.3.3 Hoạt động giao thức SSL 34 Chương VẤN ĐỀ CÔNG NGHỆ CỦA 41 CƠ SỞ HẠ TÂNG MẬT MÃ KHĨA CƠNG KHAI 41 2.1 GIỚI THIỆU 41 2.1.1 Khái niệm sở hạ tầng mật mã khóa cơng khai 41 2.1.2 Tình hình sử dụng chứng khóa cơng khai 43 2.2 CHỨNG CHỈ KHĨA CƠNG KHAI 50 2.2.1 Định dạng X.509 chứng số 50 2.2.2 Đường chứng thực tin tưởng 52 2.2.3 Các trường chứng số 52 2.2.3.1 Trường tbsCertificate 53 2.2.3.2 Trường signatureAlgorithm 54 2.2.3.3 Trường signatureValue 54 2.2.3.4 Trường version 54 2.2.3.5 Trường serialNumber 54 2.2.3.6 Trường signature 54 2.2.3.7 Trường issuer 55 2.2.3.8 Trường validity 56 2.2.3.9 Trường subject 56 2.2.3.10 Trường subjectPublicKeyInfo 56 2.2.4 Định dạng PEM chứng số 57 2.2.5 Mô hình quản lý chứng số 58 2.2.5.1 Đối tượng sử dụng 59 2.2.5.2 Thành phần CA 60 2.2.5.3 Thành phần RA 60 2.2.5.4 Kho thông tin 61 2.2.5.5 CRL Ủy quyền 61 2.2.6 Các chức quản lý chứng số 61 2.2.6.1 Đăng ký 61 2.2.6.2 Khởi tạo 62 2.2.6.3 Chứng thực 62 2.2.6.4 Phục hồi cặp khóa 62 2.2.6.5 Cập nhật cặp khóa 62 2.2.6.6 Yêu cầu thu hồi 63 2.2.6.7 Chứng thực chéo 63 2.2.6.8 Các chức thêm 63 2.2.7 Các giao thức quản lý chứng số 64 Chương THỬ NGHIỆM XÂY DỰNG HỆ THỐNG QUẢN LÝ CHỨNG CHỈ SỐ 65 3.1 TỔNG QUAN 65 3.2 YÊU CẦU 68 3.3 PHÂN TÍCH 70 3.3.1 Hoạt động hệ thống 70 3.3.2 Xem xét hệ thống góc độ khách hàng sử dụng 71 3.3.3 Xem xét hệ thống góc độ quản trị hệ thống 75 3.3.4 Hiện thực hoá hệ thống CA 78 3.4 Công cụ hỗ trợ PKI :IAIK 80 3.4.1 Giới thiệu chung IAIK 80 3.4.2 Sử dụng IAIK xây dựng hệ thống 81 3.5 HỆ THỐNG QUẢN LÝ CHỨNG CHỈ SỐ 83 3.5.1 Mơ hình phân cấp hệ thống 84 3.5.2 Một số chức hệ thống 85 3.5.2.1 Cấp 85 3.5.2.2 Gia hạn thay 86 3.5.2.3 Xem trạng thái yêu cầu 87 3.5.2.4 Tìm kiếm, xem trạng thái lấy chứng số 87 3.5.2.5 Xem cài đặt chuỗi chứng thực 88 3.5.2.6 Xem cài đặt danh sách chứng số bị thu hồi 88 3.5.2.7 Đăng ký thu hồi 89 3.5.2.8 Quản trị hệ thống 89 KẾT LUẬN 91 TÀI LIỆU THAM KHẢO 92 PHỤ LỤC 93 CÁC THUẬT NGỮ VIẾT TẮT CA – Certification Authority Thực thể có thẩm quyền chứng thực, thực thể PKI có chức cấp chứng số ASN.1 – Abstract Syntax Notation One Là ngơn ngữ hình thức mơ tả thông điệp trao đổi phạm vi rộng các dụng môi trường Internet, mạng thông minh, mạng di động, thương mại điện tử… BER – Basic Encoding Rules Luật mã hóa Một luật mã hóa sử dụng thập kỷ 80 Nó đơn giản, thơ, khơng có hiệu CRL – Certificate Revocation List Danh sách chứng số bị thu hồi hay khơng cịn hợp lệ DER – Distinguished Encoding Rules Luật mã hóa phân biệt Luật mã hóa khơng có tùy chọn đơn giản, thơ khơng có hiệu Luật mã hóa DER diễn giải thành phần tùy chọn, ví dụ: định nghĩa chiều dài hay không, lựa chọn kiểu Digital Certificate Chứng số, cấu trúc liệu sử dụng PKI để gắn thông tin xác thực đối tượng vào khóa cơng khai đối tượng Nó có nhiều cách gọi khác: certificate, public key certificate Digital Signature Chữ ký điện tử, kỹ thuật sử dụng mã khóa cơng khai cho phép khơng thể giả mạo thông điệp DSA – Digital Signature Algorithm Một thuật tốn sử dụng cho cơng nghệ chữ ký điện tử định nghĩa NIST LDAP - Lightweight Directory Access Protocol LDAP dịch vụ thư mục IETF dùng rộng rãi Internet PEM - Privacy Enhanced Mail PEM chuẩn Internet dùng để trao đổi bảo mật thư tín điện tử PKI – Public key Cryptography Infrastruture Cơ sở hạ tầng mã khóa cơng khai, hệ thống sử dụng hệ mã khóa cơng khai cho việc chứng thực, đảm bảo bí mật tồn vẹn thơng tin PKIX - Public key Cryptography Infrastruture X.509 Cơ sở hạ tầng mã khóa cơng khai dựa X.509 nhóm IETF đưa để áp dụng PKI cho Internet PKCS – Public key Cryptographic Standards Các chuẩn mã hóa khóa cơng khai Đây chuẩn RSA Laboratories định nghĩa Private Key Khóa riêng, hai khóa cặp khóa hệ mã hóa bất đối xứng Public Key Khóa cơng khai, khóa cịn lại cặp khóa tương ứng với Private key Message Digest Dạng băm thông điệp Phương pháp băm liệu sử dụng thuật tốn chiều, từ liệ băm khơng thể xác định liệu gốc Chiều dài kết băm (tính byte) cố định thuật toán băm RA – Registration Authority Thực thể CA ủy quyền quản lý việc đăng ký RFC – Requests for Comments Là cơng bố thức mạng Internet , đươ ̣c sử du ̣ng từ năm 1969 để mô tả và tiế p thu những nhâ ̣n xét về các giao thức , thủ tục, chương triǹ h và các khái niệm RSA Một hệ mã khóa cơng khai đầu tiên, cơng bố vào năm 1983 RSA nhà khoa học Rivest, Shamir Adleman tìm X.500 Đây chuẩn định nghĩa dịch vụ thư mục, bao gồm chứng số X.501 Định nghĩa trường giá trị tương ứng đăc tả dịch vụ thư mục X.509 Chuẩn định dạng chứng số, ITU ban hành Ciphertext Bản mã Plaintext Bản rõ IAIK Institute for Applied Information Processing and Communication : Cung cấp Crypto toolkit viết ngôn ngữ Java MỞ ĐẦU Cuộc cách mạng công nghệ thông tin Sự đời phát triển nhanh chóng cách mạng cơng nghệ thơng tin đem lại lực phát triển cho xã hội Mọi người sử dụng máy tính tận hưởng thành hệ thống truyền thông cách vơ thức để đạt mục đích mà không cảm nhận rõ rệt hữu chúng Điều khẳng định ảnh hưởng cách mạng công nghệ thông tin sâu đậm, để lại dấu ấn hành vi cá nhân hàng ngày, hàng Xã hội số hố Vai trị chủ đạo mạng nói chung Internet nói riêng rõ ràng kinh tế giới Trên nó, xã hội số hố hay cịn biết tên gọi khơng gian điều khiển hình thành khơng ngừng lớn rộng dần Trong giới ảo này, phương tiện, nghi thức, quy ước, luật lệ loài người dần tái sáng tạo An toàn bảo mật Một thách thức lớn mở rộng tầm ảnh hưởng xã hội số hoá thời gian gần vấn đề an toàn bảo mật Nói nơm na làm để ngăn ngừa hành vi truy nhập bất hợp pháp chế ngự loại tội phạm tin học (điều dự đốn trước xã hội khơng thể phát triển mà không dựa tảng pháp luật) Chúng tồn dạng nguy khác nhau, từ nghe trộm, sửa đổi trái phép thông tin giả mạo, gian lận thương mại Đa phần nguy bắt nguồn từ chất phân tán mạng Internet, nơi thành viên tham gia không tiếp xúc vật lý trực tiếp với (như giới thực) thông tin giao dịch buộc phải lưu chuyển qua nhiều trạm trung chuyển không nằm kiểm soát cá nhân Đơn giản, ta tưởng tượng giao dịch chuyển tiền trị giá 1.000.000$ khó lịng thực qua mạng khơng đảm bảo khơng xâm nhập để sửa đổi nghe trộm thông tin Như vậy, nhu cầu an toàn bảo mật kênh truyền tin thiết thực xúc, trở thành vấn đề thời đòi hỏi giải triệt để có hệ thống Chứng số công cụ để thực an tồn bảo mật hệ thống thơng tin Các mục tiêu chung hệ thống bảo mật đảm bảo:  Tính bí mật (Secrecy hay Confidential): Tài nguyên truy cập người có thẩm quyền  Tính tồn vẹn (Accuracy, Integrity, Authencity): Tài nguyên sửa đổi người có thẩm quyền  Tính khả dụng (Avaiability): Tài ngun (thơng tin, dịch vụ) sẵn sàng đáp ứng cho người có thẩm quyền Vì việc xây dựng Hệ Thống Quản Lý Chứng Chỉ Số cần thiết, quan trọng tất yếu Trên giới có nhiều tổ chức khác xây dựng hệ thống Verisign, GlobalSign , RSASecurity… Do tính tất yếu việc xây dựng Hệ Thống Quản Lý Chứng Chỉ Số Việt Nam vô quan trọng đóng vai trị định phát triển công nghệ thông tin nước nhà Luận văn nghiên cứu xây dựng hệ thống quản lý chứng số dựa công nghệ SSL IAIK Đồng thời đưa giải pháp công nghệ cho ứng dụng thực tế liên quan đến chứng số Luận văn bao gồm chương: Chương 1: Trình bày khái niệm bản: mã hóa đối xứng, mã hóa khóa cơng khai, giao thức SSL Chương 2: Trình bày số vấn đề công nghệ sở hạ tầng mật mã khóa cơng khai Chưong 3: Trình bày việc thử nghiệm xây dựng hệ thống cung cấp quản lý chứng số Chương CÁC KHÁI NIỆM CƠ BẢN 1.1 HỆ MÃ HÓA KHÓA ĐỐI XỨNG (Symmetric Key Cryptosystems) 1.1.1 Khái niệm mã hóa khóa đối xứng Để đảm bảo tính bí mật, thơng điệp kênh truyền tin cần phải mã hố Mơ hình truyền tin có bảo mật xem xét sau: Người gửi Mã hóa Kênh truyền tin Người nhận Giải mã Hình 1-1 Mơ hình truyền tin có bảo mật Cơ chế hoạt động: Người phát tin S muốn gửi thông tin X tới người nhận R qua kênh truyền tin, “đối tượng thứ 3” E nghe trộm để lấy thông tin X S sử dụng phép mã hố thơng tin X, để tạo đoạn mã Y khó đọc Y che giấu nội dung thông tin X Khố thơng số điều khiển phép biến đổi Giải mã trình ngược lại cho phép người nhận thu thông tin ban đầu X từ đoạn mã Y Nếu biết khóa lập mã, dễ dàng tính khóa giải mã ngược lại, hệ mã hố gọi hệ mã khố đối xứng( số hệ mã hóa khóa đối xứng, khóa lập mã khóa giải mã trùng nhau) 10 1.1.2 Hệ mã hóa DES (Data Encryption Standard) Chuẩn mã hoá liệu DES hãng IBM đề xuất năm 1974 gây tiếng vang lớn nhanh chóng sử dụng rộng rãi, đến năm 1977 chấp nhận chuẩn liên bang Mỹ Với DES liệu mã hoá theo khối 64-bits sử dụng khoá 56-bits Thuật toán chuyển đổi 64-bits đầu vào qua dãy bước đưa 64-bits mã hoá Sơ đồ mã hóa DES: Việc mã hố DES thực theo pha với hai đầu vào Dữ liệu cần mã hoá khoá Dữ liệu vào phải khối 64-bits khoá 56-bits (thực tế 64 bits khoá đưa vào hàm xử lý, nhiên có 56 bits sử dụng cho mã hố bits lại sử dụng cho parity kiểm tra chẵn lẻ) 64-bits tin rõ (plaintext) đưa qua chế hoán vị ban đầu (IP- initial permutation) sau chúng phải qua 16 vịng lặp với chức bao gồm hàm hoán vị thay Sau 16 vòng lặp thu 64-bits liệu tổ hợp tin rõ khóa phải qua đổi chỗ 32-bit, hoán vị ngược (IP1 ) với hoán vị ban đầu để mã 56 – bit key Hoán vị chọn 64-bit plaintext Hoán vị ban đầu Dịch trái Lặp Hoán vị chọn Dịchtrái Lặp Hoán vị chọn Dịch trái Lặp 16 Hoán vị chọn Dịch trái Đổi chỗ 32 -bit Hốn vị ngược Hình 1-2 Mã hóa DES 64-bit ciphertext 11 return keys; } catch(SQLException e) { throw new EJBException(" ejbFindInfoCount Error executing " + e.toString()); } finally { closeConnection(connection, statement); } } void closeConnection(Connection connection, Statement statement) { try { if (statement != null) { statement.close(); } } catch(SQLException e) { } try { if (connection != null) { connection.close(); } } catch(SQLException e) { } } 107 public void setEntityContext(EntityContext entityContext) { super.setEntityContext(entityContext); try { try { dataSource =Common.getDataSource(); } catch(Exception e) { throw new EJBException("Error looking up dataSource: " + e.toString()); } } catch(Exception e) { throw new EJBException("Error initializing context:" + e.toString()); } } public void unsetEntityContext() { super.unsetEntityContext(); this.entityContext = null; }} 108 2) Các modul liên quan đến việc tạo chứng chí số package vasc.ca.security.interfaces; /** *

Title:

*

Description:

*

Copyright: Copyright (c) 2002

* @author Vu Van Trieu * @version 1.0 */ import iaik.x509.*; import java.io.*; import java.math.*; import java.rmi.*; import javax.ejb.*; import java.security.*; import iaik.asn1.structures.*; import iaik.asn1.*; import java.util.*; import iaik.x509.extensions.*; public class iCATool { public static final boolean CA_CERT = true; public static final boolean USER_CERT = false; public static final int DER=1; public static final int PEM=2; public static final int MD5withRSA = 1; public static final int SHA1withRSA = 2; public static final int dsaWithSHA = 3; public static final int dsaWithSHA1 = 4; protected PrivateKey privateKey=null; protected PublicKey publicKey=null; protected X509Certificate certificate=null; protected int algorithm=1; protected BigInteger serial; protected String keyAlgorithm="RSA"; protected int keyLen=512; protected boolean selfCreateKeyPair=false; protected Name name; protected String idCardNum=null; 109 protected Date idCardIssueDate=null; protected String ks_alias; protected String ks_filename; protected String ks_pwd; protected String ks_provider; protected String ks_type; protected java.util.Date validFrom; protected java.util.Date validTo; protected byte[] cert_temp; protected boolean subCritical=false; protected boolean auCritical=false; protected boolean idCardNumCritical = false; protected byte[] ks_data; public PrivateKey getPrivateKey() { return privateKey; } public PublicKey getPublicKey() { return publicKey; } public boolean getSelfCreateKeyPair() { return selfCreateKeyPair; } public BigInteger getSerial() { return serial; } public void setPrivateKey(PrivateKey privateKey) { this.privateKey = privateKey; } public void setPublicKey(PublicKey publicKey) { this.publicKey = publicKey; } public void setSelfCreateKeyPair(boolean selfCreateKeyPair) 110 { this.selfCreateKeyPair = selfCreateKeyPair; } public void setSerial(BigInteger serial) { this.serial = serial; } public byte[] getCertificate() throws EJBException { ByteArrayOutputStream out = null; try { out = new ByteArrayOutputStream(1024); this.certificate.writeTo(out); } catch(Exception e) { throw new EJBException(e.getMessage()); } return out.toByteArray(); } public int getAlgorithm() { return algorithm; } public int getKeyLen() { return keyLen; } public void setAlgorithm(int algorithm) { this.algorithm = algorithm; } public void setKeyLen(int keyLen) { this.keyLen = keyLen; } public void setKeyAlgorithm(String keyAlgorithm) { 111 this.keyAlgorithm = keyAlgorithm; } public String getKeyAlgorithm() { return keyAlgorithm; } //E,CN,UID,OU,O,C public void setSubjectInfo( String emailAddress, String commonName, String organizationalUnit, String organization, String stateOrProvince, String locality, String country) { if (commonName==null || commonName.equals("")) { name=null; return; } name = new Name(); if (country!=null && !country.equals("")) name.addRDN(ObjectID.country, country); if (locality!=null && !locality.equals("")) name.addRDN(ObjectID.locality, locality); if (stateOrProvince!=null && !stateOrProvince.equals("")) name.addRDN(ObjectID.stateOrProvince, stateOrProvince); if (organization!=null && !organization.equals("")) name.addRDN(ObjectID.organization, organization); if (organizationalUnit!=null && !organizationalUnit.equals("")) name.addRDN(ObjectID.organizationalUnit, organizationalUnit); if (emailAddress!=null && !emailAddress.equals("")) name.addRDN(ObjectID.emailAddress, emailAddress); if (commonName!=null && !commonName.equals("")) name.addRDN(ObjectID.commonName, commonName); } public void addName(int oid, String name) { if (this.name==null) this.name = new Name(); switch(oid) { case iName.commonName: this.name.addRDN(ObjectID.commonName,name); break; case iName.country: this.name.addRDN(ObjectID.country,name); 112 break; case iName.emailAddress: this.name.addRDN(ObjectID.emailAddress,name); break; case iName.locality: this.name.addRDN(ObjectID.locality,name); break; case iName.organization: this.name.addRDN(ObjectID.organization,name); break; case iName.organizationalUnit: this.name.addRDN(ObjectID.organizationalUnit,name); break; case iName.stateOrProvince: this.name.addRDN(ObjectID.stateOrProvince,name); break; case iName.streetAddress: this.name.addRDN(ObjectID.streetAddress,name); break; case iName.surName: this.name.addRDN(ObjectID.surName,name); break; case iName.title: this.name.addRDN(ObjectID.title,name); break; case iName.unstructuredAddress: this.name.addRDN(ObjectID.unstructuredAddress,name); break; case iName.unstructuredName: this.name.addRDN(ObjectID.unstructuredName,name); break; default: break; } } public void setKs_alias(String ks_alias) { this.ks_alias = ks_alias; } public void setKs_filename(String ks_filename) { this.ks_filename = ks_filename; } public void setKs_pwd(String ks_pwd) { 113 this.ks_pwd = ks_pwd; } public void setKs_provider(String ks_provider) { this.ks_provider = ks_provider; } public void setKs_type(String ks_type) { this.ks_type = ks_type; } public void setValidFrom(java.util.Date validFrom) { this.validFrom = validFrom; } public java.util.Date getValidFrom() { return validFrom; } public void setValidTo(Date validTo) { this.validTo = validTo; } public Date getValidTo() { return validTo; } public void setCert_temp(byte[] cert_temp) { this.cert_temp = cert_temp; } public void setSubCritical(boolean subCritical) { this.subCritical = subCritical; } public boolean isSubCritical() { return subCritical; } public void setAuCritical(boolean auCritical) { this.auCritical = auCritical; } public boolean isAuCritical() { return auCritical; 114 } public void setKs_data(byte[] ks_data) { this.ks_data = ks_data; } public String getIdCardNum() { return idCardNum; } public void setIdCardNum(String idCardNum) { this.idCardNum = idCardNum; } public boolean isIdCardNumCritical() { return idCardNumCritical; } public void setIdCardNumCritical(boolean idCardNumCritical) { this.idCardNumCritical = idCardNumCritical; } public Date getIdCardIssueDate() { return idCardIssueDate; } public void setIdCardIssueDate(Date idCardIssueDate) { this.idCardIssueDate = idCardIssueDate; } } 115 3) Modul ký duyệt tạo lập chứng số package vasc.ca.security.ejb; import iaik.asn1.*; import iaik.asn1.structures.*; import iaik.x509.*; import iaik.x509.extensions.*; import iaik.x509.extensions.netscape.*; import iaik.pkcs.pkcs10.*; import java.io.*; import java.rmi.*; import java.security.*; import java.util.*; import javax.ejb.*; import vasc.ca.security.utils.*; import vasc.ca.security.interfaces.*; import vasc.ca.security.bean.*; import vasc.ca.bean.keystore.*; import vasc.security.x509.extensions.*; public class CertEJB extends iCATool implements SessionBean { private SessionContext sessionContext; public void ejbCreate() { } public void ejbRemove() { } public void ejbActivate() { } public void ejbPassivate() { } public void setSessionContext(SessionContext sessionContext) { this.sessionContext = sessionContext; } public void createCert() throws EJBException { try 116 { iaik.security.provider.IAIK.addAsProvider(false); //Kiem tra certificate template co hop le hay khong if (cert_temp==null) throw new EJBException("Certficcate template is NULL"); X509Certificate certTmp = new X509Certificate(this.cert_temp); ByteArrayInputStream in = new ByteArrayInputStream(this.ks_data); //Lay thong tin ve CA keystore: private key, public key, certificate KeyStore ks = Util.loadkeyStore(in,this.ks_pwd,this.ks_type,this.ks_provider); if (!ks.isKeyEntry(this.ks_alias)) throw new RemoteException("alias "+this.ks_alias+" is not associated with KeyEntry"); PrivateKey issuerPrivateKey = (PrivateKey)ks.getKey(this.ks_alias,this.ks_pwd.toCharArray()); java.security.cert.Certificate[] crt = (java.security.cert.Certificate[])ks.getCertificateChain(this.ks_alias); java.security.cert.X509Certificate cert = (java.security.cert.X509Certificate)crt[0]; X509Certificate issuerCert = new X509Certificate(cert.getEncoded()); //Vector dung cho viec luu phan mo rong extension cua certificate Vector vector = new Vector(); vector.removeAllElements(); //Neu selfCreateKeyPair=true thi phai sinh keypair truoc sign if (selfCreateKeyPair) { KeyPair keyPair =null; if (keyAlgorithm.equals("")) keyPair = vasc.ca.security.utils.Util.generateKeyPair("RSA",keyLen); else keyPair = vasc.ca.security.utils.Util.generateKeyPair(keyAlgorithm,keyLen); publicKey = keyPair.getPublic(); privateKey = keyPair.getPrivate(); } //Thong tin chung thuc public key cua doi tuong SubjectKeyIdentifier subKey = new SubjectKeyIdentifier(publicKey); if (subCritical) subKey.setCritical(false); vector.addElement(subKey); //Thong tin chung thuc public key cua CA 117 SubjectKeyIdentifier issuer = new SubjectKeyIdentifier(issuerCert.getPublicKey()); AuthorityKeyIdentifier auKey = new AuthorityKeyIdentifier(); if (auCritical) auKey.setCritical(false); auKey.setKeyIdentifier(issuer.get()); auKey.setAuthorityCertSerialNumber(issuerCert.getSerialNumber()); vector.add(auKey); // Gan them thong tin ve so chung minh thu nhan dan nhan if (this.idCardNum!=null && !this.idCardNum.equals("")) { PersonalIdentifierNumber idCard = new PersonalIdentifierNumber(); idCard.setCritical(this.isIdCardNumCritical()); idCard.setIDNumber(this.idCardNum); if (this.idCardIssueDate!=null) idCard.setIssueDate(this.idCardIssueDate); vector.add(idCard); } //Lay phan mo rong certificate template Enumeration enum = certTmp.listExtensions(); while (enum.hasMoreElements()) { V3Extension ext = (V3Extension)enum.nextElement(); if (!(ext instanceof SubjectKeyIdentifier) && !(ext instanceof AuthorityKeyIdentifier)) vector.add(ext); } //Neu khong co phan mo rong nao thi nem mot ngoai le if (vector.size()==0) throw new RemoteException("Certificate template not have any extension"); V3Extension V3extensions[] = new V3Extension[vector.size()]; vector.copyInto(V3extensions); //Dat lai thuat toan sign private key cua CA thuoc loai DSA, //boi vi DSAPrivateKey chi co the dung dsaWithSHA1 hoac dsaWithSHA if (issuerPrivateKey instanceof iaik.security.dsa.DSAPrivateKey) algorithm = iCATool.dsaWithSHA1; switch(algorithm) { case MD5withRSA: 118 this.certificate = vasc.ca.security.utils.Util.createCertificate(name,publicKey, (Name)issuerCert.getSubjectDN(),issuerPrivateKey, AlgorithmID.md5WithRSAEncryption,serial,V3extensions,validFrom, validTo); break; case SHA1withRSA: this.certificate = vasc.ca.security.utils.Util.createCertificate(name,publicKey, (Name)issuerCert.getSubjectDN(),issuerPrivateKey, AlgorithmID.sha1WithRSAEncryption,serial,V3extensions,validFrom,validTo); break; case dsaWithSHA1: this.certificate = vasc.ca.security.utils.Util.createCertificate(name,publicKey, (Name)issuerCert.getSubjectDN(),issuerPrivateKey, AlgorithmID.dsaWithSHA1,serial,V3extensions,validFrom,validTo); break; default: throw new EJBException("Algorithm for signing is invalid"); } } catch(Exception e) { throw new EJBException(e); } } public void createCertFromRequest(byte[] request) throws EJBException { this.selfCreateKeyPair=false; try { //Kiem tra xem request co hop le hay khong RequestInfo reqInfo = Common.checkRequest(new String(request)); if (reqInfo!=null) { if (reqInfo.getType().equals(RequestInfo.T_PKCS10)) { CertificateRequest req = new CertificateRequest(request); if (!req.verify()) throw new EJBException("Request is invalid"); this.publicKey = req.getPublicKey(); 119 if (this.name==null) this.name = req.getSubject(); createCert(); } else { if (reqInfo.getType().equals(RequestInfo.T_KEYGEN)) { this.publicKey = Common.getPublicKeyFromKEYGEN(new String(request)); if (this.publicKey==null) throw new EJBException("Can not parse this request"); } else throw new EJBException("Can not parse this request"); } createCert(); } else throw new EJBException("Can not parse this request"); } catch(Exception e) { throw new EJBException(e); } } } 120 Thank you for evaluating AnyBizSoft PDF Merger! To remove this page, please register your program! Go to Purchase Now>> AnyBizSoft PDF Merger  Merge multiple PDF files into one  Select page range of PDF to merge  Select specific page(s) to merge  Extract page(s) from different PDF files and merge into one

Ngày đăng: 23/09/2020, 23:05

Từ khóa liên quan

Mục lục

  • MỤC LỤC

  • CÁC THUẬT NGỮ VIẾT TẮT

  • MỞ ĐẦU

  • Chương 1. CÁC KHÁI NIỆM CƠ BẢN

  • 1.1. HỆ MÃ HÓA KHÓA ĐỐI XỨNG (Symmetric Key Cryptosystems)

  • 1.1.1. Khái niệm mã hóa khóa đối xứng.

  • 1.1.2. Hệ mã hóa DES (Data Encryption Standard)

  • 1.1.3 Hệ mã hóa RC2

  • 1.1.4. Hệ mã hóa RC4

  • 1.1.5. Hệ mã hóa IDEA

  • 1.1.6. Giao thức trao đổi khóa

  • 1.2. HỆ MÃ HÓA KHÓA CÔNG KHAI

  • 1.2.1. Khái niệm mã hóa công khai

  • 1.2.2. Hệ mã hóa RSA

  • 1.2.3. Các vấn đề liên quan đến hệ mã hóa RSA

  • 1.3. GIAO THỨC SSL

  • 1.3.1. Giới thiệu giao thức SSL

  • 1.3.2. Vị trí của tầng giao thức SSL

  • 1.3.3. Hoạt động của giao thức SSL

  • 2.1.1. Khái niệm cơ sở hạ tầng mật mã khóa công khai.

Tài liệu cùng người dùng

Tài liệu liên quan