본문 바로가기

카테고리 없음

2020-06-24 08시 개발자 글 모음 | "Daily Study Logging3" 외 8개 이야기

AES 알고리즘 by 김학진 about Algorithm

  • 확산(환치) 추가 void ShiftRows(unsigned char* state) { unsigned char tmp[16]; /* Column 1 */ tmp[0] = state[0]; tmp[1] = state[5]; tmp[2] = state[10]; tmp[3] = state[15]; /* Column 2 */ tmp[4] = state[4]; tmp[5] = state[9]; tmp[6] = state[14]; tmp[7] = state[3]; /* Column 3 */ tmp[8] = state[8]; tmp[9] = state[13]; tmp[10] = state[2]; tmp[11] = state[7]; /* Column 4 */ tmp[12] = state[12]; tmp[13] = state[1]; tmp[14] = state[6]; tmp[15] = state[11]; for (int i = 0; i < 16; i++) { state[i] = tmp[i]; } } /* MixColumns는 mul2
  • * 확산원 */ void MixColumns(unsigned char* state) { unsigned char tmp[16]; tmp[0] = (unsigned char)mul2[state[0]] ^ mul3[state[1]] ^ state[2] ^ state[3]; tmp[1] = (unsigned char)state[0] ^ mul2[state[1]] ^ mul3[state[2]] ^ state[3]; tmp[2] = (unsigned char)state[0] ^ state[1] ^ mul2[state[2]] ^ mul3[state[3]]; tmp[3] = (unsigned char)mul3[state[0]] ^ state[1] ^ state[2] ^ mul2[state[3]]; tmp[4] = (unsigned char)mul2[state[4]] ^ mul3[state[5]] ^ state[6] ^ state[7]; tmp[5] = (unsigned char)state[4] ^ mul2[state[5]] ^ mul3[state[6]] ^ state[7]; tmp[6] = (unsigned char)state[4] ^ state[5] ^ mul2[state[6]] ^ mul3[state[7]]; tmp[7] = (unsigned char)mul3[state[4]] ^ state[5] ^ state[6] ^ mul2[state[7]]; tmp[8] = (unsigned char)mul2[state[8]] ^ mul3[state[9]] ^ state[10] ^ state[11]; tmp[9] = (unsigned char)state[8] ^ mul2[state[9]] ^ mul3[state[10]] ^ state[11]; tmp[10] = (unsigned char)state[8] ^ state[9] ^ mul2[state[10]] ^ mul3[state[11]]; tmp[11] = (unsigned char)mul3[state[8]] ^ state[9] ^ state[10] ^ mul2[state[11]]; tmp[12] = (unsigned char)mul2[state[12]] ^ mul3[state[13]] ^ state[14] ^ state[15]; tmp[13] = (unsigned char)state[12] ^ mul2[state[13]] ^ mul3[state[14]] ^ state[15]; tmp[14] = (unsigned char)state[12] ^ state[13] ^ mul2[state[14]] ^ mul3[state[15]]; tmp[15] = (unsigned char)mul3[state[12]] ^ state[13] ^ state[14] ^ mul2[state[15]]; for (int i = 0; i < 16; i++) { state[i] = tmp[i]; } } /* 각 라운드는 한 번에 128비트로 작동함 * 라운드 수는 AESEncrypt()에 정의되어 있다
  • * MixColumns의 암호화 효과를 반전시켜 기둥의 혼합 해제 */ void InverseMixColumns(unsigned char* state) { unsigned char tmp[16]; tmp[0] = (unsigned char)mul14[state[0]] ^ mul11[state[1]] ^ mul13[state[2]] ^ mul9[state[3]]; tmp[1] = (unsigned char)mul9[state[0]] ^ mul14[state[1]] ^ mul11[state[2]] ^ mul13[state[3]]; tmp[2] = (unsigned char)mul13[state[0]] ^ mul9[state[1]] ^ mul14[state[2]] ^ mul11[state[3]]; tmp[3] = (unsigned char)mul11[state[0]] ^ mul13[state[1]] ^ mul9[state[2]] ^ mul14[state[3]]; tmp[4] = (unsigned char)mul14[state[4]] ^ mul11[state[5]] ^ mul13[state[6]] ^ mul9[state[7]]; tmp[5] = (unsigned char)mul9[state[4]] ^ mul14[state[5]] ^ mul11[state[6]] ^ mul13[state[7]]; tmp[6] = (unsigned char)mul13[state[4]] ^ mul9[state[5]] ^ mul14[state[6]] ^ mul11[state[7]]; tmp[7] = (unsigned char)mul11[state[4]] ^ mul13[state[5]] ^ mul9[state[6]] ^ mul14[state[7]]; tmp[8] = (unsigned char)mul14[state[8]] ^ mul11[state[9]] ^ mul13[state[10]] ^ mul9[state[11]]; tmp[9] = (unsigned char)mul9[state[8]] ^ mul14[state[9]] ^ mul11[state[10]] ^ mul13[state[11]]; tmp[10] = (unsigned char)mul13[state[8]] ^ mul9[state[9]] ^ mul14[state[10]] ^ mul11[state[11]]; tmp[11] = (unsigned char)mul11[state[8]] ^ mul13[state[9]] ^ mul9[state[10]] ^ mul14[state[11]]; tmp[12] = (unsigned char)mul14[state[12]] ^ mul11[state[13]] ^ mul13[state[14]] ^ mul9[state[15]]; tmp[13] = (unsigned char)mul9[state[12]] ^ mul14[state[13]] ^ mul11[state[14]] ^ mul13[state[15]]; tmp[14] = (unsigned char)mul13[state[12]] ^ mul9[state[13]] ^ mul14[state[14]] ^ mul11[state[15]]; tmp[15] = (unsigned char)mul11[state[12]] ^ mul13[state[13]] ^ mul9[state[14]] ^ mul14[state[15]]; for (int i = 0; i < 16; i++) { state[i] = tmp[i]; } } // 암호 해독을 위해 왼쪽이 아닌 오른쪽으로 행 이동 void ShiftRows_in(unsigned char* state) { unsigned char tmp[16]; /* Column 1 */ tmp[0] = state[0]; tmp[1] = state[13]; tmp[2] = state[10]; tmp[3] = state[7]; /* Column 2 */ tmp[4] = state[4]; tmp[5] = state[1]; tmp[6] = state[14]; tmp[7] = state[11]; /* Column 3 */ tmp[8] = state[8]; tmp[9] = state[5]; tmp[10] = state[2]; tmp[11] = state[15]; /* Column 4 */ tmp[12] = state[12]; tmp[13] = state[9]; tmp[14] = state[6]; tmp[15] = state[3]; for (int i = 0; i < 16; i++) { state[i] = tmp[i]; } } /* 16바이트 각각으로 대체 * 역 S-box를 룩업 테이블로 사용 */ void SubBytes_in(unsigned char* state) { for (int i = 0; i < 16; i++) { state[i] = inv_s[state[i]];// 16바이트 각각으로 대체 } } /* 각 라운드는 한 번에 128비트로 작동함 * 라운드 수는 AESDecrypt()에 정의되어 있다


0xNews - 구글 애널리틱스 Google Analytics 을 이용하여 신용카드 정보 도용 가능 확인 by 왕응석


    [Spring] Spring AOP - 실전편 by 염광호 about Spring

    • timeCheckPointCut()") spublic Object timeCheck(ProceedingJoinPoint joinPoint) throws Throwable { Stopwatch stopwatch = Stopwatch
    • ))") spublic Object timeCheck(ProceedingJoinPoint joinPoint) throws Throwable { Stopwatch stopwatch = Stopwatch
    • ))") spublic Object timeCheck(ProceedingJoinPoint joinPoint) throws Throwable { Stopwatch stopwatch = Stopwatch


    R Hello World 출력하기 by 김경록

    • 설명 단축키 새탭 command + shift + N 커서 있는 라인만 실행 command + Enter 전체 실행 command + shift + S
    • [1] "hello" "world"
    • 'world') message(vector1) print(vector1)


    이미테이션 게임 (The Imitation Game) by 이종립

    • C 가 A 와 B 의 목소리를 통해 답을 쉽게 맞추는 일을 막기 위해 글을 써서 응답하거나
    • "What will happen when a machine takes the part of A in this game?" Will the interrogator decide wrongly as often when the game is played like this as he does when the game is played between a man and a woman
    • "이 게임에서 기계가 A의 역할을 맡으면 어떻게 될까?" 이렇게 했을 때 질문자가 못 맞힐 가능성은 실제 남자와 여자가 참가했을 때만큼 클까


    [JAVA] static 변수와 static 메소드, Static 의 정리 by 장민

    • public class Person { private String name = "Mveloper" ; public void printName () { System
    • println ( this
    • name ); } }


    TodoList만들기!_개발환경(2) by 장봄


      java에서 STL의 multimap 구조를 구현해 봅시다. by 조경완

      • 특정한 Value를 찾는 작업은 최악의 경우에 O(List에 있는 원소 갯수)만큼 걸립니다
      • 가수 K가 V라는 앨범을 발매했는지 빠르게 찾기 위해서는 어떻게 하면 될까요
      • 그러기 위해서는 containsKey 메서드를 이용하면 됩니다


      Daily Study Logging37 - node js로 JSON 파일 만들기 by 차이새 about Node,Javascript