|
|
@ -164,8 +164,10 @@ public class KISA_SEED_CBC { |
|
|
|
// R0, R1 : right input values at each round
|
|
|
|
// R0, R1 : right input values at each round
|
|
|
|
// K : round keys at each round
|
|
|
|
// K : round keys at each round
|
|
|
|
private static final void SeedRound(int[] T, int LR[], int L0, int L1, int R0, int R1, int[] K, int K_offset) { |
|
|
|
private static final void SeedRound(int[] T, int LR[], int L0, int L1, int R0, int R1, int[] K, int K_offset) { |
|
|
|
T[0] = LR[R0] ^ K[K_offset+0]; |
|
|
|
int offset = K_offset + 0; |
|
|
|
T[1] = LR[R1] ^ K[K_offset+1]; |
|
|
|
int offset1 = K_offset + 1; |
|
|
|
|
|
|
|
T[0] = LR[R0] ^ K[offset]; |
|
|
|
|
|
|
|
T[1] = LR[R1] ^ K[offset1]; |
|
|
|
T[1] ^= T[0]; |
|
|
|
T[1] ^= T[0]; |
|
|
|
T[1] = SS0[GetB0(T[1])&0x0ff] ^ SS1[GetB1(T[1])&0x0ff] ^ |
|
|
|
T[1] = SS0[GetB0(T[1])&0x0ff] ^ SS1[GetB1(T[1])&0x0ff] ^ |
|
|
|
SS2[GetB2(T[1])&0x0ff] ^ SS3[GetB3(T[1])&0x0ff]; |
|
|
|
SS2[GetB2(T[1])&0x0ff] ^ SS3[GetB3(T[1])&0x0ff]; |
|
|
@ -372,12 +374,18 @@ public class KISA_SEED_CBC { |
|
|
|
if(ENDIAN != Common.BIG_ENDIAN) { |
|
|
|
if(ENDIAN != Common.BIG_ENDIAN) { |
|
|
|
for(i=0;i<inLen;i++) |
|
|
|
for(i=0;i<inLen;i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
data[i] = (byte)(in[i/4] >> ((i%4)*8)); |
|
|
|
int temp = in[i / 4]; |
|
|
|
|
|
|
|
int shift = (i % 4) * 8; |
|
|
|
|
|
|
|
data[i] = (byte) (temp >> shift); |
|
|
|
|
|
|
|
// data[i] = (byte)(in[i/4] >> ((i%4)*8));
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
for(i=0;i<inLen;i++) |
|
|
|
for(i=0;i<inLen;i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
data[i] = (byte)(in[i/4] >> ((3-(i%4))*8)); |
|
|
|
int temp = in[i / 4]; |
|
|
|
|
|
|
|
int shift = (3 - (i % 4)) * 8; |
|
|
|
|
|
|
|
data[i] = (byte) (temp >> shift); |
|
|
|
|
|
|
|
// data[i] = (byte)(in[i/4] >> ((3-(i%4))*8));
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -398,7 +406,8 @@ public class KISA_SEED_CBC { |
|
|
|
K = pInfo.seed_key.key_data; // Pointer of round keys
|
|
|
|
K = pInfo.seed_key.key_data; // Pointer of round keys
|
|
|
|
pInfo.encrypt = enc.value; //
|
|
|
|
pInfo.encrypt = enc.value; //
|
|
|
|
Common.memcpy(pInfo.ivec, pbszIV, 16, ENDIAN); |
|
|
|
Common.memcpy(pInfo.ivec, pbszIV, 16, ENDIAN); |
|
|
|
pInfo.last_block_flag = pInfo.buffer_length = 0; |
|
|
|
pInfo.buffer_length = 0; |
|
|
|
|
|
|
|
pInfo.last_block_flag = pInfo.buffer_length; |
|
|
|
|
|
|
|
|
|
|
|
// Set up input values for Key Schedule
|
|
|
|
// Set up input values for Key Schedule
|
|
|
|
ABCD[ABCD_A] = Common.byte_to_int(pbszUserKey, 0*4, ENDIAN); |
|
|
|
ABCD[ABCD_A] = Common.byte_to_int(pbszUserKey, 0*4, ENDIAN); |
|
|
@ -704,12 +713,20 @@ public class KISA_SEED_CBC { |
|
|
|
public static final int _KISA_DECRYPT = 0; |
|
|
|
public static final int _KISA_DECRYPT = 0; |
|
|
|
public static final int _KISA_ENCRYPT = 1; |
|
|
|
public static final int _KISA_ENCRYPT = 1; |
|
|
|
|
|
|
|
|
|
|
|
public int value; |
|
|
|
private int value; |
|
|
|
|
|
|
|
|
|
|
|
public KISA_ENC_DEC(int value ) { |
|
|
|
public KISA_ENC_DEC(int value ) { |
|
|
|
this.value = value; |
|
|
|
this.value = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getValue(){ |
|
|
|
|
|
|
|
return value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setValue(int value){ |
|
|
|
|
|
|
|
this.value = value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static final KISA_ENC_DEC KISA_ENCRYPT = new KISA_ENC_DEC(_KISA_ENCRYPT); |
|
|
|
public static final KISA_ENC_DEC KISA_ENCRYPT = new KISA_ENC_DEC(_KISA_ENCRYPT); |
|
|
|
public static final KISA_ENC_DEC KISA_DECRYPT = new KISA_ENC_DEC(_KISA_DECRYPT); |
|
|
|
public static final KISA_ENC_DEC KISA_DECRYPT = new KISA_ENC_DEC(_KISA_DECRYPT); |
|
|
|
|
|
|
|
|
|
|
@ -736,11 +753,23 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
public KISA_SEED_INFO() { |
|
|
|
public KISA_SEED_INFO() { |
|
|
|
encrypt = 0; |
|
|
|
encrypt = 0; |
|
|
|
ivec[0] = ivec[1] = ivec[2] = ivec[3] = 0; |
|
|
|
ivec[3] = 0; |
|
|
|
|
|
|
|
ivec[2] = ivec[3]; |
|
|
|
|
|
|
|
ivec[1] = ivec[2]; |
|
|
|
|
|
|
|
ivec[0] = ivec[1]; |
|
|
|
|
|
|
|
// ivec[0] = ivec[1] = ivec[2] = ivec[3] = 0;
|
|
|
|
seed_key.init(); |
|
|
|
seed_key.init(); |
|
|
|
cbc_buffer[0] = cbc_buffer[1] = cbc_buffer[2] = cbc_buffer[3] = 0; |
|
|
|
cbc_buffer[3] = 0; |
|
|
|
|
|
|
|
cbc_buffer[2] = cbc_buffer[3]; |
|
|
|
|
|
|
|
cbc_buffer[1] = cbc_buffer[2]; |
|
|
|
|
|
|
|
cbc_buffer[0] = cbc_buffer[1]; |
|
|
|
|
|
|
|
// cbc_buffer[0] = cbc_buffer[1] = cbc_buffer[2] = cbc_buffer[3] = 0;
|
|
|
|
buffer_length = 0; |
|
|
|
buffer_length = 0; |
|
|
|
cbc_last_block[0] = cbc_last_block[1] = cbc_last_block[2] = cbc_last_block[3] = 0; |
|
|
|
cbc_last_block[3] = 0; |
|
|
|
|
|
|
|
cbc_last_block[2] = cbc_last_block[3]; |
|
|
|
|
|
|
|
cbc_last_block[1] = cbc_last_block[2]; |
|
|
|
|
|
|
|
cbc_last_block[0] = cbc_last_block[1]; |
|
|
|
|
|
|
|
// cbc_last_block[0] = cbc_last_block[1] = cbc_last_block[2] = cbc_last_block[3] = 0;
|
|
|
|
last_block_flag = 0; |
|
|
|
last_block_flag = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -800,13 +829,21 @@ public class KISA_SEED_CBC { |
|
|
|
int mask_value = 0x0ff << shift_value; |
|
|
|
int mask_value = 0x0ff << shift_value; |
|
|
|
int mask_value2 = ~mask_value; |
|
|
|
int mask_value2 = ~mask_value; |
|
|
|
int value2 = (value&0x0ff) << shift_value; |
|
|
|
int value2 = (value&0x0ff) << shift_value; |
|
|
|
dst[b_offset/4] = (dst[b_offset/4] & mask_value2) | (value2 & mask_value); |
|
|
|
|
|
|
|
|
|
|
|
int dstValue = dst[b_offset / 4]; |
|
|
|
|
|
|
|
dstValue = (dstValue & mask_value2) | (value2 & mask_value); |
|
|
|
|
|
|
|
dst[b_offset / 4] = dstValue; |
|
|
|
|
|
|
|
// dst[b_offset/4] = (dst[b_offset/4] & mask_value2) | (value2 & mask_value);
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
int shift_value = (b_offset%4)*8; |
|
|
|
int shift_value = (b_offset%4)*8; |
|
|
|
int mask_value = 0x0ff << shift_value; |
|
|
|
int mask_value = 0x0ff << shift_value; |
|
|
|
int mask_value2 = ~mask_value; |
|
|
|
int mask_value2 = ~mask_value; |
|
|
|
int value2 = (value&0x0ff) << shift_value; |
|
|
|
int value2 = (value&0x0ff) << shift_value; |
|
|
|
dst[b_offset/4] = (dst[b_offset/4] & mask_value2) | (value2 & mask_value); |
|
|
|
|
|
|
|
|
|
|
|
int dstValue = dst[b_offset / 4]; |
|
|
|
|
|
|
|
dstValue = (dstValue & mask_value2) | (value2 & mask_value); |
|
|
|
|
|
|
|
dst[b_offset / 4] = dstValue; |
|
|
|
|
|
|
|
// dst[b_offset/4] = (dst[b_offset/4] & mask_value2) | (value2 & mask_value);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -814,12 +851,18 @@ public class KISA_SEED_CBC { |
|
|
|
if(ENDIAN == BIG_ENDIAN) { |
|
|
|
if(ENDIAN == BIG_ENDIAN) { |
|
|
|
int shift_value = (3-b_offset%4)*8; |
|
|
|
int shift_value = (3-b_offset%4)*8; |
|
|
|
int mask_value = 0x0ff << shift_value; |
|
|
|
int mask_value = 0x0ff << shift_value; |
|
|
|
int value = (src[b_offset/4] & mask_value) >> shift_value; |
|
|
|
int mask_value2 = src[b_offset/4]; |
|
|
|
|
|
|
|
int value2 = mask_value2 & mask_value; |
|
|
|
|
|
|
|
int value = value2 >> shift_value; |
|
|
|
|
|
|
|
// int value = (src[b_offset/4] & mask_value) >> shift_value;
|
|
|
|
return (byte)value; |
|
|
|
return (byte)value; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
int shift_value = (b_offset%4)*8; |
|
|
|
int shift_value = (b_offset%4)*8; |
|
|
|
int mask_value = 0x0ff << shift_value; |
|
|
|
int mask_value = 0x0ff << shift_value; |
|
|
|
int value = (src[b_offset/4] & mask_value) >> shift_value; |
|
|
|
int mask_value2 = src[b_offset/4]; |
|
|
|
|
|
|
|
int value2 = mask_value2 & mask_value; |
|
|
|
|
|
|
|
int value = value2 >> shift_value; |
|
|
|
|
|
|
|
// int value = (src[b_offset/4] & mask_value) >> shift_value;
|
|
|
|
return (byte)value; |
|
|
|
return (byte)value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -836,10 +879,13 @@ public class KISA_SEED_CBC { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void byte_to_int(int[] dst, int dst_offset, byte[] src, int src_offset, int ENDIAN) { |
|
|
|
public static void byte_to_int(int[] dst, int dst_offset, byte[] src, int src_offset, int ENDIAN) { |
|
|
|
|
|
|
|
int offset1 = src_offset + 1; |
|
|
|
|
|
|
|
int offset2 = src_offset + 2; |
|
|
|
|
|
|
|
int offset3 = src_offset + 3; |
|
|
|
if(ENDIAN == BIG_ENDIAN) { |
|
|
|
if(ENDIAN == BIG_ENDIAN) { |
|
|
|
dst[dst_offset] = ((0x0ff&src[src_offset]) << 24) | ((0x0ff&src[src_offset+1]) << 16) | ((0x0ff&src[src_offset+2]) << 8) | ((0x0ff&src[src_offset+3])); |
|
|
|
dst[dst_offset] = ((0x0ff&src[src_offset]) << 24) | ((0x0ff&src[offset1]) << 16) | ((0x0ff&src[offset2]) << 8) | ((0x0ff&src[offset3])); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dst[dst_offset] = ((0x0ff&src[src_offset])) | ((0x0ff&src[src_offset+1]) << 8) | ((0x0ff&src[src_offset+2]) << 16) | ((0x0ff&src[src_offset+3]) << 24); |
|
|
|
dst[dst_offset] = ((0x0ff&src[src_offset])) | ((0x0ff&src[offset1]) << 8) | ((0x0ff&src[offset2]) << 16) | ((0x0ff&src[offset3]) << 24); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -887,7 +933,8 @@ public class KISA_SEED_CBC { |
|
|
|
if(n >= 32) |
|
|
|
if(n >= 32) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
int v = x >> n; |
|
|
|
int v = x >> n; |
|
|
|
int v_mask = ~(0x80000000 >> (n-1)); |
|
|
|
int shift = n - 1; |
|
|
|
|
|
|
|
int v_mask = ~(0x80000000 >> shift); |
|
|
|
return v & v_mask; |
|
|
|
return v & v_mask; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -940,7 +987,8 @@ public class KISA_SEED_CBC { |
|
|
|
K = pInfo.seed_key.key_data; // Pointer of round keys
|
|
|
|
K = pInfo.seed_key.key_data; // Pointer of round keys
|
|
|
|
pInfo.encrypt = enc.value; //
|
|
|
|
pInfo.encrypt = enc.value; //
|
|
|
|
Common.memcpy(pInfo.ivec, pbszIV, 16, ENDIAN); |
|
|
|
Common.memcpy(pInfo.ivec, pbszIV, 16, ENDIAN); |
|
|
|
pInfo.last_block_flag = pInfo.buffer_length = 0; |
|
|
|
pInfo.buffer_length = 0; |
|
|
|
|
|
|
|
pInfo.last_block_flag = pInfo.buffer_length; |
|
|
|
|
|
|
|
|
|
|
|
// Set up input values for Key Schedule
|
|
|
|
// Set up input values for Key Schedule
|
|
|
|
ABCD[ABCD_A] = Common.byte_to_int(pbszUserKey, 0*4, ENDIAN); |
|
|
|
ABCD[ABCD_A] = Common.byte_to_int(pbszUserKey, 0*4, ENDIAN); |
|
|
@ -1028,15 +1076,25 @@ public class KISA_SEED_CBC { |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("[ Test SEED reference code CBC]"+"\n"); |
|
|
|
System.out.print("[ Test SEED reference code CBC]"+"\n"); |
|
|
|
System.out.print("\n\n"); |
|
|
|
System.out.print("\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("[ Test Encrypt mode : <EFBFBD><EFBFBD><EFBFBD> 1 ]"+"\n"); |
|
|
|
System.out.print("[ Test Encrypt mode : \uFFFD\uFFFD\uFFFD 1 ]" +"\n"); |
|
|
|
System.out.print("Key\t\t\t\t: "); |
|
|
|
System.out.print("Key\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) System.out.print(Integer.toHexString(0xff&pbUserKey[i])+" "); |
|
|
|
for (int i=0; i<16; i++) { |
|
|
|
|
|
|
|
int intValue = 0xff & pbUserKey[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff & pbUserKey[i]) + " ");
|
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("Plaintext\t\t\t: "); |
|
|
|
System.out.print("Plaintext\t\t\t: "); |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++) System.out.print(Integer.toHexString(0xff&pbData[i])+" "); |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++){ |
|
|
|
|
|
|
|
int intValue = 0xff & pbData[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&pbData[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1049,18 +1107,30 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("\nIV\t\t\t\t: "); |
|
|
|
System.out.print("\nIV\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&bszIV[i])+" "); |
|
|
|
int intValue = 0xff & bszIV[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&bszIV[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
for (int i=0; i<CIPHERTEXT_LENGTH; i++) |
|
|
|
for (int i=0; i<CIPHERTEXT_LENGTH; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&defaultCipherText[i])+" "); |
|
|
|
int intValue = 0xff & defaultCipherText[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&defaultCipherText[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt)\t: "); |
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt)\t: "); |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++) |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&PPPPP[i])+" "); |
|
|
|
int intValue = 0xff & PPPPP[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&PPPPP[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n\n"); |
|
|
|
System.out.print("\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1069,18 +1139,30 @@ public class KISA_SEED_CBC { |
|
|
|
byte[] Plain1 = SEED_CBC_Decrypt(pbUserKey, bszIV, Cipher1, 0, 16); |
|
|
|
byte[] Plain1 = SEED_CBC_Decrypt(pbUserKey, bszIV, Cipher1, 0, 16); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("IV\t\t\t\t: "); |
|
|
|
System.out.print("IV\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&bszIV[i])+" "); |
|
|
|
int intValue = 0xff & bszIV[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&bszIV[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt1)\t: "); |
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt1)\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&Cipher1[i])+" "); |
|
|
|
int intValue = 0xff & Cipher1[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&Cipher1[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt1)\t: "); |
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt1)\t: "); |
|
|
|
for (int i=0; i<2; i++) |
|
|
|
for (int i=0; i<2; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&Plain1[i])+" "); |
|
|
|
int intValue = 0xff & Plain1[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&Plain1[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n\n"); |
|
|
|
System.out.print("\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1089,18 +1171,30 @@ public class KISA_SEED_CBC { |
|
|
|
byte[] Plain2 = SEED_CBC_Decrypt(pbUserKey, bszIV, Cipher2, 0, 32); |
|
|
|
byte[] Plain2 = SEED_CBC_Decrypt(pbUserKey, bszIV, Cipher2, 0, 32); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("IV\t\t\t\t: "); |
|
|
|
System.out.print("IV\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&bszIV[i])+" "); |
|
|
|
int intValue = 0xff & bszIV[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&bszIV[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n\n"); |
|
|
|
System.out.print("\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
for (int i=0; i<32; i++) |
|
|
|
for (int i=0; i<32; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&Cipher2[i])+" "); |
|
|
|
int intValue = 0xff & Cipher2[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&Cipher2[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt)\t: "); |
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt)\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&Plain2[i])+" "); |
|
|
|
int intValue = 0xff & Plain2[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&Plain2[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n\n\n"); |
|
|
|
System.out.print("\n\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1111,18 +1205,30 @@ public class KISA_SEED_CBC { |
|
|
|
byte[] Plain3 = SEED_CBC_Decrypt(pbUserKey, bszIV, Cipher3, 0, 32); |
|
|
|
byte[] Plain3 = SEED_CBC_Decrypt(pbUserKey, bszIV, Cipher3, 0, 32); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("IV\t\t\t\t: "); |
|
|
|
System.out.print("IV\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&bszIV[i])+" "); |
|
|
|
int intValue = 0xff & bszIV[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&bszIV[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt3)\t: "); |
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt3)\t: "); |
|
|
|
for (int i=0; i<32; i++) |
|
|
|
for (int i=0; i<32; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&Cipher3[i])+" "); |
|
|
|
int intValue = 0xff & Cipher3[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&Cipher3[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt3)\t: "); |
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt3)\t: "); |
|
|
|
for (int i=0; i<18; i++) |
|
|
|
for (int i=0; i<18; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&Plain3[i])+" "); |
|
|
|
int intValue = 0xff & Plain3[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&Plain3[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1149,12 +1255,22 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
PLAINTEXT_LENGTH = 14; |
|
|
|
PLAINTEXT_LENGTH = 14; |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("\n\n[ Test Encrypt mode : <EFBFBD><EFBFBD><EFBFBD> 2 ]"+"\n"); |
|
|
|
System.out.print("\n\n[ Test Encrypt mode : \uFFFD\uFFFD\uFFFD 2 ]" +"\n"); |
|
|
|
System.out.print("Key\t\t\t\t: "); |
|
|
|
System.out.print("Key\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) System.out.print(Integer.toHexString(0xff&pbUserKey[i])+", "); |
|
|
|
for (int i=0; i<16; i++) { |
|
|
|
|
|
|
|
int intValue = 0xff & pbUserKey[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&pbUserKey[i])+", ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("Plaintext\t\t\t: "); |
|
|
|
System.out.print("Plaintext\t\t\t: "); |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++) System.out.print(Integer.toHexString(0xff&pbData[i])+", "); |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++){ |
|
|
|
|
|
|
|
int intValue = 0xff & pbData[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&pbData[i])+", ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1190,7 +1306,7 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
int[] outbuf = new int[process_blockLeng/4]; |
|
|
|
int[] outbuf = new int[process_blockLeng/4]; |
|
|
|
|
|
|
|
|
|
|
|
for(j=0; j<PLAINTEXT_LENGTH-process_blockLeng; ) |
|
|
|
for(j=0; j<PLAINTEXT_LENGTH-process_blockLeng; j+= process_blockLeng) |
|
|
|
{ |
|
|
|
{ |
|
|
|
System.arraycopy(pbData, j, newpbszPlainText, 0, process_blockLeng); |
|
|
|
System.arraycopy(pbData, j, newpbszPlainText, 0, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszPlainText, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszPlainText, process_blockLeng); |
|
|
@ -1223,13 +1339,21 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("IV\t\t\t\t: "); |
|
|
|
System.out.print("IV\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&bszIV[i])+", "); |
|
|
|
int intValue = 0xff & bszIV[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&bszIV[i])+", ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt 1)\t: "); |
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt 1)\t: "); |
|
|
|
for (int i=0; i<CIPHERTEXT_LENGTH; i++) |
|
|
|
for (int i=0; i<CIPHERTEXT_LENGTH; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&pbszCipherText[i])+", "); |
|
|
|
int intValue = 0xff & pbszCipherText[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&pbszCipherText[i])+", ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1275,7 +1399,7 @@ public class KISA_SEED_CBC { |
|
|
|
byte []pbszPlainText = new byte[nCipherTextLen]; |
|
|
|
byte []pbszPlainText = new byte[nCipherTextLen]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(j=0; j<nCipherTextLen - process_blockLeng; ) |
|
|
|
for(j=0; j<nCipherTextLen - process_blockLeng; j+= process_blockLeng) |
|
|
|
{ |
|
|
|
{ |
|
|
|
System.arraycopy(message, j, newpbszCipherText, 0, process_blockLeng); |
|
|
|
System.arraycopy(message, j, newpbszCipherText, 0, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszCipherText, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszCipherText, process_blockLeng); |
|
|
@ -1326,8 +1450,12 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt 1)\t: "); |
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt 1)\t: "); |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++) |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&result[i])+", "); |
|
|
|
int intValue = 0xff & result[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&result[i])+", ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n\n"); |
|
|
|
System.out.print("\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
data = null; |
|
|
|
data = null; |
|
|
@ -1377,7 +1505,7 @@ public class KISA_SEED_CBC { |
|
|
|
outbuf = new int[process_blockLeng/4]; |
|
|
|
outbuf = new int[process_blockLeng/4]; |
|
|
|
pbszPlainText = new byte[process_blockLeng]; |
|
|
|
pbszPlainText = new byte[process_blockLeng]; |
|
|
|
|
|
|
|
|
|
|
|
for(j=0; j<PLAINTEXT_LENGTH-process_blockLeng; ) |
|
|
|
for(j=0; j<PLAINTEXT_LENGTH-process_blockLeng; j+= process_blockLeng) |
|
|
|
{ |
|
|
|
{ |
|
|
|
System.arraycopy(pbData1, j, newpbszPlainText, 0, process_blockLeng); |
|
|
|
System.arraycopy(pbData1, j, newpbszPlainText, 0, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszPlainText, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszPlainText, process_blockLeng); |
|
|
@ -1412,13 +1540,21 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("\n\nIV\t\t\t\t: "); |
|
|
|
System.out.print("\n\nIV\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&bszIV[i])+" "); |
|
|
|
int intValue = 0xff & bszIV[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&bszIV[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&pbszCipherText[i])+" "); |
|
|
|
int intValue = 0xff & pbszCipherText[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&pbszCipherText[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1466,7 +1602,7 @@ public class KISA_SEED_CBC { |
|
|
|
pbszPlainText = new byte[nCipherTextLen]; |
|
|
|
pbszPlainText = new byte[nCipherTextLen]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(j=0; j<nCipherTextLen - process_blockLeng; ) |
|
|
|
for(j=0; j<nCipherTextLen - process_blockLeng; j+= process_blockLeng) |
|
|
|
{ |
|
|
|
{ |
|
|
|
System.arraycopy(message, j, newpbszCipherText, 0, process_blockLeng); |
|
|
|
System.arraycopy(message, j, newpbszCipherText, 0, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszCipherText, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszCipherText, process_blockLeng); |
|
|
@ -1517,8 +1653,12 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt 1)\t: "); |
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt 1)\t: "); |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++) |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&result[i])+" "); |
|
|
|
int intValue = 0xff & result[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&result[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n\n"); |
|
|
|
System.out.print("\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
data = null; |
|
|
|
data = null; |
|
|
@ -1553,7 +1693,7 @@ public class KISA_SEED_CBC { |
|
|
|
outbuf = new int[process_blockLeng/4]; |
|
|
|
outbuf = new int[process_blockLeng/4]; |
|
|
|
pbszPlainText = new byte[process_blockLeng]; |
|
|
|
pbszPlainText = new byte[process_blockLeng]; |
|
|
|
|
|
|
|
|
|
|
|
for(j=0; j<PLAINTEXT_LENGTH-process_blockLeng; ) |
|
|
|
for(j=0; j<PLAINTEXT_LENGTH-process_blockLeng; j+= process_blockLeng) |
|
|
|
{ |
|
|
|
{ |
|
|
|
System.arraycopy(pbData2, j, newpbszPlainText, 0, process_blockLeng); |
|
|
|
System.arraycopy(pbData2, j, newpbszPlainText, 0, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszPlainText, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszPlainText, process_blockLeng); |
|
|
@ -1588,13 +1728,21 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("\n\nIV\t\t\t\t: "); |
|
|
|
System.out.print("\n\nIV\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&bszIV[i])+" "); |
|
|
|
int intValue = 0xff & bszIV[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&bszIV[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
for (int i=0; i<32; i++) |
|
|
|
for (int i=0; i<32; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&pbszCipherText[i])+" "); |
|
|
|
int intValue = 0xff & pbszCipherText[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&pbszCipherText[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1641,7 +1789,7 @@ public class KISA_SEED_CBC { |
|
|
|
pbszPlainText = new byte[nCipherTextLen]; |
|
|
|
pbszPlainText = new byte[nCipherTextLen]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(j=0; j<nCipherTextLen - process_blockLeng; ) |
|
|
|
for(j=0; j<nCipherTextLen - process_blockLeng; j+= process_blockLeng) |
|
|
|
{ |
|
|
|
{ |
|
|
|
System.arraycopy(message, j, newpbszCipherText, 0, process_blockLeng); |
|
|
|
System.arraycopy(message, j, newpbszCipherText, 0, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszCipherText, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszCipherText, process_blockLeng); |
|
|
@ -1692,8 +1840,12 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt 1)\t: "); |
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt 1)\t: "); |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++) |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&result[i])+" "); |
|
|
|
int intValue = 0xff & result[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&result[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n\n"); |
|
|
|
System.out.print("\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
data = null; |
|
|
|
data = null; |
|
|
@ -1730,7 +1882,7 @@ public class KISA_SEED_CBC { |
|
|
|
outbuf = new int[process_blockLeng/4]; |
|
|
|
outbuf = new int[process_blockLeng/4]; |
|
|
|
pbszPlainText = new byte[process_blockLeng]; |
|
|
|
pbszPlainText = new byte[process_blockLeng]; |
|
|
|
|
|
|
|
|
|
|
|
for(j=0; j<PLAINTEXT_LENGTH-process_blockLeng; ) |
|
|
|
for(j=0; j<PLAINTEXT_LENGTH-process_blockLeng; j+= process_blockLeng) |
|
|
|
{ |
|
|
|
{ |
|
|
|
System.arraycopy(pbData3, j, newpbszPlainText, 0, process_blockLeng); |
|
|
|
System.arraycopy(pbData3, j, newpbszPlainText, 0, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszPlainText, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszPlainText, process_blockLeng); |
|
|
@ -1765,13 +1917,21 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("\n\nIV\t\t\t\t: "); |
|
|
|
System.out.print("\n\nIV\t\t\t\t: "); |
|
|
|
for (int i=0; i<16; i++) |
|
|
|
for (int i=0; i<16; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&bszIV[i])+" "); |
|
|
|
int intValue = 0xff & bszIV[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&bszIV[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
System.out.print("Ciphertext(SEED_CBC_Encrypt)\t: "); |
|
|
|
for (int i=0; i<32; i++) |
|
|
|
for (int i=0; i<32; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&pbszCipherText[i])+" "); |
|
|
|
int intValue = 0xff & pbszCipherText[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&pbszCipherText[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n"); |
|
|
|
System.out.print("\n"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1819,7 +1979,7 @@ public class KISA_SEED_CBC { |
|
|
|
pbszPlainText = new byte[nCipherTextLen]; |
|
|
|
pbszPlainText = new byte[nCipherTextLen]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(j=0; j<nCipherTextLen - process_blockLeng; ) |
|
|
|
for(j=0; j<nCipherTextLen - process_blockLeng; j+= process_blockLeng) |
|
|
|
{ |
|
|
|
{ |
|
|
|
System.arraycopy(message, j, newpbszCipherText, 0, process_blockLeng); |
|
|
|
System.arraycopy(message, j, newpbszCipherText, 0, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszCipherText, process_blockLeng); |
|
|
|
data = chartoint32_for_SEED_CBC(newpbszCipherText, process_blockLeng); |
|
|
@ -1870,8 +2030,12 @@ public class KISA_SEED_CBC { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt 1)\t: "); |
|
|
|
System.out.print("Plaintext(SEED_CBC_Decrypt 1)\t: "); |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++) |
|
|
|
for (int i=0; i<PLAINTEXT_LENGTH; i++){ |
|
|
|
System.out.print(Integer.toHexString(0xff&result[i])+" "); |
|
|
|
int intValue = 0xff & result[i]; |
|
|
|
|
|
|
|
String hexString = Integer.toHexString(intValue); |
|
|
|
|
|
|
|
System.out.print(hexString + " "); |
|
|
|
|
|
|
|
// System.out.print(Integer.toHexString(0xff&result[i])+" ");
|
|
|
|
|
|
|
|
} |
|
|
|
System.out.print("\n\n"); |
|
|
|
System.out.print("\n\n"); |
|
|
|
|
|
|
|
|
|
|
|
data = null; |
|
|
|
data = null; |
|
|
|