2017년 6월 19일 월요일

tls/dtls handshake


server                                                              client




helloRequest           ----------------->                   ClientHandshaker
                                                                     starthandshake
                                                                     ProtocolVersion
                                                                     clientRandom,                                                                                                  supportedClientCertificateTypes
                                                                     supportedServerCertificateTypes
                                                                     CompressionMethod
                                                                     clientHello
                    <------------------------------------     sendFlight(flight);


receivedClientHello
starthandshake  
negotiateProtocolVersion
서버 와 클라이언트 난수
세션생성후 세션 설정
세션에 압축 협상후 설정
클라이언트에서 제안한 암호화 선택
후 세션에 저장
세션에 데이터 조각 크기 지정

먼저 ServerHello (필수).
// 1) ServerHello                                                      receivedServerHello
ServerHello        -------------------------------------------> usedProtocol =                                                                                            message.getServerVersion();                                        serverRandom = message.getRandom();
                            session.setSessionIdentifier(message.getSessionId());
                            session.setCipherSuite(message.getCipherSuite());                             session.setCompressionMethod(                                                                           setSendRawPublicKey
                                            setReceiveRawPublicKey
                                                                                                       
                                                                                                           
                                                                                                           


// 2) CertificateMessage  -------------------------------> CertificateMessage
                                                                            receivedServerCertificate
Second, send Certificate
 (if required by key exchange algorithm)                                   검증                        

// 3) Server Key Exchange ------------------------------    receivedServerKeyExchange

                       message.verifySignature(serverPublicKey, clientRandom, serverRandom);
            The ServerKeyExchange message is sent by the server only when the server
CertificateMessage(if sent) does not contain enough data to
allow the client to exchange a premaster secret. Used when the key
  exchange is ECDH. The client tries to verify the server's signature and
 on success prepares the ECDH key agreement.                                                               
// 4) Certificate Request(옵션)------------------------------>







// 5) Server Hello Done(필수)                <    -->              receivedServerHelloDone  


                                               First, if required by server, send Certificate.                                                            Second, send ClientKeyExchange as specified by the                                          
                                               Third, send CertificateVerify message if necessary.
                                               Fourth, send ChangeCipherSpec
                                               Fifth, send the finished message.                                                                                                        
                                                                                                             
                                                                                                             
                                                                                                             

                                                                                                                                                                                                                           
                                                                                                             

                                                                                                             

                                                                                                             

                                                                                                             
                                                                                                             








                            





























































2017년 6월 7일 수요일

TLS 개요


TLS 개요

구성품
PKI
X509 증명서
난수 생성
대칭암호
디지털서명
키교환
공개키 암호
메세지 인증
일방향해쉬
암호모드

난수 생성
공개키 암호 키교환 대칭암호 암호모드

공개키 암호 디지털서명 x509 증명 PKI
일방향 해쉬 메세지 인증


TLS_키교환_디지털서명_WITH_대칭암호_키길이_암호모드_메세지인증(해쉬)



TLS_RSA_WITH_AES_128_GCM_SHA256

키교환 RSA 디지털서명
대칭암호 AES 128
암호 모드 GCM
메세지 인증 SHA256



암호키(대칭암호: 비밀키,공개키암호:keypair) 의 생성
암호모도초기백터 Nounce생성
MAC(메세지인증)

nexacro 인터셉터 설정

    <dependency>       <groupId>com.fasterxml.jackson.core</groupId>   <artifactId>jackson-core</artifactId&...