diff --git a/.gitignore b/.gitignore index 0a0041d..e3bbc3e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ __pycache__ /.gradle/ /.idea/ /Project/bin/ +/se-algo.iml diff --git a/Project/Src/com/cscn/Method.java b/Src/com/cscn/Method.java similarity index 100% rename from Project/Src/com/cscn/Method.java rename to Src/com/cscn/Method.java diff --git a/Src/com/cscn/XwSecurity.java b/Src/com/cscn/XwSecurity.java new file mode 100644 index 0000000..b4532c8 --- /dev/null +++ b/Src/com/cscn/XwSecurity.java @@ -0,0 +1,97 @@ +package com.cscn; + +import javacard.framework.APDU; +import javacard.framework.Applet; +import javacard.framework.ISO7816; +import javacard.framework.ISOException; + +/** + * @author liuww + * + */ +public class XwSecurity extends Applet { + + //todo test + public static final byte INS_PROCESS_DATA_TEST = (byte)0xE3; + + public static final byte INS_LOCATION_ENCRYPT = (byte)0xCA; + + public static final byte INS_STORE_KEY = (byte)0xE2; + +// public static final byte INS_INITIAL_UPDATE = (byte)0x50; +// +// public static final byte INS_EXTERNAL_AUTH = (byte)0x82; + + private Method method; + + byte[] key_store_byte; + + public XwSecurity(byte[] bArray, short bOffset, byte bLength) { + // TODO Auto-generated constructor stub + method = new Method(); //todo new? + // key store -> flash + key_store_byte = new byte[120]; + + register(bArray, (short)(bOffset + 1), bArray[bOffset]); + } + + public static void install(byte[] bArray, short bOffset, byte bLength) + { + //todo new? + // GP-compliant JavaCard applet registration + new XwSecurity(bArray, bOffset, bLength); + } + + public void process(APDU apdu) + { + // Good practice: Return 9000 on SELECT + if(selectingApplet()) + { + return; + } + + if(method == null) { + return; + } + + byte[] buf = apdu.getBuffer(); + short off = ISO7816.OFFSET_CDATA; + short len = apdu.setIncomingAndReceive(); + + switch (buf[ISO7816.OFFSET_INS]) + { +// case INS_INITIAL_UPDATE: +// SecureChannel sc = GPSystem.getSecureChannel(); +// sc.processSecurity(apdu); +// break; +// +// case INS_EXTERNAL_AUTH: +// sc = GPSystem.getSecureChannel(); +// sc.processSecurity(apdu); +// break; + + + //todo test + case INS_PROCESS_DATA_TEST: + method.testZuc256(apdu); + break; + + + case INS_LOCATION_ENCRYPT: + len = method.locationEncryptZuc(buf, off, len, key_store_byte); + apdu.setOutgoingAndSend(off, len); + break; + + case INS_STORE_KEY: + len = method.updateKey(buf, off, len, key_store_byte); + apdu.setOutgoingAndSend(off, len); + break; + + default: + // good practice: If you don't know the INStruction, say so: + ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED); + } + + + } +} \ No newline at end of file diff --git a/Project/Src/com/cscn/Zuc256Tables.java b/Src/com/cscn/Zuc256Tables.java similarity index 100% rename from Project/Src/com/cscn/Zuc256Tables.java rename to Src/com/cscn/Zuc256Tables.java diff --git a/build_tools/Bat/Delivery/cscn.cap b/build_tools/Bat/Delivery/cscn.cap new file mode 100644 index 0000000..902b6a5 Binary files /dev/null and b/build_tools/Bat/Delivery/cscn.cap differ diff --git a/build_tools/Bat/Delivery/cscn.exp b/build_tools/Bat/Delivery/cscn.exp new file mode 100644 index 0000000..6a48131 Binary files /dev/null and b/build_tools/Bat/Delivery/cscn.exp differ diff --git a/Bat/GenCap.bat b/build_tools/Bat/GenCap.bat similarity index 87% rename from Bat/GenCap.bat rename to build_tools/Bat/GenCap.bat index 1d0e846..16c4ee6 100644 --- a/Bat/GenCap.bat +++ b/build_tools/Bat/GenCap.bat @@ -47,7 +47,7 @@ ECHO ********************************************** ECHO *** Convert Java Card Assembly File *** ECHO ********************************************** -CALL converter -nowarn -i -classdir .\bin -exportpath %EXPORT_DIR% -out EXP CAP -applet 0xA0:0x00:0x00:0x03:0x00:0x73:0x74:0x61:0x72:0x2E:0x61:0x70:0x70 com.cscn.XwSecurity com.cscn 0xA0:0x00:0x00:0x03:0x00:0x73:0x74:0x61:0x72:0x2E:0x70:0x6B:0x67 1.0 +CALL converter -verbose -nowarn -i -classdir .\bin -exportpath %EXPORT_DIR% -out EXP CAP -applet 0xA0:0x00:0x00:0x03:0x00:0x73:0x74:0x61:0x72:0x2E:0x61:0x70:0x70 com.cscn.XwSecurity com.cscn 0xA0:0x00:0x00:0x03:0x00:0x73:0x74:0x61:0x72:0x2E:0x70:0x6B:0x67 1.0 ECHO ********************************************** ECHO *** Copy Exp and Cap File *** diff --git a/build_tools/Project/Src/Method.java b/build_tools/Project/Src/Method.java new file mode 100644 index 0000000..bbcaa7f --- /dev/null +++ b/build_tools/Project/Src/Method.java @@ -0,0 +1,1586 @@ +package com.cscn; + +import javacard.framework.APDU; +import javacard.framework.ISO7816; +import javacard.framework.ISOException; +import javacard.framework.JCSystem; +import javacard.framework.Util; + + +/** + * 仅做一次“自检调用”: + * 1) ctx.init(KEY, IV); Enc(Input) == EncExpected ? + * 2) ctx.init(KEY, IV); Enc(Enc(Input)) == Input ? + * Response: 2字节 [encMatch, dblEncRestored],1=真,0=假 + */ +public final class Method { + // ======= 已按你提供的数据填充 ======= + + // Key: 32字节 + private static final byte[] KEY32 = { + (byte)0x30,(byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37, + (byte)0x38,(byte)0x39,(byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66, + (byte)0x30,(byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37, + (byte)0x38,(byte)0x39,(byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66 + }; + + // IV +// private static final byte[] IV23 = { +// (byte)0x30,(byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37, +// (byte)0x38,(byte)0x39,(byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66, +// (byte)0x67,(byte)0xC3,(byte)0x1C,(byte)0xB3,(byte)0xD3,(byte)0x5D,(byte)0xB7 +// }; + private static final byte[] IV25 = { + (byte)0x30,(byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36,(byte)0x37, + (byte)0x38,(byte)0x39,(byte)0x61,(byte)0x62,(byte)0x63,(byte)0x64,(byte)0x65,(byte)0x66, + (byte)0x67,(byte)0x30,(byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34,(byte)0x35,(byte)0x36, + (byte)0x37 + }; + + // Input: 明文(38字节) + private static final byte[] INPUT = { + (byte)0x5A,(byte)0x55,(byte)0x43,(byte)0x32,(byte)0x35,(byte)0x36,(byte)0xE5,(byte)0xAF, + (byte)0xB9,(byte)0xE7,(byte)0xA7,(byte)0xB0,(byte)0xE5,(byte)0x8A,(byte)0xA0,(byte)0xE8, + (byte)0xA7,(byte)0xA3,(byte)0xE5,(byte)0xAF,(byte)0x86,(byte)0xE6,(byte)0xB5,(byte)0x8B, + (byte)0xE8,(byte)0xAF,(byte)0x95,(byte)0x3A,(byte)0x31,(byte)0x32,(byte)0x33,(byte)0x34, + (byte)0x35,(byte)0x36,(byte)0x37,(byte)0x38,(byte)0x39,(byte)0x30 + }; + + // EncResult: 期望密文(38字节) + private static final byte[] ENC_EXPECTED = { + (byte)0x6C,(byte)0xEE,(byte)0x3C,(byte)0xFA,(byte)0xDE,(byte)0xBB,(byte)0xCB,(byte)0xE5, + (byte)0x33,(byte)0x51,(byte)0x07,(byte)0x07,(byte)0x90,(byte)0x25,(byte)0x93,(byte)0x27, + (byte)0x94,(byte)0xF5,(byte)0x18,(byte)0x70,(byte)0xEF,(byte)0x71,(byte)0x72,(byte)0x7D, + (byte)0xBA,(byte)0x8D,(byte)0xBF,(byte)0x4F,(byte)0x61,(byte)0xC9,(byte)0xA8,(byte)0xE9, + (byte)0xFF,(byte)0x19,(byte)0xF9,(byte)0xF9,(byte)0xE2,(byte)0xD2 + }; + + // ====================================== + + // 输入数据缓冲区最大值 + static final short MAX_DATA_BLOCK_SIZE = 128; + // 运行时缓冲:放RAM,避免写EEPROM + byte[] ctx_buf; + short ctx_buflen; + + //todo test + byte[] buf1; // Enc(Input) + //todo test + byte[] buf2; // Enc(Enc(Input)) -> 应为 Input + + // LFSR: 原 int[16] -> hi/lo 各 16 + public short[] LFSR_hi; + public short[] LFSR_lo; + + // R1, R2: 原 int -> hi/lo + public short R1_hi; + public short R1_lo; + public short R2_hi; + public short R2_lo; + + byte[] stmsi; + byte[] location_data; + byte[] location_res_data; + + byte[] update_key_buf; + + short[] rot31_bits; + short[] rot31_resBits; + + short[] L1_t; + short[] L1_acc; + + short[] L2_t; + short[] L2_acc; + + byte[] extract_iv_last8; + byte[] extracted_iv_23; + + short[] add64_tmp; + + short[] zuc256SetMacKey_D; + short[] zuc256SetMacKey_TMP; + short[] zuc256SetMacKey_X0; + short[] zuc256SetMacKey_X1; + short[] zuc256SetMacKey_X2; + short[] zuc256SetMacKey_R1; + short[] zuc256SetMacKey_R2; + short[] zuc256SetMacKey_W; + short[] zuc256SetMacKey_W1; + short[] zuc256SetMacKey_W2; + short[] zuc256SetMacKey_U; + short[] zuc256SetMacKey_V; + short[] zuc256SetMacKey_T; + short[] zuc256SetMacKey_T2; + + short[] zuc256SetMacKey_tmp; + + short[] zuc256SetMacKey_A; + short[] zuc256SetMacKey_tmp32; + short[] zuc256SetMacKey_tmp64; + short[] zuc256SetMacKey_low31; + short[] zuc256SetMacKey_r31; + short[] zuc256SetMacKey_v64; + short[] zuc256SetMacKey_vv; + + short[] updateZuc256EncryptCtx_ks; + short[] updateZuc256EncryptCtx_plain; + short[] updateZuc256EncryptCtx_res; + short[] updateZuc256EncryptCtx_ks_hi; + short[] updateZuc256EncryptCtx_ks_lo; + short[] updateZuc256EncryptCtx_word; + + short[] zuc256GenerateKeyword_X0 ; + short[] zuc256GenerateKeyword_X1 ; + short[] zuc256GenerateKeyword_X2 ; + short[] zuc256GenerateKeyword_X3 ; + short[] zuc256GenerateKeyword_R1 ; + short[] zuc256GenerateKeyword_R2 ; + short[] zuc256GenerateKeyword_W1 ; + short[] zuc256GenerateKeyword_W2 ; + short[] zuc256GenerateKeyword_U ; + short[] zuc256GenerateKeyword_V ; + short[] zuc256GenerateKeyword_Z ; + short[] zuc256GenerateKeyword_TMP0; + short[] zuc256GenerateKeyword_TMP1; + short[] zuc256GenerateKeyword_A; + short[] zuc256GenerateKeyword_tmp32; + short[] zuc256GenerateKeyword_tmp64; + short[] zuc256GenerateKeyword_low31; + short[] zuc256GenerateKeyword_r31; + short[] zuc256GenerateKeyword_low31b; + short[] zuc256GenerateKeyword_r31b; + short[] zuc256GenerateKeyword_v64; + + short[] zuc256GenerateKeystream_tmp; + + short[] finishZuc256EncryptCtx_ks; + byte[] finishZuc256EncryptCtx_keystreamBytes; + + + public Method() { + // key list tmp buffer, lenth must equal with key_store(flash)! + update_key_buf = JCSystem.makeTransientByteArray((short)120, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + // 算法内部使用23Byte IV + extracted_iv_23 = JCSystem.makeTransientByteArray((short)23, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + ctx_buf = JCSystem.makeTransientByteArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + LFSR_hi = JCSystem.makeTransientShortArray((short)16, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + LFSR_lo = JCSystem.makeTransientShortArray((short)16, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + // todo buf1 if not use, delete please + buf1 = JCSystem.makeTransientByteArray(MAX_DATA_BLOCK_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + // todo buf2 if not use, delete please + buf2 = JCSystem.makeTransientByteArray(MAX_DATA_BLOCK_SIZE, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + stmsi = JCSystem.makeTransientByteArray((short)6, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + location_data = JCSystem.makeTransientByteArray((short)5, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + location_res_data = JCSystem.makeTransientByteArray((short)5, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + rot31_bits = JCSystem.makeTransientShortArray((short)31, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + rot31_resBits = JCSystem.makeTransientShortArray((short)31, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + L1_t = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + L1_acc = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + L2_t = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + L2_acc = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + extract_iv_last8 = JCSystem.makeTransientByteArray((short)8, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + add64_tmp = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + zuc256SetMacKey_D = JCSystem.makeTransientShortArray(Zuc256Tables.D_COLS, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_TMP = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_X0 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_X1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_X2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_R1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_R2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_W = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_W1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_W2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_U = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_V = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_T = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_T2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + zuc256SetMacKey_tmp = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); // 临时存储 makeU31 输出 (lo,hi) + + zuc256SetMacKey_A = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); // 64位累加器 + zuc256SetMacKey_tmp32 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_tmp64 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_low31 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_r31 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_v64 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256SetMacKey_vv = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + updateZuc256EncryptCtx_ks = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + updateZuc256EncryptCtx_plain = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + updateZuc256EncryptCtx_res = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + updateZuc256EncryptCtx_ks_hi = JCSystem.makeTransientShortArray((short)(MAX_DATA_BLOCK_SIZE/4), JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + updateZuc256EncryptCtx_ks_lo = JCSystem.makeTransientShortArray((short)(MAX_DATA_BLOCK_SIZE/4), JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// 临时:装一个32位字 + updateZuc256EncryptCtx_word = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + // 工作寄存器(32位值的临时 out32 缓冲,全用short[2])[lo, hi] + zuc256GenerateKeyword_X0 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_X1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_X2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_X3 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + zuc256GenerateKeyword_R1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_R2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_W1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_W2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_U = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_V = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_Z = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_TMP0 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_TMP1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_A = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); // 64位累加器,初始全0 + zuc256GenerateKeyword_tmp32 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; // 保存一个32位数 (lo,hi) + zuc256GenerateKeyword_tmp64 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; // 保存移位后的64位数 + zuc256GenerateKeyword_low31 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_r31 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_low31b = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_r31b = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + zuc256GenerateKeyword_v64 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + // 临时存放一个 32 位关键字 + zuc256GenerateKeystream_tmp = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + finishZuc256EncryptCtx_ks = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + finishZuc256EncryptCtx_keystreamBytes = JCSystem.makeTransientByteArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + } + + + //todo test + public void testZuc256(APDU apdu) { + + byte[] apduBuf = apdu.getBuffer(); + + // 第一次:Enc(Input) + initZuc256EncryptCtx(KEY32, IV25); + updateZuc256EncryptCtx(INPUT, (short) INPUT.length, buf1); + finishZuc256EncryptCtx(buf1, (short) INPUT.length); // 若 Input 长度为 4 的倍数则通常无副作用,留着更稳妥 + + boolean encMatch = (Util.arrayCompare(buf1, (short)0, ENC_EXPECTED, (short)0, (short)INPUT.length) == 0); + + // 第二次:Enc(Enc(Input)) 应还原 Input + initZuc256EncryptCtx(KEY32, IV25); + updateZuc256EncryptCtx(buf1, (short) INPUT.length, buf2); + finishZuc256EncryptCtx(buf2, (short) INPUT.length); + boolean dblOk = (Util.arrayCompare(buf2, (short)0, INPUT, (short)0, (short)INPUT.length) == 0); + + // 返回 2 字节结果:[encMatch, dblOk],1=真, 0=假 + apduBuf[0] = (byte)(encMatch ? 1 : 0); + apduBuf[1] = (byte)(dblOk ? 1 : 0); + short outLen = 2; + + apdu.setOutgoing(); + apdu.setOutgoingLength(outLen); + apdu.sendBytes((short)0, outLen); + } + + /** + * encryptLocationZuc256 + * 输入: stmsi[6], data[5] + * 输出: out[5] + */ + private void encryptLocationZuc256(byte[] stmsi, byte[] data, byte[] out) { + initZuc256EncryptCtx(KEY32, IV25); + updateZuc256EncryptCtx(data, (short) 5, out); + finishZuc256EncryptCtx(out, (short) 5); // 若 Input 长度为 4 的倍数则通常无副作用,留着更稳妥 + } + + /** + * APDU处理函数 + */ + public short locationEncryptZuc(byte[] buffer, short off, short len, byte[] key_store) { + // 至少要有 12 个字节:1+1+1+6+5 + if (len < (short)12) { + ISOException.throwIt(ISO7816.SW_WRONG_LENGTH); + } + + // === 解析入参 === + byte inType = buffer[(short)(off + 0)]; // 类型 A1 + byte inLen = buffer[(short)(off + 1)]; // 长度 0x0C + byte secParam = buffer[(short)(off + 2)]; // 安全参数 + + // STMSI + Util.arrayCopyNonAtomic(buffer, (short)(off + 3), stmsi, (short)0, (short)6); + + // data + Util.arrayCopyNonAtomic(buffer, (short)(off + 9), location_data, (short)0, (short)5); + + // === 生成 fakedata === + encryptLocationZuc256(stmsi, location_data, location_res_data); + + // === 出参组装 === + buffer[(short)(off + 0)] = (byte)0xA1; // 类型 + buffer[(short)(off + 1)] = (byte)0x06; // 长度 + buffer[(short)(off + 2)] = (byte)0x01; // 密钥选取 + Util.arrayCopyNonAtomic(location_res_data, (short)0, buffer, (short)(off + 3), (short)5); + + return (short)8; // 出参总长度 + } + + + + public short updateKey(byte[] buffer, short off, short len, byte[] key_store) { + final short SLOT_SIZE = 40; // 每个槽固定40字节 + final short HDR_LEN = 4; // 报文头长度: [0]=keyLenField, [1]=alg, [2]=keyId, [3]=ver + + // === 解析头 === + byte keyLenField = buffer[(short)(off + 0)]; // 包含头部+密钥的总长度 + byte alg = buffer[(short)(off + 1)]; + byte keyId = buffer[(short)(off + 2)]; + byte ver = buffer[(short)(off + 3)]; + + // 计算实际密钥长度 + short realKeyLen = (short)(keyLenField - (byte)3); // 长度字段 = key长度 + 3字节头 + if (realKeyLen <= 0) { + ISOException.throwIt(ISO7816.SW_DATA_INVALID); // key长度不合法 + } + + // 检查APDU长度和key长度是否匹配 + if (len != (short)(HDR_LEN + realKeyLen)) { + ISOException.throwIt(ISO7816.SW_WRONG_LENGTH); + } + if (len > SLOT_SIZE) { + ISOException.throwIt(ISO7816.SW_WRONG_LENGTH); + } + + // === 将原有 key_store 拷贝到 RAM,避免直接覆盖 EEPROM (可选) === + Util.arrayCopyNonAtomic(key_store, (short)0, update_key_buf, (short)0, (short)key_store.length); + + // === 遍历槽,找到匹配的 (alg, keyId, ver),否则找空槽 === + short slots = (short)(key_store.length / SLOT_SIZE); + short target = -1; + for (short i = 0; i < slots; i++) { + short base = (short)(i * SLOT_SIZE); + byte algOld = key_store[(short)(base + 1)]; + byte keyIdOld = key_store[(short)(base + 2)]; + byte verOld = key_store[(short)(base + 3)]; + + if (algOld == alg && keyId == keyIdOld && ver == verOld) { + target = i; // 找到已存在的,覆盖它 + break; + } + if (key_store[base] == (byte)0x00 && target == -1) { + target = i; // 找到第一个空槽 + } + } + + if (target == -1) { + ISOException.throwIt(ISO7816.SW_FILE_FULL); // 没有空位 + } + + // === 覆盖写入本次APDU的头+密钥数据 === + short base = (short)(target * SLOT_SIZE); + // 先清空槽 + Util.arrayFillNonAtomic(key_store, base, SLOT_SIZE, (byte)0x00); + // 再写入APDU传入的头+数据 (len 个字节) + Util.arrayCopyNonAtomic(buffer, off, key_store, base, len); + + return 0; // 无返回数据 + } + + // === zuc256Util + +// /** 辅助方法:将字节数组转换为32位整数 */ +// public static int getU32(byte[] p, int offset) { +// return ((p[offset] & 0xFF) << 24) | +// ((p[offset + 1] & 0xFF) << 16) | +// ((p[offset + 2] & 0xFF) << 8) | +// (p[offset + 3] & 0xFF); +// } + /** 辅助方法:从字节数组取出 32 位整数,存放到 short[2] (lo, hi) */ + public static void getU32(byte[] p, short offset, short[] out32 /* len=2 */) { + out32[0] = (short) (((p[(short)(offset + 2)] & 0xFF) << 8) | (p[(short)(offset + 3)] & 0xFF)); //低16位 + out32[1] = (short) (((p[offset] & 0xFF) << 8) | (p[(short)(offset + 1)] & 0xFF)); //高16位 + } + + +// /** 辅助方法:将32位整数转换为字节数组 */ +// public static void putU32(byte[] p, int offset, int v) { +// p[offset] = (byte) (v >> 24); +// p[offset + 1] = (byte) (v >> 16); +// p[offset + 2] = (byte) (v >> 8); +// p[offset + 3] = (byte) v; +// } + /** 辅助方法:将32位整数(vlo=低16位, vhi=高16位)写入字节数组 */ + public static void putU32(byte[] p, short offset, short vlo, short vhi) { + // 写高16位 + p[offset] = (byte) ((vhi >> 8) & 0xFF); + p[(short)(offset + 1)] = (byte) (vhi & 0xFF); + + // 写低16位 + p[(short)(offset + 2)] = (byte) ((vlo >> 8) & 0xFF); + p[(short)(offset + 3)] = (byte) (vlo & 0xFF); + } + + + // === 31/32 位运算 === + +// /** 31位加法 */ +// public static int add31(int a, int b) { +// long sum = (long)a + b; +// return (int) ((sum & 0x7FFFFFFF) + (sum >> 31)); +// } + /** 31位加法: (a+b) mod (2^31 - 1) + * 输入: a_lo=低16位, a_hi=高15位 + * b_lo=低16位, b_hi=高15位 + * 输出: out[0]=lo, out[1]=hi + */ + public static void add31(short a_lo, short a_hi, short b_lo, short b_hi, short[] out /* len==2 */) { + // ---- 低16位相加 ---- + short lo = (short)(a_lo + b_lo); + short carry = (short)( + ( ( (short)( (a_lo & b_lo) | ((a_lo | b_lo) & (short)~lo) ) ) & (short)0x8000 ) != 0 + ? 1 : 0 + ); + // ---- 高15位相加 + 进位 ---- + short hi_raw = (short)((short)((a_hi & 0x7FFF) + (b_hi & 0x7FFF)) + carry); + + // 提取第31位(hi_raw bit15) + short topbit = (short)((hi_raw >>> 15) & 1); + short hi = (short)(hi_raw & 0x7FFF); // 保留15位 + + // ---- 若第31位=1,再+1 ---- + if (topbit == 1) { + short lo2 = (short)(lo + 1); + short c2 = (short)((lo2 == 0) ? 1 : 0); // lo溢出时进位 + lo = lo2; + hi = (short)((hi + c2) & 0x7FFF); + } + + out[0] = lo; + out[1] = hi; + } + + +// /** 31位旋转 */ +// public static int rot31(int a, int k) { +// return ((a << k) | (a >>> (31 - k))) & 0x7FFFFFFF; +// } + /** 31位循环左移: (a <<< k) mod (2^31 -1) + * 输入: a_lo=低16位, a_hi=高15位 + * 输出: out[0]=lo, out[1]=hi + */ + public void rot31(short a_lo, short a_hi, short k, short[] out /* len==2 */) { + k = (short)(k % 31); // 限制在 0..30 + if (k == 0) { + out[0] = a_lo; + out[1] = (short)(a_hi & 0x7FFF); + return; + } + + // 拆成 31 位数组 [bit0..bit30] + for (short i = 0; i < 16; i++) { + rot31_bits[i] = (short)((a_lo >>> i) & 1); + } + for (short i = 0; i < 15; i++) { + rot31_bits[(short)(16 + i)] = (short)((a_hi >>> i) & 1); + } + + // 旋转 + for (short i = 0; i < 31; i++) { + short j = (short)((i + k) % 31); + rot31_resBits[j] = rot31_bits[i]; + } + + // 拼回 lo, hi + short lo = 0; + for (short i = 0; i < 16; i++) { + lo = (short)(lo | (rot31_resBits[i] << i)); + } + short hi = 0; + for (short i = 0; i < 15; i++) { + hi = (short)(hi | (rot31_resBits[(short)(16 + i)] << i)); + } + + out[0] = lo; + out[1] = hi; + } + + +// /** 32位旋转 */ +// public static int rot32(int a, int k) { +// return (a << k) | (a >>> (32 - k)); +// } + /** 32位循环左移: (a<< 0) { + // 先做 1 位循环左移 + // 注意:short 在 >>> 时会先提升为 int,所以下面都再用 &1 取最低位,避免符号扩展影响 + nw_hi = (short)((hi << 1) | ((lo >>> 15) & 1)); + nw_lo = (short)((lo << 1) | ((hi >>> 15) & 1)); + hi = nw_hi; + lo = nw_lo; + k--; + } + out[0] = lo; // 低16位 + out[1] = hi; // 高16位 + } + + +// /** +// * L1函数 +// */ +// public static int L1(int x) { +// return x ^ rot32(x, 2) ^ rot32(x, 10) ^ rot32(x, 18) ^ rot32(x, 24); +// } + /** + * L1函数: x ^ (x<<<2) ^ (x<<<10) ^ (x<<<18) ^ (x<<<24) + * 输入: x_lo, x_hi + * 输出: out[0]=lo, out[1]=hi + */ + public void L1(short x_lo, short x_hi, short[] out /*len==2*/) { + + // acc = x + L1_acc[0] = x_lo; + L1_acc[1] = x_hi; + + // acc ^= rot32(x, 2) + rot32(x_lo, x_hi, (short)2, L1_t); + L1_acc[0] ^= L1_t[0]; + L1_acc[1] ^= L1_t[1]; + + // acc ^= rot32(x, 10) + rot32(x_lo, x_hi, (short)10, L1_t); + L1_acc[0] ^= L1_t[0]; + L1_acc[1] ^= L1_t[1]; + + // acc ^= rot32(x, 18) + rot32(x_lo, x_hi, (short)18, L1_t); + L1_acc[0] ^= L1_t[0]; + L1_acc[1] ^= L1_t[1]; + + // acc ^= rot32(x, 24) + rot32(x_lo, x_hi, (short)24, L1_t); + L1_acc[0] ^= L1_t[0]; + L1_acc[1] ^= L1_t[1]; + + out[0] = L1_acc[0]; + out[1] = L1_acc[1]; + } + + +// /** +// * L2函数 +// */ +// public static int L2(int x) { +// return x ^ rot32(x, 8) ^ rot32(x, 14) ^ rot32(x, 22) ^ rot32(x, 30); +// } + /** + * L2函数: x ^ (x<<<8) ^ (x<<<14) ^ (x<<<22) ^ (x<<<30) + * 输入: x_lo, x_hi + * 输出: out[0]=lo, out[1]=hi + */ + public void L2(short x_lo, short x_hi, short[] out /*len==2*/) { + + // acc = x + L2_acc[0] = x_lo; + L2_acc[1] = x_hi; + + // acc ^= rot32(x, 8) + rot32(x_lo, x_hi, (short)8, L2_t); + L2_acc[0] ^= L2_t[0]; + L2_acc[1] ^= L2_t[1]; + + // acc ^= rot32(x, 14) + rot32(x_lo, x_hi, (short)14, L2_t); + L2_acc[0] ^= L2_t[0]; + L2_acc[1] ^= L2_t[1]; + + // acc ^= rot32(x, 22) + rot32(x_lo, x_hi, (short)22, L2_t); + L2_acc[0] ^= L2_t[0]; + L2_acc[1] ^= L2_t[1]; + + // acc ^= rot32(x, 30) + rot32(x_lo, x_hi, (short)30, L2_t); + L2_acc[0] ^= L2_t[0]; + L2_acc[1] ^= L2_t[1]; + + out[0] = L2_acc[0]; + out[1] = L2_acc[1]; + } + + +// /** 创建31位无符号整数 */ +// public static int makeU31(int a, int b, int c, int d) { +// return (((a & 0xFF) << 23) | +// ((b & 0xFF) << 16) | +// ((c & 0xFF) << 8) | +// (d & 0xFF)) & 0x7FFFFFFF; +// } + /** 创建31位无符号整数,结果放到 out[0]=lo, out[1]=hi(15位) */ + public static void makeU31(short a, short b, short c, short d, short[] out /*len==2*/) { + // 四个字节 + short b0 = (short)(a & 0xFF); // 最高字节 + short b1 = (short)(b & 0xFF); + short b2 = (short)(c & 0xFF); + short b3 = (short)(d & 0xFF); // 最低字节 + + // 拼成 32 位: b0<<24 | b1<<16 | b2<<8 | b3 + // lo = 低16位 + out[0] = (short)((b2 << 8) | b3); + + // hi = 高15位(丢弃 bit31) + out[1] = (short)((b0 << 7) | b1); + } + + +// /** 创建32位无符号整数 */ +// public static int makeU32(int a, int b, int c, int d) { +// return ((a & 0xFF) << 24) | +// ((b & 0xFF) << 16) | +// ((c & 0xFF) << 8) | +// (d & 0xFF); +// } + /** 创建32位无符号整数,结果放到 out[0]=lo, out[1]=hi */ + public static void makeU32(short a, short b, short c, short d, short[] out /*len==2*/) { + // 四个字节 + short b0 = (short)(a & 0xFF); // 最高字节 + short b1 = (short)(b & 0xFF); + short b2 = (short)(c & 0xFF); + short b3 = (short)(d & 0xFF); // 最低字节 + + // lo = 低16位 + out[0] = (short)((b2 << 8) | b3); + + // hi = 高16位 + out[1] = (short)((b0 << 8) | b1); + } + + + + /** 提取IV */ + public void extractIv(byte[] input25Byte, byte[] output23Byte) { + if (input25Byte == null || output23Byte == null) return; + + // 复制前17字节 + Util.arrayCopyNonAtomic(input25Byte, (short)0, output23Byte, (short)0, (short)17); + + + // 处理剩余8字节 + for (short i = 0; i < 8; i++) { + extract_iv_last8[i] = (byte) (input25Byte[(short)(17 + i)] & 0x3F); + } + + output23Byte[17] = (byte) ((extract_iv_last8[0] << 2) | (extract_iv_last8[1] >>> 4)); + output23Byte[18] = (byte) (((extract_iv_last8[1] & 0x0F) << 4) | (extract_iv_last8[2] >>> 2)); + output23Byte[19] = (byte) (((extract_iv_last8[2] & 0x03) << 6) | extract_iv_last8[3]); + output23Byte[20] = (byte) ((extract_iv_last8[4] << 2) | (extract_iv_last8[5] >>> 4)); + output23Byte[21] = (byte) (((extract_iv_last8[5] & 0x0F) << 4) | (extract_iv_last8[6] >>> 2)); + output23Byte[22] = (byte) (((extract_iv_last8[6] & 0x03) << 6) | extract_iv_last8[7]); + } + + /** + * 32位加法: (a_hi:a_lo) + (b_hi:b_lo) + * out[0] = lo, out[1] = hi + */ + static void add32(short a_lo, short a_hi, + short b_lo, short b_hi, + short[] out /*len=2*/) { + + // ---- 低16位 ---- + short lo_low = (short)((a_lo & 0x00FF) + (b_lo & 0x00FF)); + short carry0 = (short)(((a_lo & 0x00FF) + (b_lo & 0x00FF)) >>> 8); + + short a_lo_hi = (short)((a_lo >>> 8) & 0x00FF); + short b_lo_hi = (short)((b_lo >>> 8) & 0x00FF); + short lo_high = (short)(a_lo_hi + b_lo_hi + carry0); + short carry1 = (short)(lo_high >>> 8); + + short lo_res = (short)((lo_high << 8) | (lo_low & 0x00FF)); + + // ---- 高16位 ---- + short hi_low = (short)((a_hi & 0x00FF) + (b_hi & 0x00FF) + carry1); + short carry2 = (short)(hi_low >>> 8); + + short a_hi_hi = (short)((a_hi >>> 8) & 0x00FF); + short b_hi_hi = (short)((b_hi >>> 8) & 0x00FF); + short hi_high = (short)(a_hi_hi + b_hi_hi + carry2); + + short hi_res = (short)((hi_high << 8) | (hi_low & 0x00FF)); + + // ---- 输出 ---- + out[0] = lo_res; + out[1] = hi_res; + } + + /** + * 32位加法 + 返回进位(只用 short) + * 输入: (a_hi:a_lo) + (b_hi:b_lo) + * 输出: out[0]=lo, out[1]=hi + * 返回: 最终进位(0/1) + */ + static short add32_with_carry(short a_lo, short a_hi, + short b_lo, short b_hi, + short[] out /* len=2 */) { + // ---- 低16位:分两段8位相加 ---- + short s0 = (short)((a_lo & (short)0x00FF) + (b_lo & (short)0x00FF)); // 0..510 + short c0 = (short)(s0 >>> 8); // 0/1 + short s1 = (short)(((a_lo >>> 8) & (short)0x00FF) + + ((b_lo >>> 8) & (short)0x00FF) + + c0); // 0..511 + short c1 = (short)(s1 >>> 8); // 0/1 + short lo = (short)((s1 << 8) | (s0 & (short)0x00FF)); + + // ---- 高16位:再分两段8位相加,并加上 c1 ---- + short s2 = (short)((a_hi & (short)0x00FF) + (b_hi & (short)0x00FF) + c1); + short c2 = (short)(s2 >>> 8); // 0/1 + short s3 = (short)(((a_hi >>> 8) & (short)0x00FF) + + ((b_hi >>> 8) & (short)0x00FF) + + c2); // 0..511 + short c3 = (short)(s3 >>> 8); // 最终进位 0/1 + short hi = (short)((s3 << 8) | (s2 & (short)0x00FF)); + + out[0] = lo; + out[1] = hi; + return (short)(c3 & 1); + } + + + + /** + * 64位加法: a4 + b4 -> a4 + * 输入输出: short[4],低到高 (a[0]=lo16, a[1]=hi16, a[2]=lo16 of high dword, a[3]=hi16 of high dword) + */ + void add64(short[] a, short[] b) { + + // 低 32 位 + short carry = add32_with_carry(a[0], a[1], b[0], b[1], add64_tmp); + a[0] = add64_tmp[0]; + a[1] = add64_tmp[1]; + + // 高 32 位 + carry + add32((short)(a[2] + (short)(carry & (short)0x0001)), a[3], b[2], b[3], add64_tmp); + a[2] = add64_tmp[0]; + a[3] = add64_tmp[1]; + } + + + + // 32位异或 + public static void xor32(short a_lo, short a_hi, short b_lo, short b_hi, short[] out /*len==2*/) { + out[0] = (short)(a_lo ^ b_lo); + out[1] = (short)(a_hi ^ b_hi); + } + + /** + * 把32位数 b (b[0]=lo, b[1]=hi) 左移 k 位 (0 <= k < 32), + * 结果放到64位数 a (a[0]=最低16位 ... a[3]=最高16位)。 + */ + static void create_64b_from_32b(short[] a/*len=4*/, short[] b/*len=2*/, short k) { + short a0 = b[0], a1 = b[1], a2 = 0, a3 = 0; + + if (k >= 16) { + a3 = a2; // 0 + a2 = a1; // 原 hi16 + a1 = a0; // 原 lo16 + a0 = 0; + k = (short)(k - 16); + } + + while (k > 0) { + short c0 = (short)((a0 >>> 15) & 1); + short c1 = (short)((a1 >>> 15) & 1); + short c2 = (short)((a2 >>> 15) & 1); + + a3 = (short)((a3 << 1) | c2); + a2 = (short)((a2 << 1) | c1); + a1 = (short)((a1 << 1) | c0); + a0 = (short)(a0 << 1); + k--; + } + + a[0] = a0; a[1] = a1; a[2] = a2; a[3] = a3; + } + + + /** + * (A & 0x7FFFFFFF),结果放在 out[4],只保留低32位并清掉最高bit。 + */ + static void and64_7FFFFFFF_to32(short[] A, short[] out) { + out[0] = A[0]; // lo16 + out[1] = (short)(A[1] & 0x7FFF); // hi16 (清除最高bit) + out[2] = 0; + out[3] = 0; + } + + /** + * 64位无符号右移 31 位 + * 输入: A[0..3] (short[4], A[0]最低16位) + * 输出: out[0..3] + */ + static void shr64u_31(short[] A, short[] out) { + // 先拼出 64bit 的逻辑,逐段右移 + // A >>> 31 = (A >>> 16) >>> 15 + + // 先右移 16,相当于丢掉 A[0],整体右移一半字 + out[0] = A[1]; // 原 A[1] -> 新低16位 + out[1] = A[2]; // 原 A[2] + out[2] = A[3]; // 原 A[3] + out[3] = 0; // 高位补0 + + // 再右移 15 位 + short c0 = (short)((out[0] & (short)0xFFFF) >>> 15); // out[0] 最后一位变进位 + short c1 = (short)((out[1] & (short)0xFFFF) >>> 15); + short c2 = (short)((out[2] & (short)0xFFFF) >>> 15); + + out[0] = (short)((c0 & 0x0001) | (out[1] << 1)); + out[1] = (short)((c1 & 0x0001) | (out[2] << 1)); + out[2] = (short)(c2 & 0x0001); + } + + /** + * 32位无符号右移 1 位 + * 输入: lo,hi (short) 表示 32 位数 (hi:高16位, lo:低16位) + * 输出: out[0]=lo, out[1]=hi + */ + static void shr32u1(short lo, short hi, short[] out) { + // >>>1:先处理低16位 + short nwLo = (short)(((((lo & (short)0xFFFF) >>> 1) & (short)0x7FFF)) | ((hi & 0x0001) << 15)); + short nwHi = (short)(((hi & (short)0xFFFF) >>> 1) & (short)0x7FFF); + + out[0] = nwLo; + out[1] = nwHi; + } + + + //===zuc256core + + /** 初始化状态(Key + IV) */ + public void initState(byte[] key32, byte[] iv) { + zuc256SetMacKey(key32, iv, (short)0); + } + + /** 生成单个密钥字 */ + public void zuc256GenerateKeyword(short[] out) { +// int[] LFSR = state.LFSR; +// int R1 = state.R1; +// int R2 = state.R2; +// int X0, X1, X2, X3; +// int W1, W2, U, V; +// int Z; + + + + // 载入 R1,R2 + zuc256GenerateKeyword_R1[0] = R1_lo; + zuc256GenerateKeyword_R1[1] = R1_hi; + zuc256GenerateKeyword_R2[0] = R2_lo; + zuc256GenerateKeyword_R2[1] = R2_hi; + + + // BitReconstruction4 + short c15 = (short)((LFSR_lo[15] & (short)0x8000) >>> 15); // 左移产生的进位 + zuc256GenerateKeyword_X0[1] = (short)(((LFSR_hi[15] & (short)0x7FFF) << 1) | (short)(c15 & 0x0001)); // hi + zuc256GenerateKeyword_X0[0] = LFSR_lo[14]; // lo + + // X1 = ((L11 & 0xFFFF) << 16) | (L9 >>> 15) + zuc256GenerateKeyword_X1[1] = LFSR_lo[11]; + zuc256GenerateKeyword_X1[0] = (short)((((LFSR_lo[9] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[9] << 1)); + + // X2 = ((L7 & 0xFFFF) << 16) | (L5 >>> 15) + zuc256GenerateKeyword_X2[1] = LFSR_lo[7]; + zuc256GenerateKeyword_X2[0] = (short)((((LFSR_lo[5] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[5] << 1)); + + // X3 = ((L2 & 0xFFFF) << 16) | (L0 >>> 15) + zuc256GenerateKeyword_X3[1] = LFSR_lo[2]; + zuc256GenerateKeyword_X3[0] = (short)((((LFSR_lo[0] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[0] << 1)); + + + + // ---- 输入:X0,X1,X2,X3,R1,R2 均为 short[2]; 输出:Z,W1,W2,U,V ---- + + // Z = X3 ^ ((X0 ^ R1) + R2) + xor32(zuc256GenerateKeyword_X0[0], zuc256GenerateKeyword_X0[1], zuc256GenerateKeyword_R1[0], zuc256GenerateKeyword_R1[1], zuc256GenerateKeyword_TMP0); // TMP0 = X0 ^ R1 + add32(zuc256GenerateKeyword_TMP0[0], zuc256GenerateKeyword_TMP0[1], zuc256GenerateKeyword_R2[0], zuc256GenerateKeyword_R2[1], zuc256GenerateKeyword_TMP1); // TMP1 = TMP0 + R2 + xor32(zuc256GenerateKeyword_X3[0], zuc256GenerateKeyword_X3[1], zuc256GenerateKeyword_TMP1[0], zuc256GenerateKeyword_TMP1[1], zuc256GenerateKeyword_Z); // Z = X3 ^ TMP1 + + // F_(X1, X2) + // W1 = R1 + X1 + add32(zuc256GenerateKeyword_R1[0], zuc256GenerateKeyword_R1[1], zuc256GenerateKeyword_X1[0], zuc256GenerateKeyword_X1[1], zuc256GenerateKeyword_W1); + + // W2 = R2 ^ X2 + xor32(zuc256GenerateKeyword_R2[0], zuc256GenerateKeyword_R2[1], zuc256GenerateKeyword_X2[0], zuc256GenerateKeyword_X2[1], zuc256GenerateKeyword_W2); + + // U = L1((W1 << 16) | (W2 >>> 16)) + // (W1<<16): lo=0, hi=W1_lo + // (W2>>>16): lo=W2_hi, hi=0 + // OR 结果: lo=W2_hi, hi=W1_lo + L1(zuc256GenerateKeyword_W2[1], zuc256GenerateKeyword_W1[0], zuc256GenerateKeyword_U); + + // V = L2((W2 << 16) | (W1 >>> 16)) + // (W2<<16): lo=0, hi=W2_lo + // (W1>>>16): lo=W1_hi, hi=0 + // OR 结果: lo=W1_hi, hi=W2_lo + L2(zuc256GenerateKeyword_W1[1], zuc256GenerateKeyword_W2[0], zuc256GenerateKeyword_V); + + +// R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], +// Zuc256Tables.S1[(U >>> 16) & 0xFF], +// Zuc256Tables.S0[(U >>> 8) & 0xFF], +// Zuc256Tables.S1[U & 0xFF]); + makeU32( + (short)(Zuc256Tables.S0[((zuc256GenerateKeyword_U[1] >>> 8) & 0xFF)] & 0xFF), // (U >>> 24) & 0xFF + (short)(Zuc256Tables.S1[(zuc256GenerateKeyword_U[1] & 0xFF)] & 0xFF), // (U >>> 16) & 0xFF + (short)(Zuc256Tables.S0[((zuc256GenerateKeyword_U[0] >>> 8) & 0xFF)] & 0xFF), // (U >>> 8) & 0xFF + (short)(Zuc256Tables.S1[(zuc256GenerateKeyword_U[0] & 0xFF)] & 0xFF), // (U >>> 0) & 0xFF + zuc256GenerateKeyword_R1); + +// R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], +// Zuc256Tables.S1[(V >>> 16) & 0xFF], +// Zuc256Tables.S0[(V >>> 8) & 0xFF], +// Zuc256Tables.S1[V & 0xFF]); + makeU32( + (short)(Zuc256Tables.S0[((zuc256GenerateKeyword_V[1] >>> 8) & 0xFF)] & 0xFF), // (V >>> 24) & 0xFF + (short)(Zuc256Tables.S1[(zuc256GenerateKeyword_V[1] & 0xFF)] & 0xFF), // (V >>> 16) & 0xFF + (short)(Zuc256Tables.S0[((zuc256GenerateKeyword_V[0] >>> 8) & 0xFF)] & 0xFF), // (V >>> 8) & 0xFF + (short)(Zuc256Tables.S1[(zuc256GenerateKeyword_V[0] & 0xFF)] & 0xFF), // (V >>> 0) & 0xFF + zuc256GenerateKeyword_R2); + + + +// // LFSRWithWorkMode +// long a = LFSR[0]; +// a += (long)LFSR[0] << 8; +// a += (long)LFSR[4] << 20; +// a += (long)LFSR[10] << 21; +// a += (long)LFSR[13] << 17; +// a += (long)LFSR[15] << 15; + // ---- 先准备累加器 A (64位) ---- + zuc256GenerateKeyword_A[0] = 0; + zuc256GenerateKeyword_A[1] = 0; + zuc256GenerateKeyword_A[2] = 0; + zuc256GenerateKeyword_A[3] = 0; + + // 临时缓冲 + + // a = LFSR[0] + zuc256GenerateKeyword_tmp32[0] = LFSR_lo[0]; + zuc256GenerateKeyword_tmp32[1] = LFSR_hi[0]; + create_64b_from_32b(zuc256GenerateKeyword_tmp64, zuc256GenerateKeyword_tmp32, (short)0); + add64(zuc256GenerateKeyword_A, zuc256GenerateKeyword_tmp64); + + // a += (LFSR[0] << 8) + create_64b_from_32b(zuc256GenerateKeyword_tmp64, zuc256GenerateKeyword_tmp32, (short)8); + add64(zuc256GenerateKeyword_A, zuc256GenerateKeyword_tmp64); + + // a += (LFSR[4] << 20) + zuc256GenerateKeyword_tmp32[0] = LFSR_lo[4]; + zuc256GenerateKeyword_tmp32[1] = LFSR_hi[4]; + create_64b_from_32b(zuc256GenerateKeyword_tmp64, zuc256GenerateKeyword_tmp32, (short)20); + add64(zuc256GenerateKeyword_A, zuc256GenerateKeyword_tmp64); + + // a += (LFSR[10] << 21) + zuc256GenerateKeyword_tmp32[0] = LFSR_lo[10]; + zuc256GenerateKeyword_tmp32[1] = LFSR_hi[10]; + create_64b_from_32b(zuc256GenerateKeyword_tmp64, zuc256GenerateKeyword_tmp32, (short)21); + add64(zuc256GenerateKeyword_A, zuc256GenerateKeyword_tmp64); + + // a += (LFSR[13] << 17) + zuc256GenerateKeyword_tmp32[0] = LFSR_lo[13]; + zuc256GenerateKeyword_tmp32[1] = LFSR_hi[13]; + create_64b_from_32b(zuc256GenerateKeyword_tmp64, zuc256GenerateKeyword_tmp32, (short)17); + add64(zuc256GenerateKeyword_A, zuc256GenerateKeyword_tmp64); + + // a += (LFSR[15] << 15) + zuc256GenerateKeyword_tmp32[0] = LFSR_lo[15]; + zuc256GenerateKeyword_tmp32[1] = LFSR_hi[15]; + create_64b_from_32b(zuc256GenerateKeyword_tmp64, zuc256GenerateKeyword_tmp32, (short)15); + add64(zuc256GenerateKeyword_A, zuc256GenerateKeyword_tmp64); + +// a = (a & 0x7FFFFFFF) + (a >>> 31); + // ---- 第一次折叠:a = (a & 0x7FFFFFFF) + (a >>> 31) ---- + + and64_7FFFFFFF_to32(zuc256GenerateKeyword_A, zuc256GenerateKeyword_low31); // low31 = A & 0x7FFFFFFF + shr64u_31(zuc256GenerateKeyword_A, zuc256GenerateKeyword_r31); // r31 = A >>> 31 + + zuc256GenerateKeyword_A[0]=0; zuc256GenerateKeyword_A[1]=0; zuc256GenerateKeyword_A[2]=0; zuc256GenerateKeyword_A[3]=0; + add64(zuc256GenerateKeyword_A, zuc256GenerateKeyword_low31); + add64(zuc256GenerateKeyword_A, zuc256GenerateKeyword_r31); +// int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); + // ---- 第二次折叠,得到 v(32位)---- + + and64_7FFFFFFF_to32(zuc256GenerateKeyword_A, zuc256GenerateKeyword_low31b); + shr64u_31(zuc256GenerateKeyword_A, zuc256GenerateKeyword_r31b); + + zuc256GenerateKeyword_v64[0]=0; + zuc256GenerateKeyword_v64[1]=0; + zuc256GenerateKeyword_v64[2]=0; + zuc256GenerateKeyword_v64[3]=0; + add64(zuc256GenerateKeyword_v64, zuc256GenerateKeyword_low31b); + add64(zuc256GenerateKeyword_v64, zuc256GenerateKeyword_r31b); + + // v = 32位,取 v64 的低两段 + short v_lo = zuc256GenerateKeyword_v64[0]; + short v_hi = (short)(zuc256GenerateKeyword_v64[1] & 0x7FFF); // 只保留31位 + +// System.arraycopy(LFSR, 1, LFSR, 0, 15); + // LFSR_lo 向左移 + for (short i = 0; i < (short)15; i++) { + LFSR_lo[i] = LFSR_lo[(short)(i + 1)]; + } + // LFSR_hi 向左移 + for (short i = 0; i < (short)15; i++) { + LFSR_hi[i] = LFSR_hi[(short)(i + 1)]; + } + +// LFSR[15] = v; + // ---- 写回 LFSR[15] ---- + LFSR_lo[15] = v_lo; + LFSR_hi[15] = v_hi; + +// state.R1 = R1; +// state.R2 = R2; + R1_lo = zuc256GenerateKeyword_R1[0]; + R1_hi = zuc256GenerateKeyword_R1[1]; + + R2_lo = zuc256GenerateKeyword_R2[0]; + R2_hi = zuc256GenerateKeyword_R2[1]; + + +// return Z; + out[0] = zuc256GenerateKeyword_Z[0]; + out[1] = zuc256GenerateKeyword_Z[1]; + + } + + // 生成指定长度的密钥流 + public void zuc256GenerateKeystream(short nwords, + short[] keystream_hi, + short[] keystream_lo) { + for (short i = 0; i < nwords; i++) { + // 生成一个关键字 -> tmp[0]=lo, tmp[1]=hi + zuc256GenerateKeyword(zuc256GenerateKeystream_tmp); + // 存入输出数组 + keystream_lo[i] = zuc256GenerateKeystream_tmp[0]; + keystream_hi[i] = zuc256GenerateKeystream_tmp[1]; + } + } + + + + + // 初始化MAC密钥 + private void zuc256SetMacKey(byte[] K, byte[] IV, short macbits) { + + for(short i=0; i<2; i++) { + zuc256SetMacKey_R1[i] = (short) 0; + zuc256SetMacKey_R2[i] = (short) 0; + } + for(short i=0; i<4; i++) { + zuc256SetMacKey_A[i] = (short) 0; + zuc256SetMacKey_vv[i] = (short) 0; + zuc256SetMacKey_v64[i] = (short) 0; + } + +// short[] zuc256SetMacKey_D = JCSystem.makeTransientShortArray(Zuc256Tables.D_COLS, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_TMP = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_X0 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_X1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_X2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_R1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_R2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_W = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_W1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_W2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_U = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_V = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_T = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] zuc256SetMacKey_T2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); + + +// int IV17 = (IV[17] & 0xFF) >> 2; +// int IV18 = ((IV[17] & 0x03) << 4) | ((IV[18] & 0xFF) >> 4); +// int IV19 = ((IV[18] & 0x0F) << 2) | ((IV[19] & 0xFF) >> 6); +// int IV20 = IV[19] & 0x3F; +// int IV21 = (IV[20] & 0xFF) >> 2; +// int IV22 = ((IV[20] & 0x03) << 4) | ((IV[21] & 0xFF) >> 4); +// int IV23 = ((IV[21] & 0x0F) << 2) | ((IV[22] & 0xFF) >> 6); +// int IV24 = IV[22] & 0x3F; + // IV 拆分 + short IV17 = (short)((IV[17] & 0xFF) >>> 2); + short IV18 = (short)(((IV[17] & 0x03) << 4) | ((IV[18] & 0xFF) >>> 4)); + short IV19 = (short)(((IV[18] & 0x0F) << 2) | ((IV[19] & 0xFF) >>> 6)); + short IV20 = (short)(IV[19] & 0x3F); + short IV21 = (short)((IV[20] & 0xFF) >>> 2); + short IV22 = (short)(((IV[20] & 0x03) << 4) | ((IV[21] & 0xFF) >>> 4)); + short IV23 = (short)(((IV[21] & 0x0F) << 2) | ((IV[22] & 0xFF) >>> 6)); + short IV24 = (short)(IV[22] & 0x3F); + +// D = (macbits / 32 < 3) ? Zuc256Tables.ZUC256_D[macbits / 32] : Zuc256Tables.ZUC256_D[3]; + short row = (short)((macbits / 32) < 3 ? (macbits / 32) : 3); + Zuc256Tables.getDRow(row, zuc256SetMacKey_D, (short)0); + Zuc256Tables.getDRow(row, zuc256SetMacKey_D, (short)0); + + + // 逐项装载 LFSR +// LFSR[0] = makeU31(K[0] & 0xFF, D[0], K[21] & 0xFF, K[16] & 0xFF); + makeU31((short)(K[0] & 0xFF), (short)zuc256SetMacKey_D[0], (short)(K[21] & 0xFF), (short)(K[16] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[0] = zuc256SetMacKey_tmp[0]; LFSR_hi[0] = zuc256SetMacKey_tmp[1]; + +// LFSR[1] = makeU31(K[1] & 0xFF, D[1], K[22] & 0xFF, K[17] & 0xFF); + makeU31((short)(K[1] & 0xFF), (short)zuc256SetMacKey_D[1], (short)(K[22] & 0xFF), (short)(K[17] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[1] = zuc256SetMacKey_tmp[0]; LFSR_hi[1] = zuc256SetMacKey_tmp[1]; + +// LFSR[2] = makeU31(K[2] & 0xFF, D[2], K[23] & 0xFF, K[18] & 0xFF); + makeU31((short)(K[2] & 0xFF), (short)zuc256SetMacKey_D[2], (short)(K[23] & 0xFF), (short)(K[18] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[2] = zuc256SetMacKey_tmp[0]; LFSR_hi[2] = zuc256SetMacKey_tmp[1]; + +// LFSR[3] = makeU31(K[3] & 0xFF, D[3], K[24] & 0xFF, K[19] & 0xFF); + makeU31((short)(K[3] & 0xFF), (short)zuc256SetMacKey_D[3], (short)(K[24] & 0xFF), (short)(K[19] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[3] = zuc256SetMacKey_tmp[0]; LFSR_hi[3] = zuc256SetMacKey_tmp[1]; + +// LFSR[4] = makeU31(K[4] & 0xFF, D[4], K[25] & 0xFF, K[20] & 0xFF); + makeU31((short)(K[4] & 0xFF), (short)zuc256SetMacKey_D[4], (short)(K[25] & 0xFF), (short)(K[20] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[4] = zuc256SetMacKey_tmp[0]; LFSR_hi[4] = zuc256SetMacKey_tmp[1]; + +// LFSR[5] = makeU31(IV[0] & 0xFF, (D[5] | IV17), K[5] & 0xFF, K[26] & 0xFF); + makeU31((short)(IV[0] & 0xFF), (short)(zuc256SetMacKey_D[5] | IV17), (short)(K[5] & 0xFF), (short)(K[26] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[5] = zuc256SetMacKey_tmp[0]; LFSR_hi[5] = zuc256SetMacKey_tmp[1]; + +// LFSR[6] = makeU31(IV[1] & 0xFF, (D[6] | IV18), K[6] & 0xFF, K[27] & 0xFF); + makeU31((short)(IV[1] & 0xFF), (short)(zuc256SetMacKey_D[6] | IV18), (short)(K[6] & 0xFF), (short)(K[27] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[6] = zuc256SetMacKey_tmp[0]; LFSR_hi[6] = zuc256SetMacKey_tmp[1]; + +// LFSR[7] = makeU31(IV[10] & 0xFF, (D[7] | IV19), K[7] & 0xFF, IV[2] & 0xFF); + makeU31((short)(IV[10] & 0xFF), (short)(zuc256SetMacKey_D[7] | IV19), (short)(K[7] & 0xFF), (short)(IV[2] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[7] = zuc256SetMacKey_tmp[0]; LFSR_hi[7] = zuc256SetMacKey_tmp[1]; + +// LFSR[8] = makeU31(K[8] & 0xFF, (D[8] | IV20), IV[3] & 0xFF, IV[11] & 0xFF); + makeU31((short)(K[8] & 0xFF), (short)(zuc256SetMacKey_D[8] | IV20), (short)(IV[3] & 0xFF), (short)(IV[11] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[8] = zuc256SetMacKey_tmp[0]; LFSR_hi[8] = zuc256SetMacKey_tmp[1]; + +// LFSR[9] = makeU31(K[9] & 0xFF, (D[9] | IV21), IV[12] & 0xFF, IV[4] & 0xFF); + makeU31((short)(K[9] & 0xFF), (short)(zuc256SetMacKey_D[9] | IV21), (short)(IV[12] & 0xFF), (short)(IV[4] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[9] = zuc256SetMacKey_tmp[0]; LFSR_hi[9] = zuc256SetMacKey_tmp[1]; + +// LFSR[10] = makeU31(IV[5] & 0xFF, (D[10] | IV22), K[10] & 0xFF, K[28] & 0xFF); + makeU31((short)(IV[5] & 0xFF), (short)(zuc256SetMacKey_D[10] | IV22), (short)(K[10] & 0xFF), (short)(K[28] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[10] = zuc256SetMacKey_tmp[0]; LFSR_hi[10] = zuc256SetMacKey_tmp[1]; + +// LFSR[11] = makeU31(K[11] & 0xFF, (D[11] | IV23), IV[6] & 0xFF, IV[13] & 0xFF); + makeU31((short)(K[11] & 0xFF), (short)(zuc256SetMacKey_D[11] | IV23), (short)(IV[6] & 0xFF), (short)(IV[13] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[11] = zuc256SetMacKey_tmp[0]; LFSR_hi[11] = zuc256SetMacKey_tmp[1]; + +// LFSR[12] = makeU31(K[12] & 0xFF, (D[12] | IV24), IV[7] & 0xFF, IV[14] & 0xFF); + makeU31((short)(K[12] & 0xFF), (short)(zuc256SetMacKey_D[12] | IV24), (short)(IV[7] & 0xFF), (short)(IV[14] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[12] = zuc256SetMacKey_tmp[0]; LFSR_hi[12] = zuc256SetMacKey_tmp[1]; + +// LFSR[13] = makeU31(K[13] & 0xFF, D[13], IV[15] & 0xFF, IV[8] & 0xFF); + makeU31((short)(K[13] & 0xFF), (short)zuc256SetMacKey_D[13], (short)(IV[15] & 0xFF), (short)(IV[8] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[13] = zuc256SetMacKey_tmp[0]; LFSR_hi[13] = zuc256SetMacKey_tmp[1]; + +// LFSR[14] = makeU31(K[14] & 0xFF, (D[14] | (K[31] >>> 4)), IV[16] & 0xFF, IV[9] & 0xFF); + makeU31((short)(K[14] & 0xFF), (short)(zuc256SetMacKey_D[14] | ((K[31] & 0xFF) >>> 4)), (short)(IV[16] & 0xFF), (short)(IV[9] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[14] = zuc256SetMacKey_tmp[0]; LFSR_hi[14] = zuc256SetMacKey_tmp[1]; + +// LFSR[15] = makeU31(K[15] & 0xFF, (D[15] | (K[31] & 0x0F)), K[30] & 0xFF, K[29] & 0xFF); + makeU31((short)(K[15] & 0xFF), (short)(zuc256SetMacKey_D[15] | (K[31] & 0x0F)), (short)(K[30] & 0xFF), (short)(K[29] & 0xFF), zuc256SetMacKey_tmp); + LFSR_lo[15] = zuc256SetMacKey_tmp[0]; LFSR_hi[15] = zuc256SetMacKey_tmp[1]; + + + short c15_2 = 0; + for (short i = 0; i < 32; i++) { + // BitReconstruction3 +// X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); + // X0 = ((L15 & 0x7FFF8000)<<1) | (L14 & 0xFFFF) + c15_2 = (short)((LFSR_lo[15] & (short)0x8000) >>> 15); + zuc256SetMacKey_X0[1] = (short)(((LFSR_hi[15] & (short)0x7FFF) << 1) | (short)(c15_2 & 0x0001)); + zuc256SetMacKey_X0[0] = LFSR_lo[14]; + +// X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + // X1 = ((L11 & 0xFFFF)<<16) | (L9>>>15) + zuc256SetMacKey_X1[1] = LFSR_lo[11]; + zuc256SetMacKey_X1[0] = (short)((((LFSR_lo[9] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[9] << 1)); + +// X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + // X2 = ((L7 & 0xFFFF)<<16) | (L5>>>15) + zuc256SetMacKey_X2[1] = LFSR_lo[7]; + zuc256SetMacKey_X2[0] = (short)((((LFSR_lo[5] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[5] << 1)); + + + + // F(X0, X1, X2) + // W = (X0 ^ R1) + R2 + xor32(zuc256SetMacKey_X0[0], zuc256SetMacKey_X0[1], zuc256SetMacKey_R1[0], zuc256SetMacKey_R1[1], zuc256SetMacKey_TMP); + add32(zuc256SetMacKey_TMP[0], zuc256SetMacKey_TMP[1], zuc256SetMacKey_R2[0], zuc256SetMacKey_R2[1], zuc256SetMacKey_W); + + // W1 = R1 + X1 + add32(zuc256SetMacKey_R1[0], zuc256SetMacKey_R1[1], zuc256SetMacKey_X1[0], zuc256SetMacKey_X1[1], zuc256SetMacKey_W1); + + // W2 = R2 ^ X2 + xor32(zuc256SetMacKey_R2[0], zuc256SetMacKey_R2[1], zuc256SetMacKey_X2[0], zuc256SetMacKey_X2[1], zuc256SetMacKey_W2); + + // U = L1((W1<<16) | (W2>>>16)) + L1(zuc256SetMacKey_W2[1], zuc256SetMacKey_W1[0], zuc256SetMacKey_U); + + // V = L2((W2<<16) | (W1>>>16)) + L2(zuc256SetMacKey_W1[1], zuc256SetMacKey_W2[0], zuc256SetMacKey_V); + +// R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], +// Zuc256Tables.S1[(U >>> 16) & 0xFF], +// Zuc256Tables.S0[(U >>> 8) & 0xFF], +// Zuc256Tables.S1[U & 0xFF]); +// +// R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], +// Zuc256Tables.S1[(V >>> 16) & 0xFF], +// Zuc256Tables.S0[(V >>> 8) & 0xFF], +// Zuc256Tables.S1[V & 0xFF]); + // 更新 R1,R2 + makeU32( + (short)(Zuc256Tables.S0[((zuc256SetMacKey_U[1] >>> 8) & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S1[(zuc256SetMacKey_U[1] & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S0[((zuc256SetMacKey_U[0] >>> 8) & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S1[(zuc256SetMacKey_U[0] & 0xFF)] & 0xFF), + zuc256SetMacKey_R1); + + makeU32( + (short)(Zuc256Tables.S0[((zuc256SetMacKey_V[1] >>> 8) & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S1[(zuc256SetMacKey_V[1] & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S0[((zuc256SetMacKey_V[0] >>> 8) & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S1[(zuc256SetMacKey_V[0] & 0xFF)] & 0xFF), + zuc256SetMacKey_R2); + + // LFSRWithInitialisationMode(W >> 1) +// int v = LFSR[0]; + zuc256SetMacKey_V[0] = LFSR_lo[0]; + zuc256SetMacKey_V[1] = LFSR_hi[0]; + + // v = add31(v, rot31(LFSR[0], 8)) + rot31(LFSR_lo[0], LFSR_hi[0], (short)8, zuc256SetMacKey_T); + add31(zuc256SetMacKey_V[0], zuc256SetMacKey_V[1], zuc256SetMacKey_T[0], zuc256SetMacKey_T[1], zuc256SetMacKey_V); + +// v = add31(v, rot31(LFSR[4], 20)); + rot31(LFSR_lo[4], LFSR_hi[4], (short)20, zuc256SetMacKey_T); + add31(zuc256SetMacKey_V[0], zuc256SetMacKey_V[1], zuc256SetMacKey_T[0], zuc256SetMacKey_T[1], zuc256SetMacKey_V); + +// v = add31(v, rot31(LFSR[10], 21)); + rot31(LFSR_lo[10], LFSR_hi[10], (short)21, zuc256SetMacKey_T); + add31(zuc256SetMacKey_V[0], zuc256SetMacKey_V[1], zuc256SetMacKey_T[0], zuc256SetMacKey_T[1], zuc256SetMacKey_V); + +// v = add31(v, rot31(LFSR[13], 17)); + rot31(LFSR_lo[13], LFSR_hi[13], (short)17, zuc256SetMacKey_T); + add31(zuc256SetMacKey_V[0], zuc256SetMacKey_V[1], zuc256SetMacKey_T[0], zuc256SetMacKey_T[1], zuc256SetMacKey_V); + +// v = add31(v, rot31(LFSR[15], 15)); + rot31(LFSR_lo[15], LFSR_hi[15], (short)15, zuc256SetMacKey_T); + add31(zuc256SetMacKey_V[0], zuc256SetMacKey_V[1], zuc256SetMacKey_T[0], zuc256SetMacKey_T[1], zuc256SetMacKey_V); + +// v = add31(v, W >>> 1); + shr32u1(zuc256SetMacKey_W[0], zuc256SetMacKey_W[1], zuc256SetMacKey_T2); // T2[0]=lo, T2[1]=hi(无符号>>>1) + zuc256SetMacKey_T2[1] = (short)(zuc256SetMacKey_T2[1] & (short)0xFFFF); // 只保留31位 + add31(zuc256SetMacKey_V[0], zuc256SetMacKey_V[1], zuc256SetMacKey_T2[0], zuc256SetMacKey_T2[1], zuc256SetMacKey_V); + + // System.arraycopy(LFSR, 1, LFSR, 0, 15) +// 相当于 System.arraycopy(LFSR_lo, 1, LFSR_lo, 0, 15); + for (short j = 0; j < (short)15; j++) { + LFSR_lo[j] = LFSR_lo[(short)(j + 1)]; + } +// 相当于 System.arraycopy(LFSR_hi, 1, LFSR_hi, 0, 15); + for (short j = 0; j < (short)15; j++) { + LFSR_hi[j] = LFSR_hi[(short)(j + 1)]; + } + +// LFSR[15] = v; + LFSR_lo[15] = zuc256SetMacKey_V[0]; + LFSR_hi[15] = (short)(zuc256SetMacKey_V[1] & 0x7FFF); + } + + // BitReconstruction2 +// X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + zuc256SetMacKey_X1[1] = LFSR_lo[11]; + zuc256SetMacKey_X1[0] = (short)((((LFSR_lo[9] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[9] << 1)); + +// X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + zuc256SetMacKey_X2[1] = LFSR_lo[7]; + zuc256SetMacKey_X2[0] = (short)((((LFSR_lo[5] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[5] << 1)); + + // F_(X1, X2) +// W1 = R1 + X1; + add32(zuc256SetMacKey_R1[0], zuc256SetMacKey_R1[1], zuc256SetMacKey_X1[0], zuc256SetMacKey_X1[1], zuc256SetMacKey_W1); // W1 = R1 + X1 +// W2 = R2 ^ X2; + xor32(zuc256SetMacKey_R2[0], zuc256SetMacKey_R2[1], zuc256SetMacKey_X2[0], zuc256SetMacKey_X2[1], zuc256SetMacKey_W2); // W2 = R2 ^ X2 + +// U = L1((W1 << 16) | (W2 >>> 16)); + // U = L1((W1<<16)|(W2>>>16)) → lo=W2_hi, hi=W1_lo + L1(zuc256SetMacKey_W2[1], zuc256SetMacKey_W1[0], zuc256SetMacKey_U); + +// V = L2((W2 << 16) | (W1 >>> 16)); + // V = L2((W2<<16)|(W1>>>16)) → lo=W1_hi, hi=W2_lo + L2(zuc256SetMacKey_W1[1], zuc256SetMacKey_W2[0], zuc256SetMacKey_V); + +// R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], +// Zuc256Tables.S1[(U >>> 16) & 0xFF], +// Zuc256Tables.S0[(U >>> 8) & 0xFF], +// Zuc256Tables.S1[U & 0xFF]); + makeU32( + (short)(Zuc256Tables.S0[((zuc256SetMacKey_U[1] >>> 8) & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S1[(zuc256SetMacKey_U[1] & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S0[((zuc256SetMacKey_U[0] >>> 8) & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S1[(zuc256SetMacKey_U[0] & 0xFF)] & 0xFF), + zuc256SetMacKey_R1); + +// R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], +// Zuc256Tables.S1[(V >>> 16) & 0xFF], +// Zuc256Tables.S0[(V >>> 8) & 0xFF], +// Zuc256Tables.S1[V & 0xFF]); + makeU32( + (short)(Zuc256Tables.S0[((zuc256SetMacKey_V[1] >>> 8) & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S1[(zuc256SetMacKey_V[1] & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S0[((zuc256SetMacKey_V[0] >>> 8) & 0xFF)] & 0xFF), + (short)(Zuc256Tables.S1[(zuc256SetMacKey_V[0] & 0xFF)] & 0xFF), + zuc256SetMacKey_R2); + + // ---- LFSRWithWorkMode ---- + // LFSRWithWorkMode +// long a = LFSR[0]; + zuc256SetMacKey_tmp32[0] = LFSR_lo[0]; + zuc256SetMacKey_tmp32[1] = LFSR_hi[0]; + create_64b_from_32b(zuc256SetMacKey_tmp64, zuc256SetMacKey_tmp32, (short)0); + add64(zuc256SetMacKey_A, zuc256SetMacKey_tmp64); + +// a += (long)LFSR[0] << 8; + create_64b_from_32b(zuc256SetMacKey_tmp64, zuc256SetMacKey_tmp32, (short)8); + add64(zuc256SetMacKey_A, zuc256SetMacKey_tmp64); + +// a += (long)LFSR[4] << 20; + zuc256SetMacKey_tmp32[0] = LFSR_lo[4]; zuc256SetMacKey_tmp32[1] = LFSR_hi[4]; + create_64b_from_32b(zuc256SetMacKey_tmp64, zuc256SetMacKey_tmp32, (short)20); + add64(zuc256SetMacKey_A, zuc256SetMacKey_tmp64); + +// a += (long)LFSR[10] << 21; + zuc256SetMacKey_tmp32[0] = LFSR_lo[10]; zuc256SetMacKey_tmp32[1] = LFSR_hi[10]; + create_64b_from_32b(zuc256SetMacKey_tmp64, zuc256SetMacKey_tmp32, (short)21); + add64(zuc256SetMacKey_A, zuc256SetMacKey_tmp64); + +// a += (long)LFSR[13] << 17; + zuc256SetMacKey_tmp32[0] = LFSR_lo[13]; zuc256SetMacKey_tmp32[1] = LFSR_hi[13]; + create_64b_from_32b(zuc256SetMacKey_tmp64, zuc256SetMacKey_tmp32, (short)17); + add64(zuc256SetMacKey_A, zuc256SetMacKey_tmp64); + +// a += (long)LFSR[15] << 15; + zuc256SetMacKey_tmp32[0] = LFSR_lo[15]; zuc256SetMacKey_tmp32[1] = LFSR_hi[15]; + create_64b_from_32b(zuc256SetMacKey_tmp64, zuc256SetMacKey_tmp32, (short)15); + add64(zuc256SetMacKey_A, zuc256SetMacKey_tmp64); + +// a = (a & 0x7FFFFFFF) + (a >>> 31); + and64_7FFFFFFF_to32(zuc256SetMacKey_A, zuc256SetMacKey_low31); + shr64u_31(zuc256SetMacKey_A, zuc256SetMacKey_r31); + + add64(zuc256SetMacKey_v64, zuc256SetMacKey_low31); + add64(zuc256SetMacKey_v64, zuc256SetMacKey_r31); + +// int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); + and64_7FFFFFFF_to32(zuc256SetMacKey_v64, zuc256SetMacKey_low31); + shr64u_31(zuc256SetMacKey_v64, zuc256SetMacKey_r31); + add64(zuc256SetMacKey_vv, zuc256SetMacKey_low31); + add64(zuc256SetMacKey_vv, zuc256SetMacKey_r31); + + short v_lo = zuc256SetMacKey_vv[0]; + short v_hi = (short)(zuc256SetMacKey_vv[1] & 0x7FFF); + +// LFSR左移 +// System.arraycopy(LFSR, 1, LFSR, 0, 15); + // LFSR_lo 向左移 + for (short i = 0; i < (short)15; i++) { + LFSR_lo[i] = LFSR_lo[(short)(i + 1)]; + } + // LFSR_hi 向左移 + for (short i = 0; i < (short)15; i++) { + LFSR_hi[i] = LFSR_hi[(short)(i + 1)]; + } + +// LFSR[15] = v; + LFSR_lo[15] = v_lo; + LFSR_hi[15] = v_hi; + + R1_lo = zuc256SetMacKey_R1[0]; R1_hi = zuc256SetMacKey_R1[1]; + R2_lo = zuc256SetMacKey_R2[0]; R2_hi = zuc256SetMacKey_R2[1]; + } + + + //===zuc256Encryptctx + + // 初始化加密上下文 + public void initZuc256EncryptCtx(byte[] key32, byte[] iv_in_25) { + extractIv(iv_in_25, extracted_iv_23); +// Arrays.fill(this.buf, (byte) 0); + for (short i = 0; i < (short)this.ctx_buf.length; i++) { + this.ctx_buf[i] = (byte)0; + } + this.ctx_buflen = 0; + initState(key32, extracted_iv_23); + } + + // 分阶段处理加密数据 + public void updateZuc256EncryptCtx(byte[] in, short inlen, byte[] out) { + + + if (in == null || out == null || inlen == 0) return; + + short inPos = 0; // 输入偏移 + short outPos = 0; // 输出偏移 + + // 处理缓冲区中剩余的非4字节数据 + if (this.ctx_buflen > 0) { +// int need = 4 - this.buflen; + short need = (short)(4 - this.ctx_buflen); +// int copy = Math.min(inlen, need); + short copy = (short)((inlen < need) ? inlen : need); + + // 替代 System.arraycopy(in, 0, this.buf, this.buflen, copy); + Util.arrayCopyNonAtomic(in, (short)0, this.ctx_buf, this.ctx_buflen, copy); + + this.ctx_buflen += copy; + + // 调整输入指针和长度 +// byte[] newIn = new byte[inlen - copy]; +// if (inlen - copy > 0) { +// System.arraycopy(in, copy, newIn, 0, inlen - copy); +// } +// in = newIn; +// inlen -= copy; + // 推进输入指针与剩余长度 + inPos += copy; + inlen -= copy; + + // 缓冲区已满,处理一个完整的4字节块 + if (this.ctx_buflen == 4) { +// int keystream = zuc256GenerateKeyword(this.state); + zuc256GenerateKeyword(updateZuc256EncryptCtx_ks); // ks[0]=lo, ks[1]=hi + +// int plain = getU32(this.buf, 0); + // 取出 4 字节明文 → plain[0]=lo, plain[1]=hi + getU32(this.ctx_buf, (short)0, updateZuc256EncryptCtx_plain); + +// putU32(out, 0, plain ^ keystream); + // plain ^ ks → res + xor32(updateZuc256EncryptCtx_plain[0], updateZuc256EncryptCtx_plain[1], updateZuc256EncryptCtx_ks[0], updateZuc256EncryptCtx_ks[1], updateZuc256EncryptCtx_res); + // 写回 out 的前4字节 + putU32(out, (short)0, updateZuc256EncryptCtx_res[0], updateZuc256EncryptCtx_res[1]); + + this.ctx_buflen = 0; +// Arrays.fill(this.buf, (byte) 0); + for (short i = 0; i < (short)this.ctx_buf.length; i++) { + this.ctx_buf[i] = (byte)0; + } + + // 调整输出指针 +// byte[] newOut = new byte[out.length - 4]; +// if (out.length - 4 > 0) { +// System.arraycopy(out, 4, newOut, 0, out.length - 4); +// } +// out = newOut; + // 这里C实现就是直接指针+4的。JavaSE实现搞这个new干嘛。。 + outPos += 4; + } + } + + // 处理完整的4字节块 +// int fullBlocks = inlen / 4; + short fullBlocks = (short) (inlen / 4); + if (fullBlocks > 0) { +// int[] keystream = new int[fullBlocks]; + +// zuc256GenerateKeystream(this.state, fullBlocks, keystream); + zuc256GenerateKeystream(fullBlocks, updateZuc256EncryptCtx_ks_hi, updateZuc256EncryptCtx_ks_lo); + + + // 逐块异或加密 + for (short i = 0; i < fullBlocks; i++) { +// int plain = getU32(in, i * 4); + short off = (short) (i << 2); // i*4 + // 读明文 + getU32(in, (short)(inPos+off), updateZuc256EncryptCtx_word); // word[0]=lo, word[1]=hi + +// putU32(out, i * 4, plain ^ keystream[i]); + // XOR keystream + updateZuc256EncryptCtx_word[0] = (short)(updateZuc256EncryptCtx_word[0] ^ updateZuc256EncryptCtx_ks_lo[i]); + updateZuc256EncryptCtx_word[1] = (short)(updateZuc256EncryptCtx_word[1] ^ updateZuc256EncryptCtx_ks_hi[i]); + // 写密文 + putU32(out, (short) (outPos+off), updateZuc256EncryptCtx_word[0], updateZuc256EncryptCtx_word[1]); + } + + // 调整输入指针和长度 +// int processed = fullBlocks * 4; + short processed = (short)(fullBlocks * 4); + +// byte[] newIn = new byte[inlen - processed]; +// if (inlen - processed > 0) { +// System.arraycopy(in, processed, newIn, 0, inlen - processed); +// } +// in = newIn; +// inlen -= processed; + // 推进输入/输出指针与剩余长度 + inPos += processed; + inlen -= processed; + outPos += processed; + } + + // 缓存剩余不足4字节的数据 + if (inlen > 0) { + // 等价于 System.arraycopy(in, 0, this.buf, 0, inlen); + Util.arrayCopyNonAtomic(in, (short)inPos, this.ctx_buf, (short)0, inlen); + + this.ctx_buflen = inlen; + } + } + + // 完成加密处理 + public void finishZuc256EncryptCtx(byte[] out, short outLen) { + if (out == null) return; + // 处理缓冲区中剩余的不足4字节数据 + if (this.ctx_buflen > 0) { +// int keystream = zuc256GenerateKeyword(this.state); + // 生成一个 32-bit 密钥字:ks[0]=lo16, ks[1]=hi16 + zuc256GenerateKeyword(finishZuc256EncryptCtx_ks); + +// byte[] keystreamBytes = new byte[4]; +// putU32(keystreamBytes, 0, keystream); + putU32(finishZuc256EncryptCtx_keystreamBytes, (short)0, finishZuc256EncryptCtx_ks[0], finishZuc256EncryptCtx_ks[1]); + + // 逐字节异或 + short outOffset = (short)(outLen - this.ctx_buflen); + for (short i = 0; i < this.ctx_buflen; i++) { + out[(short)(i+outOffset)] = (byte) (this.ctx_buf[i] ^ finishZuc256EncryptCtx_keystreamBytes[i]); + } + } + + + + // 清理上下文 +// Arrays.fill(this.buf, (byte) 0); + for(short i=0; i<4; i++) { + this.ctx_buf[i] = (byte)0; + } + + this.ctx_buflen = 0; + +// Arrays.fill(this.state.LFSR, 0); + // LFSR 全部清零(高低位数组各 16 个元素) + for (short i = 0; i < 16; i++) { + LFSR_lo[i] = 0; + LFSR_hi[i] = 0; + } + + +// this.state.R1 = 0; +// this.state.R2 = 0; +// R1、R2 清零 + R1_lo = 0; + R1_hi = 0; + R2_lo = 0; + R2_hi = 0; + } +} diff --git a/Project/Src/com/cscn/XwSecurity.java b/build_tools/Project/Src/XwSecurity.java similarity index 100% rename from Project/Src/com/cscn/XwSecurity.java rename to build_tools/Project/Src/XwSecurity.java diff --git a/Project/Src/com/cscn/Zuc256Core.java b/build_tools/Project/Src/Zuc256Core.java similarity index 100% rename from Project/Src/com/cscn/Zuc256Core.java rename to build_tools/Project/Src/Zuc256Core.java diff --git a/Project/Src/com/cscn/Zuc256Demo.java b/build_tools/Project/Src/Zuc256Demo.java similarity index 100% rename from Project/Src/com/cscn/Zuc256Demo.java rename to build_tools/Project/Src/Zuc256Demo.java diff --git a/Project/Src/com/cscn/Zuc256EncryptCtx.java b/build_tools/Project/Src/Zuc256EncryptCtx.java similarity index 100% rename from Project/Src/com/cscn/Zuc256EncryptCtx.java rename to build_tools/Project/Src/Zuc256EncryptCtx.java diff --git a/Project/Src/com/cscn/Zuc256MacCtx.java b/build_tools/Project/Src/Zuc256MacCtx.java similarity index 100% rename from Project/Src/com/cscn/Zuc256MacCtx.java rename to build_tools/Project/Src/Zuc256MacCtx.java diff --git a/Project/Src/com/cscn/Zuc256State.java b/build_tools/Project/Src/Zuc256State.java similarity index 100% rename from Project/Src/com/cscn/Zuc256State.java rename to build_tools/Project/Src/Zuc256State.java diff --git a/build_tools/Project/Src/Zuc256Tables.java b/build_tools/Project/Src/Zuc256Tables.java new file mode 100644 index 0000000..cbc6539 --- /dev/null +++ b/build_tools/Project/Src/Zuc256Tables.java @@ -0,0 +1,98 @@ +package com.cscn; + +/** + * 常量表:S0/S1 与 ZUC256_D。 + * 注意:JavaCard 目标环境建议将表定义为 static final 数组,按 int/short 存放。 + * 适配说明:已将 32bit int 数组改为 16bit short 数组,符合JavaCard 16bit能力要求 + */ +public final class Zuc256Tables { + + // 私有构造函数:防止类被实例化 + private Zuc256Tables() {} + + // S盒:S0, S1 + public static final short[] S0 = { + 0x3e,0x72,0x5b,0x47,0xca,0xe0,0x00,0x33,0x04,0xd1,0x54,0x98,0x09,0xb9,0x6d,0xcb, + 0x7b,0x1b,0xf9,0x32,0xaf,0x9d,0x6a,0xa5,0xb8,0x2d,0xfc,0x1d,0x08,0x53,0x03,0x90, + 0x4d,0x4e,0x84,0x99,0xe4,0xce,0xd9,0x91,0xdd,0xb6,0x85,0x48,0x8b,0x29,0x6e,0xac, + 0xcd,0xc1,0xf8,0x1e,0x73,0x43,0x69,0xc6,0xb5,0xbd,0xfd,0x39,0x63,0x20,0xd4,0x38, + 0x76,0x7d,0xb2,0xa7,0xcf,0xed,0x57,0xc5,0xf3,0x2c,0xbb,0x14,0x21,0x06,0x55,0x9b, + 0xe3,0xef,0x5e,0x31,0x4f,0x7f,0x5a,0xa4,0x0d,0x82,0x51,0x49,0x5f,0xba,0x58,0x1c, + 0x4a,0x16,0xd5,0x17,0xa8,0x92,0x24,0x1f,0x8c,0xff,0xd8,0xae,0x2e,0x01,0xd3,0xad, + 0x3b,0x4b,0xda,0x46,0xeb,0xc9,0xde,0x9a,0x8f,0x87,0xd7,0x3a,0x80,0x6f,0x2f,0xc8, + 0xb1,0xb4,0x37,0xf7,0x0a,0x22,0x13,0x28,0x7c,0xcc,0x3c,0x89,0xc7,0xc3,0x96,0x56, + 0x07,0xbf,0x7e,0xf0,0x0b,0x2b,0x97,0x52,0x35,0x41,0x79,0x61,0xa6,0x4c,0x10,0xfe, + 0xbc,0x26,0x95,0x88,0x8a,0xb0,0xa3,0xfb,0xc0,0x18,0x94,0xf2,0xe1,0xe5,0xe9,0x5d, + 0xd0,0xdc,0x11,0x66,0x64,0x5c,0xec,0x59,0x42,0x75,0x12,0xf5,0x74,0x9c,0xaa,0x23, + 0x0e,0x86,0xab,0xbe,0x2a,0x02,0xe7,0x67,0xe6,0x44,0xa2,0x6c,0xc2,0x93,0x9f,0xf1, + 0xf6,0xfa,0x36,0xd2,0x50,0x68,0x9e,0x62,0x71,0x15,0x3d,0xd6,0x40,0xc4,0xe2,0x0f, + 0x8e,0x83,0x77,0x6b,0x25,0x05,0x3f,0x0c,0x30,0xea,0x70,0xb7,0xa1,0xe8,0xa9,0x65, + 0x8d,0x27,0x1a,0xdb,0x81,0xb3,0xa0,0xf4,0x45,0x7a,0x19,0xdf,0xee,0x78,0x34,0x60 + }; + + public static final short[] S1 = { + 0x55,0xc2,0x63,0x71,0x3b,0xc8,0x47,0x86,0x9f,0x3c,0xda,0x5b,0x29,0xaa,0xfd,0x77, + 0x8c,0xc5,0x94,0x0c,0xa6,0x1a,0x13,0x00,0xe3,0xa8,0x16,0x72,0x40,0xf9,0xf8,0x42, + 0x44,0x26,0x68,0x96,0x81,0xd9,0x45,0x3e,0x10,0x76,0xc6,0xa7,0x8b,0x39,0x43,0xe1, + 0x3a,0xb5,0x56,0x2a,0xc0,0x6d,0xb3,0x05,0x22,0x66,0xbf,0xdc,0x0b,0xfa,0x62,0x48, + 0xdd,0x20,0x11,0x06,0x36,0xc9,0xc1,0xcf,0xf6,0x27,0x52,0xbb,0x69,0xf5,0xd4,0x87, + 0x7f,0x84,0x4c,0xd2,0x9c,0x57,0xa4,0xbc,0x4f,0x9a,0xdf,0xfe,0xd6,0x8d,0x7a,0xeb, + 0x2b,0x53,0xd8,0x5c,0xa1,0x14,0x17,0xfb,0x23,0xd5,0x7d,0x30,0x67,0x73,0x08,0x09, + 0xee,0xb7,0x70,0x3f,0x61,0xb2,0x19,0x8e,0x4e,0xe5,0x4b,0x93,0x8f,0x5d,0xdb,0xa9, + 0xad,0xf1,0xae,0x2e,0xcb,0x0d,0xfc,0xf4,0x2d,0x46,0x6e,0x1d,0x97,0xe8,0xd1,0xe9, + 0x4d,0x37,0xa5,0x75,0x5e,0x83,0x9e,0xab,0x82,0x9d,0xb9,0x1c,0xe0,0xcd,0x49,0x89, + 0x01,0xb6,0xbd,0x58,0x24,0xa2,0x5f,0x38,0x78,0x99,0x15,0x90,0x50,0xb8,0x95,0xe4, + 0xd0,0x91,0xc7,0xce,0xed,0x0f,0xb4,0x6f,0xa0,0xcc,0xf0,0x02,0x4a,0x79,0xc3,0xde, + 0xa3,0xef,0xea,0x51,0xe6,0x6b,0x18,0xec,0x1b,0x2c,0x80,0xf7,0x74,0xe7,0xff,0x21, + 0x5a,0x6a,0x54,0x1e,0x41,0x31,0x92,0x35,0xc4,0x33,0x07,0x0a,0xba,0x7e,0x0e,0x34, + 0x88,0xb1,0x98,0x7c,0xf3,0x3d,0x60,0x6c,0x7b,0xca,0xd3,0x1f,0x32,0x65,0x04,0x28, + 0x64,0xbe,0x85,0x9b,0x2f,0x59,0x8a,0xd7,0xb0,0x25,0xac,0xaf,0x12,0x03,0xe2,0xf2 + }; + +// /** +// * 常量数组 D(16bit short二维数组适配) +// */ +// public static final short[][] ZUC256_D = { +// {0x22,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, +// {0x22,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, +// {0x23,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, +// {0x23,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30} +// }; + public static final short D_COLS = 16; + /** + * 常量数组 D(16bit short二维数组适配) + */ + public static final short[] ZUC256_D_FLAT = { + // row 0 + 0x22,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40, + 0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30, + + // row 1 + 0x22,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40, + 0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30, + + // row 2 + 0x23,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40, + 0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30, + + // row 3 + 0x23,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40, + 0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30 + }; + + + /** 读取 D[row][col],返回无符号值 0..255 */ + public static short getD(short row, short col) { + // idx = row * 16 + col + short idx = (short)(row * D_COLS + col); + return (short)(ZUC256_D_FLAT[idx] & 0xFF); + } + + /** 取一行 (返回一段16个short) */ + public static void getDRow(short row, short[] out, short outOff) { + short base = (short)(row * D_COLS); + for (short i = 0; i < D_COLS; i++) { + out[(short)(outOff + i)] = ZUC256_D_FLAT[(short)(base + i)]; + } + } +} \ No newline at end of file diff --git a/Project/Src/com/cscn/Zuc256Util.java b/build_tools/Project/Src/Zuc256Util.java similarity index 100% rename from Project/Src/com/cscn/Zuc256Util.java rename to build_tools/Project/Src/Zuc256Util.java diff --git a/build_tools/Project/bin/com/cscn/javacard/cscn.cap b/build_tools/Project/bin/com/cscn/javacard/cscn.cap new file mode 100644 index 0000000..902b6a5 Binary files /dev/null and b/build_tools/Project/bin/com/cscn/javacard/cscn.cap differ diff --git a/build_tools/Project/bin/com/cscn/javacard/cscn.exp b/build_tools/Project/bin/com/cscn/javacard/cscn.exp new file mode 100644 index 0000000..6a48131 Binary files /dev/null and b/build_tools/Project/bin/com/cscn/javacard/cscn.exp differ diff --git a/Tools/api_exp/JCDK222/java/io/javacard/io.exp b/build_tools/Tools/api_exp/JCDK222/java/io/javacard/io.exp similarity index 100% rename from Tools/api_exp/JCDK222/java/io/javacard/io.exp rename to build_tools/Tools/api_exp/JCDK222/java/io/javacard/io.exp diff --git a/Tools/api_exp/JCDK222/java/lang/javacard/lang.exp b/build_tools/Tools/api_exp/JCDK222/java/lang/javacard/lang.exp similarity index 100% rename from Tools/api_exp/JCDK222/java/lang/javacard/lang.exp rename to build_tools/Tools/api_exp/JCDK222/java/lang/javacard/lang.exp diff --git a/Tools/api_exp/JCDK222/java/rmi/javacard/rmi.exp b/build_tools/Tools/api_exp/JCDK222/java/rmi/javacard/rmi.exp similarity index 100% rename from Tools/api_exp/JCDK222/java/rmi/javacard/rmi.exp rename to build_tools/Tools/api_exp/JCDK222/java/rmi/javacard/rmi.exp diff --git a/Tools/api_exp/JCDK222/javacard/framework/javacard/framework.exp b/build_tools/Tools/api_exp/JCDK222/javacard/framework/javacard/framework.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacard/framework/javacard/framework.exp rename to build_tools/Tools/api_exp/JCDK222/javacard/framework/javacard/framework.exp diff --git a/Tools/api_exp/JCDK222/javacard/framework/service/javacard/service.exp b/build_tools/Tools/api_exp/JCDK222/javacard/framework/service/javacard/service.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacard/framework/service/javacard/service.exp rename to build_tools/Tools/api_exp/JCDK222/javacard/framework/service/javacard/service.exp diff --git a/Tools/api_exp/JCDK222/javacard/security/javacard/security.exp b/build_tools/Tools/api_exp/JCDK222/javacard/security/javacard/security.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacard/security/javacard/security.exp rename to build_tools/Tools/api_exp/JCDK222/javacard/security/javacard/security.exp diff --git a/Tools/api_exp/JCDK222/javacardx/apdu/javacard/apdu.exp b/build_tools/Tools/api_exp/JCDK222/javacardx/apdu/javacard/apdu.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacardx/apdu/javacard/apdu.exp rename to build_tools/Tools/api_exp/JCDK222/javacardx/apdu/javacard/apdu.exp diff --git a/Tools/api_exp/JCDK222/javacardx/biometry/javacard/biometry.exp b/build_tools/Tools/api_exp/JCDK222/javacardx/biometry/javacard/biometry.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacardx/biometry/javacard/biometry.exp rename to build_tools/Tools/api_exp/JCDK222/javacardx/biometry/javacard/biometry.exp diff --git a/Tools/api_exp/JCDK222/javacardx/crypto/javacard/crypto.exp b/build_tools/Tools/api_exp/JCDK222/javacardx/crypto/javacard/crypto.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacardx/crypto/javacard/crypto.exp rename to build_tools/Tools/api_exp/JCDK222/javacardx/crypto/javacard/crypto.exp diff --git a/Tools/api_exp/JCDK222/javacardx/external/javacard/external.exp b/build_tools/Tools/api_exp/JCDK222/javacardx/external/javacard/external.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacardx/external/javacard/external.exp rename to build_tools/Tools/api_exp/JCDK222/javacardx/external/javacard/external.exp diff --git a/Tools/api_exp/JCDK222/javacardx/framework/math/javacard/math.exp b/build_tools/Tools/api_exp/JCDK222/javacardx/framework/math/javacard/math.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacardx/framework/math/javacard/math.exp rename to build_tools/Tools/api_exp/JCDK222/javacardx/framework/math/javacard/math.exp diff --git a/Tools/api_exp/JCDK222/javacardx/framework/tlv/javacard/tlv.exp b/build_tools/Tools/api_exp/JCDK222/javacardx/framework/tlv/javacard/tlv.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacardx/framework/tlv/javacard/tlv.exp rename to build_tools/Tools/api_exp/JCDK222/javacardx/framework/tlv/javacard/tlv.exp diff --git a/Tools/api_exp/JCDK222/javacardx/framework/util/intx/javacard/intx.exp b/build_tools/Tools/api_exp/JCDK222/javacardx/framework/util/intx/javacard/intx.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacardx/framework/util/intx/javacard/intx.exp rename to build_tools/Tools/api_exp/JCDK222/javacardx/framework/util/intx/javacard/intx.exp diff --git a/Tools/api_exp/JCDK222/javacardx/framework/util/javacard/util.exp b/build_tools/Tools/api_exp/JCDK222/javacardx/framework/util/javacard/util.exp similarity index 100% rename from Tools/api_exp/JCDK222/javacardx/framework/util/javacard/util.exp rename to build_tools/Tools/api_exp/JCDK222/javacardx/framework/util/javacard/util.exp diff --git a/Tools/api_exp/gp221/org/globalplatform/javacard/globalplatform.exp b/build_tools/Tools/api_exp/gp221/org/globalplatform/javacard/globalplatform.exp similarity index 100% rename from Tools/api_exp/gp221/org/globalplatform/javacard/globalplatform.exp rename to build_tools/Tools/api_exp/gp221/org/globalplatform/javacard/globalplatform.exp diff --git a/Tools/ext_api/gp221.jar b/build_tools/Tools/ext_api/gp221.jar similarity index 100% rename from Tools/ext_api/gp221.jar rename to build_tools/Tools/ext_api/gp221.jar diff --git a/.idea/.gitignore b/build_tools/Tools/ext_api/gp221/.idea/.gitignore similarity index 100% rename from .idea/.gitignore rename to build_tools/Tools/ext_api/gp221/.idea/.gitignore diff --git a/build_tools/Tools/ext_api/gp221/.idea/misc.xml b/build_tools/Tools/ext_api/gp221/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build_tools/Tools/ext_api/gp221/.idea/modules.xml b/build_tools/Tools/ext_api/gp221/.idea/modules.xml new file mode 100644 index 0000000..356ccae --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/build_tools/Tools/ext_api/gp221/.idea/runConfigurations.xml b/build_tools/Tools/ext_api/gp221/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/build_tools/Tools/ext_api/gp221/META-INF/MANIFEST.MF b/build_tools/Tools/ext_api/gp221/META-INF/MANIFEST.MF new file mode 100644 index 0000000..6c1da2d --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Created-By: 1.6.0_30 (Sun Microsystems Inc.) + diff --git a/build_tools/Tools/ext_api/gp221/gp221.iml b/build_tools/Tools/ext_api/gp221/gp221.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/gp221.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/Application.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/Application.java new file mode 100644 index 0000000..04f4640 --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/Application.java @@ -0,0 +1,77 @@ + +package org.globalplatform; + +import javacard.framework.*; + +/** + * This interface defines a method through which an Application may forward + * input data to another Application.

+ * + * This interface shall be implemented by an Application that wishes to receive + * personalization data forwarded by its associated Security Domain. In such a + * scenario, if the Application implements both the {@link Application} and the + * {@link Personalization} interface, then the Security Domain shall use the + * {@link Personalization} interface.

+ * + * @see Personalization + * + * @since export file version 1.0 + */ + +public interface Application extends Shareable +{ + /** + * Processes application specific data received from another on-card entity.

+ * + * If the Application invoking this method is a Security Domain then it shall + * be assumed that:

+ * + *

Notes:

+ * + * @param baBuffer byte array containing input data. Must be a + * global byte array. + * @param sOffset offset of input data within baBuffer. + * @param sLength length of input data. + * + * @exception SecurityException if baBuffer is not a + * global byte array. + * @exception NullPointerException if baBuffer is null. + * @exception ArrayIndexOutOfBoundsException if reading input data would + * cause access of data outside array bounds. + */ + public abstract void processData(byte[] baBuffer, short sOffset, short sLength); + +} + + diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/Authority.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/Authority.java new file mode 100644 index 0000000..a844193 --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/Authority.java @@ -0,0 +1,131 @@ +package org.globalplatform; + +import javacard.framework.Shareable; +import javacard.security.CryptoException; + +/** + * This interface allows performing operations such as recovering a + * cryptographic key or signing data. The required algorithms and credentials + * are known implicitly.

+ * + * It is intended that Security Domains would be able to access an {@link + * Authority} instance through a Global Service by a Controlling Authority + * Security Domain (CASD) with a service name of ({@link + * GPSystem#FAMILY_AUTHORITY}<<8|0x00).

+ * + * @since

+ */ + +public interface Authority extends Shareable +{ + /** + * Used with {@link #init} method to indicate signing mode. + */ + public final byte MODE_SIGN=1; + + /** + * Used with {@link #init} method to indicate key recovery mode. + */ + public final byte MODE_KEY_RECOVERY=2; + + /** + * Initializes the Authority interface with the appropriate mode (MODE_SIGN or MODE_KEY_RECOVERY). + * + * @param theMode one of {@link #MODE_SIGN} or {@link #MODE_KEY_RECOVERY}. + * + * @exception CryptoException with the following reason code: + */ + public void init(byte theMode) throws CryptoException; + + /** + * Generates the signature of all/last input data. + * A call to this method resets this Authority interface to the state it was + * in when previously initialized via a call to init(). + * That is, the object is reset and available to sign another message. + * The input and output buffer may overlap and shall be global arrays. + * + * @param inBuff the input buffer of data to be signed + * @param inOffset the offset in input buffer at which the signature starts + * @param inLength the byte length to sign + * @param sigBuff the output buffer to store signature data + * @param sigOffset the offset into sigBuff at which to begin signature generation + * + * @return the number of bytes of signature output in sigBuff + * + * @throws CryptoException with the following reason codes: + * @throws SecurityException if the inBuff or sigBuff are not global arrays. + */ + public short sign(byte[] inBuff, + short inOffset, + short inLength, + byte[] sigBuff, + short sigOffset) + throws CryptoException; + + /** + * Accumulates input data. for the current operation (MODE_SIGN or MODE_KEY_RECOVERY). + *

+ * When this method is used, temporary storage of intermediate results is required. + * This method should only be used if all the input data required for the current operation + * is not available in one byte array. + * The sign or recoverKey methods are recommended whenever possible. + * The inBuff shall be global array. + * + * @param inBuff buffer containing input data + * @param inOffset offset of input data + * @param inLength length of input data + * @throws CryptoException with the following reason codes:

+ * @throws SecurityException if the inBuff is not global array. + */ + public void update(byte[] inBuff, + short inOffset, + short inLength) + throws CryptoException; + + /** + * Recovers a cryptographic key from a set of data + * structures provided in the input buffer (inBuff). + * As a mandatory step, the recovery mechanism includes the verification of + * the origin and integrity of the recovered key. + * This method knows, from the set of data structures present in the input + * buffer, which recovery mechanism is to be used. + * The recovered key is written in the ouput buffer (outBuff) at specified + * offset (outOffset), in the form of a key data structure whose format + * depends on the type of the key. + * A call to this method resets this instance of the Authority interface to + * the state it was in when previously initialized via a call to init(). + * That is, the object is reset and available to recover another key. + * The input and output buffers may overlap and shall be global arrays. + * + * @param inBuff containing input data. + * @param inOffset offset of input data. + * @param inLength length of input data. + * @param outBuff the buffer where recovered key data structure shall be written + * @param outOffset offset where recovered key data structure shall be written + * @return Length of the recovered key data structure written + * in outBuff at outOffset,or 0 if the recovery mechanism failed + * (e.g. recovered key was considered invalid). + * + * @throws CryptoException - with the following reason codes: + * @throws SecurityException if the inBuff or outBuff are not global arrays. + */ + public short recoverKey(byte[] inBuff, + short inOffset, + short inLength, + byte[] outBuff, + short outOffset) + throws CryptoException; + +} diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/CVM.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/CVM.java new file mode 100644 index 0000000..e864206 --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/CVM.java @@ -0,0 +1,343 @@ + +package org.globalplatform; + +import javacard.framework.*; + +/** + * This interface defines basic Cardholder Verification Method services + * (e.g. comparison of CVM value, CVM state query). It is typically exposed to + * on-card Applications by a Global Services Application implementing one or + * more Cardholder Verification Methods. Some services are restricted to + * Applications having the CVM Management Privilege.

+ * + * To retrieve an instance of this interface, an Application shall invoke the + * {@link GPSystem#getCVM} method, or shall use a {@link GlobalService} instance + * of the {@link GPSystem#FAMILY_CVM} family. For backward compatibility, the + * {@link CVM} instances retrieved using the {@link GPSystem#getCVM} method are + * mapped onto those retrieved as Global Services of the {@link + * GPSystem#FAMILY_CVM} family.

+ * + * The CVM instance maintains the following data (see Card Specification v2.2.1 + * section 8.2.2 for more details):

+ * + * Operations performed by this interface shall be independent of, and not + * interfere with, any transaction in progress (e.g. if the {@link #verify} + * method is invoked from within a transaction and this transaction is aborted, + * then the try counter is not revert to its original value).

+ * + * @since

+ */ + +public interface CVM extends Shareable +{ + /** + * The CVM value comparison was successful. + */ + public static final short CVM_SUCCESS = 0; + + /** + * The CVM value comparison failed. + */ + public static final short CVM_FAILURE = -1; + + /** + * The CVM value is formatted as ASCII bytes.

+ * + * Note:

+ */ + public static final byte FORMAT_ASCII = (byte) 0x01; + + /** + * The CVM value is formatted as numerical digits, coded on a nibble (4 bits) + * and left justified.

+ * + * Note:

+ */ + public static final byte FORMAT_BCD = (byte) 0x02; + + /** + * The CVM value is formatted as hexadecimal (binary) data.

+ * + * Note:

+ */ + public static final byte FORMAT_HEX = (byte) 0x03; + + /** + * Indicates whether this CVM instance is active, that is, whether it has + * been fully initialized (i.e. both value and try limit) and is ready + * for use. If yes, then the CVM state is deemed to be in one of the + * following states: ACTIVE, INVALID_SUBMISSION, VALIDATED or BLOCKED.

+ * + * @return true if the CVM has been fully initialized and is + * ready for use, false otherwise (i.e. the CVM state is NOT_READY). + */ + public boolean isActive(); + + /** + * Indicates whether an attempt has been made to compare the CVM value, that + * is, whether the CVM state is INVALID_SUBMISSION or VALIDATED.

+ * + * @return true if the CVM state is INVALID_SUBMISSION or + * VALIDATED, false otherwise. + */ + public boolean isSubmitted(); + + /** + * Indicates whether a successful comparison of the CVM value has occurred, + * that is, whether the CVM state is VALIDATED.

+ * + * @return true if the CVM state is VALIDATED, + * false otherwise. + */ + public boolean isVerified(); + + /** + * Indicates whether this CVM instance is blocked, that is, whether the CVM + * state is BLOCKED.

+ * + * @return true if the CVM state is BLOCKED, false + * otherwise. + */ + public boolean isBlocked(); + + /** + * Gets the CVM try counter, that is, the number of unsuccessful comparisons + * of the CVM value that may be performed before this CVM instance gets + * blocked.

+ * + * @return current value of the CVM try counter. + */ + public byte getTriesRemaining(); + + /** + * Updates the CVM value.

+ * + * If the Application invoking this method does not have the CVM Management + * Privilege, or if the specified format (bFormat) is unknown + * (or not supported by this CVM instance), or if the new CVM value is not + * consistent with respect to the specified format, then the CVM value is not + * updated.

+ * + * If the CVM value is successfully updated and the CVM try limit has already + * been successfully set previously, then this method also resets the CVM try + * counter to the CVM try limit, and (re)sets the CVM state to ACTIVE.

+ * + * Notes:

+ * + * @param baBuffer byte array containing the new CVM value. Must be a + * global byte array. + * @param sOffset offset of the new CVM value within baBuffer. + * @param bLength length of the new CVM value. + * @param bFormat format of the new CVM value: {@link #FORMAT_ASCII}, {@link + * #FORMAT_BCD} or {@link #FORMAT_HEX}. + * + * @return true if the CVM value was successfully updated, + * false otherwise. + * + * @see GPRegistryEntry#PRIVILEGE_CVM_MANAGEMENT + * + * @exception SecurityException if baBuffer is not a + * global byte array. + * @exception NullPointerException if baBuffer is null. + * @exception ArrayIndexOutOfBoundsException if reading the new CVM value + * would cause access of data outside array bounds. + */ + public boolean update(byte[] baBuffer, short sOffset, byte bLength, byte bFormat); + + /** + * Resets the CVM state to ACTIVE.

+ * + * The CVM state can only be reset to ACTIVE from the states ACTIVE, + * INVALID_SUBMISSION or VALIDATED. In particular, it cannot be reset to + * ACTIVE if it is in state BLOCKED or if the CVM instance never entered the + * state ACTIVE, that is, if the CVM instance is not fully + * initialized.

+ * + * @return true if the CVM state was reset, false otherwise. + */ + public boolean resetState(); + + /** + * Sets the CVM state to BLOCKED.

+ * + * If the Application invoking this method does not have the CVM Management + * Privilege, then the CVM state is not updated.

+ * + * The CVM state can only be set to BLOCKED if the CVM instance already + * entered the state ACTIVE once, that is, if the CVM instance is fully + * initialized. Notice that this method shall return true if the + * CVM state is already BLOCKED.

+ * + * Notes:

+ * + * @return true if the CVM state was set to BLOCKED, + * false otherwise. + * + * @see GPRegistryEntry#PRIVILEGE_CVM_MANAGEMENT + */ + public boolean blockState(); + + /** + * Resets the CVM state to ACTIVE, even if it is currently BLOCKED.

+ * + * If the Application invoking this method does not have the CVM Management + * Privilege, then the CVM state is not updated.

+ * + * The CVM state can only be set to ACTIVE if the CVM instance already + * entered the state ACTIVE once, that is, if the CVM instance is fully + * initialized. + * + * If the CVM state is successfully reset, then this method also resets the + * CVM try counter to the CVM try limit.

+ * + * Notes:

+ * + * @return true if the CVM state was reset to ACTIVE, + * false otherwise. + * + * @see GPRegistryEntry#PRIVILEGE_CVM_MANAGEMENT + */ + public boolean resetAndUnblockState(); + + /** + * Sets the CVM try limit, that is, the maximum value of the CVM try + * counter.

+ * + * If the Application invoking this method does not have the CVM Management + * Privilege, then the CVM try limit is not set.

+ * + * If the CVM try limit is successfully set, then this method also resets the + * CVM try counter to the new CVM try limit. If the CVM value has already + * been successfully set previously, then this method also (re)sets the CVM + * state to ACTIVE.

+ * + * Notes:

+ * + * @param bTryLimit the maximum number of tries for the CVM. + * + * @return true if the try limit was set, false + * otherwise. + * + * @see GPRegistryEntry#PRIVILEGE_CVM_MANAGEMENT + */ + public boolean setTryLimit(byte bTryLimit); + + /** + * Compares a value with the stored CVM value.

+ * + * If the CVM state is BLOCKED, or if the submitted format + * (bFormat) is unknown (or not supported by this CVM instance), + * or if this method throws a {@link NullPointerException} or an {@link + * ArrayIndexOutOfBoundsException}, then the comparison is deemed + * unsuccessful.

+ * + * If the submitted CVM value is not in the same format as the stored CVM + * value, then format conversion shall occur according to the following rules + * prior to comparing values:

+ * + * If the comparison is unsuccessful and the CVM state is not BLOCKED, then + * the CVM try counter must be decremented (by 1). In this case, if the CVM + * try counter reaches a value of '0' then the CVM state shall be set to + * BLOCKED, otherwise the CVM state shall be set to INVALID_SUBMISSION.

+ * + * If the comparison is successful, then the CVM try counter shall be reset + * to the CVM try limit and the CVM state shall be set to VALIDATED.

+ * + * The CVM try counter and the CVM state shall not conform to a transaction + * in progress, i.e. they shall not revert to a previous value if a + * transaction in progress is aborted.

+ * + * @param baBuffer byte array containing the submitted CVM value. Must be a + * global byte array. + * @param sOffset offset of the submitted CVM value within baBuffer. + * @param bLength length of the submitted CVM value. + * @param bFormat format of the submitted CVM value: {@link #FORMAT_ASCII}, + * {@link #FORMAT_BCD} or {@link #FORMAT_HEX}. + * + * @return {@link #CVM_SUCCESS} if the comparison was successful, {@link + * #CVM_FAILURE} otherwise. + * + * @exception SecurityException if baBuffer is not a + * global byte array. + * @exception NullPointerException if baBuffer is null. + * @exception ArrayIndexOutOfBoundsException if reading the submitted CVM + * value would cause access of data outside array bounds. + */ + public short verify(byte[] baBuffer, short sOffset, byte bLength, byte bFormat); +} + + diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/GPRegistryEntry.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/GPRegistryEntry.java new file mode 100644 index 0000000..934034c --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/GPRegistryEntry.java @@ -0,0 +1,347 @@ + +package org.globalplatform; + +import javacard.framework.*; + +/** + * This interface allows querying and potentially modifying the registry data of + * an Application registered within the GlobalPlatform Registry.

+ * + * Every {@link GPRegistryEntry} instance to an Application registered within + * the GlobalPlatform Registry.

+ * + * To retrieve an instance of this interface, an Application shall invoke the + * {@link GPSystem#getRegistryEntry} method.

+ * + * @since

+ */ + +public interface GPRegistryEntry extends Shareable +{ + /** + * Privilege indicating Authorized Management (0x09). + */ + public static final byte PRIVILEGE_AUTHORIZED_MANAGEMENT = (byte) 0x09; + + /** + * Privilege indicating Card Lock (0x03). + */ + public static final byte PRIVILEGE_CARD_LOCK = (byte) 0x03; + + /** + * Privilege indicating Card Reset (0x05). + */ + public static final byte PRIVILEGE_CARD_RESET = (byte) 0x05; + + /** + * Privilege indicating Card Terminate (0x04). + */ + public static final byte PRIVILEGE_CARD_TERMINATE = (byte) 0x04; + + /** + * Privilege indicating CVM Management (0x06). + */ + public static final byte PRIVILEGE_CVM_MANAGEMENT = (byte) 0x06; + + /** + * Privilege indicating DAP verification (0x01). + */ + public static final byte PRIVILEGE_DAP_VERIFICATION = (byte) 0x01; + + /** + * Privilege indicating Delegated Management (0x02). + */ + public static final byte PRIVILEGE_DELEGATED_MANAGEMENT = (byte) 0x02; + + /** + * Privilege indicating Final Application (0x0E). + */ + public static final byte PRIVILEGE_FINAL_APPLICATION = (byte) 0x0E; + + /** + * Privilege indicating Global Delete (0x0B). + */ + public static final byte PRIVILEGE_GLOBAL_DELETE = (byte) 0x0B; + + /** + * Privilege indicating Global Lock (0x0C). + */ + public static final byte PRIVILEGE_GLOBAL_LOCK = (byte) 0x0C; + + /** + * Privilege indicating Global Registry (0x0D). + */ + public static final byte PRIVILEGE_GLOBAL_REGISTRY = (byte) 0x0D; + + /** + * Privilege indicating Global Service (0x0F). + */ + public static final byte PRIVILEGE_GLOBAL_SERVICE = (byte) 0x0F; + + /** + * Privilege indicating Mandated DAP verification privilege (0x07). + */ + public static final byte PRIVILEGE_MANDATED_DAP = (byte) 0x07; + + /** + * Privilege indicating Receipt Generation (0x10). + */ + public static final byte PRIVILEGE_RECEIPT_GENERATION = (byte) 0x10; + + /** + * Privilege indicating application is a Security Domain (0x00). + */ + public static final byte PRIVILEGE_SECURITY_DOMAIN = (byte) 0x00; + + /** + * Privilege indicating Token Verification (0x0A). + */ + public static final byte PRIVILEGE_TOKEN_VERIFICATION = (byte) 0x0A; + + /** + * Privilege indicating Trusted Path (0x08). + */ + public static final byte PRIVILEGE_TRUSTED_PATH = (byte) 0x08; + + /** + * Privilege indicating Ciphered Load File Data Block (0x11). + */ + public static final byte PRIVILEGE_CIPHERED_LOAD_FILE_DATA_BLOCK = (byte) 0x11; + + /** + * Deregisters a service name.

+ * + * The OPEN shall check that the Application invoking this method corresponds + * to this entry, that it has the Global Service Privilege, and + * that the specified service name was previously uniquely registered by that + * same Application. If not, this method shall throw an exception (see + * below).

+ * + * @param sServiceName the service name that shall be deregistered.

+ * + * A service name is encoded on 2 bytes, the 1st byte identifying a family of + * services and the 2nd byte identifying a service within that family.

+ * + * The {@link GPSystem} class defines a set of constants + * FAMILY_XXX (of the byte type) that may be used to + * build a service name (of the short type) suitable to invoke + * this method as shown in the following examples:

+ * + * @exception ISOException if this method is not supported or if the service + * name was not found or if the conditions allowing to deregister the service + * name are not satisfied. + * + * @see #registerService + * @see GPSystem#FAMILY_CVM + * @see GPSystem#FAMILY_SECURE_CHANNEL + * @see GPSystem#FAMILY_USSM + * @see GPSystem#FAMILY_AUTHORITY + * @see GPSystem#FAMILY_HTTP_ADMINISTRATION + * @see GPSystem#FAMILY_HTTP_REPORT + */ + public void deregisterService(short sServiceName) throws ISOException; + + /** + * Gets the AID of the Application corresponding to this entry. + * + * @return {@link AID} instance identifying the Application corresponding to + * this entry. + */ + public AID getAID(); + + /** + * Gets the Privilege Bytes of the Application corresponding to + * this entry. + * + * @param baBuffer byte array where Privileges Bytes shall be written. + * @param sOffset offset within baBuffer where Privileges Bytes + * shall be written. + * + * @return sOffset + number of Privilege Bytes written to + * baBuffer. + * + * @exception SecurityException if baBuffer is not accessible in + * the caller's context e.g. baBuffer is not a global + * array nor an array belonging to the caller context. + * @exception NullPointerException if baBuffer is null. + * @exception ArrayIndexOutOfBoundsException if writing Privileges Bytes would + * cause access of data outside array bounds. + */ + public short getPrivileges(byte[] baBuffer, short sOffset) throws ArrayIndexOutOfBoundsException; + + /** + * Gets the Life Cycle State of the Application corresponding to + * this entry. + * + * @return the Life Cycle State of the Application corresponding to + * this entry. + */ + public byte getState(); + + /** + * Checks whether the Application corresponding to this entry is + * associated with the specified Security Domain.

+ * + * The OPEN shall check that the specified sdAID indeed + * identifies a Security Domain present on the card, and check that the + * Application corresponding to this entry is associated with + * this Security Domain. If not, this method shall return + * false.

+ * + * @param sdAID AID of a Security Domain. + * + * @return true if the Application corresponding to + * this entry is associated with the specified Security Domain, + * false otherwise. + */ + public boolean isAssociated(AID sdAID); + + /** + * Checks whether the Application corresponding to this entry has + * the specified privilege.

+ * + * If the specified privilege is unknown, this method shall return + * false. + * + * @param bPrivilege the privilege number to check, i.e. one of the + * PRIVILEGE_XXX constants. + * + * @return true if the Application corresponding to + * this entry has the specified privilege, false + * otherwise. + */ + public boolean isPrivileged(byte bPrivilege); + + /** + * Registers a service name identifying a service provided by the Application + * corresponding to this entry.

+ * + * The specified service name (sServiceName) shall be unique + * among all the service names previously registered in the GlobalPlatform + * Registry using this method. Following successful invocation of this method, + * this service name is known to be uniquely registered: no other Application + * on the card will be able to register the same service name (until this + * service name is deregistered (see {@link #deregisterService})). If the + * service name identifies a family of service, no other Application on the + * card will be able to register a service of that family.

+ * + * The OPEN shall first check that the Application invoking this method + * corresponds to this entry and that it has the Global Service + * Privilege.

+ * + * Then the OPEN shall check that the specified service name:

+ * + * If any of the above conditions is not satisfied, this method shall throw an + * exception (see below). Otherwise, the specified service name shall be + * uniquely registered in the GlobalPlatform Registry.

+ * + * @param sServiceName the service name that shall be uniquely registered.

+ * + * A service name is encoded on 2 bytes, the 1st byte identifying a family of + * services and the 2nd byte identifying a service within that family. If the + * 2nd byte is set to 0x00, the caller of this method is + * registering an entire family of service.

+ * + * The {@link GPSystem} class defines a set of constants + * FAMILY_XXX (of the byte type) that may be used to + * build a service name (of the short type) suitable to invoke + * this method as shown in the following examples:

+ * + * @exception ISOException if this method is not supported or if the + * conditions allowing to register the service name are not satisfied. + * + * @see #deregisterService + * @see GPSystem#getService + * @see GPSystem#FAMILY_CVM + * @see GPSystem#FAMILY_SECURE_CHANNEL + * @see GPSystem#FAMILY_USSM + * @see GPSystem#FAMILY_AUTHORITY + * @see GPSystem#FAMILY_HTTP_ADMINISTRATION + * @see GPSystem#FAMILY_HTTP_REPORT + */ + public void registerService(short sServiceName) throws ISOException; + + /** + * Sets the Life Cycle state of the Application corresponding to + * this entry.

+ * + * This method enforces the Life Cycle State transition rules described in + * Card Specification v2.2.1 section 5.

+ * + * If this entry corresponds to the Issuer Security Domain (ISD), + * then the OPEN shall check that the requested transition complies with Card + * Life Cycle State transition rules. If needed, the OPEN shall check that the + * Application invoking this method has the Card Lock Privilege or the Card + * Terminate Privilege.

+ * + * Otherwise, the following rules shall apply:

+ * + * @param bState the new Life Cycle State. See Card Specification v2.2.1 + * section 11.1.1 for details on Life Cycle State Coding. A value of {@link + * GPSystem#APPLICATION_LOCKED} (resp. 0x00) may be used to request locking + * (resp. unlocking) an Application or a Security Domain (other than the ISD). + * + * @return true if the transition was successful, + * false otherwise. + */ + public boolean setState(byte bState); + +} + + diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/GPSystem.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/GPSystem.java new file mode 100644 index 0000000..56dabb0 --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/GPSystem.java @@ -0,0 +1,507 @@ + +package org.globalplatform; + +import javacard.framework.*; + +/** + * This class exposes a subset of the behavior of the OPEN to the + * outside world. The OPEN implements and enforces a Card Issuer's security + * policy relating to these services. It provides functionality at + * the same level as the JCRE, i.e. the "system" context with special + * privileges. + * @since + */ + +public class GPSystem +{ + /** + * The current applet context is in the Life Cycle State of INSTALLED (0x03). + *

Note:

+ */ + public static final byte APPLICATION_INSTALLED = (byte) 0x03; + + /** + * The current applet context is in the Life Cycle State of SELECTABLE (0x07). + *

Note:

+ */ + public static final byte APPLICATION_SELECTABLE = (byte) 0x07; + + /** + * The current applet context is in the Life Cycle State of LOCKED (0x80). + * + * To know whether an application is locked or not, a logical AND operation + * shall be performed between this constant and the current application life + * cycle state. + */ + public static final byte APPLICATION_LOCKED = (byte) 0x80; + + /** + * The Security Domain is in the Life Cycle State of PERSONALIZED (0x0F). + */ + public static final byte SECURITY_DOMAIN_PERSONALIZED = (byte) 0x0F; + + /** + * The card is in the Life Cycle State of OP_READY (0x01). + */ + public static final byte CARD_OP_READY = (byte) 0x01; + + /** + * The card is in the Life Cycle State of INITIALIZED (0x07). + */ + public static final byte CARD_INITIALIZED = (byte) 0x07; + + /** + * The card is in the Life Cycle State of SECURED (0x0F). + */ + public static final byte CARD_SECURED = (byte) 0x0F; + + /** + * The card is in the Life Cycle State of CARD_LOCKED (0x7F). + */ + public static final byte CARD_LOCKED = (byte) 0x7F; + + /** + * The card is in the Life Cycle State of TERMINATED (0xFF). + */ + public static final byte CARD_TERMINATED = (byte) 0xFF; + + /** + * Indicates that the required CVM interface is a Global PIN (0x11). + */ + public static final byte CVM_GLOBAL_PIN = (byte) 0x11; + + /** + * Indicates that the required CVM interface is the ETSI PIN App 1 (0x01). + * @since export file version 1.5 + */ + public static final byte CVM_ETSI_PIN_APP_1 = (byte) 0x01; + + /** + * Indicates that the required CVM interface is the ETSI PIN App 2 (0x02). + * @since export file version 1.5 + */ + public static final byte CVM_ETSI_PIN_APP_2 = (byte) 0x02; + + /** + * Indicates that the required CVM interface is the ETSI PIN App 3 (0x03). + * @since export file version 1.5 + */ + public static final byte CVM_ETSI_PIN_APP_3 = (byte) 0x03; + + /** + * Indicates that the required CVM interface is the ETSI PIN App 4 (0x04). + * @since export file version 1.5 + */ + public static final byte CVM_ETSI_PIN_APP_4 = (byte) 0x04; + + /** + * Indicates that the required CVM interface is the ETSI PIN App 5 (0x05). + * @since export file version 1.5 + */ + public static final byte CVM_ETSI_PIN_APP_5 = (byte) 0x05; + + /** + * Indicates that the required CVM interface is the ETSI PIN App 6 (0x06). + * @since export file version 1.5 + */ + public static final byte CVM_ETSI_PIN_APP_6 = (byte) 0x06; + + /** + * Indicates that the required CVM interface is the ETSI PIN App 7 (0x07). + * @since export file version 1.5 + */ + public static final byte CVM_ETSI_PIN_APP_7 = (byte) 0x07; + + /** + * Indicates that the required CVM interface is the ETSI PIN App 8 (0x08). + * @since export file version 1.5 + */ + public static final byte CVM_ETSI_PIN_APP_8 = (byte) 0x08; + + /** + * Indicates the family of the Secure Channel Global Service Identifier (0x81). + * @since export file version 1.1 + */ + public static final byte FAMILY_SECURE_CHANNEL = (byte) 0x81; + + /** + * Indicates the family of the CVM Global Service Identifier (0x82). + * @since export file version 1.1 + */ + public static final byte FAMILY_CVM = (byte) 0x82; + + /** + * @since export file version 1.2 + * @deprecated Use {@link #FAMILY_AUTHORITY} instead. + */ + public static final byte FAMILY_AUHTORITY= (byte)0x83; + + /** + * Indicates the family of the Authority Service Identifier (0x83). + * @since export file version 1.2 + */ + public static final byte FAMILY_AUTHORITY= (byte)0x83; + + /** + * Indicates the family of the HTTP Administration Service Identifier (0x84). + * @since export file version 1.3 + */ + public static final byte FAMILY_HTTP_ADMINISTRATION= (byte)0x84; + + /** + * Indicates the family of the HTTP Report Service Identifier (0x85). + * @since export file version 1.3 + */ + public static final byte FAMILY_HTTP_REPORT= (byte)0x85; + + /** + * Indicates the family of the USSM Global Service Identifier (0xA0). + * @since export file version 1.1 + */ + public static final byte FAMILY_USSM = (byte) 0xA0; + + /** + * Indicates the generic Global Service Identifier (0x80). + * @since export file version 1.1 + */ + public static final byte GLOBAL_SERVICE_IDENTIFIER = (byte) 0x80; + + /** + * Gets the Life Cycle State of the current applet context.

+ * + * @return the Life Cycle State of the current applet context. + * + * @see #APPLICATION_INSTALLED + * @see #APPLICATION_SELECTABLE + * @see #APPLICATION_LOCKED + */ + public static byte getCardContentState() + { + return ((byte)0); + } + + /** + * Gets the Life Cycle State of the card.

+ * + * @return the Life Cycle State of the card. + * + * @see #CARD_OP_READY + * @see #CARD_INITIALIZED + * @see #CARD_SECURED + * @see #CARD_LOCKED + * @see #CARD_TERMINATED + */ + public static byte getCardState() + { + return((byte)0); + } + + /** + * Gets a reference to a {@link CVM} instance provided by the OPEN.

+ * + * Since export file version 1.1, this method allows looking up for CVM + * instances registered as Global Services by so-called Global Services + * Applications (i.e. Applications having the Global Service Privilege) and + * the following mechanism is defined to retrieve such instances:

+ * + * For backward compatibility, the {@link #CVM_GLOBAL_PIN} constant can still + * be used to access a Global Service registered with the ({@link + * #FAMILY_CVM}<<8|{@link #CVM_GLOBAL_PIN}) identifier, or uniquely + * registered for the entire {@link #FAMILY_CVM} family. Whether such a + * service is available or not still depends on the issuer's policy. + * + * @param bCVMIdentifier identifies the requested CVM instance. + * + * @return requested CVM instance, or null if the requested CVM + * instance is not available. + * + * @see #CVM_GLOBAL_PIN + */ + public static CVM getCVM(byte bCVMIdentifier) + { + return (null); + } + + /** + * Gets a {@link SecureChannel} instance.

+ * + * This method allows the Application associated with the current applet + * context to retrieve a {@link SecureChannel} instance provided by its + * associated Security Domain.

+ * + * Since export file version 1.1, although not required, this method may be + * implemented using the Global Service facility, in which case {@link + * SecureChannel} instances would be registered by Security Domains as Global + * Services. In this case, Security Domains shall check that they only provide + * such {@link SecureChannel} instances to their associated Applications.

+ * + * @return the SecureChannel interface object reference. + * + * @see #getCVM the GPSystem.getCVM() method for an example of how to access a Global Service. + */ + public static SecureChannel getSecureChannel() + { + return (null); + } + + /** + * Locks the card. + * + * This method shall be used to transition the card to {@link #CARD_LOCKED} + * Life Cycle State.

+ * + * The OPEN shall check that the Application invoking this method has the Card + * Lock Privilege. If not, the transition shall be rejected.

+ * + * @return true if the card was locked, false otherwise. + */ + public static boolean lockCard() + { + return (false); + } + + /** + * Terminates the card. + * + * This method shall be used to transition the card to {@link + * #CARD_TERMINATED} Life Cycle State.

+ * + * The OPEN shall check that the Application invoking this method has the Card + * Terminate Privilege. If not, the transition shall be rejected.

+ * + * @return true if the card was terminated, false otherwise. + */ + public static boolean terminateCard() + { + return (false); + } + + /** + * Sets the historical bytes of the Answer To Reset (ATR) string.

+ * + * This method only updates the ATR string that is used for the contact-based + * IO interface (as specified by [ISO/IEC 7816] upon power-up or cold + * reset. The ATR string used for warm reset shall remain unchanged. The new + * historical bytes shall be visible upon next power-up or cold reset.

+ * + * The OPEN shall check that the Application invoking this method has the Card + * Reset Privilege and that the bLength is both positive and + * lower than 16. If not, the change shall be rejected.

+ * + * Notes:

+ * + * @param baBuffer byte array containing the ATR historical bytes. + * @param sOffset offset of the ATR historical bytes. + * @param bLength length of the ATR historical bytes. + * + * @return true if ATR historical bytes were set, false otherwise. + */ + public static boolean setATRHistBytes (byte[] baBuffer, short sOffset, byte bLength) + { + return (false); + } + + /** + * Sets the Life Cycle state of the Application invoking this method. + * + * This method allows the Application associated with the current applet + * context to lock itself or to change its state from an application specific + * Life Cycle State to another application specific Life Cycle State. An + * Application cannot unlock itself.

+ * + * The OPEN shall check that the Application is currently in an application + * specific Life Cycle State (i.e. in the range [0x07 .. 0x7F] and with its 3 + * low order bits set to 1), in particular that it is not in the {@link + * #APPLICATION_INSTALLED} state and not currently locked. If not, the change + * shall be rejected. + * + * The OPEN shall check that bState either encodes an application + * specific Life Cycle State or has its high order bit (b8) set to 1: the + * latter case shall be interpreted as a request from the the Application to + * lock itself. + * + * @param bState either an application specific Life Cycle State (i.e. in the + * range [0x07 .. 0x7F] and with its 3 low order bits set to 1), or any value + * having its high order bit (b8) set to 1. A value of {@link + * #APPLICATION_LOCKED} may be used to request locking the Application. + * + * @return true if the Life Cycle State of the Application was + * changed, false otherwise. + * + * @see #APPLICATION_INSTALLED + * @see #APPLICATION_LOCKED + * + * @since

+ */ + public static boolean setCardContentState(byte bState) + { + return (false); + } + + /** + * Gets a {@link GPRegistryEntry} instance.

+ * + * This method allows the Application associated with the current applet + * context to get its own {@link GPRegistryEntry} instance or the one of + * another Application. + * + * If the aid parameter is not null and does not + * identify the Application invoking this method, the OPEN shall check that + * the Application invoking this method has the Global Registry Privilege. If + * not, this method shall return null.

+ * + * @param aid the AID of the Application whose {@link GPRegistryEntry} + * instance is requested. Use null to retrieve the {@link + * GPRegistryEntry} instance of the current applet context. + * + * @return the requested {@link GPRegistryEntry} instance if it was found in + * the GlobalPlatform Registry and the Application invoking this method is + * allowed to access that entry, null otherwise. + * + * @since export file version 1.1 + */ + public static GPRegistryEntry getRegistryEntry(AID aid) + { + return (null); + } + + /** + * Gets a {@link GlobalService} instance matching the specified service name + * (sServiceName).

+ * + * The serverAID parameter is optional (i.e. may be set to + * null) and identifies the Global Services Application providing + * the service.

+ * + * The OPEN shall look for the Global Services Application providing the + * service:

+ * + * If a Global Services Application was found, then the OPEN shall retrieve + * the {@link GlobalService} instance by invoking the {@link + * Applet#getShareableInterfaceObject} method of that Global Services + * Application with the clientAID parameter set to the AID of the + * current applet context (i.e. the one invoking this method) and the + * parameter parameter set to {@link #GLOBAL_SERVICE_IDENTIFIER}. + * + * @param serverAID AID of the Global Services Application providing the + * requested service, or null if the caller of this method is + * requesting a uniquely registered service name.

+ * + * @param sServiceName service name identifying a service or a family of + * services.

+ * + * A service name is encoded on 2 bytes, the 1st byte identifying a family of + * services and the 2nd byte identifying a service within that family. If the + * 2nd byte is set to 0x00, the caller of this method is + * requesting a service of the specified family, but does not care exactly + * which service within that family.

+ * + * This class defines a set of constants FAMILY_XXX (of the + * byte type) that may be used to build a service name (of the + * short type) suitable to invoke this method as shown in the + * following examples:

+ * + * @return the {@link GlobalService} instance giving access to the requested + * service, or null if the Global Services Application could not + * be found or did not provide a {@link GlobalService} instance. + * + * @see #GLOBAL_SERVICE_IDENTIFIER + * @see #FAMILY_CVM + * @see #FAMILY_SECURE_CHANNEL + * @see #FAMILY_USSM + * @see #FAMILY_AUTHORITY + * @see #FAMILY_HTTP_ADMINISTRATION + * @see #FAMILY_HTTP_REPORT + * @see GPRegistryEntry#registerService + * + * @since export file version 1.1 + */ + public static GlobalService getService(AID serverAID, short sServiceName) + { + return (null); + } + +} + + diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/GlobalService.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/GlobalService.java new file mode 100644 index 0000000..a13dbfe --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/GlobalService.java @@ -0,0 +1,258 @@ + +package org.globalplatform; + +import javacard.framework.*; + +/** + * This interface allows requesting a Global Services Application for a + * Shareable Interface Object (SIO) providing the actual service.

+ * + * To retrieve an instance of this interface, an Application shall invoke the + * {@link GPSystem#getService} method.

+ * + * @since export file version 1.1 + */ + +public interface GlobalService extends Shareable +{ + /** + * Key Access indicating key may be used by the Security Domain and any + * associated Application (0x00). + */ + public static final byte KEY_ACCESS_ANY = (byte) 0x00; + + /** + * Key Access indicating key may be used by the Security Domain but not by any + * associated Application (0x01). + */ + public static final byte KEY_ACCESS_SECURITY_DOMAIN = (byte) 0x01; + + /** + * Key Access indicating key may be used by any associated Application but not + * by the Security Domain (0x02). + */ + public static final byte KEY_ACCESS_APPLICATION = (byte) 0x02; + + /** + * Key type indicating AES (0x88). + */ + public static final byte KEY_TYPE_AES = (byte) 0x88; + + /** + * Key type indicating Triple DES reserved for specific implementations (0x81). + */ + public static final byte KEY_TYPE_3DES = (byte) 0x81; + + /** + * Key type indicating Triple DES in CBC mode (0x82). + */ + public static final byte KEY_TYPE_3DES_CBC = (byte) 0x82; + + /** + * Key type indicating DES with ECB/CBC implicitly known (0x80). + */ + public static final byte KEY_TYPE_DES = (byte) 0x80; + + /** + * Key type indicating DES in CBC mode (0x84). + */ + public static final byte KEY_TYPE_DES_CBC = (byte) 0x84; + + /** + * Key type indicating DES in ECB mode (0x83). + */ + public static final byte KEY_TYPE_DES_ECB = (byte) 0x83; + + /** + * Key type indicating extended key format (0xFF). + */ + public static final byte KEY_TYPE_EXTENDED = (byte) 0xFF; + + /** + * Key type indicating HMAC SHA1, length of HMAC implicitly known (0x90). + */ + public static final byte KEY_TYPE_HMAC_SHA1 = (byte) 0x90; + + /** + * Key type indicating HMAC SHA1, length of HMAC is 160 bits (0x91). + */ + public static final byte KEY_TYPE_HMAC_SHA1_160 = (byte) 0x91; + + /** + * Key type indicating RSA Private Key Chinese Remainder p component (0xA4). + */ + public static final byte KEY_TYPE_RSA_PRIVATE_CRT_P = (byte) 0xA4; + + /** + * Key type indicating RSA Private Key Chinese Remainder q component (0xA5). + */ + public static final byte KEY_TYPE_RSA_PRIVATE_CRT_Q = (byte) 0xA5; + + /** + * Key type indicating RSA Private Key Chinese Remainder pq component (0xA6). + */ + public static final byte KEY_TYPE_RSA_PRIVATE_CRT_PQ = (byte) 0xA6; + + /** + * Key type indicating RSA Private Key Chinese Remainder dp1 component (0xA7). + */ + public static final byte KEY_TYPE_RSA_PRIVATE_CRT_DP1 = (byte) 0xA7; + + /** + * Key type indicating RSA Private Key Chinese Remainder dq1 component (0xA8). + */ + public static final byte KEY_TYPE_RSA_PRIVATE_CRT_DQ1 = (byte) 0xA8; + + /** + * Key type indicating RSA Private exponent (0xA3). + */ + public static final byte KEY_TYPE_RSA_PRIVATE_EXPONENT = (byte) 0xA3; + + /** + * Key type indicating RSA Private Key modulus (0xA2). + */ + public static final byte KEY_TYPE_RSA_PRIVATE_MODULUS = (byte) 0xA2; + + /** + * Key type indicating RSA Public Key exponent (0xA0). + */ + public static final byte KEY_TYPE_RSA_PUBLIC_EXPONENT = (byte) 0xA0; + + /** + * Key type indicating RSA Public Key modulus (0xA1). + */ + public static final byte KEY_TYPE_RSA_PUBLIC_MODULUS = (byte) 0xA1; + + /** + * Key usage indicating computation and decipherment (0x40). + */ + public static final byte KEY_USAGE_COMPUTATION_DECIPHERMENT = (byte) 0x40; + + /** + * Key usage indicating sensitive data confidentiality (0x08). + */ + public static final byte KEY_USAGE_CONFIDENTIALITY = (byte) 0x08; + + /** + * Key usage indicating cryptographic authorization (0x01). + */ + public static final byte KEY_USAGE_CRYPTOGRAPHIC_AUTHORIZATION = (byte) 0x01; + + /** + * Key usage indicating cryptographic checksum e.g. MAC (0x04). + */ + public static final byte KEY_USAGE_CRYPTOGRAPHIC_CHECKSUM = (byte) 0x04; + + /** + * Key usage indicating Digital Signature (0x02). + */ + public static final byte KEY_USAGE_DIGITAL_SIGNATURE = (byte) 0x02; + + /** + * Key usage indicating Secure Messaging in command data field (0x10). + */ + public static final byte KEY_USAGE_SM_COMMAND = (byte) 0x10; + + /** + * Key usage indicating Secure Messaging in response data field (0x20). + */ + public static final byte KEY_USAGE_SM_RESPONSE = (byte) 0x20; + + /** + * Key usage indicating verification and encipherment (0x80). + */ + public static final byte KEY_USAGE_VERIFICATION_ENCIPHERMENT = (byte) 0x80; + + /** + * Gets a Shareable Interface Object (SIO) actually providing the requested service.

+ * + * The Application invoking this method shall set the + * clientRegistryEntry to its own {@link GPRegistryEntry} + * instance.

+ * + * The Global Services Application shall verify the validity of the request + * according to its own security policies for the specified + * sServiceName, based on the identity and characteristics of the + * Application invoking this method as registered by the specified + * clientRegistryEntry, and possibly based on the data contained + * in the baBuffer byte array.

+ * + * If the request is valid, the Global Service Application returns a SIO + * implementing the actual service: this SIO may either be this {@link + * GlobalService} instance or another object. If the request is deemed to be + * invalid, the Global Services Application shall reject the request by either + * throwing an exception or returning null.

+ * + * It is assumed that the Application invoking this method is aware of the + * interface (extension of the {@link Shareable} interface) to which the + * retrieved SIO shall be casted in order to acces the service.

+ * + * Notes:

+ * + * @param clientRegistryEntry the {@link GPRegistryEntry} instance of the + * requesting Application.

+ * @param sServiceName a service name identifying the requested service.

+ * + * A service name is encoded on 2 bytes, the 1st byte identifying a family of + * services and the 2nd byte identifying a service within that family.

+ * + * The {@link GPSystem} class defines a set of constants + * FAMILY_XXX (of the byte type) that may be used to + * build a service name (of the short type) suitable to invoke + * this method as shown in the following examples:

+ * + * @param baBuffer byte array containing additional parameters of the request, + * potentially authentication data. Must be global byte array. + * @param sOffset offset of the additional parameters. + * @param sLength length of the additional parameters. + * + * @return the SIO providing the actual service, or null if the + * service is not available or the request was rejected. Alternatively, this + * method may reject the request by throwing an ISOException. + * + * @exception ISOException if the request was rejected. Although not + * mandatory, it is recommended to use one of the following reason codes: + * Alternatively, this method may reject the request by returning null. + * + * @exception SecurityException if the Global Services Application requires + * reading data from baBuffer and baBuffer is not a + * global byte array. + * @exception NullPointerException if the Global Services Application requires + * reading data from baBuffer and baBuffer is + * null. + * @exception ArrayIndexOutOfBoundsException if the Global Services + * Application requires reading data from baBuffer and reading + * data would cause access of data outside array bounds. + * + * @see GPSystem#getService + * @see GPSystem#FAMILY_CVM + * @see GPSystem#FAMILY_SECURE_CHANNEL + * @see GPSystem#FAMILY_USSM + * @see GPSystem#FAMILY_AUTHORITY + * @see GPSystem#FAMILY_HTTP_ADMINISTRATION + * @see GPSystem#FAMILY_HTTP_REPORT + */ + public Shareable getServiceInterface(GPRegistryEntry clientRegistryEntry, short sServiceName, byte[] baBuffer, short sOffset, short sLength) throws ISOException; + +} diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/HTTPAdministration.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/HTTPAdministration.java new file mode 100644 index 0000000..34aebfd --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/HTTPAdministration.java @@ -0,0 +1,53 @@ +package org.globalplatform; + +import javacard.framework.*; + +/** + * This interface defines a method to trigger a new HTTP administration session.

+ * + * To retrieve an instance of this interface, an Application shall use the + * {@link GlobalService} instance, if available, registered with a service name + * of ({@link GPSystem#FAMILY_HTTP_ADMINISTRATION}<<8|0x00). + * + * @see GlobalService + * @see GPSystem#getService + * + * @since

+ */ +public interface HTTPAdministration extends Shareable +{ + /** + * Triggers a new administration session.

+ * + * The Security Domain of the Application invoking this method will handle the + * SCP81 (PSK TLS) security of the communication.

+ * + * The Application invoking this method will be notified of the result of the + * request if it implements the {@link HTTPReportListener} interface.

+ * + * @param triggeringParameters byte array containing administration session + * triggering parameters. + * @param offset offset of triggering parameters within triggeringParameters. + * @param length length of triggering parameters. + * + * @exception SecurityException if triggeringParameters is not + * accessible in the caller's context. + * @exception NullPointerException if triggeringParameters is + * null. + * @exception ArrayIndexOutOfBoundsException if reading triggering parameters + * command would cause access of data outside array bounds. + * + * @exception ISOException with one of the following reason codes:

+ */ + void requestHTTPAdministrationSession (byte[] triggeringParameters, + short offset, + short length); +} diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/HTTPReportListener.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/HTTPReportListener.java new file mode 100644 index 0000000..bad8c7d --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/HTTPReportListener.java @@ -0,0 +1,47 @@ +package org.globalplatform; + +import javacard.framework.Shareable; + +/** + * This interface defines a method to receive a notification upon completion + * (success or failure) of an HTTP Administration Session.

+ * + * An Application that wishes to receive such a notification shall implement the + * {@link javacard.framework.Applet#getShareableInterfaceObject} to return an + * {@link HTTPReportListener} instance when the clientAID parameter + * is set to null, and the parameter parameter is set + * to {@link GPSystem#FAMILY_HTTP_REPORT}.

+ * + * @since

+ */ + +public interface HTTPReportListener extends Shareable +{ + /** + * Constant notifying that a HTTP Administration Session ended successfully + */ + public final static short HTTP_SESSION_NO_ERROR=0x0001; + + /** + * Constant notifying that a HTTP Administration Session failed. That is, the + * retry policy of the session is exhausted and the administration session + * request is aborted. + */ + public final static short HTTP_SESSION_ERROR=(short) 0x8001; + + /** + * Notifies the Application that the requested HTTP Administration Session + * successfully completed or not.

+ * + * The OPEN notifies the Application when the HTTP Administration Session ends + * or when the retry policy is exhausted.

+ * + * @param status Either {@link #HTTP_SESSION_NO_ERROR} (failure) or {@link + * #HTTP_SESSION_ERROR} (success). + */ + public void httpAdministationSessionReport(short status); + +} \ No newline at end of file diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/Personalization.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/Personalization.java new file mode 100644 index 0000000..a68480a --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/Personalization.java @@ -0,0 +1,85 @@ +package org.globalplatform; + +import javacard.framework.*; + +/** + * This interface defines a method through which an Application may forward + * input data to another Application and retrieve output data from that + * Application.

+ * + * This interface shall be implemented by an Application that wishes to receive + * personalization data forwarded by its associated Security Domain and request + * outputting response data. In such a scenario, if the Application implements + * both the {@link Application} and the {@link Personalization} interface, then + * the Security Domain shall use the {@link Personalization} interface.

+ * + * @see Application + * + * @since export file version 1.2 + */ +public interface Personalization extends Shareable +{ + /** + * Processes application specific data received from another on-card entity.

+ * + * If the Application invoking this method is a Security Domain then it shall + * be assumed that:

+ * + *

Notes:

+ * + * @param inBuffer byte array containing input data. Must be a global + * byte array. + * @param inOffset offset of input data within inBuffer. + * @param inLength length of input data. + * @param outBuffer byte array where output data shall be written. Must be a + * global byte array. + * @param outOffset offset where output data shall be written within + * inBuffer. + * + * @return the number of bytes written to outBuffer. + * + * @exception SecurityException if inBuffer or + * outBuffer is not a global byte array. + * @exception NullPointerException if inBuffer or + * outBuffer is null. + * @exception ArrayIndexOutOfBoundsException if reading intput data or writing + * output data would cause access of data outside array bounds. + */ + public short processData (byte[] inBuffer, short inOffset, short inLength, byte[] outBuffer, short outOffset); + +} diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/SecureChannel.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/SecureChannel.java new file mode 100644 index 0000000..76b0e4c --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/SecureChannel.java @@ -0,0 +1,493 @@ + +package org.globalplatform; + +import javacard.framework.*; + +/** + * This interface defines basic Secure Channel services used to manage entity + * authentication and protect APDU commands and responses. It is typically + * exposed by a Security Domain to its associated Applications.

+ * + * Using an instance of this interface requires no knowledge of the underlying + * protocols, algorithms and secrets used to perform entity authentication and + * provide integrity and confidentiality of APDU commands and responses, which + * only need to be known by the provider of the instance.

+ * + * An Application that wishes to delegate such activities to its associated + * Security Domain shall retrieve a {@link SecureChannel} instance provided by + * its associated Security Domain using the {@link GPSystem#getSecureChannel} + * method. On some implementations, this {@link SecureChannel} instance may also + * be retrieved using the {@link GPSystem#getService} method.

+ * + * If the card supports logical channels, this interface is responsible for + * correctly handling any indication of a logical channel number present in the + * class byte of APDU commands. In particular, it shall be able to verify and + * remove (i.e. unwrap) the protection (if any) of an APDU command without + * altering such indication of a logical channel number. + * + * Upon successful initialization of a Secure Channel Session, the + * implementation shall establish both a compulsory Session Security Level and a + * Current Security Level:

+ * + * See Card Specification v2.2.1 section 10.2.3 for details + * about abortion and termination of a Secure Channel Session.

+ * + * Until it is aborted, a Secure Channel Session shall be bound to the following + * information:

+ * + * @since + */ + +public interface SecureChannel extends Shareable +{ + /** + * Entity Authentication has occurred as Application Provider (0x80). + *

Note:

+ */ + public static final byte AUTHENTICATED = (byte) 0x80; + + /** + * The {@link #unwrap} method will decrypt incoming command data (0x02). + *

Note:

+ */ + public static final byte C_DECRYPTION = (byte) 0x02; + + /** + * The {@link #unwrap} method will verify the MAC on an incoming command (0x01). + *

Note:

+ */ + public static final byte C_MAC = (byte) 0x01; + + /** + * The {@link #wrap} method will encrypt the outgoing response data (0x20). + *

Note:

+ */ + public static final byte R_ENCRYPTION = (byte) 0x20; + + /** + * The {@link #wrap} method will generate a MAC for the outgoing response data (0x10). + *

Note:

+ */ + public static final byte R_MAC = (byte) 0x10; + + /** + * Entity Authentication has not occurred (0x00). + *

Note:

+ */ + public static final byte NO_SECURITY_LEVEL = (byte) 0x00; + + /** + * Entity Any Authentication has occurred (0x40). + *

Note:

+ */ + public static final byte ANY_AUTHENTICATED = (byte) 0x40; + + /** + * Processes security related APDU commands, that is, APDU commands relating + * to the underlying security protocol.

+ * + * As the intention is to allow an Application to use Secure Channel services + * without having any knowledge of the underlying security protocols, the + * Application may assume that APDU commands that it does not recognize are + * part of the security protocol and will be recognized by this {@link + * SecureChannel} instance. Therefore, the Application may either invoke this + * method prior to determining if it recognizes the command or only invoke + * this method for commands it does not recognize. In turn, this method will + * throw an {@link ISOException} if it does not recognize the APDU command as + * a security related APDU command.

+ * + * This method is responsible for receiving the data field of APDU commands + * that are recognized (i.e. that belong to the security protocol). When + * processing a command, this method shall write response data in the + * APDU buffer at offset {@link ISO7816#OFFSET_CDATA} or return + * a status word under the form of an {@link ISOException}. The Application is + * responsible for outputting such response data and/or status word.

+ * + * @param apdu the incoming APDU object. + * + * @return the number of bytes to be output (i.e. length of response data). + * + * @exception ISOException with a reason code reflecting some error detected + * by the underlying security protocol, or with one of the following reason + * codes if the APDU command is not recognized and does not relate to the + * underlying security protocol:

+ */ + public short processSecurity(APDU apdu) throws ISOException; + + /** + * Computes and adds security protection to an outgoing APDU response + * according to the Current Security Level.

+ * + * If the Current Security Level is {@link #NO_SECURITY_LEVEL} and is + * different from the compulsory Session Security Level (i.e. a previous + * Secure Channel Session was aborted but not fully + * terminated), then this method shall throw an exception (see below).

+ * + * Otherwise, this method shall attempt computing and adding a security + * protection to the outgoing message according to the Current Security Level + * (e.g. {@link #R_MAC} and/or {@link #R_ENCRYPTION}). If the Current + * Security Level does not require any protection for APDU responses (which + * includes the case where there is no Secure Channel Session currently + * open), the outgoing response message shall remain as is in the within the + * baBuffer byte array and the returned length shall be set to a + * value of (sLength - 2), indicating the status bytes are no + * longer present at the end of the returned data.

+ * + * Notes:

+ * + * @param baBuffer byte array containing response data (including the + * expected status bytes). + * @param sOffset offset of response data. + * @param sLength length of response data (including the expected status + * bytes). + * + * @return length of the reformatted (wrapped) response data, with security + * information added and status bytes removed. + * + * @exception SecurityException if baBuffer is not accessible in + * the caller's context e.g. baBuffer is not a global + * array nor an array belonging to the caller context. + * @exception NullPointerException if baBuffer is null. + * @exception ArrayIndexOutOfBoundsException if writing security information + * in baBuffer would cause access of data outside array bounds. + */ + public short wrap(byte[] baBuffer, short sOffset, short sLength) throws ISOException; + + /** + * Verifies and removes the security protection of an incoming APDU command + * according to the Current Security Level.

+ * + * If the Current Security Level is {@link #NO_SECURITY_LEVEL} and is + * different from the compulsory Session Security Level (i.e. a previous + * Secure Channel Session was aborted but not fully + * terminated), then this method shall throw an exception (see below).

+ * + * If the class byte does not indicate secure messaging (according to ISO/IEC + * 7816-4), then this method shall not attempt to verify and remove any + * security protection: the incoming command shall remain as is within the + * baBuffer byte array and the returned length shall be set to + * the value of the sLength parameter.

+ * + * If the class byte indicates secure messaging (according to ISO/IEC + * 7816-4), then this method shall attempt verifying and removing the + * security protection according to the Current Security Level:

+ * + * Notes: + * + * @param baBuffer byte array containing the incoming APDU command. + * @param sOffset offset of the incoming APDU command, i.e. offset of the + * class byte. + * @param sLength length of the incoming APDU command, i.e length of the + * entire APDU command (header + data field). + * + * @return length of the reformatted (unwrapped) APDU command, i.e length of + * the entire APDU command (header + data field). + * + * @exception ISOException with one of the following reason codes (other + * reason codes specific to the underlying security protocol may be + * returned): + * + * @exception SecurityException if baBuffer is not accessible in + * the caller's context e.g. baBuffer is not a global array nor + * an array belonging to the caller context. + * @exception NullPointerException if baBuffer is null. + * @exception ArrayIndexOutOfBoundsException if reading the incoming APDU + * command would cause access of data outside array bounds. + */ + public short unwrap(byte [] baBuffer, short sOffset, short sLength) throws ISOException; + + /** + * Decrypts sensitive user data.

+ * + * The decryption algorithm and cryptographic key used to decrypt data, as + * well as any padding method, are known implicitly and depend on the + * underlying security protocol.

+ * + * If the Current Security Level is {@link #NO_SECURITY_LEVEL} or the + * necessary cryptographic keys are not available, then this method shall + * throw an exception (see below).

+ * + * Otherwise, the data shall be decrypted and the clear text data shall + * replace the encrypted data within the baBuffer byte + * array. The removal of padding may cause the length of the clear text data + * to be shorter than the length of the encrypted data. Any failure in the + * decryption or padding removal process shall result in an exception being + * thrown (see below).

+ * + * Notes:

+ * + * @param baBuffer byte array containing the data that shall be decrypted. + * @param sOffset offset of the data that shall be decrypted. + * @param sLength length of the data that shall be decrypted. + * + * @return length of the decrypted data, with any padding removed if a padding + * method is defined for the underlying security protocol. + * + * @exception ISOException with one of the following reason codes (other + * reason codes specific to the underlying security protocol may be + * returned): + * + * @exception SecurityException if baBuffer is not accessible in + * the caller's context e.g. baBuffer is not a global + * array nor an array belonging to the caller context. + * @exception NullPointerException if baBuffer is + * null. + * @exception ArrayIndexOutOfBoundsException if reading user data or writing + * decrypted data would cause access of data outside array bounds. + */ + public short decryptData(byte[] baBuffer, short sOffset, short sLength) throws ISOException; + + /** + * Encrypts sensitive user data.

+ * + * If this method is not supported by the implementation or the underlying + * protocol does not define any sensitive data encryption mechanism, it shall + * do nothing and simply throw an exception (see below).

+ * + * The encryption algorithm and cryptographic key used to encrypt data, as + * well as any padding method, are known implicitly and depend on the + * underlying security protocol.

+ * + * If the Current Security Level is {@link #NO_SECURITY_LEVEL} or the + * necessary cryptographic keys are not available, then this method shall + * throw an exception (see below).

+ * + * Otherwise, the data shall be padded (NOTE: depends on the underlying + * protocol) and encrypted and the encrypted data shall replace the clear + * text data within the baBuffer byte array. The addition of + * padding may cause the length of the encrypted data to be longer than the + * length of the clear text data. Any failure in the padding or encryption + * process shall result in an exception being thrown (see below).

+ * + * Notes:

+ * + * @param baBuffer byte array containing the data that shall be encrypted. + * @param sOffset offset of the data that shall be encrypted. + * @param sLength length of the data that shall be encrypted. + * + * @return length of the encrypted data. + * + * @exception ISOException with one of the following reason codes (other + * reason codes specific to the underlying security protocol may be + * returned): + * + * @exception SecurityException if baBuffer is not accessible in + * the caller's context e.g. baBuffer is not a global + * array nor an array belonging to the caller context. + * @exception NullPointerException if baBuffer is + * null. + * @exception ArrayIndexOutOfBoundsException if reading user data or writing + * encrypted data would cause access of data outside array bounds. + */ + public short encryptData(byte[] baBuffer, short sOffset, short sLength) throws ISOException; + + /** + * Terminates the current Secure Channel Session. + * + * This method resets both the compulsory Session Security Level and the + * Current Security Level to {@link #NO_SECURITY_LEVEL} and resets all + * information relating to the current Secure Channel Session (e.g. internal + * states, session keys).

+ * + * This method shall not fail and shall simply return if no Secure + * Channel Session has been initiated.

+ + * Notes:

+ */ + public void resetSecurity(); + + /** + * Gets the Current Security Level. + * + * An Application shall invoke this method to ensure that its own specific + * security requirements are enforced by this interface. It shall also take + * into account that the Current Security Level may change during the Secure + * Channel Session (e.g. R_MAC may be enabled or disabled during a C_MAC + * session).

+ * + * Notes:

+ * + * @return The Current Security Level, which is a combination of one or more + * the following constants: + */ + public byte getSecurityLevel(); +} + + diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/SecureChannelx.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/SecureChannelx.java new file mode 100644 index 0000000..f4c7f2e --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/SecureChannelx.java @@ -0,0 +1,73 @@ + +package org.globalplatform; + +import javacard.framework.*; + +/** + * This interface is an extension of the {@link SecureChannel} interface that + * defines one supplementary method to update the Current Security Level + * during a Secure Channel Session.

+ * + * An Application that wishes to use the {@link SecureChannelx} interface shall + * obtain a reference to a {@link SecureChannel} instance and try to cast it to + * the {@link SecureChannelx} interface. Whether the objects returned by the + * {@link GPSystem#getSecureChannel} method also implement the {@link + * SecureChannelx} interface is implementation dependent, however, this may be + * expressed as a requirement in specific GlobalPlatform configuration + * documents. + * + * @since

+ */ +public interface SecureChannelx extends SecureChannel +{ + /** + * Updates the Current Security Level. + * + * If this method is not supported by the implementation or the underlying + * protocol does not define any sensitive data encryption mechanism, it shall + * do nothing and simply throw an exception (see below).

+ * + * The Current Security Level cannot be set below the compulsory Session + * Security Level, but only equal or above. It may be increased or + * decreased during a Secure Channel Session as long as it is at least equal + * to the compulsory Session Security Level.

+ * + * If the Current Security Level is {@link #NO_SECURITY_LEVEL} or the + * cryptographic keys required by the new Current Security Level are not + * available, then this method shall throw an exception (see below).

+ * + * The new Current Security Level shall apply for all subsequent invocations + * of {@link SecureChannel#wrap} and {@link SecureChannel#unwrap} methods, + * except when there is no current Secure Channel Session.

+ + * @param bSecurityLevel The new Current Security Level, which shall a + * combination of one or more the following constants:

+ * + * @exception ISOException with one of the following reason codes (other + * reason codes specific to the underlying security protocol may be + * returned): + */ + public void setSecurityLevel(byte bSecurityLevel); +} + + diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/SecureChannelx2.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/SecureChannelx2.java new file mode 100644 index 0000000..eff2a10 --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/SecureChannelx2.java @@ -0,0 +1,70 @@ +package org.globalplatform; + +import javacard.framework.ISOException; + +/** + * This interface is an extension of the {@link SecureChannel} interface that + * defines one supplementary method overriding the {@link + * SecureChannel#processSecurity} method.

+ * + * An Application that wishes to use the {@link SecureChannelx2} interface shall + * obtain a reference to a {@link SecureChannel} instance and try to cast it to + * the {@link SecureChannelx2} interface. Whether the objects returned by the + * {@link GPSystem#getSecureChannel} method also implement the {@link + * SecureChannelx2} interface is implementation dependent, however, this may be + * expressed as a requirement in specific GlobalPlatform configuration + * documents. + * + * @since

+ */ +public interface SecureChannelx2 extends SecureChannel +{ + /** + * Processes security related APDU commands, that is, APDU commands relating + * to the underlying security protocol.

+ * + * This method shall be used in the same way as the {@link + * SecureChannel#processSecurity} method, except that the incoming APDU + * command shall be read from, and any response data shall be written to the + * baBuffer byte array.

+ * + * Notes:

+ * + * @param baBuffer byte array containing the incoming APDU command. + * @param sInOffset offset of the incoming APDU command, i.e. offset of the + * class byte. + * @param sInLength length of the incoming APDU command, i.e length of the + * entire APDU command (header + data field). + * @param sOutOffset offset within baBuffer where response data + * (if any) shall be written. + * + * @return the number of bytes to be output (i.e. length of response data). + * + * @exception ISOException with a reason code reflecting some error detected + * by the underlying security protocol, or with one of the following reason + * codes if the APDU command is not recognized and does not relate to the + * underlying security protocol: + * + * @exception SecurityException if baBuffer is not accessible in + * the caller's context e.g. baBuffer is not a global array nor + * an array belonging to the caller context. + * @exception NullPointerException if baBuffer is null. + * @exception ArrayIndexOutOfBoundsException if reading the incoming APDU + * command would cause access of data outside array bounds. + */ + public short processSecurity(byte[] baBuffer, short sInOffset, short sInLength, short sOutOffset) throws ISOException; + +} diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/javacard/globalplatform.exp b/build_tools/Tools/ext_api/gp221/org/globalplatform/javacard/globalplatform.exp new file mode 100644 index 0000000..4d4bdbe Binary files /dev/null and b/build_tools/Tools/ext_api/gp221/org/globalplatform/javacard/globalplatform.exp differ diff --git a/build_tools/Tools/ext_api/gp221/org/globalplatform/package-info.java b/build_tools/Tools/ext_api/gp221/org/globalplatform/package-info.java new file mode 100644 index 0000000..7cfdc39 --- /dev/null +++ b/build_tools/Tools/ext_api/gp221/org/globalplatform/package-info.java @@ -0,0 +1,8 @@ +/** + * Provides a framework of classes and interfaces related to core services + * defined for smart cards based on GlobalPlatform specifications. + * @version This documentation describes API elements and behaviors associated + * with version 1.6 of this package export file. + */ +package org.globalplatform; + diff --git a/Tools/jcdk222/api_export_files/java/io/javacard/io.exp b/build_tools/Tools/jcdk222/api_export_files/java/io/javacard/io.exp similarity index 100% rename from Tools/jcdk222/api_export_files/java/io/javacard/io.exp rename to build_tools/Tools/jcdk222/api_export_files/java/io/javacard/io.exp diff --git a/Tools/jcdk222/api_export_files/java/lang/javacard/lang.exp b/build_tools/Tools/jcdk222/api_export_files/java/lang/javacard/lang.exp similarity index 100% rename from Tools/jcdk222/api_export_files/java/lang/javacard/lang.exp rename to build_tools/Tools/jcdk222/api_export_files/java/lang/javacard/lang.exp diff --git a/Tools/jcdk222/api_export_files/java/rmi/javacard/rmi.exp b/build_tools/Tools/jcdk222/api_export_files/java/rmi/javacard/rmi.exp similarity index 100% rename from Tools/jcdk222/api_export_files/java/rmi/javacard/rmi.exp rename to build_tools/Tools/jcdk222/api_export_files/java/rmi/javacard/rmi.exp diff --git a/Tools/jcdk222/api_export_files/javacard/framework/javacard/framework.exp b/build_tools/Tools/jcdk222/api_export_files/javacard/framework/javacard/framework.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacard/framework/javacard/framework.exp rename to build_tools/Tools/jcdk222/api_export_files/javacard/framework/javacard/framework.exp diff --git a/Tools/jcdk222/api_export_files/javacard/framework/service/javacard/service.exp b/build_tools/Tools/jcdk222/api_export_files/javacard/framework/service/javacard/service.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacard/framework/service/javacard/service.exp rename to build_tools/Tools/jcdk222/api_export_files/javacard/framework/service/javacard/service.exp diff --git a/Tools/jcdk222/api_export_files/javacard/security/javacard/security.exp b/build_tools/Tools/jcdk222/api_export_files/javacard/security/javacard/security.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacard/security/javacard/security.exp rename to build_tools/Tools/jcdk222/api_export_files/javacard/security/javacard/security.exp diff --git a/Tools/jcdk222/api_export_files/javacardx/apdu/javacard/apdu.exp b/build_tools/Tools/jcdk222/api_export_files/javacardx/apdu/javacard/apdu.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacardx/apdu/javacard/apdu.exp rename to build_tools/Tools/jcdk222/api_export_files/javacardx/apdu/javacard/apdu.exp diff --git a/Tools/jcdk222/api_export_files/javacardx/biometry/javacard/biometry.exp b/build_tools/Tools/jcdk222/api_export_files/javacardx/biometry/javacard/biometry.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacardx/biometry/javacard/biometry.exp rename to build_tools/Tools/jcdk222/api_export_files/javacardx/biometry/javacard/biometry.exp diff --git a/Tools/jcdk222/api_export_files/javacardx/crypto/javacard/crypto.exp b/build_tools/Tools/jcdk222/api_export_files/javacardx/crypto/javacard/crypto.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacardx/crypto/javacard/crypto.exp rename to build_tools/Tools/jcdk222/api_export_files/javacardx/crypto/javacard/crypto.exp diff --git a/Tools/jcdk222/api_export_files/javacardx/external/javacard/external.exp b/build_tools/Tools/jcdk222/api_export_files/javacardx/external/javacard/external.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacardx/external/javacard/external.exp rename to build_tools/Tools/jcdk222/api_export_files/javacardx/external/javacard/external.exp diff --git a/Tools/jcdk222/api_export_files/javacardx/framework/math/javacard/math.exp b/build_tools/Tools/jcdk222/api_export_files/javacardx/framework/math/javacard/math.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacardx/framework/math/javacard/math.exp rename to build_tools/Tools/jcdk222/api_export_files/javacardx/framework/math/javacard/math.exp diff --git a/Tools/jcdk222/api_export_files/javacardx/framework/tlv/javacard/tlv.exp b/build_tools/Tools/jcdk222/api_export_files/javacardx/framework/tlv/javacard/tlv.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacardx/framework/tlv/javacard/tlv.exp rename to build_tools/Tools/jcdk222/api_export_files/javacardx/framework/tlv/javacard/tlv.exp diff --git a/Tools/jcdk222/api_export_files/javacardx/framework/util/intx/javacard/intx.exp b/build_tools/Tools/jcdk222/api_export_files/javacardx/framework/util/intx/javacard/intx.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacardx/framework/util/intx/javacard/intx.exp rename to build_tools/Tools/jcdk222/api_export_files/javacardx/framework/util/intx/javacard/intx.exp diff --git a/Tools/jcdk222/api_export_files/javacardx/framework/util/javacard/util.exp b/build_tools/Tools/jcdk222/api_export_files/javacardx/framework/util/javacard/util.exp similarity index 100% rename from Tools/jcdk222/api_export_files/javacardx/framework/util/javacard/util.exp rename to build_tools/Tools/jcdk222/api_export_files/javacardx/framework/util/javacard/util.exp diff --git a/Tools/jcdk222/bin/apdutool.bat b/build_tools/Tools/jcdk222/bin/apdutool.bat similarity index 100% rename from Tools/jcdk222/bin/apdutool.bat rename to build_tools/Tools/jcdk222/bin/apdutool.bat diff --git a/Tools/jcdk222/bin/capdump.bat b/build_tools/Tools/jcdk222/bin/capdump.bat similarity index 100% rename from Tools/jcdk222/bin/capdump.bat rename to build_tools/Tools/jcdk222/bin/capdump.bat diff --git a/Tools/jcdk222/bin/capgen.bat b/build_tools/Tools/jcdk222/bin/capgen.bat similarity index 100% rename from Tools/jcdk222/bin/capgen.bat rename to build_tools/Tools/jcdk222/bin/capgen.bat diff --git a/Tools/jcdk222/bin/converter.bat b/build_tools/Tools/jcdk222/bin/converter.bat similarity index 100% rename from Tools/jcdk222/bin/converter.bat rename to build_tools/Tools/jcdk222/bin/converter.bat diff --git a/Tools/jcdk222/bin/cref.eeprom b/build_tools/Tools/jcdk222/bin/cref.eeprom similarity index 100% rename from Tools/jcdk222/bin/cref.eeprom rename to build_tools/Tools/jcdk222/bin/cref.eeprom diff --git a/Tools/jcdk222/bin/cref.exe b/build_tools/Tools/jcdk222/bin/cref.exe similarity index 100% rename from Tools/jcdk222/bin/cref.exe rename to build_tools/Tools/jcdk222/bin/cref.exe diff --git a/Tools/jcdk222/bin/exp2text.bat b/build_tools/Tools/jcdk222/bin/exp2text.bat similarity index 100% rename from Tools/jcdk222/bin/exp2text.bat rename to build_tools/Tools/jcdk222/bin/exp2text.bat diff --git a/Tools/jcdk222/bin/jcwde.bat b/build_tools/Tools/jcdk222/bin/jcwde.bat similarity index 100% rename from Tools/jcdk222/bin/jcwde.bat rename to build_tools/Tools/jcdk222/bin/jcwde.bat diff --git a/Tools/jcdk222/bin/jpcsclite.dll b/build_tools/Tools/jcdk222/bin/jpcsclite.dll similarity index 100% rename from Tools/jcdk222/bin/jpcsclite.dll rename to build_tools/Tools/jcdk222/bin/jpcsclite.dll diff --git a/Tools/jcdk222/bin/scriptgen.bat b/build_tools/Tools/jcdk222/bin/scriptgen.bat similarity index 100% rename from Tools/jcdk222/bin/scriptgen.bat rename to build_tools/Tools/jcdk222/bin/scriptgen.bat diff --git a/Tools/jcdk222/bin/verifycap.bat b/build_tools/Tools/jcdk222/bin/verifycap.bat similarity index 100% rename from Tools/jcdk222/bin/verifycap.bat rename to build_tools/Tools/jcdk222/bin/verifycap.bat diff --git a/Tools/jcdk222/bin/verifyexp.bat b/build_tools/Tools/jcdk222/bin/verifyexp.bat similarity index 100% rename from Tools/jcdk222/bin/verifyexp.bat rename to build_tools/Tools/jcdk222/bin/verifyexp.bat diff --git a/Tools/jcdk222/bin/verifyrev.bat b/build_tools/Tools/jcdk222/bin/verifyrev.bat similarity index 100% rename from Tools/jcdk222/bin/verifyrev.bat rename to build_tools/Tools/jcdk222/bin/verifyrev.bat diff --git a/Tools/jcdk222/lib/apduio.jar b/build_tools/Tools/jcdk222/lib/apduio.jar similarity index 100% rename from Tools/jcdk222/lib/apduio.jar rename to build_tools/Tools/jcdk222/lib/apduio.jar diff --git a/Tools/jcdk222/lib/apdutool.jar b/build_tools/Tools/jcdk222/lib/apdutool.jar similarity index 100% rename from Tools/jcdk222/lib/apdutool.jar rename to build_tools/Tools/jcdk222/lib/apdutool.jar diff --git a/Tools/jcdk222/lib/api.jar b/build_tools/Tools/jcdk222/lib/api.jar similarity index 100% rename from Tools/jcdk222/lib/api.jar rename to build_tools/Tools/jcdk222/lib/api.jar diff --git a/Tools/jcdk222/lib/api_16.jar b/build_tools/Tools/jcdk222/lib/api_16.jar similarity index 100% rename from Tools/jcdk222/lib/api_16.jar rename to build_tools/Tools/jcdk222/lib/api_16.jar diff --git a/Tools/jcdk222/lib/capdump.jar b/build_tools/Tools/jcdk222/lib/capdump.jar similarity index 100% rename from Tools/jcdk222/lib/capdump.jar rename to build_tools/Tools/jcdk222/lib/capdump.jar diff --git a/Tools/jcdk222/lib/converter.jar b/build_tools/Tools/jcdk222/lib/converter.jar similarity index 100% rename from Tools/jcdk222/lib/converter.jar rename to build_tools/Tools/jcdk222/lib/converter.jar diff --git a/Tools/jcdk222/lib/installer.jar b/build_tools/Tools/jcdk222/lib/installer.jar similarity index 100% rename from Tools/jcdk222/lib/installer.jar rename to build_tools/Tools/jcdk222/lib/installer.jar diff --git a/Tools/jcdk222/lib/javacardframework.jar b/build_tools/Tools/jcdk222/lib/javacardframework.jar similarity index 100% rename from Tools/jcdk222/lib/javacardframework.jar rename to build_tools/Tools/jcdk222/lib/javacardframework.jar diff --git a/Tools/jcdk222/lib/jcclientsamples.jar b/build_tools/Tools/jcdk222/lib/jcclientsamples.jar similarity index 100% rename from Tools/jcdk222/lib/jcclientsamples.jar rename to build_tools/Tools/jcdk222/lib/jcclientsamples.jar diff --git a/Tools/jcdk222/lib/jcrmiclientframework.jar b/build_tools/Tools/jcdk222/lib/jcrmiclientframework.jar similarity index 100% rename from Tools/jcdk222/lib/jcrmiclientframework.jar rename to build_tools/Tools/jcdk222/lib/jcrmiclientframework.jar diff --git a/Tools/jcdk222/lib/jcwde.jar b/build_tools/Tools/jcdk222/lib/jcwde.jar similarity index 100% rename from Tools/jcdk222/lib/jcwde.jar rename to build_tools/Tools/jcdk222/lib/jcwde.jar diff --git a/Tools/jcdk222/lib/jcwde_16.jar b/build_tools/Tools/jcdk222/lib/jcwde_16.jar similarity index 100% rename from Tools/jcdk222/lib/jcwde_16.jar rename to build_tools/Tools/jcdk222/lib/jcwde_16.jar diff --git a/Tools/jcdk222/lib/offcardverifier.jar b/build_tools/Tools/jcdk222/lib/offcardverifier.jar similarity index 100% rename from Tools/jcdk222/lib/offcardverifier.jar rename to build_tools/Tools/jcdk222/lib/offcardverifier.jar diff --git a/Tools/jcdk222/lib/scriptgen.jar b/build_tools/Tools/jcdk222/lib/scriptgen.jar similarity index 100% rename from Tools/jcdk222/lib/scriptgen.jar rename to build_tools/Tools/jcdk222/lib/scriptgen.jar diff --git a/Tools/jdk1.5.0_19/bin/HtmlConverter.exe b/build_tools/Tools/jdk1.5.0_19/bin/HtmlConverter.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/HtmlConverter.exe rename to build_tools/Tools/jdk1.5.0_19/bin/HtmlConverter.exe diff --git a/Tools/jdk1.5.0_19/bin/appletviewer.exe b/build_tools/Tools/jdk1.5.0_19/bin/appletviewer.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/appletviewer.exe rename to build_tools/Tools/jdk1.5.0_19/bin/appletviewer.exe diff --git a/Tools/jdk1.5.0_19/bin/apt.exe b/build_tools/Tools/jdk1.5.0_19/bin/apt.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/apt.exe rename to build_tools/Tools/jdk1.5.0_19/bin/apt.exe diff --git a/Tools/jdk1.5.0_19/bin/beanreg.dll b/build_tools/Tools/jdk1.5.0_19/bin/beanreg.dll similarity index 100% rename from Tools/jdk1.5.0_19/bin/beanreg.dll rename to build_tools/Tools/jdk1.5.0_19/bin/beanreg.dll diff --git a/Tools/jdk1.5.0_19/bin/extcheck.exe b/build_tools/Tools/jdk1.5.0_19/bin/extcheck.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/extcheck.exe rename to build_tools/Tools/jdk1.5.0_19/bin/extcheck.exe diff --git a/Tools/jdk1.5.0_19/bin/idlj.exe b/build_tools/Tools/jdk1.5.0_19/bin/idlj.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/idlj.exe rename to build_tools/Tools/jdk1.5.0_19/bin/idlj.exe diff --git a/Tools/jdk1.5.0_19/bin/jar.exe b/build_tools/Tools/jdk1.5.0_19/bin/jar.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/jar.exe rename to build_tools/Tools/jdk1.5.0_19/bin/jar.exe diff --git a/Tools/jdk1.5.0_19/bin/jarsigner.exe b/build_tools/Tools/jdk1.5.0_19/bin/jarsigner.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/jarsigner.exe rename to build_tools/Tools/jdk1.5.0_19/bin/jarsigner.exe diff --git a/Tools/jdk1.5.0_19/bin/java.exe b/build_tools/Tools/jdk1.5.0_19/bin/java.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/java.exe rename to build_tools/Tools/jdk1.5.0_19/bin/java.exe diff --git a/Tools/jdk1.5.0_19/bin/javac.exe b/build_tools/Tools/jdk1.5.0_19/bin/javac.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/javac.exe rename to build_tools/Tools/jdk1.5.0_19/bin/javac.exe diff --git a/Tools/jdk1.5.0_19/bin/javadoc.exe b/build_tools/Tools/jdk1.5.0_19/bin/javadoc.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/javadoc.exe rename to build_tools/Tools/jdk1.5.0_19/bin/javadoc.exe diff --git a/Tools/jdk1.5.0_19/bin/javah.exe b/build_tools/Tools/jdk1.5.0_19/bin/javah.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/javah.exe rename to build_tools/Tools/jdk1.5.0_19/bin/javah.exe diff --git a/Tools/jdk1.5.0_19/bin/javap.exe b/build_tools/Tools/jdk1.5.0_19/bin/javap.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/javap.exe rename to build_tools/Tools/jdk1.5.0_19/bin/javap.exe diff --git a/Tools/jdk1.5.0_19/bin/javaw.exe b/build_tools/Tools/jdk1.5.0_19/bin/javaw.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/javaw.exe rename to build_tools/Tools/jdk1.5.0_19/bin/javaw.exe diff --git a/Tools/jdk1.5.0_19/bin/javaws.exe b/build_tools/Tools/jdk1.5.0_19/bin/javaws.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/javaws.exe rename to build_tools/Tools/jdk1.5.0_19/bin/javaws.exe diff --git a/Tools/jdk1.5.0_19/bin/jconsole.exe b/build_tools/Tools/jdk1.5.0_19/bin/jconsole.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/jconsole.exe rename to build_tools/Tools/jdk1.5.0_19/bin/jconsole.exe diff --git a/Tools/jdk1.5.0_19/bin/jdb.exe b/build_tools/Tools/jdk1.5.0_19/bin/jdb.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/jdb.exe rename to build_tools/Tools/jdk1.5.0_19/bin/jdb.exe diff --git a/Tools/jdk1.5.0_19/bin/jps.exe b/build_tools/Tools/jdk1.5.0_19/bin/jps.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/jps.exe rename to build_tools/Tools/jdk1.5.0_19/bin/jps.exe diff --git a/Tools/jdk1.5.0_19/bin/jstat.exe b/build_tools/Tools/jdk1.5.0_19/bin/jstat.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/jstat.exe rename to build_tools/Tools/jdk1.5.0_19/bin/jstat.exe diff --git a/Tools/jdk1.5.0_19/bin/jstatd.exe b/build_tools/Tools/jdk1.5.0_19/bin/jstatd.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/jstatd.exe rename to build_tools/Tools/jdk1.5.0_19/bin/jstatd.exe diff --git a/Tools/jdk1.5.0_19/bin/keytool.exe b/build_tools/Tools/jdk1.5.0_19/bin/keytool.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/keytool.exe rename to build_tools/Tools/jdk1.5.0_19/bin/keytool.exe diff --git a/Tools/jdk1.5.0_19/bin/kinit.exe b/build_tools/Tools/jdk1.5.0_19/bin/kinit.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/kinit.exe rename to build_tools/Tools/jdk1.5.0_19/bin/kinit.exe diff --git a/Tools/jdk1.5.0_19/bin/klist.exe b/build_tools/Tools/jdk1.5.0_19/bin/klist.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/klist.exe rename to build_tools/Tools/jdk1.5.0_19/bin/klist.exe diff --git a/Tools/jdk1.5.0_19/bin/ktab.exe b/build_tools/Tools/jdk1.5.0_19/bin/ktab.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/ktab.exe rename to build_tools/Tools/jdk1.5.0_19/bin/ktab.exe diff --git a/Tools/jdk1.5.0_19/bin/native2ascii.exe b/build_tools/Tools/jdk1.5.0_19/bin/native2ascii.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/native2ascii.exe rename to build_tools/Tools/jdk1.5.0_19/bin/native2ascii.exe diff --git a/Tools/jdk1.5.0_19/bin/orbd.exe b/build_tools/Tools/jdk1.5.0_19/bin/orbd.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/orbd.exe rename to build_tools/Tools/jdk1.5.0_19/bin/orbd.exe diff --git a/Tools/jdk1.5.0_19/bin/pack200.exe b/build_tools/Tools/jdk1.5.0_19/bin/pack200.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/pack200.exe rename to build_tools/Tools/jdk1.5.0_19/bin/pack200.exe diff --git a/Tools/jdk1.5.0_19/bin/packager.exe b/build_tools/Tools/jdk1.5.0_19/bin/packager.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/packager.exe rename to build_tools/Tools/jdk1.5.0_19/bin/packager.exe diff --git a/Tools/jdk1.5.0_19/bin/policytool.exe b/build_tools/Tools/jdk1.5.0_19/bin/policytool.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/policytool.exe rename to build_tools/Tools/jdk1.5.0_19/bin/policytool.exe diff --git a/Tools/jdk1.5.0_19/bin/rmic.exe b/build_tools/Tools/jdk1.5.0_19/bin/rmic.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/rmic.exe rename to build_tools/Tools/jdk1.5.0_19/bin/rmic.exe diff --git a/Tools/jdk1.5.0_19/bin/rmid.exe b/build_tools/Tools/jdk1.5.0_19/bin/rmid.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/rmid.exe rename to build_tools/Tools/jdk1.5.0_19/bin/rmid.exe diff --git a/Tools/jdk1.5.0_19/bin/rmiregistry.exe b/build_tools/Tools/jdk1.5.0_19/bin/rmiregistry.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/rmiregistry.exe rename to build_tools/Tools/jdk1.5.0_19/bin/rmiregistry.exe diff --git a/Tools/jdk1.5.0_19/bin/serialver.exe b/build_tools/Tools/jdk1.5.0_19/bin/serialver.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/serialver.exe rename to build_tools/Tools/jdk1.5.0_19/bin/serialver.exe diff --git a/Tools/jdk1.5.0_19/bin/servertool.exe b/build_tools/Tools/jdk1.5.0_19/bin/servertool.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/servertool.exe rename to build_tools/Tools/jdk1.5.0_19/bin/servertool.exe diff --git a/Tools/jdk1.5.0_19/bin/tnameserv.exe b/build_tools/Tools/jdk1.5.0_19/bin/tnameserv.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/tnameserv.exe rename to build_tools/Tools/jdk1.5.0_19/bin/tnameserv.exe diff --git a/Tools/jdk1.5.0_19/bin/unpack200.exe b/build_tools/Tools/jdk1.5.0_19/bin/unpack200.exe similarity index 100% rename from Tools/jdk1.5.0_19/bin/unpack200.exe rename to build_tools/Tools/jdk1.5.0_19/bin/unpack200.exe diff --git a/Tools/jdk1.5.0_19/include/jawt.h b/build_tools/Tools/jdk1.5.0_19/include/jawt.h similarity index 100% rename from Tools/jdk1.5.0_19/include/jawt.h rename to build_tools/Tools/jdk1.5.0_19/include/jawt.h diff --git a/Tools/jdk1.5.0_19/include/jdwpTransport.h b/build_tools/Tools/jdk1.5.0_19/include/jdwpTransport.h similarity index 100% rename from Tools/jdk1.5.0_19/include/jdwpTransport.h rename to build_tools/Tools/jdk1.5.0_19/include/jdwpTransport.h diff --git a/Tools/jdk1.5.0_19/include/jni.h b/build_tools/Tools/jdk1.5.0_19/include/jni.h similarity index 100% rename from Tools/jdk1.5.0_19/include/jni.h rename to build_tools/Tools/jdk1.5.0_19/include/jni.h diff --git a/Tools/jdk1.5.0_19/include/jvmdi.h b/build_tools/Tools/jdk1.5.0_19/include/jvmdi.h similarity index 100% rename from Tools/jdk1.5.0_19/include/jvmdi.h rename to build_tools/Tools/jdk1.5.0_19/include/jvmdi.h diff --git a/Tools/jdk1.5.0_19/include/jvmpi.h b/build_tools/Tools/jdk1.5.0_19/include/jvmpi.h similarity index 100% rename from Tools/jdk1.5.0_19/include/jvmpi.h rename to build_tools/Tools/jdk1.5.0_19/include/jvmpi.h diff --git a/Tools/jdk1.5.0_19/include/jvmti.h b/build_tools/Tools/jdk1.5.0_19/include/jvmti.h similarity index 100% rename from Tools/jdk1.5.0_19/include/jvmti.h rename to build_tools/Tools/jdk1.5.0_19/include/jvmti.h diff --git a/Tools/jdk1.5.0_19/include/win32/jawt_md.h b/build_tools/Tools/jdk1.5.0_19/include/win32/jawt_md.h similarity index 100% rename from Tools/jdk1.5.0_19/include/win32/jawt_md.h rename to build_tools/Tools/jdk1.5.0_19/include/win32/jawt_md.h diff --git a/Tools/jdk1.5.0_19/include/win32/jni_md.h b/build_tools/Tools/jdk1.5.0_19/include/win32/jni_md.h similarity index 100% rename from Tools/jdk1.5.0_19/include/win32/jni_md.h rename to build_tools/Tools/jdk1.5.0_19/include/win32/jni_md.h diff --git a/Tools/jdk1.5.0_19/jre/CHANGES b/build_tools/Tools/jdk1.5.0_19/jre/CHANGES similarity index 100% rename from Tools/jdk1.5.0_19/jre/CHANGES rename to build_tools/Tools/jdk1.5.0_19/jre/CHANGES diff --git a/Tools/jdk1.5.0_19/jre/COPYRIGHT b/build_tools/Tools/jdk1.5.0_19/jre/COPYRIGHT similarity index 100% rename from Tools/jdk1.5.0_19/jre/COPYRIGHT rename to build_tools/Tools/jdk1.5.0_19/jre/COPYRIGHT diff --git a/Tools/jdk1.5.0_19/jre/LICENSE b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE diff --git a/Tools/jdk1.5.0_19/jre/LICENSE.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE.rtf diff --git a/Tools/jdk1.5.0_19/jre/LICENSE_de.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE_de.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE_de.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE_de.rtf diff --git a/Tools/jdk1.5.0_19/jre/LICENSE_es.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE_es.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE_es.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE_es.rtf diff --git a/Tools/jdk1.5.0_19/jre/LICENSE_fr.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE_fr.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE_fr.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE_fr.rtf diff --git a/Tools/jdk1.5.0_19/jre/LICENSE_it.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE_it.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE_it.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE_it.rtf diff --git a/Tools/jdk1.5.0_19/jre/LICENSE_ja.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE_ja.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE_ja.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE_ja.rtf diff --git a/Tools/jdk1.5.0_19/jre/LICENSE_ko.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE_ko.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE_ko.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE_ko.rtf diff --git a/Tools/jdk1.5.0_19/jre/LICENSE_sv.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE_sv.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE_sv.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE_sv.rtf diff --git a/Tools/jdk1.5.0_19/jre/LICENSE_zh_CN.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE_zh_CN.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE_zh_CN.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE_zh_CN.rtf diff --git a/Tools/jdk1.5.0_19/jre/LICENSE_zh_TW.rtf b/build_tools/Tools/jdk1.5.0_19/jre/LICENSE_zh_TW.rtf similarity index 100% rename from Tools/jdk1.5.0_19/jre/LICENSE_zh_TW.rtf rename to build_tools/Tools/jdk1.5.0_19/jre/LICENSE_zh_TW.rtf diff --git a/Tools/jdk1.5.0_19/jre/README.txt b/build_tools/Tools/jdk1.5.0_19/jre/README.txt similarity index 100% rename from Tools/jdk1.5.0_19/jre/README.txt rename to build_tools/Tools/jdk1.5.0_19/jre/README.txt diff --git a/Tools/jdk1.5.0_19/jre/THIRDPARTYLICENSEREADME.txt b/build_tools/Tools/jdk1.5.0_19/jre/THIRDPARTYLICENSEREADME.txt similarity index 100% rename from Tools/jdk1.5.0_19/jre/THIRDPARTYLICENSEREADME.txt rename to build_tools/Tools/jdk1.5.0_19/jre/THIRDPARTYLICENSEREADME.txt diff --git a/Tools/jdk1.5.0_19/jre/Welcome.html b/build_tools/Tools/jdk1.5.0_19/jre/Welcome.html similarity index 100% rename from Tools/jdk1.5.0_19/jre/Welcome.html rename to build_tools/Tools/jdk1.5.0_19/jre/Welcome.html diff --git a/Tools/jdk1.5.0_19/jre/bin/JavaWebStart.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/JavaWebStart.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/JavaWebStart.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/JavaWebStart.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/JdbcOdbc.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/JdbcOdbc.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/JdbcOdbc.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/JdbcOdbc.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/NPJPI150_19.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/NPJPI150_19.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/NPJPI150_19.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/NPJPI150_19.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/NPJava11.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava11.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/NPJava11.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava11.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/NPJava12.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava12.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/NPJava12.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava12.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/NPJava13.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava13.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/NPJava13.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava13.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/NPJava14.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava14.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/NPJava14.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava14.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/NPJava32.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava32.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/NPJava32.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/NPJava32.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/NPOJI610.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/NPOJI610.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/NPOJI610.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/NPOJI610.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/RegUtils.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/RegUtils.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/RegUtils.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/RegUtils.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/awt.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/awt.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/awt.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/awt.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/axbridge.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/axbridge.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/axbridge.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/axbridge.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/client/Xusage.txt b/build_tools/Tools/jdk1.5.0_19/jre/bin/client/Xusage.txt similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/client/Xusage.txt rename to build_tools/Tools/jdk1.5.0_19/jre/bin/client/Xusage.txt diff --git a/Tools/jdk1.5.0_19/jre/bin/client/classes.jsa b/build_tools/Tools/jdk1.5.0_19/jre/bin/client/classes.jsa similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/client/classes.jsa rename to build_tools/Tools/jdk1.5.0_19/jre/bin/client/classes.jsa diff --git a/Tools/jdk1.5.0_19/jre/bin/client/jvm.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/client/jvm.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/client/jvm.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/client/jvm.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/cmm.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/cmm.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/cmm.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/cmm.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/dcpr.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/dcpr.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/dcpr.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/dcpr.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/deploy.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/deploy.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/deploy.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/deploy.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/dt_shmem.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/dt_shmem.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/dt_shmem.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/dt_shmem.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/dt_socket.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/dt_socket.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/dt_socket.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/dt_socket.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/eula.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/eula.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/eula.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/eula.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/fontmanager.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/fontmanager.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/fontmanager.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/fontmanager.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/hpi.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/hpi.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/hpi.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/hpi.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/hprof.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/hprof.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/hprof.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/hprof.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/instrument.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/instrument.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/instrument.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/instrument.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/ioser12.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/ioser12.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/ioser12.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/ioser12.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/j2pkcs11.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/j2pkcs11.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/j2pkcs11.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/j2pkcs11.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jaas_nt.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jaas_nt.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jaas_nt.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jaas_nt.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/java.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/java.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/java.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/java.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/java.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/java.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/java.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/java.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/java_crw_demo.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/java_crw_demo.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/java_crw_demo.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/java_crw_demo.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/javacpl.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/javacpl.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/javacpl.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/javacpl.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/javaw.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/javaw.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/javaw.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/javaw.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/javaws.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/javaws.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/javaws.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/javaws.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/jawt.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jawt.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jawt.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jawt.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jdwp.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jdwp.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jdwp.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jdwp.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jpeg.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jpeg.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jpeg.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jpeg.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jpicom32.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jpicom32.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jpicom32.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jpicom32.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jpicpl32.cpl b/build_tools/Tools/jdk1.5.0_19/jre/bin/jpicpl32.cpl similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jpicpl32.cpl rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jpicpl32.cpl diff --git a/Tools/jdk1.5.0_19/jre/bin/jpiexp32.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jpiexp32.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jpiexp32.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jpiexp32.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jpinscp.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jpinscp.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jpinscp.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jpinscp.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jpioji.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jpioji.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jpioji.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jpioji.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jpishare.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jpishare.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jpishare.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jpishare.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jsound.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jsound.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jsound.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jsound.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jsoundds.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/jsoundds.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jsoundds.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jsoundds.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/jucheck.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/jucheck.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jucheck.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jucheck.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/jusched.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/jusched.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/jusched.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/jusched.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/keytool.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/keytool.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/keytool.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/keytool.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/kinit.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/kinit.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/kinit.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/kinit.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/klist.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/klist.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/klist.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/klist.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/ktab.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/ktab.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/ktab.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/ktab.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/management.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/management.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/management.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/management.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/net.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/net.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/net.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/net.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/nio.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/nio.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/nio.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/nio.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/orbd.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/orbd.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/orbd.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/orbd.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/pack200.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/pack200.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/pack200.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/pack200.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/policytool.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/policytool.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/policytool.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/policytool.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/rmi.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/rmi.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/rmi.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/rmi.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/rmid.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/rmid.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/rmid.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/rmid.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/rmiregistry.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/rmiregistry.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/rmiregistry.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/rmiregistry.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/server/Xusage.txt b/build_tools/Tools/jdk1.5.0_19/jre/bin/server/Xusage.txt similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/server/Xusage.txt rename to build_tools/Tools/jdk1.5.0_19/jre/bin/server/Xusage.txt diff --git a/Tools/jdk1.5.0_19/jre/bin/server/jvm.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/server/jvm.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/server/jvm.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/server/jvm.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/servertool.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/servertool.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/servertool.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/servertool.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/ssv.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/ssv.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/ssv.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/ssv.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/ssvagent.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/ssvagent.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/ssvagent.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/ssvagent.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/tnameserv.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/tnameserv.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/tnameserv.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/tnameserv.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/unicows.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/unicows.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/unicows.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/unicows.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/unpack.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/unpack.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/unpack.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/unpack.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/unpack200.exe b/build_tools/Tools/jdk1.5.0_19/jre/bin/unpack200.exe similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/unpack200.exe rename to build_tools/Tools/jdk1.5.0_19/jre/bin/unpack200.exe diff --git a/Tools/jdk1.5.0_19/jre/bin/verify.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/verify.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/verify.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/verify.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/w2k_lsa_auth.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/w2k_lsa_auth.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/w2k_lsa_auth.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/w2k_lsa_auth.dll diff --git a/Tools/jdk1.5.0_19/jre/bin/zip.dll b/build_tools/Tools/jdk1.5.0_19/jre/bin/zip.dll similarity index 100% rename from Tools/jdk1.5.0_19/jre/bin/zip.dll rename to build_tools/Tools/jdk1.5.0_19/jre/bin/zip.dll diff --git a/Tools/jdk1.5.0_19/jre/lib/audio/soundbank.gm b/build_tools/Tools/jdk1.5.0_19/jre/lib/audio/soundbank.gm similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/audio/soundbank.gm rename to build_tools/Tools/jdk1.5.0_19/jre/lib/audio/soundbank.gm diff --git a/Tools/jdk1.5.0_19/jre/lib/charsets.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/charsets.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/charsets.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/charsets.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/classlist b/build_tools/Tools/jdk1.5.0_19/jre/lib/classlist similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/classlist rename to build_tools/Tools/jdk1.5.0_19/jre/lib/classlist diff --git a/Tools/jdk1.5.0_19/jre/lib/cmm/CIEXYZ.pf b/build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/CIEXYZ.pf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/cmm/CIEXYZ.pf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/CIEXYZ.pf diff --git a/Tools/jdk1.5.0_19/jre/lib/cmm/GRAY.pf b/build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/GRAY.pf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/cmm/GRAY.pf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/GRAY.pf diff --git a/Tools/jdk1.5.0_19/jre/lib/cmm/LINEAR_RGB.pf b/build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/LINEAR_RGB.pf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/cmm/LINEAR_RGB.pf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/LINEAR_RGB.pf diff --git a/Tools/jdk1.5.0_19/jre/lib/cmm/PYCC.pf b/build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/PYCC.pf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/cmm/PYCC.pf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/PYCC.pf diff --git a/Tools/jdk1.5.0_19/jre/lib/cmm/sRGB.pf b/build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/sRGB.pf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/cmm/sRGB.pf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/cmm/sRGB.pf diff --git a/Tools/jdk1.5.0_19/jre/lib/content-types.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/content-types.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/content-types.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/content-types.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/deploy.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/deploy.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/deploy.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/deploy.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/deploy/ffjcext.zip b/build_tools/Tools/jdk1.5.0_19/jre/lib/deploy/ffjcext.zip similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/deploy/ffjcext.zip rename to build_tools/Tools/jdk1.5.0_19/jre/lib/deploy/ffjcext.zip diff --git a/Tools/jdk1.5.0_19/jre/lib/ext/dnsns.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/ext/dnsns.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/ext/dnsns.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/ext/dnsns.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/ext/localedata.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/ext/localedata.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/ext/localedata.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/ext/localedata.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/ext/sunjce_provider.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/ext/sunjce_provider.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/ext/sunjce_provider.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/ext/sunjce_provider.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/ext/sunpkcs11.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/ext/sunpkcs11.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/ext/sunpkcs11.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/ext/sunpkcs11.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/flavormap.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/flavormap.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/flavormap.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/flavormap.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/fontconfig.98.bfc b/build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.98.bfc similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fontconfig.98.bfc rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.98.bfc diff --git a/Tools/jdk1.5.0_19/jre/lib/fontconfig.98.properties.src b/build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.98.properties.src similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fontconfig.98.properties.src rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.98.properties.src diff --git a/Tools/jdk1.5.0_19/jre/lib/fontconfig.Me.bfc b/build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.Me.bfc similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fontconfig.Me.bfc rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.Me.bfc diff --git a/Tools/jdk1.5.0_19/jre/lib/fontconfig.Me.properties.src b/build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.Me.properties.src similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fontconfig.Me.properties.src rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.Me.properties.src diff --git a/Tools/jdk1.5.0_19/jre/lib/fontconfig.bfc b/build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.bfc similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fontconfig.bfc rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.bfc diff --git a/Tools/jdk1.5.0_19/jre/lib/fontconfig.properties.src b/build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.properties.src similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fontconfig.properties.src rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fontconfig.properties.src diff --git a/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightDemiBold.ttf b/build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightDemiBold.ttf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightDemiBold.ttf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightDemiBold.ttf diff --git a/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightDemiItalic.ttf b/build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightDemiItalic.ttf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightDemiItalic.ttf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightDemiItalic.ttf diff --git a/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightItalic.ttf b/build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightItalic.ttf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightItalic.ttf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightItalic.ttf diff --git a/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightRegular.ttf b/build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightRegular.ttf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightRegular.ttf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaBrightRegular.ttf diff --git a/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaSansDemiBold.ttf b/build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaSansDemiBold.ttf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fonts/LucidaSansDemiBold.ttf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaSansDemiBold.ttf diff --git a/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaSansRegular.ttf b/build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaSansRegular.ttf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fonts/LucidaSansRegular.ttf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaSansRegular.ttf diff --git a/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaTypewriterBold.ttf b/build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaTypewriterBold.ttf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fonts/LucidaTypewriterBold.ttf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaTypewriterBold.ttf diff --git a/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaTypewriterRegular.ttf b/build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaTypewriterRegular.ttf similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/fonts/LucidaTypewriterRegular.ttf rename to build_tools/Tools/jdk1.5.0_19/jre/lib/fonts/LucidaTypewriterRegular.ttf diff --git a/Tools/jdk1.5.0_19/jre/lib/i386/jvm.cfg b/build_tools/Tools/jdk1.5.0_19/jre/lib/i386/jvm.cfg similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/i386/jvm.cfg rename to build_tools/Tools/jdk1.5.0_19/jre/lib/i386/jvm.cfg diff --git a/Tools/jdk1.5.0_19/jre/lib/im/indicim.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/im/indicim.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/im/indicim.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/im/indicim.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/im/thaiim.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/im/thaiim.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/im/thaiim.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/im/thaiim.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/images/cursors/cursors.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/cursors.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/images/cursors/cursors.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/cursors.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/images/cursors/invalid32x32.gif b/build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/invalid32x32.gif similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/images/cursors/invalid32x32.gif rename to build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/invalid32x32.gif diff --git a/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_CopyDrop32x32.gif b/build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_CopyDrop32x32.gif similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_CopyDrop32x32.gif rename to build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_CopyDrop32x32.gif diff --git a/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_CopyNoDrop32x32.gif b/build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_CopyNoDrop32x32.gif similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_CopyNoDrop32x32.gif rename to build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_CopyNoDrop32x32.gif diff --git a/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_LinkDrop32x32.gif b/build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_LinkDrop32x32.gif similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_LinkDrop32x32.gif rename to build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_LinkDrop32x32.gif diff --git a/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_LinkNoDrop32x32.gif b/build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_LinkNoDrop32x32.gif similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_LinkNoDrop32x32.gif rename to build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_LinkNoDrop32x32.gif diff --git a/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_MoveDrop32x32.gif b/build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_MoveDrop32x32.gif similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_MoveDrop32x32.gif rename to build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_MoveDrop32x32.gif diff --git a/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_MoveNoDrop32x32.gif b/build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_MoveNoDrop32x32.gif similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_MoveNoDrop32x32.gif rename to build_tools/Tools/jdk1.5.0_19/jre/lib/images/cursors/win32_MoveNoDrop32x32.gif diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_de.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_de.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_de.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_de.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_es.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_es.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_es.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_es.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_fr.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_fr.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_fr.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_fr.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_it.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_it.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_it.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_it.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_ja.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_ja.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_ja.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_ja.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_ko.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_ko.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_ko.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_ko.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_sv.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_sv.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_sv.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_sv.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_CN.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_CN.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_CN.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_CN.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_HK.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_HK.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_HK.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_HK.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_TW.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_TW.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_TW.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/messages_zh_TW.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/javaws/miniSplash.jpg b/build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/miniSplash.jpg similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/javaws/miniSplash.jpg rename to build_tools/Tools/jdk1.5.0_19/jre/lib/javaws/miniSplash.jpg diff --git a/Tools/jdk1.5.0_19/jre/lib/jce.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/jce.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/jce.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/jce.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/jsse.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/jsse.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/jsse.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/jsse.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/jvm.hprof.txt b/build_tools/Tools/jdk1.5.0_19/jre/lib/jvm.hprof.txt similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/jvm.hprof.txt rename to build_tools/Tools/jdk1.5.0_19/jre/lib/jvm.hprof.txt diff --git a/Tools/jdk1.5.0_19/jre/lib/logging.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/logging.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/logging.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/logging.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/management/jmxremote.access b/build_tools/Tools/jdk1.5.0_19/jre/lib/management/jmxremote.access similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/management/jmxremote.access rename to build_tools/Tools/jdk1.5.0_19/jre/lib/management/jmxremote.access diff --git a/Tools/jdk1.5.0_19/jre/lib/management/jmxremote.password.template b/build_tools/Tools/jdk1.5.0_19/jre/lib/management/jmxremote.password.template similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/management/jmxremote.password.template rename to build_tools/Tools/jdk1.5.0_19/jre/lib/management/jmxremote.password.template diff --git a/Tools/jdk1.5.0_19/jre/lib/management/management.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/management/management.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/management/management.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/management/management.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/management/snmp.acl.template b/build_tools/Tools/jdk1.5.0_19/jre/lib/management/snmp.acl.template similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/management/snmp.acl.template rename to build_tools/Tools/jdk1.5.0_19/jre/lib/management/snmp.acl.template diff --git a/Tools/jdk1.5.0_19/jre/lib/net.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/net.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/net.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/net.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/plugin.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/plugin.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/plugin.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/plugin.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/psfont.properties.ja b/build_tools/Tools/jdk1.5.0_19/jre/lib/psfont.properties.ja similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/psfont.properties.ja rename to build_tools/Tools/jdk1.5.0_19/jre/lib/psfont.properties.ja diff --git a/Tools/jdk1.5.0_19/jre/lib/psfontj2d.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/psfontj2d.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/psfontj2d.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/psfontj2d.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/rt.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/rt.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/rt.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/rt.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/security/US_export_policy.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/security/US_export_policy.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/security/US_export_policy.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/security/US_export_policy.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/security/cacerts b/build_tools/Tools/jdk1.5.0_19/jre/lib/security/cacerts similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/security/cacerts rename to build_tools/Tools/jdk1.5.0_19/jre/lib/security/cacerts diff --git a/Tools/jdk1.5.0_19/jre/lib/security/java.policy b/build_tools/Tools/jdk1.5.0_19/jre/lib/security/java.policy similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/security/java.policy rename to build_tools/Tools/jdk1.5.0_19/jre/lib/security/java.policy diff --git a/Tools/jdk1.5.0_19/jre/lib/security/java.security b/build_tools/Tools/jdk1.5.0_19/jre/lib/security/java.security similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/security/java.security rename to build_tools/Tools/jdk1.5.0_19/jre/lib/security/java.security diff --git a/Tools/jdk1.5.0_19/jre/lib/security/javaws.policy b/build_tools/Tools/jdk1.5.0_19/jre/lib/security/javaws.policy similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/security/javaws.policy rename to build_tools/Tools/jdk1.5.0_19/jre/lib/security/javaws.policy diff --git a/Tools/jdk1.5.0_19/jre/lib/security/local_policy.jar b/build_tools/Tools/jdk1.5.0_19/jre/lib/security/local_policy.jar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/security/local_policy.jar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/security/local_policy.jar diff --git a/Tools/jdk1.5.0_19/jre/lib/servicetag/jdk_header.png b/build_tools/Tools/jdk1.5.0_19/jre/lib/servicetag/jdk_header.png similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/servicetag/jdk_header.png rename to build_tools/Tools/jdk1.5.0_19/jre/lib/servicetag/jdk_header.png diff --git a/Tools/jdk1.5.0_19/jre/lib/sound.properties b/build_tools/Tools/jdk1.5.0_19/jre/lib/sound.properties similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/sound.properties rename to build_tools/Tools/jdk1.5.0_19/jre/lib/sound.properties diff --git a/Tools/jdk1.5.0_19/jre/lib/tzmappings b/build_tools/Tools/jdk1.5.0_19/jre/lib/tzmappings similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/tzmappings rename to build_tools/Tools/jdk1.5.0_19/jre/lib/tzmappings diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Abidjan b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Abidjan similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Abidjan rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Abidjan diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Accra b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Accra similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Accra rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Accra diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Addis_Ababa b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Addis_Ababa similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Addis_Ababa rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Addis_Ababa diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Algiers b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Algiers similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Algiers rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Algiers diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Asmara b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Asmara similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Asmara rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Asmara diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bamako b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bamako similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bamako rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bamako diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bangui b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bangui similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bangui rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bangui diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Banjul b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Banjul similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Banjul rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Banjul diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bissau b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bissau similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bissau rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bissau diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Blantyre b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Blantyre similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Blantyre rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Blantyre diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Brazzaville b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Brazzaville similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Brazzaville rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Brazzaville diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bujumbura b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bujumbura similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bujumbura rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Bujumbura diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Cairo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Cairo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Cairo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Cairo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Casablanca b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Casablanca similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Casablanca rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Casablanca diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ceuta b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ceuta similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ceuta rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ceuta diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Conakry b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Conakry similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Conakry rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Conakry diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Dakar b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Dakar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Dakar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Dakar diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Dar_es_Salaam b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Dar_es_Salaam similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Dar_es_Salaam rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Dar_es_Salaam diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Djibouti b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Djibouti similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Djibouti rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Djibouti diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Douala b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Douala similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Douala rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Douala diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/El_Aaiun b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/El_Aaiun similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/El_Aaiun rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/El_Aaiun diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Freetown b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Freetown similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Freetown rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Freetown diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Gaborone b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Gaborone similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Gaborone rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Gaborone diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Harare b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Harare similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Harare rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Harare diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Johannesburg b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Johannesburg similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Johannesburg rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Johannesburg diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kampala b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kampala similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kampala rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kampala diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Khartoum b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Khartoum similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Khartoum rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Khartoum diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kigali b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kigali similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kigali rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kigali diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kinshasa b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kinshasa similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kinshasa rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Kinshasa diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lagos b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lagos similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lagos rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lagos diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Libreville b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Libreville similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Libreville rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Libreville diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lome b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lome similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lome rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lome diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Luanda b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Luanda similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Luanda rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Luanda diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lubumbashi b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lubumbashi similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lubumbashi rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lubumbashi diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lusaka b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lusaka similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lusaka rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Lusaka diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Malabo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Malabo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Malabo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Malabo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Maputo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Maputo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Maputo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Maputo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Maseru b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Maseru similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Maseru rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Maseru diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Mbabane b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Mbabane similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Mbabane rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Mbabane diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Mogadishu b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Mogadishu similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Mogadishu rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Mogadishu diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Monrovia b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Monrovia similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Monrovia rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Monrovia diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Nairobi b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Nairobi similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Nairobi rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Nairobi diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ndjamena b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ndjamena similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ndjamena rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ndjamena diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Niamey b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Niamey similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Niamey rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Niamey diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Nouakchott b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Nouakchott similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Nouakchott rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Nouakchott diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ouagadougou b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ouagadougou similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ouagadougou rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Ouagadougou diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Porto-Novo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Porto-Novo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Porto-Novo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Porto-Novo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Sao_Tome b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Sao_Tome similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Sao_Tome rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Sao_Tome diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Tripoli b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Tripoli similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Tripoli rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Tripoli diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Tunis b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Tunis similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Tunis rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Tunis diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Windhoek b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Windhoek similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Africa/Windhoek rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Africa/Windhoek diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Adak b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Adak similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Adak rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Adak diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Anchorage b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Anchorage similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Anchorage rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Anchorage diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Anguilla b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Anguilla similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Anguilla rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Anguilla diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Antigua b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Antigua similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Antigua rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Antigua diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Araguaina b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Araguaina similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Araguaina rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Araguaina diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Buenos_Aires b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Buenos_Aires similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Buenos_Aires rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Buenos_Aires diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Catamarca b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Catamarca similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Catamarca rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Catamarca diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Cordoba b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Cordoba similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Cordoba rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Cordoba diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Jujuy b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Jujuy similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Jujuy rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Jujuy diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/La_Rioja b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/La_Rioja similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/La_Rioja rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/La_Rioja diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Mendoza b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Mendoza similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Mendoza rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Mendoza diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Rio_Gallegos b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Rio_Gallegos similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Rio_Gallegos rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Rio_Gallegos diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Salta b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Salta similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Salta rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Salta diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/San_Juan b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/San_Juan similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/San_Juan rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/San_Juan diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/San_Luis b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/San_Luis similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/San_Luis rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/San_Luis diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Tucuman b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Tucuman similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Tucuman rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Tucuman diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Ushuaia b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Ushuaia similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Ushuaia rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Argentina/Ushuaia diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Aruba b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Aruba similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Aruba rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Aruba diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Asuncion b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Asuncion similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Asuncion rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Asuncion diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Atikokan b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Atikokan similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Atikokan rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Atikokan diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Bahia b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Bahia similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Bahia rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Bahia diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Barbados b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Barbados similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Barbados rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Barbados diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Belem b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Belem similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Belem rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Belem diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Belize b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Belize similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Belize rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Belize diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Blanc-Sablon b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Blanc-Sablon similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Blanc-Sablon rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Blanc-Sablon diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Boa_Vista b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Boa_Vista similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Boa_Vista rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Boa_Vista diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Bogota b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Bogota similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Bogota rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Bogota diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Boise b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Boise similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Boise rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Boise diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Cambridge_Bay b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cambridge_Bay similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Cambridge_Bay rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cambridge_Bay diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Campo_Grande b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Campo_Grande similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Campo_Grande rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Campo_Grande diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Cancun b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cancun similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Cancun rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cancun diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Caracas b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Caracas similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Caracas rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Caracas diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Cayenne b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cayenne similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Cayenne rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cayenne diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Cayman b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cayman similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Cayman rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cayman diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Chicago b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Chicago similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Chicago rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Chicago diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Chihuahua b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Chihuahua similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Chihuahua rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Chihuahua diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Costa_Rica b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Costa_Rica similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Costa_Rica rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Costa_Rica diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Cuiaba b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cuiaba similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Cuiaba rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Cuiaba diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Curacao b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Curacao similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Curacao rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Curacao diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Danmarkshavn b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Danmarkshavn similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Danmarkshavn rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Danmarkshavn diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Dawson b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Dawson similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Dawson rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Dawson diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Dawson_Creek b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Dawson_Creek similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Dawson_Creek rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Dawson_Creek diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Denver b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Denver similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Denver rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Denver diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Detroit b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Detroit similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Detroit rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Detroit diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Dominica b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Dominica similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Dominica rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Dominica diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Edmonton b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Edmonton similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Edmonton rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Edmonton diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Eirunepe b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Eirunepe similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Eirunepe rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Eirunepe diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/El_Salvador b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/El_Salvador similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/El_Salvador rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/El_Salvador diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Fortaleza b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Fortaleza similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Fortaleza rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Fortaleza diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Glace_Bay b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Glace_Bay similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Glace_Bay rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Glace_Bay diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Godthab b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Godthab similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Godthab rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Godthab diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Goose_Bay b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Goose_Bay similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Goose_Bay rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Goose_Bay diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Grand_Turk b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Grand_Turk similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Grand_Turk rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Grand_Turk diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Grenada b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Grenada similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Grenada rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Grenada diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Guadeloupe b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Guadeloupe similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Guadeloupe rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Guadeloupe diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Guatemala b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Guatemala similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Guatemala rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Guatemala diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Guayaquil b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Guayaquil similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Guayaquil rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Guayaquil diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Guyana b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Guyana similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Guyana rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Guyana diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Halifax b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Halifax similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Halifax rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Halifax diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Havana b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Havana similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Havana rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Havana diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Hermosillo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Hermosillo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Hermosillo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Hermosillo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Indianapolis b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Indianapolis similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Indianapolis rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Indianapolis diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Knox b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Knox similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Knox rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Knox diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Marengo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Marengo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Marengo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Marengo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Petersburg b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Petersburg similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Petersburg rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Petersburg diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Tell_City b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Tell_City similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Tell_City rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Tell_City diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Vevay b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Vevay similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Vevay rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Vevay diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Vincennes b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Vincennes similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Vincennes rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Vincennes diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Winamac b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Winamac similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Winamac rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Indiana/Winamac diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Inuvik b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Inuvik similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Inuvik rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Inuvik diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Iqaluit b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Iqaluit similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Iqaluit rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Iqaluit diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Jamaica b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Jamaica similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Jamaica rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Jamaica diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Juneau b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Juneau similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Juneau rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Juneau diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Kentucky/Louisville b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Kentucky/Louisville similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Kentucky/Louisville rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Kentucky/Louisville diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Kentucky/Monticello b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Kentucky/Monticello similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Kentucky/Monticello rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Kentucky/Monticello diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/La_Paz b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/La_Paz similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/La_Paz rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/La_Paz diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Lima b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Lima similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Lima rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Lima diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Los_Angeles b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Los_Angeles similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Los_Angeles rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Los_Angeles diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Maceio b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Maceio similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Maceio rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Maceio diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Managua b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Managua similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Managua rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Managua diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Manaus b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Manaus similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Manaus rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Manaus diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Martinique b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Martinique similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Martinique rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Martinique diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Mazatlan b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Mazatlan similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Mazatlan rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Mazatlan diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Menominee b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Menominee similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Menominee rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Menominee diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Merida b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Merida similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Merida rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Merida diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Mexico_City b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Mexico_City similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Mexico_City rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Mexico_City diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Miquelon b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Miquelon similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Miquelon rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Miquelon diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Moncton b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Moncton similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Moncton rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Moncton diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Monterrey b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Monterrey similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Monterrey rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Monterrey diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Montevideo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Montevideo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Montevideo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Montevideo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Montreal b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Montreal similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Montreal rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Montreal diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Montserrat b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Montserrat similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Montserrat rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Montserrat diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Nassau b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Nassau similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Nassau rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Nassau diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/New_York b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/New_York similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/New_York rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/New_York diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Nipigon b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Nipigon similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Nipigon rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Nipigon diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Nome b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Nome similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Nome rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Nome diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Noronha b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Noronha similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Noronha rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Noronha diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/North_Dakota/Center b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/North_Dakota/Center similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/North_Dakota/Center rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/North_Dakota/Center diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/North_Dakota/New_Salem b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/North_Dakota/New_Salem similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/North_Dakota/New_Salem rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/North_Dakota/New_Salem diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Panama b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Panama similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Panama rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Panama diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Pangnirtung b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Pangnirtung similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Pangnirtung rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Pangnirtung diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Paramaribo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Paramaribo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Paramaribo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Paramaribo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Phoenix b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Phoenix similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Phoenix rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Phoenix diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Port-au-Prince b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Port-au-Prince similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Port-au-Prince rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Port-au-Prince diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Port_of_Spain b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Port_of_Spain similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Port_of_Spain rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Port_of_Spain diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Porto_Velho b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Porto_Velho similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Porto_Velho rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Porto_Velho diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Puerto_Rico b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Puerto_Rico similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Puerto_Rico rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Puerto_Rico diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Rainy_River b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Rainy_River similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Rainy_River rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Rainy_River diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Rankin_Inlet b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Rankin_Inlet similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Rankin_Inlet rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Rankin_Inlet diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Recife b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Recife similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Recife rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Recife diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Regina b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Regina similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Regina rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Regina diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Resolute b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Resolute similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Resolute rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Resolute diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Rio_Branco b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Rio_Branco similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Rio_Branco rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Rio_Branco diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Santarem b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Santarem similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Santarem rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Santarem diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Santiago b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Santiago similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Santiago rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Santiago diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Santo_Domingo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Santo_Domingo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Santo_Domingo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Santo_Domingo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Sao_Paulo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Sao_Paulo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Sao_Paulo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Sao_Paulo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Scoresbysund b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Scoresbysund similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Scoresbysund rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Scoresbysund diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Johns b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Johns similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/St_Johns rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Johns diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Kitts b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Kitts similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/St_Kitts rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Kitts diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Lucia b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Lucia similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/St_Lucia rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Lucia diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Thomas b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Thomas similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/St_Thomas rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Thomas diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Vincent b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Vincent similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/St_Vincent rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/St_Vincent diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Swift_Current b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Swift_Current similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Swift_Current rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Swift_Current diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Tegucigalpa b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Tegucigalpa similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Tegucigalpa rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Tegucigalpa diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Thule b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Thule similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Thule rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Thule diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Thunder_Bay b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Thunder_Bay similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Thunder_Bay rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Thunder_Bay diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Tijuana b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Tijuana similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Tijuana rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Tijuana diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Toronto b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Toronto similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Toronto rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Toronto diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Tortola b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Tortola similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Tortola rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Tortola diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Vancouver b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Vancouver similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Vancouver rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Vancouver diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Whitehorse b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Whitehorse similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Whitehorse rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Whitehorse diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Winnipeg b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Winnipeg similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Winnipeg rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Winnipeg diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Yakutat b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Yakutat similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Yakutat rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Yakutat diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/America/Yellowknife b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Yellowknife similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/America/Yellowknife rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/America/Yellowknife diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Casey b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Casey similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Casey rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Casey diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Davis b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Davis similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Davis rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Davis diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/DumontDUrville b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/DumontDUrville similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/DumontDUrville rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/DumontDUrville diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Mawson b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Mawson similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Mawson rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Mawson diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/McMurdo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/McMurdo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/McMurdo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/McMurdo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Palmer b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Palmer similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Palmer rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Palmer diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Rothera b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Rothera similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Rothera rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Rothera diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Syowa b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Syowa similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Syowa rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Syowa diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Vostok b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Vostok similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Vostok rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Antarctica/Vostok diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aden b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aden similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aden rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aden diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Almaty b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Almaty similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Almaty rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Almaty diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Amman b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Amman similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Amman rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Amman diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Anadyr b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Anadyr similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Anadyr rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Anadyr diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aqtau b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aqtau similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aqtau rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aqtau diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aqtobe b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aqtobe similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aqtobe rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Aqtobe diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ashgabat b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ashgabat similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ashgabat rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ashgabat diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Baghdad b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Baghdad similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Baghdad rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Baghdad diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bahrain b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bahrain similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bahrain rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bahrain diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Baku b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Baku similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Baku rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Baku diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bangkok b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bangkok similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bangkok rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bangkok diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Beirut b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Beirut similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Beirut rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Beirut diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bishkek b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bishkek similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bishkek rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Bishkek diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Brunei b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Brunei similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Brunei rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Brunei diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Choibalsan b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Choibalsan similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Choibalsan rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Choibalsan diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Chongqing b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Chongqing similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Chongqing rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Chongqing diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Colombo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Colombo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Colombo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Colombo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Damascus b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Damascus similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Damascus rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Damascus diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dhaka b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dhaka similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dhaka rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dhaka diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dili b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dili similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dili rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dili diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dubai b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dubai similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dubai rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dubai diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dushanbe b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dushanbe similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dushanbe rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Dushanbe diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Gaza b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Gaza similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Gaza rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Gaza diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Harbin b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Harbin similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Harbin rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Harbin diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ho_Chi_Minh b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ho_Chi_Minh similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ho_Chi_Minh rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ho_Chi_Minh diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Hong_Kong b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Hong_Kong similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Hong_Kong rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Hong_Kong diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Hovd b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Hovd similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Hovd rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Hovd diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Irkutsk b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Irkutsk similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Irkutsk rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Irkutsk diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jakarta b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jakarta similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jakarta rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jakarta diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jayapura b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jayapura similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jayapura rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jayapura diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jerusalem b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jerusalem similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jerusalem rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Jerusalem diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kabul b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kabul similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kabul rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kabul diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kamchatka b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kamchatka similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kamchatka rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kamchatka diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Karachi b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Karachi similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Karachi rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Karachi diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kashgar b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kashgar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kashgar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kashgar diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kathmandu b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kathmandu similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kathmandu rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kathmandu diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kolkata b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kolkata similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kolkata rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kolkata diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Krasnoyarsk b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Krasnoyarsk similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Krasnoyarsk rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Krasnoyarsk diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuala_Lumpur b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuala_Lumpur similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuala_Lumpur rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuala_Lumpur diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuching b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuching similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuching rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuching diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuwait b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuwait similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuwait rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Kuwait diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Macau b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Macau similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Macau rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Macau diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Magadan b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Magadan similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Magadan rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Magadan diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Makassar b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Makassar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Makassar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Makassar diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Manila b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Manila similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Manila rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Manila diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Muscat b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Muscat similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Muscat rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Muscat diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Nicosia b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Nicosia similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Nicosia rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Nicosia diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Novosibirsk b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Novosibirsk similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Novosibirsk rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Novosibirsk diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Omsk b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Omsk similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Omsk rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Omsk diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Oral b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Oral similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Oral rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Oral diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Phnom_Penh b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Phnom_Penh similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Phnom_Penh rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Phnom_Penh diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Pontianak b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Pontianak similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Pontianak rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Pontianak diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Pyongyang b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Pyongyang similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Pyongyang rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Pyongyang diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Qatar b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Qatar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Qatar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Qatar diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Qyzylorda b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Qyzylorda similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Qyzylorda rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Qyzylorda diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Rangoon b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Rangoon similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Rangoon rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Rangoon diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh87 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh87 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh87 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh87 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh88 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh88 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh88 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh88 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh89 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh89 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh89 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Riyadh89 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Sakhalin b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Sakhalin similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Sakhalin rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Sakhalin diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Samarkand b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Samarkand similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Samarkand rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Samarkand diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Seoul b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Seoul similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Seoul rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Seoul diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Shanghai b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Shanghai similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Shanghai rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Shanghai diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Singapore b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Singapore similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Singapore rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Singapore diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Taipei b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Taipei similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Taipei rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Taipei diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tashkent b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tashkent similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tashkent rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tashkent diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tbilisi b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tbilisi similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tbilisi rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tbilisi diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tehran b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tehran similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tehran rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tehran diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Thimphu b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Thimphu similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Thimphu rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Thimphu diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tokyo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tokyo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tokyo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Tokyo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ulaanbaatar b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ulaanbaatar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ulaanbaatar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Ulaanbaatar diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Urumqi b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Urumqi similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Urumqi rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Urumqi diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Vientiane b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Vientiane similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Vientiane rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Vientiane diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Vladivostok b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Vladivostok similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Vladivostok rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Vladivostok diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yakutsk b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yakutsk similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yakutsk rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yakutsk diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yekaterinburg b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yekaterinburg similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yekaterinburg rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yekaterinburg diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yerevan b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yerevan similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yerevan rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Asia/Yerevan diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Azores b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Azores similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Azores rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Azores diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Bermuda b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Bermuda similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Bermuda rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Bermuda diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Canary b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Canary similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Canary rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Canary diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Cape_Verde b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Cape_Verde similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Cape_Verde rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Cape_Verde diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Faroe b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Faroe similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Faroe rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Faroe diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Madeira b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Madeira similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Madeira rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Madeira diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Reykjavik b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Reykjavik similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Reykjavik rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Reykjavik diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/South_Georgia b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/South_Georgia similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/South_Georgia rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/South_Georgia diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/St_Helena b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/St_Helena similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/St_Helena rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/St_Helena diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Stanley b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Stanley similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Stanley rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Atlantic/Stanley diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Adelaide b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Adelaide similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Adelaide rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Adelaide diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Brisbane b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Brisbane similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Brisbane rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Brisbane diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Broken_Hill b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Broken_Hill similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Broken_Hill rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Broken_Hill diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Currie b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Currie similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Currie rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Currie diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Darwin b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Darwin similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Darwin rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Darwin diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Eucla b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Eucla similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Eucla rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Eucla diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Hobart b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Hobart similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Hobart rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Hobart diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Lindeman b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Lindeman similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Lindeman rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Lindeman diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Lord_Howe b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Lord_Howe similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Lord_Howe rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Lord_Howe diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Melbourne b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Melbourne similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Melbourne rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Melbourne diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Perth b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Perth similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Perth rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Perth diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Sydney b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Sydney similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Australia/Sydney rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Australia/Sydney diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/CET b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/CET similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/CET rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/CET diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/CST6CDT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/CST6CDT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/CST6CDT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/CST6CDT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/EET b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/EET similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/EET rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/EET diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/EST b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/EST similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/EST rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/EST diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/EST5EDT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/EST5EDT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/EST5EDT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/EST5EDT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+1 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+1 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+1 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+1 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+10 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+10 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+10 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+10 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+11 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+11 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+11 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+11 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+12 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+12 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+12 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+12 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+2 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+2 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+2 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+2 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+3 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+3 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+3 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+3 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+4 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+4 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+4 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+4 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+5 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+5 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+5 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+5 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+6 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+6 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+6 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+6 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+7 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+7 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+7 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+7 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+8 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+8 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+8 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+8 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+9 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+9 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+9 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT+9 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-1 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-1 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-1 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-1 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-10 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-10 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-10 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-10 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-11 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-11 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-11 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-11 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-12 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-12 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-12 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-12 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-13 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-13 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-13 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-13 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-14 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-14 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-14 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-14 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-2 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-2 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-2 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-2 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-3 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-3 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-3 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-3 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-4 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-4 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-4 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-4 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-5 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-5 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-5 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-5 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-6 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-6 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-6 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-6 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-7 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-7 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-7 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-7 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-8 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-8 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-8 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-8 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-9 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-9 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-9 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/GMT-9 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/UCT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/UCT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/UCT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/UCT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Etc/UTC b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/UTC similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Etc/UTC rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Etc/UTC diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Amsterdam b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Amsterdam similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Amsterdam rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Amsterdam diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Andorra b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Andorra similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Andorra rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Andorra diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Athens b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Athens similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Athens rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Athens diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Belgrade b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Belgrade similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Belgrade rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Belgrade diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Berlin b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Berlin similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Berlin rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Berlin diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Brussels b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Brussels similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Brussels rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Brussels diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Bucharest b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Bucharest similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Bucharest rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Bucharest diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Budapest b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Budapest similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Budapest rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Budapest diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Chisinau b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Chisinau similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Chisinau rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Chisinau diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Copenhagen b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Copenhagen similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Copenhagen rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Copenhagen diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Dublin b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Dublin similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Dublin rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Dublin diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Gibraltar b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Gibraltar similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Gibraltar rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Gibraltar diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Helsinki b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Helsinki similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Helsinki rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Helsinki diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Istanbul b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Istanbul similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Istanbul rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Istanbul diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Kaliningrad b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Kaliningrad similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Kaliningrad rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Kaliningrad diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Kiev b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Kiev similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Kiev rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Kiev diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Lisbon b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Lisbon similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Lisbon rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Lisbon diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/London b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/London similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/London rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/London diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Luxembourg b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Luxembourg similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Luxembourg rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Luxembourg diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Madrid b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Madrid similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Madrid rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Madrid diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Malta b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Malta similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Malta rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Malta diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Minsk b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Minsk similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Minsk rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Minsk diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Monaco b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Monaco similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Monaco rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Monaco diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Moscow b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Moscow similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Moscow rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Moscow diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Oslo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Oslo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Oslo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Oslo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Paris b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Paris similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Paris rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Paris diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Prague b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Prague similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Prague rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Prague diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Riga b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Riga similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Riga rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Riga diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Rome b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Rome similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Rome rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Rome diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Samara b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Samara similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Samara rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Samara diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Simferopol b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Simferopol similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Simferopol rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Simferopol diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Sofia b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Sofia similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Sofia rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Sofia diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Stockholm b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Stockholm similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Stockholm rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Stockholm diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Tallinn b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Tallinn similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Tallinn rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Tallinn diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Tirane b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Tirane similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Tirane rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Tirane diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Uzhgorod b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Uzhgorod similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Uzhgorod rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Uzhgorod diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vaduz b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vaduz similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vaduz rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vaduz diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vienna b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vienna similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vienna rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vienna diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vilnius b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vilnius similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vilnius rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Vilnius diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Volgograd b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Volgograd similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Volgograd rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Volgograd diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Warsaw b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Warsaw similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Warsaw rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Warsaw diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Zaporozhye b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Zaporozhye similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Zaporozhye rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Zaporozhye diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Zurich b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Zurich similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Europe/Zurich rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Europe/Zurich diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/GMT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/GMT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/GMT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/GMT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/HST b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/HST similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/HST rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/HST diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Antananarivo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Antananarivo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Antananarivo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Antananarivo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Chagos b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Chagos similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Chagos rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Chagos diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Christmas b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Christmas similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Christmas rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Christmas diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Cocos b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Cocos similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Cocos rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Cocos diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Comoro b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Comoro similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Comoro rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Comoro diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Kerguelen b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Kerguelen similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Kerguelen rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Kerguelen diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mahe b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mahe similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mahe rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mahe diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Maldives b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Maldives similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Maldives rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Maldives diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mauritius b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mauritius similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mauritius rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mauritius diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mayotte b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mayotte similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mayotte rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Mayotte diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Reunion b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Reunion similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Indian/Reunion rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Indian/Reunion diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/MET b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/MET similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/MET rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/MET diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/MST b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/MST similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/MST rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/MST diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/MST7MDT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/MST7MDT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/MST7MDT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/MST7MDT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/PST8PDT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/PST8PDT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/PST8PDT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/PST8PDT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Apia b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Apia similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Apia rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Apia diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Auckland b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Auckland similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Auckland rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Auckland diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Chatham b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Chatham similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Chatham rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Chatham diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Easter b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Easter similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Easter rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Easter diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Efate b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Efate similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Efate rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Efate diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Enderbury b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Enderbury similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Enderbury rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Enderbury diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Fakaofo b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Fakaofo similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Fakaofo rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Fakaofo diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Fiji b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Fiji similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Fiji rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Fiji diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Funafuti b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Funafuti similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Funafuti rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Funafuti diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Galapagos b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Galapagos similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Galapagos rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Galapagos diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Gambier b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Gambier similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Gambier rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Gambier diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Guadalcanal b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Guadalcanal similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Guadalcanal rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Guadalcanal diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Guam b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Guam similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Guam rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Guam diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Honolulu b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Honolulu similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Honolulu rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Honolulu diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Johnston b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Johnston similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Johnston rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Johnston diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kiritimati b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kiritimati similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kiritimati rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kiritimati diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kosrae b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kosrae similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kosrae rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kosrae diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kwajalein b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kwajalein similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kwajalein rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Kwajalein diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Majuro b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Majuro similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Majuro rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Majuro diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Marquesas b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Marquesas similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Marquesas rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Marquesas diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Midway b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Midway similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Midway rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Midway diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Nauru b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Nauru similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Nauru rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Nauru diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Niue b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Niue similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Niue rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Niue diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Norfolk b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Norfolk similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Norfolk rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Norfolk diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Noumea b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Noumea similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Noumea rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Noumea diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Pago_Pago b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Pago_Pago similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Pago_Pago rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Pago_Pago diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Palau b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Palau similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Palau rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Palau diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Pitcairn b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Pitcairn similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Pitcairn rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Pitcairn diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Ponape b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Ponape similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Ponape rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Ponape diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Port_Moresby b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Port_Moresby similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Port_Moresby rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Port_Moresby diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Rarotonga b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Rarotonga similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Rarotonga rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Rarotonga diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Saipan b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Saipan similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Saipan rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Saipan diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tahiti b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tahiti similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tahiti rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tahiti diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tarawa b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tarawa similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tarawa rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tarawa diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tongatapu b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tongatapu similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tongatapu rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Tongatapu diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Truk b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Truk similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Truk rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Truk diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Wake b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Wake similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Wake rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Wake diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Wallis b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Wallis similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Wallis rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/Pacific/Wallis diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/AST4 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/AST4 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/AST4 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/AST4 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/AST4ADT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/AST4ADT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/AST4ADT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/AST4ADT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/CST6 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/CST6 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/CST6 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/CST6 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/CST6CDT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/CST6CDT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/CST6CDT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/CST6CDT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/EST5 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/EST5 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/EST5 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/EST5 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/EST5EDT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/EST5EDT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/EST5EDT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/EST5EDT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/HST10 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/HST10 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/HST10 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/HST10 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/MST7 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/MST7 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/MST7 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/MST7 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/MST7MDT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/MST7MDT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/MST7MDT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/MST7MDT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/PST8 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/PST8 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/PST8 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/PST8 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/PST8PDT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/PST8PDT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/PST8PDT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/PST8PDT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/YST9 b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/YST9 similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/YST9 rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/YST9 diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/YST9YDT b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/YST9YDT similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/SystemV/YST9YDT rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/SystemV/YST9YDT diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/WET b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/WET similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/WET rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/WET diff --git a/Tools/jdk1.5.0_19/jre/lib/zi/ZoneInfoMappings b/build_tools/Tools/jdk1.5.0_19/jre/lib/zi/ZoneInfoMappings similarity index 100% rename from Tools/jdk1.5.0_19/jre/lib/zi/ZoneInfoMappings rename to build_tools/Tools/jdk1.5.0_19/jre/lib/zi/ZoneInfoMappings diff --git a/Tools/jdk1.5.0_19/lib/dt.jar b/build_tools/Tools/jdk1.5.0_19/lib/dt.jar similarity index 100% rename from Tools/jdk1.5.0_19/lib/dt.jar rename to build_tools/Tools/jdk1.5.0_19/lib/dt.jar diff --git a/Tools/jdk1.5.0_19/lib/htmlconverter.jar b/build_tools/Tools/jdk1.5.0_19/lib/htmlconverter.jar similarity index 100% rename from Tools/jdk1.5.0_19/lib/htmlconverter.jar rename to build_tools/Tools/jdk1.5.0_19/lib/htmlconverter.jar diff --git a/Tools/jdk1.5.0_19/lib/ir.idl b/build_tools/Tools/jdk1.5.0_19/lib/ir.idl similarity index 100% rename from Tools/jdk1.5.0_19/lib/ir.idl rename to build_tools/Tools/jdk1.5.0_19/lib/ir.idl diff --git a/Tools/jdk1.5.0_19/lib/jawt.lib b/build_tools/Tools/jdk1.5.0_19/lib/jawt.lib similarity index 100% rename from Tools/jdk1.5.0_19/lib/jawt.lib rename to build_tools/Tools/jdk1.5.0_19/lib/jawt.lib diff --git a/Tools/jdk1.5.0_19/lib/jconsole.jar b/build_tools/Tools/jdk1.5.0_19/lib/jconsole.jar similarity index 100% rename from Tools/jdk1.5.0_19/lib/jconsole.jar rename to build_tools/Tools/jdk1.5.0_19/lib/jconsole.jar diff --git a/Tools/jdk1.5.0_19/lib/jvm.lib b/build_tools/Tools/jdk1.5.0_19/lib/jvm.lib similarity index 100% rename from Tools/jdk1.5.0_19/lib/jvm.lib rename to build_tools/Tools/jdk1.5.0_19/lib/jvm.lib diff --git a/Tools/jdk1.5.0_19/lib/orb.idl b/build_tools/Tools/jdk1.5.0_19/lib/orb.idl similarity index 100% rename from Tools/jdk1.5.0_19/lib/orb.idl rename to build_tools/Tools/jdk1.5.0_19/lib/orb.idl diff --git a/Tools/jdk1.5.0_19/lib/tools.jar b/build_tools/Tools/jdk1.5.0_19/lib/tools.jar similarity index 100% rename from Tools/jdk1.5.0_19/lib/tools.jar rename to build_tools/Tools/jdk1.5.0_19/lib/tools.jar diff --git a/ref_c_java/zuc256_c/inc/type.h b/ref_c_java/zuc256_c/inc/type.h new file mode 100644 index 0000000..180519a --- /dev/null +++ b/ref_c_java/zuc256_c/inc/type.h @@ -0,0 +1,28 @@ +#pragma once +#ifndef __TYPE_H +#define __TYPE_H + +#include +/* IO definitions */ +#define __I volatile const /* defines 'read only' permissions */ + +#define __O volatile /* defines 'write only' permissions */ +#define __IO volatile /* defines 'read / write' permissions */ + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +typedef __IO uint64_t vu64; +typedef __IO uint32_t vu32; +typedef __IO uint16_t vu16; +typedef __IO uint8_t vu8; + +typedef __I uint64_t vuc64; /* Read Only */ +typedef __I uint32_t vuc32; /* Read Only */ +typedef __I uint16_t vuc16; /* Read Only */ +typedef __I uint8_t vuc8; /* Read Only */ + + +#endif /*__TYPE_H*/ \ No newline at end of file diff --git a/ref_c_java/zuc256_c/inc/zuc256.h b/ref_c_java/zuc256_c/inc/zuc256.h new file mode 100644 index 0000000..0438ef9 --- /dev/null +++ b/ref_c_java/zuc256_c/inc/zuc256.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2025. Institute of Information Engineering, CAS + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @file: zuc256.h + * @brief: zuc256模块对外接口声明 + * @author: QZH + * @version: 1.0.0 + * @date: 2025-09-01 + * + * @attention: 接口使用注意事项 + */ +#ifndef __ZUC256_H +#define __ZUC256_H + +#include +#include +#include + +// 类型定义 +typedef uint32_t ZUC_UINT31; // 31位无符号整数 +typedef uint8_t ZUC_UINT7; // 7位无符号整数 +typedef uint8_t ZUC_UINT6; // 6位无符号整数 +typedef uint32_t ZUC_UINT32; // 32位无符号整数 +// ZUC状态结构体 +typedef struct { + ZUC_UINT31 LFSR[16]; // 线性反馈移位寄存器 + uint32_t R1; // 寄存器1 + uint32_t R2; // 寄存器2 +} ZUC_STATE; +typedef ZUC_STATE ZUC256_STATE; +// 加密上下文结构体(用于分阶段处理) +typedef struct { + ZUC_STATE state; // 基础ZUC状态 + uint8_t buf[4]; // 输入缓冲区(处理非4字节对齐数据) + size_t buflen; // 缓冲区中有效字节数 +} ZUC256_ENCRYPT_CTX; +// ZUC256 MAC 上下文结构体 +typedef struct { + ZUC_UINT31 LFSR[16]; // ZUC256 线性反馈移位寄存器 + uint32_t R1; // 非线性函数寄存器R1 + uint32_t R2; // 非线性函数寄存器R2 + uint8_t buf[4]; // 数据缓存(处理不足4字节的待认证数据) + size_t buflen; // 缓存中有效数据长度(0~3) + uint32_t T[4]; // MAC 累加器(支持最大128位MAC,4个32位字) + uint32_t K0[4]; // MAC 初始密钥字(与T长度匹配) + int macbits; // MAC 输出位数(32/64/128,按32位对齐) +} ZUC256_MAC_CTX; + +// 初始化ZUC256状态 +void zuc256_init(ZUC_STATE *state, const uint8_t K[32], const uint8_t IV[23]); + +// 生成单个密钥字 +uint32_t zuc256_generate_keyword(ZUC_STATE *state); + +// 生成指定长度的密钥流 +void zuc256_generate_keystream(ZUC_STATE *state, size_t nwords, uint32_t *keystream); + +// 初始化加密上下文 +void zuc256_encrypt_init(ZUC256_ENCRYPT_CTX *ctx, const uint8_t K[32], const uint8_t IV[23]); + +// 分阶段处理加密数据(支持流式输入) +void zuc256_encrypt_update(ZUC256_ENCRYPT_CTX *ctx, const uint8_t *in, size_t inlen, uint8_t *out); + +// 完成加密处理(处理剩余数据并清理上下文) +void zuc256_encrypt_finish(ZUC256_ENCRYPT_CTX *ctx, uint8_t *out); + +// 一次性加密函数 +void zuc256_crypt(ZUC_STATE *state, const uint8_t *in, size_t inlen, uint8_t *out); +void extract_iv(const uint8_t *input_25byte, uint8_t *output_23byte); +#endif /*__ZUC256_H */ + \ No newline at end of file diff --git a/ref_c_java/zuc256_c/src/main.c b/ref_c_java/zuc256_c/src/main.c new file mode 100644 index 0000000..18fd0ae --- /dev/null +++ b/ref_c_java/zuc256_c/src/main.c @@ -0,0 +1,64 @@ +#include +#include +#include "zuc256.h" + +// 打印字节数组为十六进制 +void print_hex(const char *label, const uint8_t *data, size_t len) { + printf("%s: ", label); + for (size_t i = 0; i < len; i++) { + printf("%02x ", data[i]); + } + printf("\n"); +} + +int main() { +// 1. 明文 + uint8_t plaintext[] = "ZUC256对称加解密测试:1234567890"; + size_t plaintext_len = strlen((char*)plaintext); + printf("明文: %s\n", plaintext); + print_hex("明文(十六进制)", plaintext, plaintext_len); + + // 2. 密钥(32字节ASCII) + uint8_t key[32] = "0123456789abcdef0123456789abcdef"; + print_hex("密钥", key, 32); + + // 3. 初始向量(25字节ASCII) + //注:初始向量长度为184bit分布到25个字节中,前面17个初始向量为8bit字节,后面8个初始向量为6bit字节(占据一个字节的低6位) + uint8_t input_iv_25byte[25] = "0123456789abcdefg01234567"; + uint8_t iv[23]; + extract_iv(input_iv_25byte, iv); + print_hex("提取后的IV", iv, 23); + + // 4. 分配加密/解密缓冲区 + uint8_t *ciphertext = (uint8_t*)malloc(plaintext_len); + uint8_t *decryptedtext = (uint8_t*)malloc(plaintext_len); + if (!ciphertext || !decryptedtext) { + printf("内存分配失败\n"); + return 1; + } + + // 5. 加密 + ZUC_STATE state; + zuc256_init(&state, key, iv); + zuc256_crypt(&state, plaintext, plaintext_len, ciphertext); + print_hex("密文", ciphertext, plaintext_len); + + // 6. 解密(重新初始化状态) + zuc256_init(&state, key, iv); + zuc256_crypt(&state, ciphertext, plaintext_len, decryptedtext); + print_hex("解密后", decryptedtext, plaintext_len); + printf("解密文本: %s\n", decryptedtext); + + // 7. 验证结果 + if (memcmp(plaintext, decryptedtext, plaintext_len) == 0) { + printf("=== 测试成功: 解密结果与明文一致 ===\n"); + } else { + printf("=== 测试失败: 解密结果与明文不一致 ===\n"); + } + + // 8. 释放内存 + free(ciphertext); + free(decryptedtext); + + return 0; +} diff --git a/ref_c_java/zuc256_c/src/zuc256.c b/ref_c_java/zuc256_c/src/zuc256.c new file mode 100644 index 0000000..e39c821 --- /dev/null +++ b/ref_c_java/zuc256_c/src/zuc256.c @@ -0,0 +1,618 @@ +/* + * Copyright (C) 2025. Institute of Information Engineering, CAS + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * @file: zuc256.c + * @brief: zuc256 的纯c代码 + * @author: QZH + * @version: 1.0.0 + * @date: 2025-09-01 + * + * @note: 无 + * + * Change Logs: + * Date Author Notes + * 2025-08-04 QZH 创建文件 + */ +#include +#include +#include "zuc256.h" +// S盒定义 +static const uint8_t S0[256] = { + 0x3e,0x72,0x5b,0x47,0xca,0xe0,0x00,0x33,0x04,0xd1,0x54,0x98,0x09,0xb9,0x6d,0xcb, + 0x7b,0x1b,0xf9,0x32,0xaf,0x9d,0x6a,0xa5,0xb8,0x2d,0xfc,0x1d,0x08,0x53,0x03,0x90, + 0x4d,0x4e,0x84,0x99,0xe4,0xce,0xd9,0x91,0xdd,0xb6,0x85,0x48,0x8b,0x29,0x6e,0xac, + 0xcd,0xc1,0xf8,0x1e,0x73,0x43,0x69,0xc6,0xb5,0xbd,0xfd,0x39,0x63,0x20,0xd4,0x38, + 0x76,0x7d,0xb2,0xa7,0xcf,0xed,0x57,0xc5,0xf3,0x2c,0xbb,0x14,0x21,0x06,0x55,0x9b, + 0xe3,0xef,0x5e,0x31,0x4f,0x7f,0x5a,0xa4,0x0d,0x82,0x51,0x49,0x5f,0xba,0x58,0x1c, + 0x4a,0x16,0xd5,0x17,0xa8,0x92,0x24,0x1f,0x8c,0xff,0xd8,0xae,0x2e,0x01,0xd3,0xad, + 0x3b,0x4b,0xda,0x46,0xeb,0xc9,0xde,0x9a,0x8f,0x87,0xd7,0x3a,0x80,0x6f,0x2f,0xc8, + 0xb1,0xb4,0x37,0xf7,0x0a,0x22,0x13,0x28,0x7c,0xcc,0x3c,0x89,0xc7,0xc3,0x96,0x56, + 0x07,0xbf,0x7e,0xf0,0x0b,0x2b,0x97,0x52,0x35,0x41,0x79,0x61,0xa6,0x4c,0x10,0xfe, + 0xbc,0x26,0x95,0x88,0x8a,0xb0,0xa3,0xfb,0xc0,0x18,0x94,0xf2,0xe1,0xe5,0xe9,0x5d, + 0xd0,0xdc,0x11,0x66,0x64,0x5c,0xec,0x59,0x42,0x75,0x12,0xf5,0x74,0x9c,0xaa,0x23, + 0x0e,0x86,0xab,0xbe,0x2a,0x02,0xe7,0x67,0xe6,0x44,0xa2,0x6c,0xc2,0x93,0x9f,0xf1, + 0xf6,0xfa,0x36,0xd2,0x50,0x68,0x9e,0x62,0x71,0x15,0x3d,0xd6,0x40,0xc4,0xe2,0x0f, + 0x8e,0x83,0x77,0x6b,0x25,0x05,0x3f,0x0c,0x30,0xea,0x70,0xb7,0xa1,0xe8,0xa9,0x65, + 0x8d,0x27,0x1a,0xdb,0x81,0xb3,0xa0,0xf4,0x45,0x7a,0x19,0xdf,0xee,0x78,0x34,0x60, +}; + +static const uint8_t S1[256] = { + 0x55,0xc2,0x63,0x71,0x3b,0xc8,0x47,0x86,0x9f,0x3c,0xda,0x5b,0x29,0xaa,0xfd,0x77, + 0x8c,0xc5,0x94,0x0c,0xa6,0x1a,0x13,0x00,0xe3,0xa8,0x16,0x72,0x40,0xf9,0xf8,0x42, + 0x44,0x26,0x68,0x96,0x81,0xd9,0x45,0x3e,0x10,0x76,0xc6,0xa7,0x8b,0x39,0x43,0xe1, + 0x3a,0xb5,0x56,0x2a,0xc0,0x6d,0xb3,0x05,0x22,0x66,0xbf,0xdc,0x0b,0xfa,0x62,0x48, + 0xdd,0x20,0x11,0x06,0x36,0xc9,0xc1,0xcf,0xf6,0x27,0x52,0xbb,0x69,0xf5,0xd4,0x87, + 0x7f,0x84,0x4c,0xd2,0x9c,0x57,0xa4,0xbc,0x4f,0x9a,0xdf,0xfe,0xd6,0x8d,0x7a,0xeb, + 0x2b,0x53,0xd8,0x5c,0xa1,0x14,0x17,0xfb,0x23,0xd5,0x7d,0x30,0x67,0x73,0x08,0x09, + 0xee,0xb7,0x70,0x3f,0x61,0xb2,0x19,0x8e,0x4e,0xe5,0x4b,0x93,0x8f,0x5d,0xdb,0xa9, + 0xad,0xf1,0xae,0x2e,0xcb,0x0d,0xfc,0xf4,0x2d,0x46,0x6e,0x1d,0x97,0xe8,0xd1,0xe9, + 0x4d,0x37,0xa5,0x75,0x5e,0x83,0x9e,0xab,0x82,0x9d,0xb9,0x1c,0xe0,0xcd,0x49,0x89, + 0x01,0xb6,0xbd,0x58,0x24,0xa2,0x5f,0x38,0x78,0x99,0x15,0x90,0x50,0xb8,0x95,0xe4, + 0xd0,0x91,0xc7,0xce,0xed,0x0f,0xb4,0x6f,0xa0,0xcc,0xf0,0x02,0x4a,0x79,0xc3,0xde, + 0xa3,0xef,0xea,0x51,0xe6,0x6b,0x18,0xec,0x1b,0x2c,0x80,0xf7,0x74,0xe7,0xff,0x21, + 0x5a,0x6a,0x54,0x1e,0x41,0x31,0x92,0x35,0xc4,0x33,0x07,0x0a,0xba,0x7e,0x0e,0x34, + 0x88,0xb1,0x98,0x7c,0xf3,0x3d,0x60,0x6c,0x7b,0xca,0xd3,0x1f,0x32,0x65,0x04,0x28, + 0x64,0xbe,0x85,0x9b,0x2f,0x59,0x8a,0xd7,0xb0,0x25,0xac,0xaf,0x12,0x03,0xe2,0xf2, +}; + +// 常量数组D + +#define F_(X1,X2) \ + W1 = R1 + X1; \ + W2 = R2 ^ X2; \ + U = L1((W1 << 16) | (W2 >> 16)); \ + V = L2((W2 << 16) | (W1 >> 16)); \ + R1 = MAKEU32( S0[U >> 24], \ + S1[(U >> 16) & 0xFF], \ + S0[(U >> 8) & 0xFF], \ + S1[U & 0xFF]); \ + R2 = MAKEU32( S0[V >> 24], \ + S1[(V >> 16) & 0xFF], \ + S0[(V >> 8) & 0xFF], \ + S1[V & 0xFF]) + +#define F(X0,X1,X2) \ + ((X0 ^ R1) + R2); \ + F_(X1, X2) +#define ADD31(a,b) a += (b); a = (a & 0x7fffffff) + (a >> 31) +#define ROT31(a,k) ((((a) << (k)) | ((a) >> (31 - (k)))) & 0x7FFFFFFF) +#define ROT32(a,k) (((a) << (k)) | ((a) >> (32 - (k)))) + +#define L1(X) \ + ((X) ^ \ + ROT32((X), 2) ^ \ + ROT32((X), 10) ^ \ + ROT32((X), 18) ^ \ + ROT32((X), 24)) + +#define L2(X) \ + ((X) ^ \ + ROT32((X), 8) ^ \ + ROT32((X), 14) ^ \ + ROT32((X), 22) ^ \ + ROT32((X), 30)) + + +#define LFSRWithInitialisationMode(u) \ + V = LFSR[0]; \ + ADD31(V, ROT31(LFSR[ 0], 8)); \ + ADD31(V, ROT31(LFSR[ 4], 20)); \ + ADD31(V, ROT31(LFSR[10], 21)); \ + ADD31(V, ROT31(LFSR[13], 17)); \ + ADD31(V, ROT31(LFSR[15], 15)); \ + ADD31(V, (u)); \ + {int j; for (j=0; j<15;j++) LFSR[j]=LFSR[j+1];} \ + LFSR[15] = V + +#define LFSRWithWorkMode() \ + { \ + int j; \ + uint64_t a = LFSR[0]; \ + a += ((uint64_t)LFSR[ 0]) << 8; \ + a += ((uint64_t)LFSR[ 4]) << 20; \ + a += ((uint64_t)LFSR[10]) << 21; \ + a += ((uint64_t)LFSR[13]) << 17; \ + a += ((uint64_t)LFSR[15]) << 15; \ + a = (a & 0x7fffffff) + (a >> 31); \ + V = (uint32_t)((a & 0x7fffffff) + (a >> 31)); \ + for (j = 0; j < 15; j++) \ + LFSR[j] = LFSR[j+1]; \ + LFSR[15] = V; \ + } + +#define BitReconstruction2(X1,X2) \ + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >> 15); \ + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >> 15) + +#define BitReconstruction3(X0,X1,X2) \ + X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); \ + BitReconstruction2(X1,X2) + +#define BitReconstruction4(X0,X1,X2,X3) \ + BitReconstruction3(X0,X1,X2); \ + X3 = ((LFSR[2] & 0xFFFF) << 16) | (LFSR[0] >> 15) + +#define MAKEU32(a, b, c, d) \ + (((uint32_t)(a) << 24) | \ + ((uint32_t)(b) << 16) | \ + ((uint32_t)(c) << 8) | \ + ((uint32_t)(d))) + +#define ZUC256_MAKEU31(a,b,c,d) \ + (((uint32_t)(a) << 23) | \ + ((uint32_t)(b) << 16) | \ + ((uint32_t)(c) << 8) | \ + (uint32_t)(d)) & 0x7FFFFFFF /* 确保31位 */ + + +// 辅助函数:字节序转换 +static inline uint32_t GETU32(const uint8_t *p) { + return ((uint32_t)p[0] << 24) | ((uint32_t)p[1] << 16) | + ((uint32_t)p[2] << 8) | (uint32_t)p[3]; +} +static inline void PUTU32(uint8_t *p, uint32_t v) { + p[0] = (uint8_t)(v >> 24); + p[1] = (uint8_t)(v >> 16); + p[2] = (uint8_t)(v >> 8); + p[3] = (uint8_t)v; +} + + +static const ZUC_UINT7 ZUC256_D[][16] = { + {0x22,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, + {0x22,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, + {0x23,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, + {0x23,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, +}; + +static void zuc256_set_mac_key(ZUC_STATE *key, const uint8_t K[32], + const uint8_t IV[23], int macbits) +{ + ZUC_UINT31 *LFSR = key->LFSR; + uint32_t R1, R2; + uint32_t X0, X1, X2; + uint32_t W, W1, W2, U, V; + const ZUC_UINT7 *D; + int i; + + ZUC_UINT6 IV17 = IV[17] >> 2; + ZUC_UINT6 IV18 = ((IV[17] & 0x3) << 4) | (IV[18] >> 4); + ZUC_UINT6 IV19 = ((IV[18] & 0xf) << 2) | (IV[19] >> 6); + ZUC_UINT6 IV20 = IV[19] & 0x3f; + ZUC_UINT6 IV21 = IV[20] >> 2; + ZUC_UINT6 IV22 = ((IV[20] & 0x3) << 4) | (IV[21] >> 4); + ZUC_UINT6 IV23 = ((IV[21] & 0xf) << 2) | (IV[22] >> 6); + ZUC_UINT6 IV24 = IV[22] & 0x3f; + + D = macbits/32 < 3 ? ZUC256_D[macbits/32] : ZUC256_D[3]; + LFSR[0] = ZUC256_MAKEU31(K[0], D[0], K[21], K[16]); + LFSR[1] = ZUC256_MAKEU31(K[1], D[1], K[22], K[17]); + LFSR[2] = ZUC256_MAKEU31(K[2], D[2], K[23], K[18]); + LFSR[3] = ZUC256_MAKEU31(K[3], D[3], K[24], K[19]); + LFSR[4] = ZUC256_MAKEU31(K[4], D[4], K[25], K[20]); + LFSR[5] = ZUC256_MAKEU31(IV[0], (D[5] | IV17), K[5], K[26]); + LFSR[6] = ZUC256_MAKEU31(IV[1], (D[6] | IV18), K[6], K[27]); + LFSR[7] = ZUC256_MAKEU31(IV[10], (D[7] | IV19), K[7], IV[2]); + LFSR[8] = ZUC256_MAKEU31(K[8], (D[8] | IV20), IV[3], IV[11]); + LFSR[9] = ZUC256_MAKEU31(K[9], (D[9] | IV21), IV[12], IV[4]); + LFSR[10] = ZUC256_MAKEU31(IV[5], (D[10] | IV22), K[10], K[28]); + LFSR[11] = ZUC256_MAKEU31(K[11], (D[11] | IV23), IV[6], IV[13]); + LFSR[12] = ZUC256_MAKEU31(K[12], (D[12] | IV24), IV[7], IV[14]); + LFSR[13] = ZUC256_MAKEU31(K[13], D[13], IV[15], IV[8]); + LFSR[14] = ZUC256_MAKEU31(K[14], (D[14] | (K[31] >> 4)), IV[16], IV[9]); + LFSR[15] = ZUC256_MAKEU31(K[15], (D[15] | (K[31] & 0x0F)), K[30], K[29]); + + R1 = 0; + R2 = 0; + + for (i = 0; i < 32; i++) { + BitReconstruction3(X0, X1, X2); + W = F(X0, X1, X2); + LFSRWithInitialisationMode(W >> 1); + } + + BitReconstruction2(X1, X2); + F_(X1, X2); + LFSRWithWorkMode(); + + key->R1 = R1; + key->R2 = R2; +} + + + +// 初始化ZUC256状态 +void zuc256_init(ZUC_STATE *key, const uint8_t K[32], + const uint8_t IV[23]) +{ + if (!key || !K || !IV) return; + zuc256_set_mac_key(key, K, IV, 0); +} +// 生成单个密钥字 +uint32_t zuc256_generate_keyword(ZUC_STATE *state) { + ZUC_UINT31 *LFSR = state->LFSR; + uint32_t R1 = state->R1; + uint32_t R2 = state->R2; + uint32_t X0, X1, X2, X3; + uint32_t W1, W2, U, V; + uint32_t Z; + + BitReconstruction4(X0, X1, X2, X3); + Z = X3 ^ F(X0, X1, X2); + LFSRWithWorkMode(); + + state->R1 = R1; + state->R2 = R2; + + return Z; +} + +void zuc256_generate_keystream(ZUC_STATE *state, size_t nwords, uint32_t *keystream) { + ZUC_UINT31 *LFSR = state->LFSR; + uint32_t R1 = state->R1; + uint32_t R2 = state->R2; + uint32_t X0, X1, X2, X3; + uint32_t W1, W2, U, V; + size_t i; + + for (i = 0; i < nwords; i ++) { + /* + BitReconstruction4(X0, X1, X2, X3); + keystream[i] = X3 ^ F(X0, X1, X2); + LFSRWithWorkMode(); + */ + uint32_t T0, T1, T2, T3, T4, T5, T6, T7; + uint64_t a; + int j; + + // expand BitReconstruction4(X0, X1, X2, X3) + X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); + X1 = ((LFSR[11] & 0x0000FFFF) << 16) | (LFSR[ 9] >> 15); + X2 = ((LFSR[ 7] & 0x0000FFFF) << 16) | (LFSR[ 5] >> 15); + X3 = ((LFSR[ 2] & 0x0000FFFF) << 16) | (LFSR[ 0] >> 15); + + //keystream[i] = X3 ^ F(X0, X1, X2); + keystream[i] = X3 ^ ((X0 ^ R1) + R2); + + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >> 16)); + V = L2((W2 << 16) | (W1 >> 16)); + + // table lookup together makes 10% faster + T0 = S0[(U >> 24) ]; + T2 = S0[(U >> 8) & 0xFF]; + T4 = S0[(V >> 24) ]; + T6 = S0[(V >> 8) & 0xFF]; + + T1 = S1[(U >> 16) & 0xFF]; + T3 = S1[(U ) & 0xFF]; + T5 = S1[(V >> 16) & 0xFF]; + T7 = S1[(V ) & 0xFF]; + + R1 = MAKEU32(T0, T1, T2, T3); + R2 = MAKEU32(T4, T5, T6, T7); + + // expand LFSRWithWorkMode() + a = LFSR[0]; + a += ((uint64_t)LFSR[ 0]) << 8; + a += ((uint64_t)LFSR[ 4]) << 20; + a += ((uint64_t)LFSR[10]) << 21; + a += ((uint64_t)LFSR[13]) << 17; + a += ((uint64_t)LFSR[15]) << 15; + a = (a & 0x7fffffff) + (a >> 31); + V = (uint32_t)((a & 0x7fffffff) + (a >> 31)); + + for (j = 0; j < 15; j++) { + LFSR[j] = LFSR[j+1]; + } + LFSR[15] = V; + } + + state->R1 = R1; + state->R2 = R2; +} + + +// 初始化加密上下文 +void zuc256_encrypt_init(ZUC256_ENCRYPT_CTX *ctx, const uint8_t K[32], const uint8_t IV[23]) { + if (!ctx) return; + memset(ctx, 0, sizeof(*ctx)); + zuc256_init(&ctx->state, K, IV); +} + +// 分阶段处理加密数据(支持流式输入) +void zuc256_encrypt_update(ZUC256_ENCRYPT_CTX *ctx, const uint8_t *in, size_t inlen, uint8_t *out) { + if (!ctx || !in || !out || inlen == 0) return; + + // 先处理缓冲区中剩余的非4字节数据 + if (ctx->buflen > 0) { + size_t need = 4 - ctx->buflen; + size_t copy = (inlen < need) ? inlen : need; + + memcpy(ctx->buf + ctx->buflen, in, copy); + ctx->buflen += copy; + in += copy; + inlen -= copy; + + // 缓冲区已满,处理一个完整的4字节块 + if (ctx->buflen == 4) { + uint32_t keystream = zuc256_generate_keyword(&ctx->state); + uint32_t plain = GETU32(ctx->buf); + PUTU32(out, plain ^ keystream); + + ctx->buflen = 0; + memset(ctx->buf, 0, 4); // 清空缓冲区 + out += 4; + } + } + + // 处理完整的4字节块 + size_t full_blocks = inlen / 4; + if (full_blocks > 0) { + size_t keystream_len = full_blocks; + uint32_t *keystream = (uint32_t*)malloc(keystream_len * sizeof(uint32_t)); + if (keystream) { + zuc256_generate_keystream(&ctx->state, keystream_len, keystream); + + // 逐块异或加密 + for (size_t i = 0; i < full_blocks; i++) { + uint32_t plain = GETU32(in + i*4); + PUTU32(out + i*4, plain ^ keystream[i]); + } + + free(keystream); + in += full_blocks * 4; + inlen -= full_blocks * 4; + out += full_blocks * 4; + } + } + + // 缓存剩余不足4字节的数据 + if (inlen > 0) { + memcpy(ctx->buf, in, inlen); + ctx->buflen = inlen; + } +} + +// 完成加密处理(处理剩余数据并清理上下文) +void zuc256_encrypt_finish(ZUC256_ENCRYPT_CTX *ctx, uint8_t *out) { + if (!ctx || !out) return; + + // 处理缓冲区中剩余的不足4字节数据 + if (ctx->buflen > 0) { + uint32_t keystream = zuc256_generate_keyword(&ctx->state); + uint8_t keystream_bytes[4]; + PUTU32(keystream_bytes, keystream); + + // 逐字节异或 + for (size_t i = 0; i < ctx->buflen; i++) { + out[i] = ctx->buf[i] ^ keystream_bytes[i]; + } + } + + // 清理上下文(安全考虑) + memset(ctx, 0, sizeof(*ctx)); +} + +// 一次性加密函数(ZUC加密和解密相同) +void zuc256_crypt(ZUC_STATE *state, const uint8_t *in, size_t inlen, uint8_t *out) { + if (!state || !in || !out) return; + + ZUC256_ENCRYPT_CTX ctx; + // 修复1:初始化ctx内存(仅清空,不调用zuc256_encrypt_init) + memset(&ctx, 0, sizeof(ZUC256_ENCRYPT_CTX)); + // 修复2:将传入的合法state复制到ctx->state,复用已有状态(含K/IV对应的初始化结果) + memcpy(&ctx.state, state, sizeof(ZUC_STATE)); + + // 正常执行加解密(使用复用的state) + zuc256_encrypt_update(&ctx, in, inlen, out); + // 计算剩余数据的偏移:(inlen / 4)*4 是完整4字节块的长度,剩余数据从这里开始 + size_t remaining_offset = (inlen / 4) * 4; + zuc256_encrypt_finish(&ctx, out + remaining_offset); + + // 修复3:将ctx->state的最新状态回写到传入的state(确保后续连续加解密的状态正确) + memcpy(state, &ctx.state, sizeof(ZUC_STATE)); +} +void extract_iv(const uint8_t *input_25byte, uint8_t *output_23byte) { + if (!input_25byte || !output_23byte) return; + for (int i = 0; i < 17; i++) { + output_23byte[i] = input_25byte[i]; + } + uint8_t src[8]; + for (int i = 0; i < 8; i++) { + src[i] = input_25byte[17 + i] & 0x3F; + } + output_23byte[17] = (src[0] << 2) | (src[1] >> 4); + output_23byte[18] = ((src[1] & 0x0F) << 4) | (src[2] >> 2); + output_23byte[19] = ((src[2] & 0x03) << 6) | src[3]; + output_23byte[20] = (src[4] << 2) | (src[5] >> 4); + output_23byte[21] = ((src[5] & 0x0F) << 4) | (src[6] >> 2); + output_23byte[22] = ((src[6] & 0x03) << 6) | src[7]; + +} + +/** + * @brief 初始化ZUC256 MAC上下文 + * @param ctx:MAC上下文指针(输出) + * @param key:256位密钥(32字节,输入) + * @param iv:23字节初始向量(输入) + * @param macbits:期望MAC输出位数(32/64/128,自动调整范围:<32→32,>128→128) + */ +void zuc256_mac_init(ZUC256_MAC_CTX *ctx, const uint8_t key[32], + const uint8_t iv[23], int macbits) +{ + if (macbits < 32) + macbits = 32; + else if (macbits > 64) + macbits = 128; + memset(ctx, 0, sizeof(*ctx)); + zuc256_set_mac_key((ZUC256_STATE *)ctx, key, iv, macbits); + zuc256_generate_keystream((ZUC256_STATE *)ctx, macbits/32, ctx->T); + zuc256_generate_keystream((ZUC256_STATE *)ctx, macbits/32, ctx->K0); + ctx->macbits = (macbits/32) * 32; +} +/** + * @brief 更新ZUC256 MAC待认证数据(支持分块输入) + * @param ctx:已初始化的MAC上下文(输入/输出) + * @param data:待认证数据块(输入,可NULL) + * @param len:待认证数据长度(字节,输入,0则无操作) + */ +void zuc256_mac_update(ZUC256_MAC_CTX *ctx, const uint8_t *data, size_t len) +{ + ZUC_UINT32 K1, M; + size_t n = ctx->macbits / 32; + size_t i, j; + + if (!data || !len) { + return; + } + + if (ctx->buflen) { + size_t num = sizeof(ctx->buf) - ctx->buflen; + if (len < num) { + memcpy(ctx->buf + ctx->buflen, data, len); + ctx->buflen += len; + return; + } + + memcpy(ctx->buf + ctx->buflen, data, num); + M = GETU32(ctx->buf); + ctx->buflen = 0; + + K1 = zuc256_generate_keyword((ZUC_STATE *)ctx); + + for (i = 0; i < 32; i++) { + if (M & 0x80000000) { + for (j = 0; j < n; j++) { + ctx->T[j] ^= ctx->K0[j]; + } + } + M <<= 1; + for (j = 0; j < n - 1; j++) { + ctx->K0[j] = (ctx->K0[j] << 1) | (ctx->K0[j + 1] >> 31); + } + ctx->K0[j] = (ctx->K0[j] << 1) | (K1 >> 31); + K1 <<= 1; + } + + data += num; + len -= num; + } + + while (len >= 4) { + M = GETU32(data); + K1 = zuc256_generate_keyword((ZUC_STATE *)ctx); + + for (i = 0; i < 32; i++) { + if (M & 0x80000000) { + for (j = 0; j < n; j++) { + ctx->T[j] ^= ctx->K0[j]; + } + } + M <<= 1; + for (j = 0; j < n - 1; j++) { + ctx->K0[j] = (ctx->K0[j] << 1) | (ctx->K0[j + 1] >> 31); + } + ctx->K0[j] = (ctx->K0[j] << 1) | (K1 >> 31); + K1 <<= 1; + } + + data += 4; + len -= 4; + } + + if (len) { + memcpy(ctx->buf, data, len); + ctx->buflen = len; + } +} +/** + * @brief 完成ZUC256 MAC计算,输出最终认证码 + * @param ctx:已更新数据的MAC上下文(输入/输出,调用后清空) + * @param data:最后一块待认证数据(可NULL,若需补充不足1字节的比特) + * @param nbits:最后一块数据的额外比特数(0~7,仅当data非NULL时有效) + * @param mac:MAC输出缓冲区(需提前分配至少 ctx->macbits/8 字节空间) + */ +void zuc256_mac_finish(ZUC256_MAC_CTX *ctx, const uint8_t *data, size_t nbits, uint8_t *mac) +{ + ZUC_UINT32 K1, M; + size_t n = ctx->macbits/32; + size_t i, j; + + + if (!data) + nbits = 0; + + if (nbits >= 8) { + zuc256_mac_update(ctx, data, nbits/8); + data += nbits/8; + nbits %= 8; + } + + if (nbits) + ctx->buf[ctx->buflen] = *data; + + if (ctx->buflen || nbits) { + M = GETU32(ctx->buf); + K1 = zuc256_generate_keyword((ZUC_STATE *)ctx); + + + for (i = 0; i < ctx->buflen * 8 + nbits; i++) { + if (M & 0x80000000) { + for (j = 0; j < n; j++) { + ctx->T[j] ^= ctx->K0[j]; + } + } + M <<= 1; + for (j = 0; j < n - 1; j++) { + ctx->K0[j] = (ctx->K0[j] << 1) | (ctx->K0[j + 1] >> 31); + } + ctx->K0[j] = (ctx->K0[j] << 1) | (K1 >> 31); + K1 <<= 1; + } + } + + for (j = 0; j < n; j++) { + ctx->T[j] ^= ctx->K0[j]; + PUTU32(mac, ctx->T[j]); + mac += 4; + } + + memset(ctx, 0, sizeof(*ctx)); +} +/** + * @brief 一次性ZUC256 MAC计算(简化接口,适用于非流式数据 + * @param K:256位密钥(32字节,输入) + * @param IV:23字节初始向量(输入) + * @param data:待认证数据(输入,可NULL) + * @param len:待认证数据长度(字节,输入) + * @param macbits:MAC输出位数(32/64/128,输入) + * @param mac:MAC输出缓冲区(输出,需提前分配空间) + */ +void zuc256_mac(const uint8_t K[32], const uint8_t IV[23], const uint8_t *data, size_t len, int macbits, uint8_t *mac) { + ZUC256_MAC_CTX ctx; + zuc256_mac_init(&ctx, K, IV, macbits); + if (data && len > 0) { + zuc256_mac_update(&ctx, data, len); + } + zuc256_mac_finish(&ctx, NULL, 0, mac); +} \ No newline at end of file diff --git a/ref_c_java/zuc256_java/zuc256.java b/ref_c_java/zuc256_java/zuc256.java new file mode 100644 index 0000000..a26be75 --- /dev/null +++ b/ref_c_java/zuc256_java/zuc256.java @@ -0,0 +1,552 @@ +import java.util.Arrays; + +public class zuc256 { + // S盒定义 + private static final int[] S0 = { + 0x3e,0x72,0x5b,0x47,0xca,0xe0,0x00,0x33,0x04,0xd1,0x54,0x98,0x09,0xb9,0x6d,0xcb, + 0x7b,0x1b,0xf9,0x32,0xaf,0x9d,0x6a,0xa5,0xb8,0x2d,0xfc,0x1d,0x08,0x53,0x03,0x90, + 0x4d,0x4e,0x84,0x99,0xe4,0xce,0xd9,0x91,0xdd,0xb6,0x85,0x48,0x8b,0x29,0x6e,0xac, + 0xcd,0xc1,0xf8,0x1e,0x73,0x43,0x69,0xc6,0xb5,0xbd,0xfd,0x39,0x63,0x20,0xd4,0x38, + 0x76,0x7d,0xb2,0xa7,0xcf,0xed,0x57,0xc5,0xf3,0x2c,0xbb,0x14,0x21,0x06,0x55,0x9b, + 0xe3,0xef,0x5e,0x31,0x4f,0x7f,0x5a,0xa4,0x0d,0x82,0x51,0x49,0x5f,0xba,0x58,0x1c, + 0x4a,0x16,0xd5,0x17,0xa8,0x92,0x24,0x1f,0x8c,0xff,0xd8,0xae,0x2e,0x01,0xd3,0xad, + 0x3b,0x4b,0xda,0x46,0xeb,0xc9,0xde,0x9a,0x8f,0x87,0xd7,0x3a,0x80,0x6f,0x2f,0xc8, + 0xb1,0xb4,0x37,0xf7,0x0a,0x22,0x13,0x28,0x7c,0xcc,0x3c,0x89,0xc7,0xc3,0x96,0x56, + 0x07,0xbf,0x7e,0xf0,0x0b,0x2b,0x97,0x52,0x35,0x41,0x79,0x61,0xa6,0x4c,0x10,0xfe, + 0xbc,0x26,0x95,0x88,0x8a,0xb0,0xa3,0xfb,0xc0,0x18,0x94,0xf2,0xe1,0xe5,0xe9,0x5d, + 0xd0,0xdc,0x11,0x66,0x64,0x5c,0xec,0x59,0x42,0x75,0x12,0xf5,0x74,0x9c,0xaa,0x23, + 0x0e,0x86,0xab,0xbe,0x2a,0x02,0xe7,0x67,0xe6,0x44,0xa2,0x6c,0xc2,0x93,0x9f,0xf1, + 0xf6,0xfa,0x36,0xd2,0x50,0x68,0x9e,0x62,0x71,0x15,0x3d,0xd6,0x40,0xc4,0xe2,0x0f, + 0x8e,0x83,0x77,0x6b,0x25,0x05,0x3f,0x0c,0x30,0xea,0x70,0xb7,0xa1,0xe8,0xa9,0x65, + 0x8d,0x27,0x1a,0xdb,0x81,0xb3,0xa0,0xf4,0x45,0x7a,0x19,0xdf,0xee,0x78,0x34,0x60 + }; + + private static final int[] S1 = { + 0x55,0xc2,0x63,0x71,0x3b,0xc8,0x47,0x86,0x9f,0x3c,0xda,0x5b,0x29,0xaa,0xfd,0x77, + 0x8c,0xc5,0x94,0x0c,0xa6,0x1a,0x13,0x00,0xe3,0xa8,0x16,0x72,0x40,0xf9,0xf8,0x42, + 0x44,0x26,0x68,0x96,0x81,0xd9,0x45,0x3e,0x10,0x76,0xc6,0xa7,0x8b,0x39,0x43,0xe1, + 0x3a,0xb5,0x56,0x2a,0xc0,0x6d,0xb3,0x05,0x22,0x66,0xbf,0xdc,0x0b,0xfa,0x62,0x48, + 0xdd,0x20,0x11,0x06,0x36,0xc9,0xc1,0xcf,0xf6,0x27,0x52,0xbb,0x69,0xf5,0xd4,0x87, + 0x7f,0x84,0x4c,0xd2,0x9c,0x57,0xa4,0xbc,0x4f,0x9a,0xdf,0xfe,0xd6,0x8d,0x7a,0xeb, + 0x2b,0x53,0xd8,0x5c,0xa1,0x14,0x17,0xfb,0x23,0xd5,0x7d,0x30,0x67,0x73,0x08,0x09, + 0xee,0xb7,0x70,0x3f,0x61,0xb2,0x19,0x8e,0x4e,0xe5,0x4b,0x93,0x8f,0x5d,0xdb,0xa9, + 0xad,0xf1,0xae,0x2e,0xcb,0x0d,0xfc,0xf4,0x2d,0x46,0x6e,0x1d,0x97,0xe8,0xd1,0xe9, + 0x4d,0x37,0xa5,0x75,0x5e,0x83,0x9e,0xab,0x82,0x9d,0xb9,0x1c,0xe0,0xcd,0x49,0x89, + 0x01,0xb6,0xbd,0x58,0x24,0xa2,0x5f,0x38,0x78,0x99,0x15,0x90,0x50,0xb8,0x95,0xe4, + 0xd0,0x91,0xc7,0xce,0xed,0x0f,0xb4,0x6f,0xa0,0xcc,0xf0,0x02,0x4a,0x79,0xc3,0xde, + 0xa3,0xef,0xea,0x51,0xe6,0x6b,0x18,0xec,0x1b,0x2c,0x80,0xf7,0x74,0xe7,0xff,0x21, + 0x5a,0x6a,0x54,0x1e,0x41,0x31,0x92,0x35,0xc4,0x33,0x07,0x0a,0xba,0x7e,0x0e,0x34, + 0x88,0xb1,0x98,0x7c,0xf3,0x3d,0x60,0x6c,0x7b,0xca,0xd3,0x1f,0x32,0x65,0x04,0x28, + 0x64,0xbe,0x85,0x9b,0x2f,0x59,0x8a,0xd7,0xb0,0x25,0xac,0xaf,0x12,0x03,0xe2,0xf2 + }; + + // 常量数组D + private static final int[][] ZUC256_D = { + {0x22,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, + {0x22,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, + {0x23,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, + {0x23,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30} + }; + + // ZUC状态类 + public static class ZUCState { + int[] LFSR = new int[16]; // 线性反馈移位寄存器 + int R1; // 寄存器1 + int R2; // 寄存器2 + } + + // 加密上下文类 + public static class ZUC256EncryptCtx { + ZUCState state = new ZUCState(); + byte[] buf = new byte[4]; + int buflen; + } + + // MAC上下文类 + public static class ZUC256MacCtx { + int[] LFSR = new int[16]; + int R1; + int R2; + byte[] buf = new byte[4]; + int buflen; + int[] T = new int[4]; + int[] K0 = new int[4]; + int macbits; + } + + // 辅助方法:将字节数组转换为32位整数 + private static int getU32(byte[] p, int offset) { + return ((p[offset] & 0xFF) << 24) | + ((p[offset + 1] & 0xFF) << 16) | + ((p[offset + 2] & 0xFF) << 8) | + (p[offset + 3] & 0xFF); + } + + // 辅助方法:将32位整数转换为字节数组 + private static void putU32(byte[] p, int offset, int v) { + p[offset] = (byte) (v >> 24); + p[offset + 1] = (byte) (v >> 16); + p[offset + 2] = (byte) (v >> 8); + p[offset + 3] = (byte) v; + } + + // 31位加法 + private static int add31(int a, int b) { + long sum = (long)a + b; + return (int) ((sum & 0x7FFFFFFF) + (sum >> 31)); + } + + // 31位旋转 + private static int rot31(int a, int k) { + return ((a << k) | (a >>> (31 - k))) & 0x7FFFFFFF; + } + + // 32位旋转 + private static int rot32(int a, int k) { + return (a << k) | (a >>> (32 - k)); + } + + // L1函数 + private static int L1(int x) { + return x ^ rot32(x, 2) ^ rot32(x, 10) ^ rot32(x, 18) ^ rot32(x, 24); + } + + // L2函数 + private static int L2(int x) { + return x ^ rot32(x, 8) ^ rot32(x, 14) ^ rot32(x, 22) ^ rot32(x, 30); + } + + // 初始化MAC密钥 + private static void zuc256SetMacKey(ZUCState key, byte[] K, byte[] IV, int macbits) { + int[] LFSR = key.LFSR; + int R1 = 0; + int R2 = 0; + int X0, X1, X2; + int W, W1, W2, U, V; + int[] D; + + int IV17 = (IV[17] & 0xFF) >> 2; + int IV18 = ((IV[17] & 0x03) << 4) | ((IV[18] & 0xFF) >> 4); + int IV19 = ((IV[18] & 0x0F) << 2) | ((IV[19] & 0xFF) >> 6); + int IV20 = IV[19] & 0x3F; + int IV21 = (IV[20] & 0xFF) >> 2; + int IV22 = ((IV[20] & 0x03) << 4) | ((IV[21] & 0xFF) >> 4); + int IV23 = ((IV[21] & 0x0F) << 2) | ((IV[22] & 0xFF) >> 6); + int IV24 = IV[22] & 0x3F; + + D = (macbits / 32 < 3) ? ZUC256_D[macbits / 32] : ZUC256_D[3]; + + LFSR[0] = makeU31(K[0] & 0xFF, D[0], K[21] & 0xFF, K[16] & 0xFF); + LFSR[1] = makeU31(K[1] & 0xFF, D[1], K[22] & 0xFF, K[17] & 0xFF); + LFSR[2] = makeU31(K[2] & 0xFF, D[2], K[23] & 0xFF, K[18] & 0xFF); + LFSR[3] = makeU31(K[3] & 0xFF, D[3], K[24] & 0xFF, K[19] & 0xFF); + LFSR[4] = makeU31(K[4] & 0xFF, D[4], K[25] & 0xFF, K[20] & 0xFF); + LFSR[5] = makeU31(IV[0] & 0xFF, (D[5] | IV17), K[5] & 0xFF, K[26] & 0xFF); + LFSR[6] = makeU31(IV[1] & 0xFF, (D[6] | IV18), K[6] & 0xFF, K[27] & 0xFF); + LFSR[7] = makeU31(IV[10] & 0xFF, (D[7] | IV19), K[7] & 0xFF, IV[2] & 0xFF); + LFSR[8] = makeU31(K[8] & 0xFF, (D[8] | IV20), IV[3] & 0xFF, IV[11] & 0xFF); + LFSR[9] = makeU31(K[9] & 0xFF, (D[9] | IV21), IV[12] & 0xFF, IV[4] & 0xFF); + LFSR[10] = makeU31(IV[5] & 0xFF, (D[10] | IV22), K[10] & 0xFF, K[28] & 0xFF); + LFSR[11] = makeU31(K[11] & 0xFF, (D[11] | IV23), IV[6] & 0xFF, IV[13] & 0xFF); + LFSR[12] = makeU31(K[12] & 0xFF, (D[12] | IV24), IV[7] & 0xFF, IV[14] & 0xFF); + LFSR[13] = makeU31(K[13] & 0xFF, D[13], IV[15] & 0xFF, IV[8] & 0xFF); + LFSR[14] = makeU31(K[14] & 0xFF, (D[14] | (K[31] >>> 4)), IV[16] & 0xFF, IV[9] & 0xFF); + LFSR[15] = makeU31(K[15] & 0xFF, (D[15] | (K[31] & 0x0F)), K[30] & 0xFF, K[29] & 0xFF); + + for (int i = 0; i < 32; i++) { + // BitReconstruction3 + X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + + // F(X0, X1, X2) + W = (X0 ^ R1) + R2; + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >>> 16)); + V = L2((W2 << 16) | (W1 >>> 16)); + + R1 = makeU32(S0[(U >>> 24) & 0xFF], + S1[(U >>> 16) & 0xFF], + S0[(U >>> 8) & 0xFF], + S1[U & 0xFF]); + + R2 = makeU32(S0[(V >>> 24) & 0xFF], + S1[(V >>> 16) & 0xFF], + S0[(V >>> 8) & 0xFF], + S1[V & 0xFF]); + + // LFSRWithInitialisationMode(W >> 1) + int v = LFSR[0]; + v = add31(v, rot31(LFSR[0], 8)); + v = add31(v, rot31(LFSR[4], 20)); + v = add31(v, rot31(LFSR[10], 21)); + v = add31(v, rot31(LFSR[13], 17)); + v = add31(v, rot31(LFSR[15], 15)); + v = add31(v, W >>> 1); + + System.arraycopy(LFSR, 1, LFSR, 0, 15); + LFSR[15] = v; + } + + // BitReconstruction2 + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + + // F_(X1, X2) + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >>> 16)); + V = L2((W2 << 16) | (W1 >>> 16)); + + R1 = makeU32(S0[(U >>> 24) & 0xFF], + S1[(U >>> 16) & 0xFF], + S0[(U >>> 8) & 0xFF], + S1[U & 0xFF]); + + R2 = makeU32(S0[(V >>> 24) & 0xFF], + S1[(V >>> 16) & 0xFF], + S0[(V >>> 8) & 0xFF], + S1[V & 0xFF]); + + // LFSRWithWorkMode + long a = LFSR[0]; + a += (long)LFSR[0] << 8; + a += (long)LFSR[4] << 20; + a += (long)LFSR[10] << 21; + a += (long)LFSR[13] << 17; + a += (long)LFSR[15] << 15; + a = (a & 0x7FFFFFFF) + (a >>> 31); + int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); + + System.arraycopy(LFSR, 1, LFSR, 0, 15); + LFSR[15] = v; + + key.R1 = R1; + key.R2 = R2; + } + + // 创建31位无符号整数 + private static int makeU31(int a, int b, int c, int d) { + return (((a & 0xFF) << 23) | + ((b & 0xFF) << 16) | + ((c & 0xFF) << 8) | + (d & 0xFF)) & 0x7FFFFFFF; + } + + // 创建32位无符号整数 + private static int makeU32(int a, int b, int c, int d) { + return ((a & 0xFF) << 24) | + ((b & 0xFF) << 16) | + ((c & 0xFF) << 8) | + (d & 0xFF); + } + + // 初始化ZUC256状态 + public static void zuc256Init(ZUCState state, byte[] K, byte[] IV) { + zuc256SetMacKey(state, K, IV, 0); + } + + // 生成单个密钥字 + public static int zuc256GenerateKeyword(ZUCState state) { + int[] LFSR = state.LFSR; + int R1 = state.R1; + int R2 = state.R2; + int X0, X1, X2, X3; + int W1, W2, U, V; + int Z; + + // BitReconstruction4 + X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + X3 = ((LFSR[2] & 0xFFFF) << 16) | (LFSR[0] >>> 15); + + Z = X3 ^ ((X0 ^ R1) + R2); + + // F_(X1, X2) + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >>> 16)); + V = L2((W2 << 16) | (W1 >>> 16)); + + R1 = makeU32(S0[(U >>> 24) & 0xFF], + S1[(U >>> 16) & 0xFF], + S0[(U >>> 8) & 0xFF], + S1[U & 0xFF]); + + R2 = makeU32(S0[(V >>> 24) & 0xFF], + S1[(V >>> 16) & 0xFF], + S0[(V >>> 8) & 0xFF], + S1[V & 0xFF]); + + // LFSRWithWorkMode + long a = LFSR[0]; + a += (long)LFSR[0] << 8; + a += (long)LFSR[4] << 20; + a += (long)LFSR[10] << 21; + a += (long)LFSR[13] << 17; + a += (long)LFSR[15] << 15; + a = (a & 0x7FFFFFFF) + (a >>> 31); + int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); + + System.arraycopy(LFSR, 1, LFSR, 0, 15); + LFSR[15] = v; + + state.R1 = R1; + state.R2 = R2; + + return Z; + } + + // 生成指定长度的密钥流 + public static void zuc256GenerateKeystream(ZUCState state, int nwords, int[] keystream) { + int[] LFSR = state.LFSR; + int R1 = state.R1; + int R2 = state.R2; + int X0, X1, X2, X3; + int W1, W2, U, V; + + for (int i = 0; i < nwords; i++) { + // BitReconstruction4 + X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + X3 = ((LFSR[2] & 0xFFFF) << 16) | (LFSR[0] >>> 15); + + keystream[i] = X3 ^ ((X0 ^ R1) + R2); + + // F_(X1, X2) + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >>> 16)); + V = L2((W2 << 16) | (W1 >>> 16)); + + // S盒查找 + int T0 = S0[(U >>> 24) & 0xFF] & 0xFF; + int T2 = S0[(U >>> 8) & 0xFF] & 0xFF; + int T4 = S0[(V >>> 24) & 0xFF] & 0xFF; + int T6 = S0[(V >>> 8) & 0xFF] & 0xFF; + + int T1 = S1[(U >>> 16) & 0xFF] & 0xFF; + int T3 = S1[U & 0xFF] & 0xFF; + int T5 = S1[(V >>> 16) & 0xFF] & 0xFF; + int T7 = S1[V & 0xFF] & 0xFF; + + R1 = makeU32(T0, T1, T2, T3); + R2 = makeU32(T4, T5, T6, T7); + + // LFSRWithWorkMode + long a = LFSR[0]; + a += (long)LFSR[0] << 8; + a += (long)LFSR[4] << 20; + a += (long)LFSR[10] << 21; + a += (long)LFSR[13] << 17; + a += (long)LFSR[15] << 15; + a = (a & 0x7FFFFFFF) + (a >>> 31); + int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); + + System.arraycopy(LFSR, 1, LFSR, 0, 15); + LFSR[15] = v; + } + + state.R1 = R1; + state.R2 = R2; + } + + // 初始化加密上下文 + public static void zuc256EncryptInit(ZUC256EncryptCtx ctx, byte[] K, byte[] IV) { + Arrays.fill(ctx.buf, (byte) 0); + ctx.buflen = 0; + zuc256Init(ctx.state, K, IV); + } + + // 分阶段处理加密数据 + public static void zuc256EncryptUpdate(ZUC256EncryptCtx ctx, byte[] in, int inlen, byte[] out) { + if (in == null || out == null || inlen == 0) return; + + // 处理缓冲区中剩余的非4字节数据 + if (ctx.buflen > 0) { + int need = 4 - ctx.buflen; + int copy = Math.min(inlen, need); + + System.arraycopy(in, 0, ctx.buf, ctx.buflen, copy); + ctx.buflen += copy; + + // 调整输入指针和长度 + byte[] newIn = new byte[inlen - copy]; + if (inlen - copy > 0) { + System.arraycopy(in, copy, newIn, 0, inlen - copy); + } + in = newIn; + inlen -= copy; + + // 缓冲区已满,处理一个完整的4字节块 + if (ctx.buflen == 4) { + int keystream = zuc256GenerateKeyword(ctx.state); + int plain = getU32(ctx.buf, 0); + putU32(out, 0, plain ^ keystream); + + ctx.buflen = 0; + Arrays.fill(ctx.buf, (byte) 0); + + // 调整输出指针 + byte[] newOut = new byte[out.length - 4]; + if (out.length - 4 > 0) { + System.arraycopy(out, 4, newOut, 0, out.length - 4); + } + out = newOut; + } + } + + // 处理完整的4字节块 + int fullBlocks = inlen / 4; + if (fullBlocks > 0) { + int[] keystream = new int[fullBlocks]; + zuc256GenerateKeystream(ctx.state, fullBlocks, keystream); + + // 逐块异或加密 + for (int i = 0; i < fullBlocks; i++) { + int plain = getU32(in, i * 4); + putU32(out, i * 4, plain ^ keystream[i]); + } + + // 调整输入指针和长度 + int processed = fullBlocks * 4; + byte[] newIn = new byte[inlen - processed]; + if (inlen - processed > 0) { + System.arraycopy(in, processed, newIn, 0, inlen - processed); + } + in = newIn; + inlen -= processed; + } + + // 缓存剩余不足4字节的数据 + if (inlen > 0) { + System.arraycopy(in, 0, ctx.buf, 0, inlen); + ctx.buflen = inlen; + } + } + + // 完成加密处理 + public static void zuc256EncryptFinish(ZUC256EncryptCtx ctx, byte[] out) { + if (ctx == null || out == null) return; + + // 处理缓冲区中剩余的不足4字节数据 + if (ctx.buflen > 0) { + int keystream = zuc256GenerateKeyword(ctx.state); + byte[] keystreamBytes = new byte[4]; + putU32(keystreamBytes, 0, keystream); + + // 逐字节异或 + for (int i = 0; i < ctx.buflen; i++) { + out[i] = (byte) (ctx.buf[i] ^ keystreamBytes[i]); + } + } + + // 清理上下文 + Arrays.fill(ctx.buf, (byte) 0); + ctx.buflen = 0; + Arrays.fill(ctx.state.LFSR, 0); + ctx.state.R1 = 0; + ctx.state.R2 = 0; + } + + // 一次性加密函数 + public static void zuc256Crypt(ZUCState state, byte[] in, int inlen, byte[] out) { + if (state == null || in == null || out == null) return; + + ZUC256EncryptCtx ctx = new ZUC256EncryptCtx(); + // 复制状态 + System.arraycopy(state.LFSR, 0, ctx.state.LFSR, 0, state.LFSR.length); + ctx.state.R1 = state.R1; + ctx.state.R2 = state.R2; + + // 执行加解密 + zuc256EncryptUpdate(ctx, in, inlen, out); + int remainingOffset = (inlen / 4) * 4; + byte[] finishOut = new byte[out.length - remainingOffset]; + if (finishOut.length > 0) { + System.arraycopy(out, remainingOffset, finishOut, 0, finishOut.length); + } + zuc256EncryptFinish(ctx, finishOut); + System.arraycopy(finishOut, 0, out, remainingOffset, finishOut.length); + + // 更新状态 + System.arraycopy(ctx.state.LFSR, 0, state.LFSR, 0, ctx.state.LFSR.length); + state.R1 = ctx.state.R1; + state.R2 = ctx.state.R2; + } + + // 提取IV + public static void extractIv(byte[] input25Byte, byte[] output23Byte) { + if (input25Byte == null || output23Byte == null) return; + + // 复制前17字节 + System.arraycopy(input25Byte, 0, output23Byte, 0, 17); + + // 处理剩余8字节 + byte[] src = new byte[8]; + for (int i = 0; i < 8; i++) { + src[i] = (byte) (input25Byte[17 + i] & 0x3F); + } + + output23Byte[17] = (byte) ((src[0] << 2) | (src[1] >>> 4)); + output23Byte[18] = (byte) (((src[1] & 0x0F) << 4) | (src[2] >>> 2)); + output23Byte[19] = (byte) (((src[2] & 0x03) << 6) | src[3]); + output23Byte[20] = (byte) ((src[4] << 2) | (src[5] >>> 4)); + output23Byte[21] = (byte) (((src[5] & 0x0F) << 4) | (src[6] >>> 2)); + output23Byte[22] = (byte) (((src[6] & 0x03) << 6) | src[7]); + } + + // 打印字节数组为十六进制 + public static void printHex(String label, byte[] data, int len) { + System.out.print(label + ": "); + for (int i = 0; i < len; i++) { + System.out.printf("%02x ", data[i] & 0xFF); + } + System.out.println(); + } + + // 主函数,验证ZUC256加解密功能 + public static void main(String[] args) { + // 1. 明文 + byte[] plaintext = "ZUC256对称加解密测试:1234567890".getBytes(); + int plaintextLen = plaintext.length; + System.out.println("明文: " + new String(plaintext)); + printHex("明文(十六进制)", plaintext, plaintextLen); + + // 2. 密钥(32字节ASCII) + byte[] key = "0123456789abcdef0123456789abcdef".getBytes(); + printHex("密钥", key, 32); + + // 3. 初始向量(25字节ASCII) + byte[] inputIv25Byte = "0123456789abcdefg01234567".getBytes(); + byte[] iv = new byte[23]; + extractIv(inputIv25Byte, iv); + printHex("提取后的IV", iv, 23); + + // 4. 分配加密/解密缓冲区 + byte[] ciphertext = new byte[plaintextLen]; + byte[] decryptedtext = new byte[plaintextLen]; + + // 5. 加密 + ZUCState state = new ZUCState(); + zuc256Init(state, key, iv); + zuc256Crypt(state, plaintext, plaintextLen, ciphertext); + printHex("密文", ciphertext, plaintextLen); + + // 6. 解密(重新初始化状态) + zuc256Init(state, key, iv); + zuc256Crypt(state, ciphertext, plaintextLen, decryptedtext); + printHex("解密后", decryptedtext, plaintextLen); + System.out.println("解密文本: " + new String(decryptedtext)); + + // 7. 验证结果 + if (Arrays.equals(plaintext, decryptedtext)) { + System.out.println("=== 测试成功: 解密结果与明文一致 ==="); + } else { + System.out.println("=== 测试失败: 解密结果与明文不一致 ==="); + } + } +} diff --git a/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Core.java b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Core.java new file mode 100644 index 0000000..90add4f --- /dev/null +++ b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Core.java @@ -0,0 +1,295 @@ +package com.zuc.zuc256; + + +import static com.zuc.zuc256.Zuc256Util.L1; +import static com.zuc.zuc256.Zuc256Util.L2; +import static com.zuc.zuc256.Zuc256Util.add31; +import static com.zuc.zuc256.Zuc256Util.makeU31; +import static com.zuc.zuc256.Zuc256Util.makeU32; +import static com.zuc.zuc256.Zuc256Util.rot31; + +/** + * ZUC-256 核心:状态初始化、密钥字生成、密钥流生成。 + */ +public final class Zuc256Core { + + private Zuc256Core() {} + + /** 初始化状态(Key + IV) */ + public static void initState(Zuc256State state, byte[] key32, byte[] iv) { + zuc256SetMacKey(state, key32, iv, 0); + } + + /** 生成单个密钥字 */ + public static int generateKeyword(Zuc256State state) { + int[] LFSR = state.LFSR; + int R1 = state.R1; + int R2 = state.R2; + int X0, X1, X2, X3; + int W1, W2, U, V; + int Z; + + // BitReconstruction4 + X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + X3 = ((LFSR[2] & 0xFFFF) << 16) | (LFSR[0] >>> 15); + + Z = X3 ^ ((X0 ^ R1) + R2); + + // F_(X1, X2) + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >>> 16)); + V = L2((W2 << 16) | (W1 >>> 16)); + + R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], + Zuc256Tables.S1[(U >>> 16) & 0xFF], + Zuc256Tables.S0[(U >>> 8) & 0xFF], + Zuc256Tables.S1[U & 0xFF]); + + R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], + Zuc256Tables.S1[(V >>> 16) & 0xFF], + Zuc256Tables.S0[(V >>> 8) & 0xFF], + Zuc256Tables.S1[V & 0xFF]); + + // LFSRWithWorkMode + long a = LFSR[0]; + a += (long)LFSR[0] << 8; + a += (long)LFSR[4] << 20; + a += (long)LFSR[10] << 21; + a += (long)LFSR[13] << 17; + a += (long)LFSR[15] << 15; + a = (a & 0x7FFFFFFF) + (a >>> 31); + int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); + + System.arraycopy(LFSR, 1, LFSR, 0, 15); + LFSR[15] = v; + + state.R1 = R1; + state.R2 = R2; + + return Z; + } + + // 生成指定长度的密钥流 + public static void zuc256GenerateKeystream(Zuc256State state, int nwords, int[] keystream) { + int[] LFSR = state.LFSR; + int R1 = state.R1; + int R2 = state.R2; + int X0, X1, X2, X3; + int W1, W2, U, V; + + for (int i = 0; i < nwords; i++) { + // BitReconstruction4 + X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + X3 = ((LFSR[2] & 0xFFFF) << 16) | (LFSR[0] >>> 15); + + keystream[i] = X3 ^ ((X0 ^ R1) + R2); + + // F_(X1, X2) + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >>> 16)); + V = L2((W2 << 16) | (W1 >>> 16)); + + // S盒查找 + int T0 = Zuc256Tables.S0[(U >>> 24) & 0xFF] & 0xFF; + int T2 = Zuc256Tables.S0[(U >>> 8) & 0xFF] & 0xFF; + int T4 = Zuc256Tables.S0[(V >>> 24) & 0xFF] & 0xFF; + int T6 = Zuc256Tables.S0[(V >>> 8) & 0xFF] & 0xFF; + + int T1 = Zuc256Tables.S1[(U >>> 16) & 0xFF] & 0xFF; + int T3 = Zuc256Tables.S1[U & 0xFF] & 0xFF; + int T5 = Zuc256Tables.S1[(V >>> 16) & 0xFF] & 0xFF; + int T7 = Zuc256Tables.S1[V & 0xFF] & 0xFF; + + R1 = makeU32(T0, T1, T2, T3); + R2 = makeU32(T4, T5, T6, T7); + + // LFSRWithWorkMode + long a = LFSR[0]; + a += (long)LFSR[0] << 8; + a += (long)LFSR[4] << 20; + a += (long)LFSR[10] << 21; + a += (long)LFSR[13] << 17; + a += (long)LFSR[15] << 15; + a = (a & 0x7FFFFFFF) + (a >>> 31); + int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); + + System.arraycopy(LFSR, 1, LFSR, 0, 15); + LFSR[15] = v; + } + + state.R1 = R1; + state.R2 = R2; + } + + + // 生成单个密钥字 + public static int zuc256GenerateKeyword(Zuc256State state) { + int[] LFSR = state.LFSR; + int R1 = state.R1; + int R2 = state.R2; + int X0, X1, X2, X3; + int W1, W2, U, V; + int Z; + + // BitReconstruction4 + X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + X3 = ((LFSR[2] & 0xFFFF) << 16) | (LFSR[0] >>> 15); + + Z = X3 ^ ((X0 ^ R1) + R2); + + // F_(X1, X2) + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >>> 16)); + V = L2((W2 << 16) | (W1 >>> 16)); + + R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], + Zuc256Tables.S1[(U >>> 16) & 0xFF], + Zuc256Tables.S0[(U >>> 8) & 0xFF], + Zuc256Tables.S1[U & 0xFF]); + + R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], + Zuc256Tables.S1[(V >>> 16) & 0xFF], + Zuc256Tables.S0[(V >>> 8) & 0xFF], + Zuc256Tables.S1[V & 0xFF]); + + // LFSRWithWorkMode + long a = LFSR[0]; + a += (long)LFSR[0] << 8; + a += (long)LFSR[4] << 20; + a += (long)LFSR[10] << 21; + a += (long)LFSR[13] << 17; + a += (long)LFSR[15] << 15; + a = (a & 0x7FFFFFFF) + (a >>> 31); + int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); + + System.arraycopy(LFSR, 1, LFSR, 0, 15); + LFSR[15] = v; + + state.R1 = R1; + state.R2 = R2; + + return Z; + } + + + // 初始化MAC密钥 + private static void zuc256SetMacKey(Zuc256State key, byte[] K, byte[] IV, int macbits) { + int[] LFSR = key.LFSR; + int R1 = 0; + int R2 = 0; + int X0, X1, X2; + int W, W1, W2, U, V; + int[] D; + + int IV17 = (IV[17] & 0xFF) >> 2; + int IV18 = ((IV[17] & 0x03) << 4) | ((IV[18] & 0xFF) >> 4); + int IV19 = ((IV[18] & 0x0F) << 2) | ((IV[19] & 0xFF) >> 6); + int IV20 = IV[19] & 0x3F; + int IV21 = (IV[20] & 0xFF) >> 2; + int IV22 = ((IV[20] & 0x03) << 4) | ((IV[21] & 0xFF) >> 4); + int IV23 = ((IV[21] & 0x0F) << 2) | ((IV[22] & 0xFF) >> 6); + int IV24 = IV[22] & 0x3F; + + D = (macbits / 32 < 3) ? Zuc256Tables.ZUC256_D[macbits / 32] : Zuc256Tables.ZUC256_D[3]; + + LFSR[0] = makeU31(K[0] & 0xFF, D[0], K[21] & 0xFF, K[16] & 0xFF); + LFSR[1] = makeU31(K[1] & 0xFF, D[1], K[22] & 0xFF, K[17] & 0xFF); + LFSR[2] = makeU31(K[2] & 0xFF, D[2], K[23] & 0xFF, K[18] & 0xFF); + LFSR[3] = makeU31(K[3] & 0xFF, D[3], K[24] & 0xFF, K[19] & 0xFF); + LFSR[4] = makeU31(K[4] & 0xFF, D[4], K[25] & 0xFF, K[20] & 0xFF); + LFSR[5] = makeU31(IV[0] & 0xFF, (D[5] | IV17), K[5] & 0xFF, K[26] & 0xFF); + LFSR[6] = makeU31(IV[1] & 0xFF, (D[6] | IV18), K[6] & 0xFF, K[27] & 0xFF); + LFSR[7] = makeU31(IV[10] & 0xFF, (D[7] | IV19), K[7] & 0xFF, IV[2] & 0xFF); + LFSR[8] = makeU31(K[8] & 0xFF, (D[8] | IV20), IV[3] & 0xFF, IV[11] & 0xFF); + LFSR[9] = makeU31(K[9] & 0xFF, (D[9] | IV21), IV[12] & 0xFF, IV[4] & 0xFF); + LFSR[10] = makeU31(IV[5] & 0xFF, (D[10] | IV22), K[10] & 0xFF, K[28] & 0xFF); + LFSR[11] = makeU31(K[11] & 0xFF, (D[11] | IV23), IV[6] & 0xFF, IV[13] & 0xFF); + LFSR[12] = makeU31(K[12] & 0xFF, (D[12] | IV24), IV[7] & 0xFF, IV[14] & 0xFF); + LFSR[13] = makeU31(K[13] & 0xFF, D[13], IV[15] & 0xFF, IV[8] & 0xFF); + LFSR[14] = makeU31(K[14] & 0xFF, (D[14] | (K[31] >>> 4)), IV[16] & 0xFF, IV[9] & 0xFF); + LFSR[15] = makeU31(K[15] & 0xFF, (D[15] | (K[31] & 0x0F)), K[30] & 0xFF, K[29] & 0xFF); + + for (int i = 0; i < 32; i++) { + // BitReconstruction3 + X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + + // F(X0, X1, X2) + W = (X0 ^ R1) + R2; + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >>> 16)); + V = L2((W2 << 16) | (W1 >>> 16)); + + R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], + Zuc256Tables.S1[(U >>> 16) & 0xFF], + Zuc256Tables.S0[(U >>> 8) & 0xFF], + Zuc256Tables.S1[U & 0xFF]); + + R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], + Zuc256Tables.S1[(V >>> 16) & 0xFF], + Zuc256Tables.S0[(V >>> 8) & 0xFF], + Zuc256Tables.S1[V & 0xFF]); + + // LFSRWithInitialisationMode(W >> 1) + int v = LFSR[0]; + v = add31(v, rot31(LFSR[0], 8)); + v = add31(v, rot31(LFSR[4], 20)); + v = add31(v, rot31(LFSR[10], 21)); + v = add31(v, rot31(LFSR[13], 17)); + v = add31(v, rot31(LFSR[15], 15)); + int t = W >>> 1; + v = add31(v, t); + + System.arraycopy(LFSR, 1, LFSR, 0, 15); + LFSR[15] = v; + } + + // BitReconstruction2 + X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); + X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); + + // F_(X1, X2) + W1 = R1 + X1; + W2 = R2 ^ X2; + U = L1((W1 << 16) | (W2 >>> 16)); + V = L2((W2 << 16) | (W1 >>> 16)); + + R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], + Zuc256Tables.S1[(U >>> 16) & 0xFF], + Zuc256Tables.S0[(U >>> 8) & 0xFF], + Zuc256Tables.S1[U & 0xFF]); + + R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], + Zuc256Tables.S1[(V >>> 16) & 0xFF], + Zuc256Tables.S0[(V >>> 8) & 0xFF], + Zuc256Tables.S1[V & 0xFF]); + + // LFSRWithWorkMode + long a = LFSR[0]; + a += (long)LFSR[0] << 8; + a += (long)LFSR[4] << 20; + a += (long)LFSR[10] << 21; + a += (long)LFSR[13] << 17; + a += (long)LFSR[15] << 15; + a = (a & 0x7FFFFFFF) + (a >>> 31); + int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); + + System.arraycopy(LFSR, 1, LFSR, 0, 15); + LFSR[15] = v; + + key.R1 = R1; + key.R2 = R2; + } +} + diff --git a/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Demo.java b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Demo.java new file mode 100644 index 0000000..a6dad8f --- /dev/null +++ b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Demo.java @@ -0,0 +1,74 @@ +package com.zuc.zuc256; + +import java.util.Arrays; + +import static com.zuc.zuc256.Zuc256Util.extractIv; +import static com.zuc.zuc256.Zuc256Util.printHex; + + + +/** + * 演示主函数 + */ +public final class Zuc256Demo { + + public static void main(String[] args) { + // 1. 明文 +// byte[] plaintext = "ZUC256对称加解密测试:1234567890".getBytes(); + byte[] plaintext = {(byte)0xaa, (byte)0xbb, (byte)0xcc, (byte)0xdd, (byte)0xee}; + int plaintextLen = plaintext.length; + System.out.println("明文: " + new String(plaintext)); + printHex("明文(十六进制)", plaintext, plaintextLen); + + // 2. 密钥(32字节ASCII) + byte[] key = "0123456789abcdef0123456789abcdef".getBytes(); + printHex("密钥", key, 32); + + // 3. 初始向量(25字节ASCII) + byte[] inputIv25Byte = "0123456789abcdefg01234567".getBytes(); + byte[] iv = new byte[23]; + extractIv(inputIv25Byte, iv); + printHex("提取后的IV", iv, 23); + + // 4. 分配加密/解密缓冲区 + byte[] ciphertext = new byte[plaintextLen]; + byte[] decryptedtext = new byte[plaintextLen]; + + // 5. 加密 + Zuc256State stateEnc = new Zuc256State(); + Zuc256Core.initState(stateEnc, key, iv); + zuc256Crypt(stateEnc, plaintext, plaintextLen, ciphertext); + printHex("密文", ciphertext, plaintextLen); + + // 6. 解密(重新初始化状态) + Zuc256State stateDec = new Zuc256State(); + Zuc256Core.initState(stateDec, key, iv); + zuc256Crypt(stateDec, ciphertext, plaintextLen, decryptedtext); + printHex("解密后", decryptedtext, plaintextLen); + System.out.println("解密文本: " + new String(decryptedtext)); + + // 7. 验证结果 + if (Arrays.equals(plaintext, decryptedtext)) { + System.out.println("=== 测试成功: 解密结果与明文一致 ==="); + } else { + System.out.println("=== 测试失败: 解密结果与明文不一致 ==="); + } + } + + // 一次性加密 + public static void zuc256Crypt(Zuc256State state, byte[] in, int inlen, byte[] out) { + if (state == null || in == null || out == null) return; + + Zuc256EncryptCtx ctx = new Zuc256EncryptCtx(state); + + // 执行加解密 + ctx.update(in, inlen, out); + int remainingOffset = (inlen / 4) * 4; + byte[] finishOut = new byte[out.length - remainingOffset]; + if (finishOut.length > 0) { + System.arraycopy(out, remainingOffset, finishOut, 0, finishOut.length); + } + ctx.finish(finishOut); + System.arraycopy(finishOut, 0, out, remainingOffset, finishOut.length); + } +} diff --git a/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256EncryptCtx.java b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256EncryptCtx.java new file mode 100644 index 0000000..9772a40 --- /dev/null +++ b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256EncryptCtx.java @@ -0,0 +1,131 @@ +package com.zuc.zuc256; + +import java.util.Arrays; + +import static com.zuc.zuc256.Zuc256Core.zuc256GenerateKeystream; +import static com.zuc.zuc256.Zuc256Core.zuc256GenerateKeyword; +import static com.zuc.zuc256.Zuc256Util.getU32; +import static com.zuc.zuc256.Zuc256Util.putU32; + + +/** + * 加密上下文类 + */ +public final class Zuc256EncryptCtx { + Zuc256State state; + byte[] buf; + int buflen; + + public Zuc256EncryptCtx(Zuc256State state, byte[] buf){ + this.state = state; + this.buf = buf; + } + + public Zuc256EncryptCtx(Zuc256State state){ + this.state = state; + this.buf = new byte[4]; + } + + public Zuc256EncryptCtx(){ + this.state = new Zuc256State(); + this.buf = new byte[4]; + } + + // 初始化加密上下文 + public void init(byte[] key32, byte[] iv) { + Arrays.fill(this.buf, (byte) 0); + this.buflen = 0; + Zuc256Core.initState(this.state, key32, iv); + } + + // 分阶段处理加密数据 + public void update(byte[] in, int inlen, byte[] out) { + if (in == null || out == null || inlen == 0) return; + + // 处理缓冲区中剩余的非4字节数据 + if (this.buflen > 0) { + int need = 4 - this.buflen; + int copy = Math.min(inlen, need); + + System.arraycopy(in, 0, this.buf, this.buflen, copy); + this.buflen += copy; + + // 调整输入指针和长度 + byte[] newIn = new byte[inlen - copy]; + if (inlen - copy > 0) { + System.arraycopy(in, copy, newIn, 0, inlen - copy); + } + in = newIn; + inlen -= copy; + + // 缓冲区已满,处理一个完整的4字节块 + if (this.buflen == 4) { + int keystream = zuc256GenerateKeyword(this.state); + int plain = getU32(this.buf, 0); + putU32(out, 0, plain ^ keystream); + + this.buflen = 0; + Arrays.fill(this.buf, (byte) 0); + + // 调整输出指针 + byte[] newOut = new byte[out.length - 4]; + if (out.length - 4 > 0) { + System.arraycopy(out, 4, newOut, 0, out.length - 4); + } + out = newOut; + } + } + + // 处理完整的4字节块 + int fullBlocks = inlen / 4; + if (fullBlocks > 0) { + int[] keystream = new int[fullBlocks]; + zuc256GenerateKeystream(this.state, fullBlocks, keystream); + + // 逐块异或加密 + for (int i = 0; i < fullBlocks; i++) { + int plain = getU32(in, i * 4); + putU32(out, i * 4, plain ^ keystream[i]); + } + + // 调整输入指针和长度 + int processed = fullBlocks * 4; + byte[] newIn = new byte[inlen - processed]; + if (inlen - processed > 0) { + System.arraycopy(in, processed, newIn, 0, inlen - processed); + } + in = newIn; + inlen -= processed; + } + + // 缓存剩余不足4字节的数据 + if (inlen > 0) { + System.arraycopy(in, 0, this.buf, 0, inlen); + this.buflen = inlen; + } + } + + // 完成加密处理 + public void finish(byte[] out) { + if (this == null || out == null) return; + + // 处理缓冲区中剩余的不足4字节数据 + if (this.buflen > 0) { + int keystream = zuc256GenerateKeyword(this.state); + byte[] keystreamBytes = new byte[4]; + putU32(keystreamBytes, 0, keystream); + + // 逐字节异或 + for (int i = 0; i < this.buflen; i++) { + out[i] = (byte) (this.buf[i] ^ keystreamBytes[i]); + } + } + + // 清理上下文 + Arrays.fill(this.buf, (byte) 0); + this.buflen = 0; + Arrays.fill(this.state.LFSR, 0); + this.state.R1 = 0; + this.state.R2 = 0; + } +} diff --git a/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256MacCtx.java b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256MacCtx.java new file mode 100644 index 0000000..554637c --- /dev/null +++ b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256MacCtx.java @@ -0,0 +1,15 @@ +package com.zuc.zuc256; + +/** + * MAC上下文类 + */ +public final class Zuc256MacCtx { + int[] LFSR = new int[16]; + int R1; + int R2; + byte[] buf = new byte[4]; + int buflen; + int[] T = new int[4]; + int[] K0 = new int[4]; + int macbits; +} diff --git a/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256State.java b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256State.java new file mode 100644 index 0000000..7e64d60 --- /dev/null +++ b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256State.java @@ -0,0 +1,10 @@ +package com.zuc.zuc256; + +/** + * ZUC状态类 + */ +public final class Zuc256State { + int[] LFSR = new int[16]; // 线性反馈移位寄存器 + int R1; // 寄存器1 + int R2; // 寄存器2 +} diff --git a/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Tables.java b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Tables.java new file mode 100644 index 0000000..311863f --- /dev/null +++ b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Tables.java @@ -0,0 +1,59 @@ +package com.zuc.zuc256; + +/** + * 常量表:S0/S1 与 ZUC256_D。 + * 注意:JavaCard 目标环境建议将表定义为 static final 数组,按 int/short 存放。 + */ +public final class Zuc256Tables { + + private Zuc256Tables() {} + + // S盒:S0, S1 + public static final int[] S0 = { + 0x3e,0x72,0x5b,0x47,0xca,0xe0,0x00,0x33,0x04,0xd1,0x54,0x98,0x09,0xb9,0x6d,0xcb, + 0x7b,0x1b,0xf9,0x32,0xaf,0x9d,0x6a,0xa5,0xb8,0x2d,0xfc,0x1d,0x08,0x53,0x03,0x90, + 0x4d,0x4e,0x84,0x99,0xe4,0xce,0xd9,0x91,0xdd,0xb6,0x85,0x48,0x8b,0x29,0x6e,0xac, + 0xcd,0xc1,0xf8,0x1e,0x73,0x43,0x69,0xc6,0xb5,0xbd,0xfd,0x39,0x63,0x20,0xd4,0x38, + 0x76,0x7d,0xb2,0xa7,0xcf,0xed,0x57,0xc5,0xf3,0x2c,0xbb,0x14,0x21,0x06,0x55,0x9b, + 0xe3,0xef,0x5e,0x31,0x4f,0x7f,0x5a,0xa4,0x0d,0x82,0x51,0x49,0x5f,0xba,0x58,0x1c, + 0x4a,0x16,0xd5,0x17,0xa8,0x92,0x24,0x1f,0x8c,0xff,0xd8,0xae,0x2e,0x01,0xd3,0xad, + 0x3b,0x4b,0xda,0x46,0xeb,0xc9,0xde,0x9a,0x8f,0x87,0xd7,0x3a,0x80,0x6f,0x2f,0xc8, + 0xb1,0xb4,0x37,0xf7,0x0a,0x22,0x13,0x28,0x7c,0xcc,0x3c,0x89,0xc7,0xc3,0x96,0x56, + 0x07,0xbf,0x7e,0xf0,0x0b,0x2b,0x97,0x52,0x35,0x41,0x79,0x61,0xa6,0x4c,0x10,0xfe, + 0xbc,0x26,0x95,0x88,0x8a,0xb0,0xa3,0xfb,0xc0,0x18,0x94,0xf2,0xe1,0xe5,0xe9,0x5d, + 0xd0,0xdc,0x11,0x66,0x64,0x5c,0xec,0x59,0x42,0x75,0x12,0xf5,0x74,0x9c,0xaa,0x23, + 0x0e,0x86,0xab,0xbe,0x2a,0x02,0xe7,0x67,0xe6,0x44,0xa2,0x6c,0xc2,0x93,0x9f,0xf1, + 0xf6,0xfa,0x36,0xd2,0x50,0x68,0x9e,0x62,0x71,0x15,0x3d,0xd6,0x40,0xc4,0xe2,0x0f, + 0x8e,0x83,0x77,0x6b,0x25,0x05,0x3f,0x0c,0x30,0xea,0x70,0xb7,0xa1,0xe8,0xa9,0x65, + 0x8d,0x27,0x1a,0xdb,0x81,0xb3,0xa0,0xf4,0x45,0x7a,0x19,0xdf,0xee,0x78,0x34,0x60 + }; + + public static final int[] S1 = { + 0x55,0xc2,0x63,0x71,0x3b,0xc8,0x47,0x86,0x9f,0x3c,0xda,0x5b,0x29,0xaa,0xfd,0x77, + 0x8c,0xc5,0x94,0x0c,0xa6,0x1a,0x13,0x00,0xe3,0xa8,0x16,0x72,0x40,0xf9,0xf8,0x42, + 0x44,0x26,0x68,0x96,0x81,0xd9,0x45,0x3e,0x10,0x76,0xc6,0xa7,0x8b,0x39,0x43,0xe1, + 0x3a,0xb5,0x56,0x2a,0xc0,0x6d,0xb3,0x05,0x22,0x66,0xbf,0xdc,0x0b,0xfa,0x62,0x48, + 0xdd,0x20,0x11,0x06,0x36,0xc9,0xc1,0xcf,0xf6,0x27,0x52,0xbb,0x69,0xf5,0xd4,0x87, + 0x7f,0x84,0x4c,0xd2,0x9c,0x57,0xa4,0xbc,0x4f,0x9a,0xdf,0xfe,0xd6,0x8d,0x7a,0xeb, + 0x2b,0x53,0xd8,0x5c,0xa1,0x14,0x17,0xfb,0x23,0xd5,0x7d,0x30,0x67,0x73,0x08,0x09, + 0xee,0xb7,0x70,0x3f,0x61,0xb2,0x19,0x8e,0x4e,0xe5,0x4b,0x93,0x8f,0x5d,0xdb,0xa9, + 0xad,0xf1,0xae,0x2e,0xcb,0x0d,0xfc,0xf4,0x2d,0x46,0x6e,0x1d,0x97,0xe8,0xd1,0xe9, + 0x4d,0x37,0xa5,0x75,0x5e,0x83,0x9e,0xab,0x82,0x9d,0xb9,0x1c,0xe0,0xcd,0x49,0x89, + 0x01,0xb6,0xbd,0x58,0x24,0xa2,0x5f,0x38,0x78,0x99,0x15,0x90,0x50,0xb8,0x95,0xe4, + 0xd0,0x91,0xc7,0xce,0xed,0x0f,0xb4,0x6f,0xa0,0xcc,0xf0,0x02,0x4a,0x79,0xc3,0xde, + 0xa3,0xef,0xea,0x51,0xe6,0x6b,0x18,0xec,0x1b,0x2c,0x80,0xf7,0x74,0xe7,0xff,0x21, + 0x5a,0x6a,0x54,0x1e,0x41,0x31,0x92,0x35,0xc4,0x33,0x07,0x0a,0xba,0x7e,0x0e,0x34, + 0x88,0xb1,0x98,0x7c,0xf3,0x3d,0x60,0x6c,0x7b,0xca,0xd3,0x1f,0x32,0x65,0x04,0x28, + 0x64,0xbe,0x85,0x9b,0x2f,0x59,0x8a,0xd7,0xb0,0x25,0xac,0xaf,0x12,0x03,0xe2,0xf2 + }; + + /** + * 常量数组 D + */ + public static final int[][] ZUC256_D = { + {0x22,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, + {0x22,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, + {0x23,0x2F,0x24,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30}, + {0x23,0x2F,0x25,0x2A,0x6D,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x52,0x10,0x30} + }; +} diff --git a/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Util.java b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Util.java new file mode 100644 index 0000000..99a8ebe --- /dev/null +++ b/ref_c_java/zuc256_java_2/com/zuc/zuc256/Zuc256Util.java @@ -0,0 +1,112 @@ +package com.zuc.zuc256; + +/** + * 辅助工具:装载/存储、位运算、线性变换、打印等。 + */ +public final class Zuc256Util { + + private Zuc256Util() {} + + /** 辅助方法:将字节数组转换为32位整数 */ + public static int getU32(byte[] p, int offset) { + return ((p[offset] & 0xFF) << 24) | + ((p[offset + 1] & 0xFF) << 16) | + ((p[offset + 2] & 0xFF) << 8) | + (p[offset + 3] & 0xFF); + } + + /** 辅助方法:将32位整数转换为字节数组 */ + public static void putU32(byte[] p, int offset, int v) { + p[offset] = (byte) (v >> 24); + p[offset + 1] = (byte) (v >> 16); + p[offset + 2] = (byte) (v >> 8); + p[offset + 3] = (byte) v; + } + + // === 31/32 位运算 === + + /** 31位加法 */ + public static int add31(int a, int b) { + long sum = (long)a + b; + long q = (sum & 0x7FFFFFFF); + long w = (sum >> 31); + long e = q+w; + return (int) (e); + } + + /** 31位旋转 */ + public static int rot31(int a, int k) { + return ((a << k) | (a >>> (31 - k))) & 0x7FFFFFFF; + } + + /** 32位旋转 */ + public static int rot32(int a, int k) { + int t = (a << k) | (a >>> (32 - k)); + return t; + } + + /** + * L1函数 + */ + public static int L1(int x) { + return x ^ + rot32(x, 2) ^ + rot32(x, 10) ^ + rot32(x, 18) ^ + rot32(x, 24); + } + + /** + * L2函数 + */ + public static int L2(int x) { + return x ^ rot32(x, 8) ^ rot32(x, 14) ^ rot32(x, 22) ^ rot32(x, 30); + } + + /** 创建31位无符号整数 */ + public static int makeU31(int a, int b, int c, int d) { + return (((a & 0xFF) << 23) | + ((b & 0xFF) << 16) | + ((c & 0xFF) << 8) | + (d & 0xFF)) & 0x7FFFFFFF; + } + + /** 创建32位无符号整数 */ + public static int makeU32(int a, int b, int c, int d) { + return ((a & 0xFF) << 24) | + ((b & 0xFF) << 16) | + ((c & 0xFF) << 8) | + (d & 0xFF); + } + + + /** 提取IV */ + public static void extractIv(byte[] input25Byte, byte[] output23Byte) { + if (input25Byte == null || output23Byte == null) return; + + // 复制前17字节 + System.arraycopy(input25Byte, 0, output23Byte, 0, 17); + + // 处理剩余8字节 + byte[] src = new byte[8]; + for (int i = 0; i < 8; i++) { + src[i] = (byte) (input25Byte[17 + i] & 0x3F); + } + + output23Byte[17] = (byte) ((src[0] << 2) | (src[1] >>> 4)); + output23Byte[18] = (byte) (((src[1] & 0x0F) << 4) | (src[2] >>> 2)); + output23Byte[19] = (byte) (((src[2] & 0x03) << 6) | src[3]); + output23Byte[20] = (byte) ((src[4] << 2) | (src[5] >>> 4)); + output23Byte[21] = (byte) (((src[5] & 0x0F) << 4) | (src[6] >>> 2)); + output23Byte[22] = (byte) (((src[6] & 0x03) << 6) | src[7]); + } + + /** 打印十六进制(调试用,TODO 生产/JC 环境可移除) */ + public static void printHex(String label, byte[] data, int len) { + System.out.print(label + ": "); + for (int i = 0; i < len; i++) { + System.out.printf("%02x ", data[i] & 0xFF); + } + System.out.println(); + } +} diff --git a/Project/Src/com/cscn/Method_old.java b/ref_c_java/zuc256_javacard_old/Method_old.java similarity index 100% rename from Project/Src/com/cscn/Method_old.java rename to ref_c_java/zuc256_javacard_old/Method_old.java diff --git a/ref_c_java/zuc256_javacard_old/Zuc256Core.java b/ref_c_java/zuc256_javacard_old/Zuc256Core.java new file mode 100644 index 0000000..bd2b0c1 --- /dev/null +++ b/ref_c_java/zuc256_javacard_old/Zuc256Core.java @@ -0,0 +1,595 @@ +//package com.cscn; +// +// +//import javacard.framework.JCSystem; +// +//import static com.cscn.Zuc256Util.L1; +//import static com.cscn.Zuc256Util.L2; +//import static com.cscn.Zuc256Util.add31; +//import static com.cscn.Zuc256Util.add32; +//import static com.cscn.Zuc256Util.add64; +//import static com.cscn.Zuc256Util.and64_7FFFFFFF_to32; +//import static com.cscn.Zuc256Util.create_64b_from_32b; +//import static com.cscn.Zuc256Util.makeU31; +//import static com.cscn.Zuc256Util.makeU32; +//import static com.cscn.Zuc256Util.rot31; +//import static com.cscn.Zuc256Util.shr32u1; +//import static com.cscn.Zuc256Util.shr64u_31; +//import static com.cscn.Zuc256Util.xor32; +// +///** +// * ZUC-256 核心:状态初始化、密钥字生成、密钥流生成。 +// */ +//public class Zuc256Core { +// +// private Zuc256Core() {} +// +// /** 初始化状态(Key + IV) */ +// public static void initState(Zuc256State state, byte[] key32, byte[] iv) { +// zuc256SetMacKey(state, key32, iv, (short)0); +// } +// +// /** 生成单个密钥字 */ +// public static void zuc256GenerateKeyword(Zuc256State state, short[] out) { +//// int[] LFSR = state.LFSR; +//// int R1 = state.R1; +//// int R2 = state.R2; +//// int X0, X1, X2, X3; +//// int W1, W2, U, V; +//// int Z; +// +// short[] LFSR_hi = state.LFSR_hi; +// short[] LFSR_lo = state.LFSR_lo; +// +// // 工作寄存器(32位值的临时 out32 缓冲,全用short[2])[lo, hi] +// short[] X0 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] X1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] X2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] X3 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// short[] R1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] R2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] W1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] W2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] U = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] V = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] Z = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] TMP0 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] TMP1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] TMP2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// // 载入 R1,R2 +// R1[0] = state.R1_lo; +// R1[1] = state.R1_hi; +// R2[0] = state.R2_lo; +// R2[1] = state.R2_hi; +// +// +// // BitReconstruction4 +// short c15 = (short)((LFSR_lo[15] & (short)0x8000) >>> 15); // 左移产生的进位 +// X0[1] = (short)(((LFSR_hi[15] & (short)0x7FFF) << 1) | (short)(c15 & 0x0001)); // hi +// X0[0] = LFSR_lo[14]; // lo +// +// // X1 = ((L11 & 0xFFFF) << 16) | (L9 >>> 15) +// X1[1] = LFSR_lo[11]; +// X1[0] = (short)((((LFSR_lo[9] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[9] << 1)); +// +// // X2 = ((L7 & 0xFFFF) << 16) | (L5 >>> 15) +// X2[1] = LFSR_lo[7]; +// X2[0] = (short)((((LFSR_lo[5] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[5] << 1)); +// +// // X3 = ((L2 & 0xFFFF) << 16) | (L0 >>> 15) +// X3[1] = LFSR_lo[2]; +// X3[0] = (short)((((LFSR_lo[0] & (short)0x8000) >>> 15) & 0X0001) | (LFSR_hi[0] << 1)); +// +// +// +// // ---- 输入:X0,X1,X2,X3,R1,R2 均为 short[2]; 输出:Z,W1,W2,U,V ---- +// +// // Z = X3 ^ ((X0 ^ R1) + R2) +// xor32(X0[0], X0[1], R1[0], R1[1], TMP0); // TMP0 = X0 ^ R1 +// add32(TMP0[0], TMP0[1], R2[0], R2[1], TMP1); // TMP1 = TMP0 + R2 +// xor32(X3[0], X3[1], TMP1[0], TMP1[1], Z); // Z = X3 ^ TMP1 +// +// // F_(X1, X2) +// // W1 = R1 + X1 +// add32(R1[0], R1[1], X1[0], X1[1], W1); +// +// // W2 = R2 ^ X2 +// xor32(R2[0], R2[1], X2[0], X2[1], W2); +// +// // U = L1((W1 << 16) | (W2 >>> 16)) +// // (W1<<16): lo=0, hi=W1_lo +// // (W2>>>16): lo=W2_hi, hi=0 +// // OR 结果: lo=W2_hi, hi=W1_lo +// L1(W2[1], W1[0], U); +// +// // V = L2((W2 << 16) | (W1 >>> 16)) +// // (W2<<16): lo=0, hi=W2_lo +// // (W1>>>16): lo=W1_hi, hi=0 +// // OR 结果: lo=W1_hi, hi=W2_lo +// L2(W1[1], W2[0], V); +// +// +//// R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], +//// Zuc256Tables.S1[(U >>> 16) & 0xFF], +//// Zuc256Tables.S0[(U >>> 8) & 0xFF], +//// Zuc256Tables.S1[U & 0xFF]); +// makeU32( +// (short)(Zuc256Tables.S0[((U[1] >>> 8) & 0xFF)] & 0xFF), // (U >>> 24) & 0xFF +// (short)(Zuc256Tables.S1[(U[1] & 0xFF)] & 0xFF), // (U >>> 16) & 0xFF +// (short)(Zuc256Tables.S0[((U[0] >>> 8) & 0xFF)] & 0xFF), // (U >>> 8) & 0xFF +// (short)(Zuc256Tables.S1[(U[0] & 0xFF)] & 0xFF), // (U >>> 0) & 0xFF +// R1); +// +//// R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], +//// Zuc256Tables.S1[(V >>> 16) & 0xFF], +//// Zuc256Tables.S0[(V >>> 8) & 0xFF], +//// Zuc256Tables.S1[V & 0xFF]); +// makeU32( +// (short)(Zuc256Tables.S0[((V[1] >>> 8) & 0xFF)] & 0xFF), // (V >>> 24) & 0xFF +// (short)(Zuc256Tables.S1[(V[1] & 0xFF)] & 0xFF), // (V >>> 16) & 0xFF +// (short)(Zuc256Tables.S0[((V[0] >>> 8) & 0xFF)] & 0xFF), // (V >>> 8) & 0xFF +// (short)(Zuc256Tables.S1[(V[0] & 0xFF)] & 0xFF), // (V >>> 0) & 0xFF +// R2); +// +// +// +//// // LFSRWithWorkMode +//// long a = LFSR[0]; +//// a += (long)LFSR[0] << 8; +//// a += (long)LFSR[4] << 20; +//// a += (long)LFSR[10] << 21; +//// a += (long)LFSR[13] << 17; +//// a += (long)LFSR[15] << 15; +// // ---- 先准备累加器 A (64位) ---- +// short[] A = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); // 64位累加器,初始全0 +// A[0] = 0; A[1] = 0; A[2] = 0; A[3] = 0; +// +// // 临时缓冲 +// short[] tmp32 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; // 保存一个32位数 (lo,hi) +// short[] tmp64 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; // 保存移位后的64位数 +// +// // a = LFSR[0] +// tmp32[0] = state.LFSR_lo[0]; +// tmp32[1] = state.LFSR_hi[0]; +// create_64b_from_32b(tmp64, tmp32, (short)0); +// add64(A, tmp64); +// +// // a += (LFSR[0] << 8) +// create_64b_from_32b(tmp64, tmp32, (short)8); +// add64(A, tmp64); +// +// // a += (LFSR[4] << 20) +// tmp32[0] = state.LFSR_lo[4]; +// tmp32[1] = state.LFSR_hi[4]; +// create_64b_from_32b(tmp64, tmp32, (short)20); +// add64(A, tmp64); +// +// // a += (LFSR[10] << 21) +// tmp32[0] = state.LFSR_lo[10]; +// tmp32[1] = state.LFSR_hi[10]; +// create_64b_from_32b(tmp64, tmp32, (short)21); +// add64(A, tmp64); +// +// // a += (LFSR[13] << 17) +// tmp32[0] = state.LFSR_lo[13]; +// tmp32[1] = state.LFSR_hi[13]; +// create_64b_from_32b(tmp64, tmp32, (short)17); +// add64(A, tmp64); +// +// // a += (LFSR[15] << 15) +// tmp32[0] = state.LFSR_lo[15]; +// tmp32[1] = state.LFSR_hi[15]; +// create_64b_from_32b(tmp64, tmp32, (short)15); +// add64(A, tmp64); +// +//// a = (a & 0x7FFFFFFF) + (a >>> 31); +// // ---- 第一次折叠:a = (a & 0x7FFFFFFF) + (a >>> 31) ---- +// short[] low31 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] r31 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// and64_7FFFFFFF_to32(A, low31); // low31 = A & 0x7FFFFFFF +// shr64u_31(A, r31); // r31 = A >>> 31 +// +// A[0]=0; A[1]=0; A[2]=0; A[3]=0; +// add64(A, low31); +// add64(A, r31); +//// int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); +// // ---- 第二次折叠,得到 v(32位)---- +// short[] low31b = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] r31b = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] v64 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// and64_7FFFFFFF_to32(A, low31b); +// shr64u_31(A, r31b); +// +// v64[0]=0; v64[1]=0; v64[2]=0; v64[3]=0; +// add64(v64, low31b); +// add64(v64, r31b); +// +// // v = 32位,取 v64 的低两段 +// short v_lo = v64[0]; +// short v_hi = (short)(v64[1] & 0x7FFF); // 只保留31位 +// +//// System.arraycopy(LFSR, 1, LFSR, 0, 15); +// // LFSR_lo 向左移 +// for (short i = 0; i < (short)15; i++) { +// state.LFSR_lo[i] = state.LFSR_lo[(short)(i + 1)]; +// } +// // LFSR_hi 向左移 +// for (short i = 0; i < (short)15; i++) { +// state.LFSR_hi[i] = state.LFSR_hi[(short)(i + 1)]; +// } +// +//// LFSR[15] = v; +// // ---- 写回 LFSR[15] ---- +// state.LFSR_lo[15] = v_lo; +// state.LFSR_hi[15] = v_hi; +// +//// state.R1 = R1; +//// state.R2 = R2; +// state.R1_lo = R1[0]; +// state.R1_hi = R1[1]; +// +// state.R2_lo = R2[0]; +// state.R2_hi = R2[1]; +// +// +//// return Z; +// out[0] = Z[0]; +// out[1] = Z[1]; +// +// } +// +// // 生成指定长度的密钥流 +// public static void zuc256GenerateKeystream(Zuc256State state, +// short nwords, +// short[] keystream_hi, +// short[] keystream_lo) { +// // 临时存放一个 32 位关键字 +// short[] tmp = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// for (short i = 0; i < nwords; i++) { +// // 生成一个关键字 -> tmp[0]=lo, tmp[1]=hi +// zuc256GenerateKeyword(state, tmp); +// // 存入输出数组 +// keystream_lo[i] = tmp[0]; +// keystream_hi[i] = tmp[1]; +// } +// } +// +// +// +// +// // 初始化MAC密钥 +// private static void zuc256SetMacKey(Zuc256State state, byte[] K, byte[] IV, short macbits) { +// short[] D = JCSystem.makeTransientShortArray(Zuc256Tables.D_COLS, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] TMP = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] X0 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] X1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] X2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] R1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] R2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] W = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] W1 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] W2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] U = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] V = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] T = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] T2 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// +//// int IV17 = (IV[17] & 0xFF) >> 2; +//// int IV18 = ((IV[17] & 0x03) << 4) | ((IV[18] & 0xFF) >> 4); +//// int IV19 = ((IV[18] & 0x0F) << 2) | ((IV[19] & 0xFF) >> 6); +//// int IV20 = IV[19] & 0x3F; +//// int IV21 = (IV[20] & 0xFF) >> 2; +//// int IV22 = ((IV[20] & 0x03) << 4) | ((IV[21] & 0xFF) >> 4); +//// int IV23 = ((IV[21] & 0x0F) << 2) | ((IV[22] & 0xFF) >> 6); +//// int IV24 = IV[22] & 0x3F; +// // IV 拆分 +// short IV17 = (short)((IV[17] & 0xFF) >>> 2); +// short IV18 = (short)(((IV[17] & 0x03) << 4) | ((IV[18] & 0xFF) >>> 4)); +// short IV19 = (short)(((IV[18] & 0x0F) << 2) | ((IV[19] & 0xFF) >>> 6)); +// short IV20 = (short)(IV[19] & 0x3F); +// short IV21 = (short)((IV[20] & 0xFF) >>> 2); +// short IV22 = (short)(((IV[20] & 0x03) << 4) | ((IV[21] & 0xFF) >>> 4)); +// short IV23 = (short)(((IV[21] & 0x0F) << 2) | ((IV[22] & 0xFF) >>> 6)); +// short IV24 = (short)(IV[22] & 0x3F); +// +//// D = (macbits / 32 < 3) ? Zuc256Tables.ZUC256_D[macbits / 32] : Zuc256Tables.ZUC256_D[3]; +// short row = (short)((macbits / 32) < 3 ? (macbits / 32) : 3); +// Zuc256Tables.getDRow(row, D, (short)0); +// Zuc256Tables.getDRow(row, D, (short)0); +// +// +// short[] tmp = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); // 临时存储 makeU31 输出 (lo,hi) +// +// // 逐项装载 LFSR +//// LFSR[0] = makeU31(K[0] & 0xFF, D[0], K[21] & 0xFF, K[16] & 0xFF); +// makeU31((short)(K[0] & 0xFF), (short)D[0], (short)(K[21] & 0xFF), (short)(K[16] & 0xFF), tmp); +// state.LFSR_lo[0] = tmp[0]; state.LFSR_hi[0] = tmp[1]; +// +//// LFSR[1] = makeU31(K[1] & 0xFF, D[1], K[22] & 0xFF, K[17] & 0xFF); +// makeU31((short)(K[1] & 0xFF), (short)D[1], (short)(K[22] & 0xFF), (short)(K[17] & 0xFF), tmp); +// state.LFSR_lo[1] = tmp[0]; state.LFSR_hi[1] = tmp[1]; +// +//// LFSR[2] = makeU31(K[2] & 0xFF, D[2], K[23] & 0xFF, K[18] & 0xFF); +// makeU31((short)(K[2] & 0xFF), (short)D[2], (short)(K[23] & 0xFF), (short)(K[18] & 0xFF), tmp); +// state.LFSR_lo[2] = tmp[0]; state.LFSR_hi[2] = tmp[1]; +// +//// LFSR[3] = makeU31(K[3] & 0xFF, D[3], K[24] & 0xFF, K[19] & 0xFF); +// makeU31((short)(K[3] & 0xFF), (short)D[3], (short)(K[24] & 0xFF), (short)(K[19] & 0xFF), tmp); +// state.LFSR_lo[3] = tmp[0]; state.LFSR_hi[3] = tmp[1]; +// +//// LFSR[4] = makeU31(K[4] & 0xFF, D[4], K[25] & 0xFF, K[20] & 0xFF); +// makeU31((short)(K[4] & 0xFF), (short)D[4], (short)(K[25] & 0xFF), (short)(K[20] & 0xFF), tmp); +// state.LFSR_lo[4] = tmp[0]; state.LFSR_hi[4] = tmp[1]; +// +//// LFSR[5] = makeU31(IV[0] & 0xFF, (D[5] | IV17), K[5] & 0xFF, K[26] & 0xFF); +// makeU31((short)(IV[0] & 0xFF), (short)(D[5] | IV17), (short)(K[5] & 0xFF), (short)(K[26] & 0xFF), tmp); +// state.LFSR_lo[5] = tmp[0]; state.LFSR_hi[5] = tmp[1]; +// +//// LFSR[6] = makeU31(IV[1] & 0xFF, (D[6] | IV18), K[6] & 0xFF, K[27] & 0xFF); +// makeU31((short)(IV[1] & 0xFF), (short)(D[6] | IV18), (short)(K[6] & 0xFF), (short)(K[27] & 0xFF), tmp); +// state.LFSR_lo[6] = tmp[0]; state.LFSR_hi[6] = tmp[1]; +// +//// LFSR[7] = makeU31(IV[10] & 0xFF, (D[7] | IV19), K[7] & 0xFF, IV[2] & 0xFF); +// makeU31((short)(IV[10] & 0xFF), (short)(D[7] | IV19), (short)(K[7] & 0xFF), (short)(IV[2] & 0xFF), tmp); +// state.LFSR_lo[7] = tmp[0]; state.LFSR_hi[7] = tmp[1]; +// +//// LFSR[8] = makeU31(K[8] & 0xFF, (D[8] | IV20), IV[3] & 0xFF, IV[11] & 0xFF); +// makeU31((short)(K[8] & 0xFF), (short)(D[8] | IV20), (short)(IV[3] & 0xFF), (short)(IV[11] & 0xFF), tmp); +// state.LFSR_lo[8] = tmp[0]; state.LFSR_hi[8] = tmp[1]; +// +//// LFSR[9] = makeU31(K[9] & 0xFF, (D[9] | IV21), IV[12] & 0xFF, IV[4] & 0xFF); +// makeU31((short)(K[9] & 0xFF), (short)(D[9] | IV21), (short)(IV[12] & 0xFF), (short)(IV[4] & 0xFF), tmp); +// state.LFSR_lo[9] = tmp[0]; state.LFSR_hi[9] = tmp[1]; +// +//// LFSR[10] = makeU31(IV[5] & 0xFF, (D[10] | IV22), K[10] & 0xFF, K[28] & 0xFF); +// makeU31((short)(IV[5] & 0xFF), (short)(D[10] | IV22), (short)(K[10] & 0xFF), (short)(K[28] & 0xFF), tmp); +// state.LFSR_lo[10] = tmp[0]; state.LFSR_hi[10] = tmp[1]; +// +//// LFSR[11] = makeU31(K[11] & 0xFF, (D[11] | IV23), IV[6] & 0xFF, IV[13] & 0xFF); +// makeU31((short)(K[11] & 0xFF), (short)(D[11] | IV23), (short)(IV[6] & 0xFF), (short)(IV[13] & 0xFF), tmp); +// state.LFSR_lo[11] = tmp[0]; state.LFSR_hi[11] = tmp[1]; +// +//// LFSR[12] = makeU31(K[12] & 0xFF, (D[12] | IV24), IV[7] & 0xFF, IV[14] & 0xFF); +// makeU31((short)(K[12] & 0xFF), (short)(D[12] | IV24), (short)(IV[7] & 0xFF), (short)(IV[14] & 0xFF), tmp); +// state.LFSR_lo[12] = tmp[0]; state.LFSR_hi[12] = tmp[1]; +// +//// LFSR[13] = makeU31(K[13] & 0xFF, D[13], IV[15] & 0xFF, IV[8] & 0xFF); +// makeU31((short)(K[13] & 0xFF), (short)D[13], (short)(IV[15] & 0xFF), (short)(IV[8] & 0xFF), tmp); +// state.LFSR_lo[13] = tmp[0]; state.LFSR_hi[13] = tmp[1]; +// +//// LFSR[14] = makeU31(K[14] & 0xFF, (D[14] | (K[31] >>> 4)), IV[16] & 0xFF, IV[9] & 0xFF); +// makeU31((short)(K[14] & 0xFF), (short)(D[14] | ((K[31] & 0xFF) >>> 4)), (short)(IV[16] & 0xFF), (short)(IV[9] & 0xFF), tmp); +// state.LFSR_lo[14] = tmp[0]; state.LFSR_hi[14] = tmp[1]; +// +//// LFSR[15] = makeU31(K[15] & 0xFF, (D[15] | (K[31] & 0x0F)), K[30] & 0xFF, K[29] & 0xFF); +// makeU31((short)(K[15] & 0xFF), (short)(D[15] | (K[31] & 0x0F)), (short)(K[30] & 0xFF), (short)(K[29] & 0xFF), tmp); +// state.LFSR_lo[15] = tmp[0]; state.LFSR_hi[15] = tmp[1]; +// +// +// short c15_2 = 0; +// for (short i = 0; i < 32; i++) { +// // BitReconstruction3 +//// X0 = ((LFSR[15] & 0x7FFF8000) << 1) | (LFSR[14] & 0xFFFF); +// // X0 = ((L15 & 0x7FFF8000)<<1) | (L14 & 0xFFFF) +// c15_2 = (short)((state.LFSR_lo[15] & (short)0x8000) >>> 15); +// X0[1] = (short)(((state.LFSR_hi[15] & (short)0x7FFF) << 1) | (short)(c15_2 & 0x0001)); +// X0[0] = state.LFSR_lo[14]; +// +//// X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); +// // X1 = ((L11 & 0xFFFF)<<16) | (L9>>>15) +// X1[1] = state.LFSR_lo[11]; +// X1[0] = (short)((((state.LFSR_lo[9] & (short)0x8000) >>> 15) & 0X0001) | (state.LFSR_hi[9] << 1)); +// +//// X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); +// // X2 = ((L7 & 0xFFFF)<<16) | (L5>>>15) +// X2[1] = state.LFSR_lo[7]; +// X2[0] = (short)((((state.LFSR_lo[5] & (short)0x8000) >>> 15) & 0X0001) | (state.LFSR_hi[5] << 1)); +// +// +// +// // F(X0, X1, X2) +// // W = (X0 ^ R1) + R2 +// xor32(X0[0], X0[1], R1[0], R1[1], TMP); +// add32(TMP[0], TMP[1], R2[0], R2[1], W); +// +// // W1 = R1 + X1 +// add32(R1[0], R1[1], X1[0], X1[1], W1); +// +// // W2 = R2 ^ X2 +// xor32(R2[0], R2[1], X2[0], X2[1], W2); +// +// // U = L1((W1<<16) | (W2>>>16)) +// L1(W2[1], W1[0], U); +// +// // V = L2((W2<<16) | (W1>>>16)) +// L2(W1[1], W2[0], V); +// +//// R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], +//// Zuc256Tables.S1[(U >>> 16) & 0xFF], +//// Zuc256Tables.S0[(U >>> 8) & 0xFF], +//// Zuc256Tables.S1[U & 0xFF]); +//// +//// R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], +//// Zuc256Tables.S1[(V >>> 16) & 0xFF], +//// Zuc256Tables.S0[(V >>> 8) & 0xFF], +//// Zuc256Tables.S1[V & 0xFF]); +// // 更新 R1,R2 +// makeU32( +// (short)(Zuc256Tables.S0[((U[1] >>> 8) & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S1[(U[1] & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S0[((U[0] >>> 8) & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S1[(U[0] & 0xFF)] & 0xFF), +// R1); +// +// makeU32( +// (short)(Zuc256Tables.S0[((V[1] >>> 8) & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S1[(V[1] & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S0[((V[0] >>> 8) & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S1[(V[0] & 0xFF)] & 0xFF), +// R2); +// +// // LFSRWithInitialisationMode(W >> 1) +//// int v = LFSR[0]; +// V[0] = state.LFSR_lo[0]; +// V[1] = state.LFSR_hi[0]; +// +// // v = add31(v, rot31(state.LFSR[0], 8)) +// rot31(state.LFSR_lo[0], state.LFSR_hi[0], (short)8, T); +// add31(V[0], V[1], T[0], T[1], V); +// +//// v = add31(v, rot31(state.LFSR[4], 20)); +// rot31(state.LFSR_lo[4], state.LFSR_hi[4], (short)20, T); +// add31(V[0], V[1], T[0], T[1], V); +// +//// v = add31(v, rot31(state.LFSR[10], 21)); +// rot31(state.LFSR_lo[10], state.LFSR_hi[10], (short)21, T); +// add31(V[0], V[1], T[0], T[1], V); +// +//// v = add31(v, rot31(state.LFSR[13], 17)); +// rot31(state.LFSR_lo[13], state.LFSR_hi[13], (short)17, T); +// add31(V[0], V[1], T[0], T[1], V); +// +//// v = add31(v, rot31(state.LFSR[15], 15)); +// rot31(state.LFSR_lo[15], state.LFSR_hi[15], (short)15, T); +// add31(V[0], V[1], T[0], T[1], V); +// +//// v = add31(v, W >>> 1); +// shr32u1(W[0], W[1], T2); // T2[0]=lo, T2[1]=hi(无符号>>>1) +// T2[1] = (short)(T2[1] & (short)0xFFFF); // 只保留31位 +// add31(V[0], V[1], T2[0], T2[1], V); +// +// // System.arraycopy(state.LFSR, 1, state.LFSR, 0, 15) +//// 相当于 System.arraycopy(state.LFSR_lo, 1, state.LFSR_lo, 0, 15); +// for (short j = 0; j < (short)15; j++) { +// state.LFSR_lo[j] = state.LFSR_lo[(short)(j + 1)]; +// } +//// 相当于 System.arraycopy(state.LFSR_hi, 1, state.LFSR_hi, 0, 15); +// for (short j = 0; j < (short)15; j++) { +// state.LFSR_hi[j] = state.LFSR_hi[(short)(j + 1)]; +// } +// +//// state.LFSR[15] = v; +// state.LFSR_lo[15] = V[0]; +// state.LFSR_hi[15] = (short)(V[1] & 0x7FFF); +// } +// +// // BitReconstruction2 +//// X1 = ((LFSR[11] & 0xFFFF) << 16) | (LFSR[9] >>> 15); +// X1[1] = state.LFSR_lo[11]; +// X1[0] = (short)((((state.LFSR_lo[9] & (short)0x8000) >>> 15) & 0X0001) | (state.LFSR_hi[9] << 1)); +// +//// X2 = ((LFSR[7] & 0xFFFF) << 16) | (LFSR[5] >>> 15); +// X2[1] = state.LFSR_lo[7]; +// X2[0] = (short)((((state.LFSR_lo[5] & (short)0x8000) >>> 15) & 0X0001) | (state.LFSR_hi[5] << 1)); +// +// // F_(X1, X2) +//// W1 = R1 + X1; +// add32(R1[0], R1[1], X1[0], X1[1], W1); // W1 = R1 + X1 +//// W2 = R2 ^ X2; +// xor32(R2[0], R2[1], X2[0], X2[1], W2); // W2 = R2 ^ X2 +// +//// U = L1((W1 << 16) | (W2 >>> 16)); +// // U = L1((W1<<16)|(W2>>>16)) → lo=W2_hi, hi=W1_lo +// L1(W2[1], W1[0], U); +// +//// V = L2((W2 << 16) | (W1 >>> 16)); +// // V = L2((W2<<16)|(W1>>>16)) → lo=W1_hi, hi=W2_lo +// L2(W1[1], W2[0], V); +// +//// R1 = makeU32(Zuc256Tables.S0[(U >>> 24) & 0xFF], +//// Zuc256Tables.S1[(U >>> 16) & 0xFF], +//// Zuc256Tables.S0[(U >>> 8) & 0xFF], +//// Zuc256Tables.S1[U & 0xFF]); +// makeU32( +// (short)(Zuc256Tables.S0[((U[1] >>> 8) & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S1[(U[1] & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S0[((U[0] >>> 8) & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S1[(U[0] & 0xFF)] & 0xFF), +// R1); +// +//// R2 = makeU32(Zuc256Tables.S0[(V >>> 24) & 0xFF], +//// Zuc256Tables.S1[(V >>> 16) & 0xFF], +//// Zuc256Tables.S0[(V >>> 8) & 0xFF], +//// Zuc256Tables.S1[V & 0xFF]); +// makeU32( +// (short)(Zuc256Tables.S0[((V[1] >>> 8) & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S1[(V[1] & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S0[((V[0] >>> 8) & 0xFF)] & 0xFF), +// (short)(Zuc256Tables.S1[(V[0] & 0xFF)] & 0xFF), +// R2); +// +// // ---- LFSRWithWorkMode ---- +// short[] A = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; // 64位累加器 +// short[] tmp32 = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; +// short[] tmp64 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; +// +// // LFSRWithWorkMode +//// long a = LFSR[0]; +// tmp32[0] = state.LFSR_lo[0]; +// tmp32[1] = state.LFSR_hi[0]; +// create_64b_from_32b(tmp64, tmp32, (short)0); add64(A, tmp64); +// +//// a += (long)LFSR[0] << 8; +// create_64b_from_32b(tmp64, tmp32, (short)8); add64(A, tmp64); +// +//// a += (long)LFSR[4] << 20; +// tmp32[0] = state.LFSR_lo[4]; tmp32[1] = state.LFSR_hi[4]; +// create_64b_from_32b(tmp64, tmp32, (short)20); add64(A, tmp64); +// +//// a += (long)LFSR[10] << 21; +// tmp32[0] = state.LFSR_lo[10]; tmp32[1] = state.LFSR_hi[10]; +// create_64b_from_32b(tmp64, tmp32, (short)21); add64(A, tmp64); +// +//// a += (long)LFSR[13] << 17; +// tmp32[0] = state.LFSR_lo[13]; tmp32[1] = state.LFSR_hi[13]; +// create_64b_from_32b(tmp64, tmp32, (short)17); add64(A, tmp64); +// +//// a += (long)LFSR[15] << 15; +// tmp32[0] = state.LFSR_lo[15]; tmp32[1] = state.LFSR_hi[15]; +// create_64b_from_32b(tmp64, tmp32, (short)15); add64(A, tmp64); +// +//// a = (a & 0x7FFFFFFF) + (a >>> 31); +// short[] low31 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; +// short[] r31 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; +// and64_7FFFFFFF_to32(A, low31); +// shr64u_31(A, r31); +// +// short[] v64 = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; +// add64(v64, low31); +// add64(v64, r31); +// +//// int v = (int) ((a & 0x7FFFFFFF) + (a >>> 31)); +// and64_7FFFFFFF_to32(v64, low31); +// shr64u_31(v64, r31); +// short[] vv = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET);; +// add64(vv, low31); +// add64(vv, r31); +// +// short v_lo = vv[0]; +// short v_hi = (short)(vv[1] & 0x7FFF); +// +//// LFSR左移 +//// System.arraycopy(LFSR, 1, LFSR, 0, 15); +// // LFSR_lo 向左移 +// for (short i = 0; i < (short)15; i++) { +// state.LFSR_lo[i] = state.LFSR_lo[(short)(i + 1)]; +// } +// // LFSR_hi 向左移 +// for (short i = 0; i < (short)15; i++) { +// state.LFSR_hi[i] = state.LFSR_hi[(short)(i + 1)]; +// } +// +//// LFSR[15] = v; +// state.LFSR_lo[15] = v_lo; +// state.LFSR_hi[15] = v_hi; +// +// state.R1_lo = R1[0]; state.R1_hi = R1[1]; +// state.R2_lo = R2[0]; state.R2_hi = R2[1]; +// } +//} +// diff --git a/ref_c_java/zuc256_javacard_old/Zuc256Demo.java b/ref_c_java/zuc256_javacard_old/Zuc256Demo.java new file mode 100644 index 0000000..ce8bba7 --- /dev/null +++ b/ref_c_java/zuc256_javacard_old/Zuc256Demo.java @@ -0,0 +1,66 @@ +//package com.cscn; +// +///** +// * 演示主函数 +// */ +//public final class Zuc256Demo { +// +// public static void main(String[] args) { +// // 1. 明文 +// byte[] plaintext = "ZUC256对称加解密测试:1234567890".getBytes(); +// int plaintextLen = plaintext.length; +// System.out.println("明文: " + new String(plaintext)); +// printHex("明文(十六进制)", plaintext, plaintextLen); +// +// // 2. 密钥(32字节ASCII) +// byte[] key = "0123456789abcdef0123456789abcdef".getBytes(); +// printHex("密钥", key, 32); +// +// // 3. 初始向量(25字节ASCII) +// byte[] inputIv25Byte = "0123456789abcdefg01234567".getBytes(); +// byte[] iv = new byte[23]; +// extractIv(inputIv25Byte, iv); +// printHex("提取后的IV", iv, 23); +// +// // 4. 分配加密/解密缓冲区 +// byte[] ciphertext = new byte[plaintextLen]; +// byte[] decryptedtext = new byte[plaintextLen]; +// +// // 5. 加密 +// Zuc256State stateEnc = new Zuc256State(); +// Zuc256Core.initState(stateEnc, key, iv); +// zuc256Crypt(stateEnc, plaintext, plaintextLen, ciphertext); +// printHex("密文", ciphertext, plaintextLen); +// +// // 6. 解密(重新初始化状态) +// Zuc256State stateDec = new Zuc256State(); +// Zuc256Core.initState(stateDec, key, iv); +// zuc256Crypt(stateDec, ciphertext, plaintextLen, decryptedtext); +// printHex("解密后", decryptedtext, plaintextLen); +// System.out.println("解密文本: " + new String(decryptedtext)); +// +// // 7. 验证结果 +// if (Arrays.equals(plaintext, decryptedtext)) { +// System.out.println("=== 测试成功: 解密结果与明文一致 ==="); +// } else { +// System.out.println("=== 测试失败: 解密结果与明文不一致 ==="); +// } +// } +// +// // 一次性加密 +// public static void zuc256Crypt(Zuc256State state, byte[] in, int inlen, byte[] out) { +// if (state == null || in == null || out == null) return; +// +// Zuc256EncryptCtx ctx = new Zuc256EncryptCtx(state); +// +// // 执行加解密 +// ctx.update(in, inlen, out); +// int remainingOffset = (inlen / 4) * 4; +// byte[] finishOut = new byte[out.length - remainingOffset]; +// if (finishOut.length > 0) { +// System.arraycopy(out, remainingOffset, finishOut, 0, finishOut.length); +// } +// ctx.finish(finishOut); +// System.arraycopy(finishOut, 0, out, remainingOffset, finishOut.length); +// } +//} diff --git a/ref_c_java/zuc256_javacard_old/Zuc256EncryptCtx.java b/ref_c_java/zuc256_javacard_old/Zuc256EncryptCtx.java new file mode 100644 index 0000000..7c675ff --- /dev/null +++ b/ref_c_java/zuc256_javacard_old/Zuc256EncryptCtx.java @@ -0,0 +1,214 @@ +//package com.cscn; +// +//import javacard.framework.JCSystem; +//import javacard.framework.Util; +// +//import static com.cscn.Zuc256Core.zuc256GenerateKeystream; +//import static com.cscn.Zuc256Core.zuc256GenerateKeyword; +//import static com.cscn.Zuc256Util.getU32; +//import static com.cscn.Zuc256Util.putU32; +//import static com.cscn.Zuc256Util.xor32; +// +// +///** +// * 加密上下文类 +// */ +//public final class Zuc256EncryptCtx { +// Zuc256State state; +// byte[] buf; +// short buflen; +// +// public Zuc256EncryptCtx(Zuc256State state, byte[] buf){ +// this.state = state; +// this.buf = buf; +// } +// +// public Zuc256EncryptCtx(Zuc256State state){ +// this.state = state; +// this.buf = JCSystem.makeTransientByteArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// } +// +// public Zuc256EncryptCtx(){ +// this.state = new Zuc256State(); //todo how to put in ram? +// this.buf = JCSystem.makeTransientByteArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// } +// +// // 初始化加密上下文 +// public void initZuc256EncryptCtx(byte[] key32, byte[] iv) { +//// Arrays.fill(this.buf, (byte) 0); +// for (short i = 0; i < (short)this.buf.length; i++) { +// this.buf[i] = (byte)0; +// } +// this.buflen = 0; +// Zuc256Core.initState(this.state, key32, iv); +// } +// +// // 分阶段处理加密数据 +// public void updateZuc256EncryptCtx(byte[] in, short inlen, byte[] out) { +// if (in == null || out == null || inlen == 0) return; +// +// short inPos = 0; // 输入偏移 +// short outPos = 0; // 输出偏移 +// +// // 处理缓冲区中剩余的非4字节数据 +// if (this.buflen > 0) { +//// int need = 4 - this.buflen; +// short need = (short)(4 - this.buflen); +//// int copy = Math.min(inlen, need); +// short copy = (short)((inlen < need) ? inlen : need); +// +// // 替代 System.arraycopy(in, 0, this.buf, this.buflen, copy); +// Util.arrayCopyNonAtomic(in, (short)0, this.buf, this.buflen, copy); +// +// this.buflen += copy; +// +// // 调整输入指针和长度 +//// byte[] newIn = new byte[inlen - copy]; +//// if (inlen - copy > 0) { +//// System.arraycopy(in, copy, newIn, 0, inlen - copy); +//// } +//// in = newIn; +//// inlen -= copy; +// // 推进输入指针与剩余长度 +// inPos += copy; +// inlen -= copy; +// +// // 缓冲区已满,处理一个完整的4字节块 +// if (this.buflen == 4) { +//// int keystream = zuc256GenerateKeyword(this.state); +// short[] ks = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// zuc256GenerateKeyword(this.state, ks); // ks[0]=lo, ks[1]=hi +// +//// int plain = getU32(this.buf, 0); +// // 取出 4 字节明文 → plain[0]=lo, plain[1]=hi +// short[] plain = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// getU32(this.buf, (short)0, plain); +// +//// putU32(out, 0, plain ^ keystream); +// // plain ^ ks → res +// short[] res = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// xor32(plain[0], plain[1], ks[0], ks[1], res); +// // 写回 out 的前4字节 +// putU32(out, (short)0, res[0], res[1]); +// +// this.buflen = 0; +//// Arrays.fill(this.buf, (byte) 0); +// for (short i = 0; i < (short)this.buf.length; i++) { +// this.buf[i] = (byte)0; +// } +// +// // 调整输出指针 +//// byte[] newOut = new byte[out.length - 4]; +//// if (out.length - 4 > 0) { +//// System.arraycopy(out, 4, newOut, 0, out.length - 4); +//// } +//// out = newOut; +// // 这里C实现就是直接指针+4的。JavaSE实现搞这个new干嘛。。 +// outPos += 4; +// } +// } +// +// // 处理完整的4字节块 +//// int fullBlocks = inlen / 4; +// short fullBlocks = (short) (inlen / 4); +// if (fullBlocks > 0) { +//// int[] keystream = new int[fullBlocks]; +// short[] ks_hi = JCSystem.makeTransientShortArray(fullBlocks, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] ks_lo = JCSystem.makeTransientShortArray(fullBlocks, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +//// zuc256GenerateKeystream(this.state, fullBlocks, keystream); +// zuc256GenerateKeystream(this.state, fullBlocks, ks_hi, ks_lo); +// +// // 临时:装一个32位字 +// short[] word = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// // 逐块异或加密 +// for (short i = 0; i < fullBlocks; i++) { +//// int plain = getU32(in, i * 4); +// short off = (short) (i << 2); // i*4 +// // 读明文 +// getU32(in, (short)(inPos+off), word); // word[0]=lo, word[1]=hi +// +//// putU32(out, i * 4, plain ^ keystream[i]); +// // XOR keystream +// word[0] = (short)(word[0] ^ ks_lo[i]); +// word[1] = (short)(word[1] ^ ks_hi[i]); +// // 写密文 +// putU32(out, (short) (outPos+off), word[0], word[1]); +// } +// +// // 调整输入指针和长度 +//// int processed = fullBlocks * 4; +// short processed = (short)(fullBlocks * 4); +// +//// byte[] newIn = new byte[inlen - processed]; +//// if (inlen - processed > 0) { +//// System.arraycopy(in, processed, newIn, 0, inlen - processed); +//// } +//// in = newIn; +//// inlen -= processed; +// // 推进输入/输出指针与剩余长度 +// inPos += processed; +// inlen -= processed; +// outPos += processed; +// } +// +// // 缓存剩余不足4字节的数据 +// if (inlen > 0) { +// // 等价于 System.arraycopy(in, 0, this.buf, 0, inlen); +// Util.arrayCopyNonAtomic(in, (short)inPos, this.buf, (short)0, inlen); +// +// this.buflen = inlen; +// } +// } +// +// // 完成加密处理 +// public void finishZuc256EncryptCtx(byte[] out) { +// if (out == null) return; +// +// // 处理缓冲区中剩余的不足4字节数据 +// if (this.buflen > 0) { +//// int keystream = zuc256GenerateKeyword(this.state); +// // 生成一个 32-bit 密钥字:ks[0]=lo16, ks[1]=hi16 +// short[] ks = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// zuc256GenerateKeyword(this.state, ks); +// +//// byte[] keystreamBytes = new byte[4]; +//// putU32(keystreamBytes, 0, keystream); +// byte[] keystreamBytes = JCSystem.makeTransientByteArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// putU32(keystreamBytes, (short)0, ks[0], ks[1]); +// +// // 逐字节异或 +// short outOffset = (short)(out.length - this.buflen); +// for (short i = 0; i < this.buflen; i++) { +// out[(short)(i+outOffset)] = (byte) (this.buf[i] ^ keystreamBytes[i]); +// } +// } +// +// +// +// // 清理上下文 +//// Arrays.fill(this.buf, (byte) 0); +// for(short i=0; i<4; i++) { +// this.buf[i] = (byte)0; +// } +// +// this.buflen = 0; +// +//// Arrays.fill(this.state.LFSR, 0); +// // LFSR 全部清零(高低位数组各 16 个元素) +// for (short i = 0; i < 16; i++) { +// this.state.LFSR_lo[i] = 0; +// this.state.LFSR_hi[i] = 0; +// } +// +// +//// this.state.R1 = 0; +//// this.state.R2 = 0; +//// R1、R2 清零 +// this.state.R1_lo = 0; +// this.state.R1_hi = 0; +// this.state.R2_lo = 0; +// this.state.R2_hi = 0; +// } +//} diff --git a/ref_c_java/zuc256_javacard_old/Zuc256MacCtx.java b/ref_c_java/zuc256_javacard_old/Zuc256MacCtx.java new file mode 100644 index 0000000..fc53e8b --- /dev/null +++ b/ref_c_java/zuc256_javacard_old/Zuc256MacCtx.java @@ -0,0 +1,32 @@ +//package com.cscn; +// +///** +// * MAC上下文类(JavaCard版,int 拆分为两个 short) +// */ +//public final class Zuc256MacCtx { +// // LFSR: 原本 int[16],拆成 hi/lo 各 16 short +// short[] LFSR_hi = JCSystem.makeTransientShortArray((short)16, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// //todo -> ram +// short[] LFSR_lo = JCSystem.makeTransientShortArray((short)16, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// // R1、R2: 原本 int,拆成 hi/lo +// short R1_hi; +// short R1_lo; +// short R2_hi; +// short R2_lo; +// +// // 缓冲区 +// byte[] buf = JCSystem.makeTransientByteArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short buflen; +// +// // T: 原本 int[4],拆成 hi/lo +// short[] T_hi = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] T_lo = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// // K0: 原本 int[4],拆成 hi/lo +// short[] K0_hi = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] K0_lo = JCSystem.makeTransientShortArray((short)4, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// // macbits: 原本 int,改成 short 足够 +// short macbits; +//} diff --git a/ref_c_java/zuc256_javacard_old/Zuc256State.java b/ref_c_java/zuc256_javacard_old/Zuc256State.java new file mode 100644 index 0000000..14640d6 --- /dev/null +++ b/ref_c_java/zuc256_javacard_old/Zuc256State.java @@ -0,0 +1,25 @@ +//package com.cscn; +// +///** +// * ZUC状态类(JavaCard版,int 拆为 hi/lo short) +// */ +//public class Zuc256State { +// // LFSR: 原 int[16] -> hi/lo 各 16 +// public short[] LFSR_hi; +// public short[] LFSR_lo; +// +// // R1, R2: 原 int -> hi/lo +// public short R1_hi; +// public short R1_lo; +// public short R2_hi; +// public short R2_lo; +// +// public Zuc256State() { +// this.LFSR_hi = JCSystem.makeTransientShortArray((short)16, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// this.LFSR_lo = JCSystem.makeTransientShortArray((short)16, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// } +// public Zuc256State(short[] LSFR_HIGH, short[] LSFR_LOW) { +// this.LFSR_hi = LSFR_HIGH; +// this.LFSR_lo = LSFR_LOW; +// } +//} diff --git a/ref_c_java/zuc256_javacard_old/Zuc256Util.java b/ref_c_java/zuc256_javacard_old/Zuc256Util.java new file mode 100644 index 0000000..a000336 --- /dev/null +++ b/ref_c_java/zuc256_javacard_old/Zuc256Util.java @@ -0,0 +1,497 @@ +//package com.cscn; +// +//import javacard.framework.Util; +//import javacard.framework.JCSystem; +// +///** +// * 辅助工具:装载/存储、位运算、线性变换、打印等。 +// */ +//public final class Zuc256Util { +// +// private Zuc256Util() {} +// +//// /** 辅助方法:将字节数组转换为32位整数 */ +//// public static int getU32(byte[] p, int offset) { +//// return ((p[offset] & 0xFF) << 24) | +//// ((p[offset + 1] & 0xFF) << 16) | +//// ((p[offset + 2] & 0xFF) << 8) | +//// (p[offset + 3] & 0xFF); +//// } +// /** 辅助方法:从字节数组取出 32 位整数,存放到 short[2] (lo, hi) */ +// public static void getU32(byte[] p, short offset, short[] out32 /* len=2 */) { +// out32[0] = (short) (((p[(short)(offset + 2)] & 0xFF) << 8) | (p[(short)(offset + 3)] & 0xFF)); //低16位 +// out32[1] = (short) (((p[offset] & 0xFF) << 8) | (p[(short)(offset + 1)] & 0xFF)); //高16位 +// } +// +// +//// /** 辅助方法:将32位整数转换为字节数组 */ +//// public static void putU32(byte[] p, int offset, int v) { +//// p[offset] = (byte) (v >> 24); +//// p[offset + 1] = (byte) (v >> 16); +//// p[offset + 2] = (byte) (v >> 8); +//// p[offset + 3] = (byte) v; +//// } +// /** 辅助方法:将32位整数(vlo=低16位, vhi=高16位)写入字节数组 */ +// public static void putU32(byte[] p, short offset, short vlo, short vhi) { +// // 写高16位 +// p[offset] = (byte) ((vhi >> 8) & 0xFF); +// p[(short)(offset + 1)] = (byte) (vhi & 0xFF); +// +// // 写低16位 +// p[(short)(offset + 2)] = (byte) ((vlo >> 8) & 0xFF); +// p[(short)(offset + 3)] = (byte) (vlo & 0xFF); +// } +// +// +// // === 31/32 位运算 === +// +//// /** 31位加法 */ +//// public static int add31(int a, int b) { +//// long sum = (long)a + b; +//// return (int) ((sum & 0x7FFFFFFF) + (sum >> 31)); +//// } +// /** 31位加法: (a+b) mod (2^31 - 1) +// * 输入: a_lo=低16位, a_hi=高15位 +// * b_lo=低16位, b_hi=高15位 +// * 输出: out[0]=lo, out[1]=hi +// */ +// public static void add31(short a_lo, short a_hi, short b_lo, short b_hi, short[] out /* len==2 */) { +// // ---- 低16位相加 ---- +// short lo = (short)(a_lo + b_lo); +// short carry = (short)( +// ( ( (short)( (a_lo & b_lo) | ((a_lo | b_lo) & (short)~lo) ) ) & (short)0x8000 ) != 0 +// ? 1 : 0 +// ); +// // ---- 高15位相加 + 进位 ---- +// short hi_raw = (short)((short)((a_hi & 0x7FFF) + (b_hi & 0x7FFF)) + carry); +// +// // 提取第31位(hi_raw bit15) +// short topbit = (short)((hi_raw >>> 15) & 1); +// short hi = (short)(hi_raw & 0x7FFF); // 保留15位 +// +// // ---- 若第31位=1,再+1 ---- +// if (topbit == 1) { +// short lo2 = (short)(lo + 1); +// short c2 = (short)((lo2 == 0) ? 1 : 0); // lo溢出时进位 +// lo = lo2; +// hi = (short)((hi + c2) & 0x7FFF); +// } +// +// out[0] = lo; +// out[1] = hi; +// } +// +// +//// /** 31位旋转 */ +//// public static int rot31(int a, int k) { +//// return ((a << k) | (a >>> (31 - k))) & 0x7FFFFFFF; +//// } +// /** 31位循环左移: (a <<< k) mod (2^31 -1) +// * 输入: a_lo=低16位, a_hi=高15位 +// * 输出: out[0]=lo, out[1]=hi +// */ +// public static void rot31(short a_lo, short a_hi, short k, short[] out /* len==2 */) { +// k = (short)(k % 31); // 限制在 0..30 +// if (k == 0) { +// out[0] = a_lo; +// out[1] = (short)(a_hi & 0x7FFF); +// return; +// } +// +// // 拆成 31 位数组 [bit0..bit30] +// short[] bits = JCSystem.makeTransientShortArray((short)31, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// for (short i = 0; i < 16; i++) { +// bits[i] = (short)((a_lo >>> i) & 1); +// } +// for (short i = 0; i < 15; i++) { +// bits[(short)(16 + i)] = (short)((a_hi >>> i) & 1); +// } +// +// // 旋转 +// short[] resBits = JCSystem.makeTransientShortArray((short)31, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// for (short i = 0; i < 31; i++) { +// short j = (short)((i + k) % 31); +// resBits[j] = bits[i]; +// } +// +// // 拼回 lo, hi +// short lo = 0; +// for (short i = 0; i < 16; i++) { +// lo = (short)(lo | (resBits[i] << i)); +// } +// short hi = 0; +// for (short i = 0; i < 15; i++) { +// hi = (short)(hi | (resBits[(short)(16 + i)] << i)); +// } +// +// out[0] = lo; +// out[1] = hi; +// } +// +// +//// /** 32位旋转 */ +//// public static int rot32(int a, int k) { +//// return (a << k) | (a >>> (32 - k)); +//// } +// /** 32位循环左移: (a<< 0) { +// // 先做 1 位循环左移 +// // 注意:short 在 >>> 时会先提升为 int,所以下面都再用 &1 取最低位,避免符号扩展影响 +// nw_hi = (short)((hi << 1) | ((lo >>> 15) & 1)); +// nw_lo = (short)((lo << 1) | ((hi >>> 15) & 1)); +// hi = nw_hi; +// lo = nw_lo; +// k--; +// } +// out[0] = lo; // 低16位 +// out[1] = hi; // 高16位 +// } +// +// +//// /** +//// * L1函数 +//// */ +//// public static int L1(int x) { +//// return x ^ rot32(x, 2) ^ rot32(x, 10) ^ rot32(x, 18) ^ rot32(x, 24); +//// } +// /** +// * L1函数: x ^ (x<<<2) ^ (x<<<10) ^ (x<<<18) ^ (x<<<24) +// * 输入: x_lo, x_hi +// * 输出: out[0]=lo, out[1]=hi +// */ +// public static void L1(short x_lo, short x_hi, short[] out /*len==2*/) { +// short[] t = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] acc = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// // acc = x +// acc[0] = x_lo; +// acc[1] = x_hi; +// +// // acc ^= rot32(x, 2) +// rot32(x_lo, x_hi, (short)2, t); +// acc[0] ^= t[0]; +// acc[1] ^= t[1]; +// +// // acc ^= rot32(x, 10) +// rot32(x_lo, x_hi, (short)10, t); +// acc[0] ^= t[0]; +// acc[1] ^= t[1]; +// +// // acc ^= rot32(x, 18) +// rot32(x_lo, x_hi, (short)18, t); +// acc[0] ^= t[0]; +// acc[1] ^= t[1]; +// +// // acc ^= rot32(x, 24) +// rot32(x_lo, x_hi, (short)24, t); +// acc[0] ^= t[0]; +// acc[1] ^= t[1]; +// +// out[0] = acc[0]; +// out[1] = acc[1]; +// } +// +// +//// /** +//// * L2函数 +//// */ +//// public static int L2(int x) { +//// return x ^ rot32(x, 8) ^ rot32(x, 14) ^ rot32(x, 22) ^ rot32(x, 30); +//// } +// /** +// * L2函数: x ^ (x<<<8) ^ (x<<<14) ^ (x<<<22) ^ (x<<<30) +// * 输入: x_lo, x_hi +// * 输出: out[0]=lo, out[1]=hi +// */ +// public static void L2(short x_lo, short x_hi, short[] out /*len==2*/) { +// short[] t = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// short[] acc = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// // acc = x +// acc[0] = x_lo; +// acc[1] = x_hi; +// +// // acc ^= rot32(x, 8) +// rot32(x_lo, x_hi, (short)8, t); +// acc[0] ^= t[0]; +// acc[1] ^= t[1]; +// +// // acc ^= rot32(x, 14) +// rot32(x_lo, x_hi, (short)14, t); +// acc[0] ^= t[0]; +// acc[1] ^= t[1]; +// +// // acc ^= rot32(x, 22) +// rot32(x_lo, x_hi, (short)22, t); +// acc[0] ^= t[0]; +// acc[1] ^= t[1]; +// +// // acc ^= rot32(x, 30) +// rot32(x_lo, x_hi, (short)30, t); +// acc[0] ^= t[0]; +// acc[1] ^= t[1]; +// +// out[0] = acc[0]; +// out[1] = acc[1]; +// } +// +// +//// /** 创建31位无符号整数 */ +//// public static int makeU31(int a, int b, int c, int d) { +//// return (((a & 0xFF) << 23) | +//// ((b & 0xFF) << 16) | +//// ((c & 0xFF) << 8) | +//// (d & 0xFF)) & 0x7FFFFFFF; +//// } +// /** 创建31位无符号整数,结果放到 out[0]=lo, out[1]=hi(15位) */ +// public static void makeU31(short a, short b, short c, short d, short[] out /*len==2*/) { +// // 四个字节 +// short b0 = (short)(a & 0xFF); // 最高字节 +// short b1 = (short)(b & 0xFF); +// short b2 = (short)(c & 0xFF); +// short b3 = (short)(d & 0xFF); // 最低字节 +// +// // 拼成 32 位: b0<<24 | b1<<16 | b2<<8 | b3 +// // lo = 低16位 +// out[0] = (short)((b2 << 8) | b3); +// +// // hi = 高15位(丢弃 bit31) +// out[1] = (short)((b0 << 7) | b1); +// } +// +// +//// /** 创建32位无符号整数 */ +//// public static int makeU32(int a, int b, int c, int d) { +//// return ((a & 0xFF) << 24) | +//// ((b & 0xFF) << 16) | +//// ((c & 0xFF) << 8) | +//// (d & 0xFF); +//// } +// /** 创建32位无符号整数,结果放到 out[0]=lo, out[1]=hi */ +// public static void makeU32(short a, short b, short c, short d, short[] out /*len==2*/) { +// // 四个字节 +// short b0 = (short)(a & 0xFF); // 最高字节 +// short b1 = (short)(b & 0xFF); +// short b2 = (short)(c & 0xFF); +// short b3 = (short)(d & 0xFF); // 最低字节 +// +// // lo = 低16位 +// out[0] = (short)((b2 << 8) | b3); +// +// // hi = 高16位 +// out[1] = (short)((b0 << 8) | b1); +// } +// +// +// +// /** 提取IV */ +// public static void extractIv(byte[] input25Byte, byte[] output23Byte) { +// if (input25Byte == null || output23Byte == null) return; +// +// // 复制前17字节 +// Util.arrayCopyNonAtomic(input25Byte, (short)0, output23Byte, (short)0, (short)17); +// +// +// // 处理剩余8字节 +// byte[] src = JCSystem.makeTransientByteArray((short)8, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// for (short i = 0; i < 8; i++) { +// src[i] = (byte) (input25Byte[(short)(17 + i)] & 0x3F); +// } +// +// output23Byte[17] = (byte) ((src[0] << 2) | (src[1] >>> 4)); +// output23Byte[18] = (byte) (((src[1] & 0x0F) << 4) | (src[2] >>> 2)); +// output23Byte[19] = (byte) (((src[2] & 0x03) << 6) | src[3]); +// output23Byte[20] = (byte) ((src[4] << 2) | (src[5] >>> 4)); +// output23Byte[21] = (byte) (((src[5] & 0x0F) << 4) | (src[6] >>> 2)); +// output23Byte[22] = (byte) (((src[6] & 0x03) << 6) | src[7]); +// } +// +// /** +// * 32位加法: (a_hi:a_lo) + (b_hi:b_lo) +// * out[0] = lo, out[1] = hi +// */ +// static void add32(short a_lo, short a_hi, +// short b_lo, short b_hi, +// short[] out /*len=2*/) { +// +// // ---- 低16位 ---- +// short lo_low = (short)((a_lo & 0x00FF) + (b_lo & 0x00FF)); +// short carry0 = (short)(((a_lo & 0x00FF) + (b_lo & 0x00FF)) >>> 8); +// +// short a_lo_hi = (short)((a_lo >>> 8) & 0x00FF); +// short b_lo_hi = (short)((b_lo >>> 8) & 0x00FF); +// short lo_high = (short)(a_lo_hi + b_lo_hi + carry0); +// short carry1 = (short)(lo_high >>> 8); +// +// short lo_res = (short)((lo_high << 8) | (lo_low & 0x00FF)); +// +// // ---- 高16位 ---- +// short hi_low = (short)((a_hi & 0x00FF) + (b_hi & 0x00FF) + carry1); +// short carry2 = (short)(hi_low >>> 8); +// +// short a_hi_hi = (short)((a_hi >>> 8) & 0x00FF); +// short b_hi_hi = (short)((b_hi >>> 8) & 0x00FF); +// short hi_high = (short)(a_hi_hi + b_hi_hi + carry2); +// +// short hi_res = (short)((hi_high << 8) | (hi_low & 0x00FF)); +// +// // ---- 输出 ---- +// out[0] = lo_res; +// out[1] = hi_res; +// } +// +// /** +// * 32位加法 + 返回进位(只用 short) +// * 输入: (a_hi:a_lo) + (b_hi:b_lo) +// * 输出: out[0]=lo, out[1]=hi +// * 返回: 最终进位(0/1) +// */ +// static short add32_with_carry(short a_lo, short a_hi, +// short b_lo, short b_hi, +// short[] out /* len=2 */) { +// // ---- 低16位:分两段8位相加 ---- +// short s0 = (short)((a_lo & (short)0x00FF) + (b_lo & (short)0x00FF)); // 0..510 +// short c0 = (short)(s0 >>> 8); // 0/1 +// short s1 = (short)(((a_lo >>> 8) & (short)0x00FF) +// + ((b_lo >>> 8) & (short)0x00FF) +// + c0); // 0..511 +// short c1 = (short)(s1 >>> 8); // 0/1 +// short lo = (short)((s1 << 8) | (s0 & (short)0x00FF)); +// +// // ---- 高16位:再分两段8位相加,并加上 c1 ---- +// short s2 = (short)((a_hi & (short)0x00FF) + (b_hi & (short)0x00FF) + c1); +// short c2 = (short)(s2 >>> 8); // 0/1 +// short s3 = (short)(((a_hi >>> 8) & (short)0x00FF) +// + ((b_hi >>> 8) & (short)0x00FF) +// + c2); // 0..511 +// short c3 = (short)(s3 >>> 8); // 最终进位 0/1 +// short hi = (short)((s3 << 8) | (s2 & (short)0x00FF)); +// +// out[0] = lo; +// out[1] = hi; +// return (short)(c3 & 1); +// } +// +// +// +// /** +// * 64位加法: a4 + b4 -> a4 +// * 输入输出: short[4],低到高 (a[0]=lo16, a[1]=hi16, a[2]=lo16 of high dword, a[3]=hi16 of high dword) +// */ +// static void add64(short[] a, short[] b) { +// short[] tmp = JCSystem.makeTransientShortArray((short)2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET); +// +// // 低 32 位 +// short carry = add32_with_carry(a[0], a[1], b[0], b[1], tmp); +// a[0] = tmp[0]; +// a[1] = tmp[1]; +// +// // 高 32 位 + carry +// add32((short)(a[2] + (short)(carry & (short)0x0001)), a[3], b[2], b[3], tmp); +// a[2] = tmp[0]; +// a[3] = tmp[1]; +// } +// +// +// +// // 32位异或 +// public static void xor32(short a_lo, short a_hi, short b_lo, short b_hi, short[] out /*len==2*/) { +// out[0] = (short)(a_lo ^ b_lo); +// out[1] = (short)(a_hi ^ b_hi); +// } +// +// /** +// * 把32位数 b (b[0]=lo, b[1]=hi) 左移 k 位 (0 <= k < 32), +// * 结果放到64位数 a (a[0]=最低16位 ... a[3]=最高16位)。 +// */ +// static void create_64b_from_32b(short[] a/*len=4*/, short[] b/*len=2*/, short k) { +// short a0 = b[0], a1 = b[1], a2 = 0, a3 = 0; +// +// if (k >= 16) { +// a3 = a2; // 0 +// a2 = a1; // 原 hi16 +// a1 = a0; // 原 lo16 +// a0 = 0; +// k = (short)(k - 16); +// } +// +// while (k > 0) { +// short c0 = (short)((a0 >>> 15) & 1); +// short c1 = (short)((a1 >>> 15) & 1); +// short c2 = (short)((a2 >>> 15) & 1); +// +// a3 = (short)((a3 << 1) | c2); +// a2 = (short)((a2 << 1) | c1); +// a1 = (short)((a1 << 1) | c0); +// a0 = (short)(a0 << 1); +// k--; +// } +// +// a[0] = a0; a[1] = a1; a[2] = a2; a[3] = a3; +// } +// +// +// /** +// * (A & 0x7FFFFFFF),结果放在 out[4],只保留低32位并清掉最高bit。 +// */ +// static void and64_7FFFFFFF_to32(short[] A, short[] out) { +// out[0] = A[0]; // lo16 +// out[1] = (short)(A[1] & 0x7FFF); // hi16 (清除最高bit) +// out[2] = 0; +// out[3] = 0; +// } +// +// /** +// * 64位无符号右移 31 位 +// * 输入: A[0..3] (short[4], A[0]最低16位) +// * 输出: out[0..3] +// */ +// static void shr64u_31(short[] A, short[] out) { +// // 先拼出 64bit 的逻辑,逐段右移 +// // A >>> 31 = (A >>> 16) >>> 15 +// +// // 先右移 16,相当于丢掉 A[0],整体右移一半字 +// out[0] = A[1]; // 原 A[1] -> 新低16位 +// out[1] = A[2]; // 原 A[2] +// out[2] = A[3]; // 原 A[3] +// out[3] = 0; // 高位补0 +// +// // 再右移 15 位 +// short c0 = (short)((out[0] & (short)0xFFFF) >>> 15); // out[0] 最后一位变进位 +// short c1 = (short)((out[1] & (short)0xFFFF) >>> 15); +// short c2 = (short)((out[2] & (short)0xFFFF) >>> 15); +// +// out[0] = (short)((c0 & 0x0001) | (out[1] << 1)); +// out[1] = (short)((c1 & 0x0001) | (out[2] << 1)); +// out[2] = (short)(c2 & 0x0001); +// } +// +// /** +// * 32位无符号右移 1 位 +// * 输入: lo,hi (short) 表示 32 位数 (hi:高16位, lo:低16位) +// * 输出: out[0]=lo, out[1]=hi +// */ +// static void shr32u1(short lo, short hi, short[] out) { +// // >>>1:先处理低16位 +// short nwLo = (short)(((((lo & (short)0xFFFF) >>> 1) & (short)0x7FFF)) | ((hi & 0x0001) << 15)); +// short nwHi = (short)(((hi & (short)0xFFFF) >>> 1) & (short)0x7FFF); +// +// out[0] = nwLo; +// out[1] = nwHi; +// } +// +// +// +// +// /** 打印/*十六进制(调试用,TODO 生产/JC 环境可移除) *//* +// public static void printHex(String label, byte[] data, int len) { +// System.out.print(label + ": "); +// for (int i = 0; i < len; i++) { +// System.out.printf("%02x ", data[i] & 0xFF); +// } +// System.out.println(); +// }*/ +//}