티스토리 뷰

P rogramming/C conf

KISA의 SEED test src

Only I Can 2012. 8. 23. 11:31

/*******************************************************************************
* This source code "SEED_test_KISA.c" is not the official souce code.
* This source code is the only example.
* This source code show how the encryption and decryption functions are operated.
* This source code can compare the standard test vector with the result.
*
*******************************************************************************/

/******************************* Include files ********************************/

#include "SEED_KISA.h"

/*******************************SEED test code ********************************/

void main()
{
 DWORD pdwRoundKey[32];              // Round keys for encryption or decryption
 BYTE pbUserKey[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   // User secret key
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 BYTE pbData[16]    = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   // input plaintext to be encrypted
                        0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
 int i;

// Print user secret key
 printf ("Key        : ");
 for (i=0;i<16;i++) 
  printf("%02X ",pbUserKey[i]);

// Print plaintext to be encrypted
 printf ("\nPlaintext  : ");
 for (i=0;i<16;i++) 
  printf("%02X ",pbData[i]);
  
// Derive roundkeys from user secret key
 SeedRoundKey(
  pdwRoundKey,
  pbUserKey);
 
// Encryption
 printf ("\n\nEncryption....\n");
 SeedEncrypt(
  pbData,
  pdwRoundKey);

// print encrypted data(ciphertext)
 printf ("Ciphertext : ");
 for (i=0;i<16;i++) 
  printf("%02X ",pbData[i]);

// Decryption
 printf ("\n\nDecryption....\n");
 SeedDecrypt(
  pbData,
  pdwRoundKey);

// Print decrypted data(plaintext)
 printf ("Plaintext  : ");
 for (i=0;i<16;i++) 
  printf("%02X ",pbData[i]);

// Print round keys at round i
 printf ("\n\nRound Key  : \n");
 for (i=0;i<16;i++) {
  printf("K%2d,0 : %08X\t", i+1, pdwRoundKey[2*i]);
  printf("K%2d,1 : %08X\n", i+1, pdwRoundKey[2*i+1]);
 }
}

'P rogramming > C conf' 카테고리의 다른 글

memset() 사용법  (0) 2012.09.13
struct timeval 사용  (0) 2012.09.13
getopt  (0) 2012.09.11
AF PF 차이  (0) 2012.09.10
Shared Memmory  (0) 2012.09.10
함수 포인터의 유용성 : 동적바인딩  (0) 2012.09.05
KISA의 SEED test src  (0) 2012.08.23
Compile Error : LINK : fatal error LNK1561: 진입점이 정의되어야 합니다  (0) 2012.08.23
댓글
댓글쓰기 폼