Are the AES Crypt' C and Java versions incompatible?

Discussion related to AES Crypt, the file encryption software for Windows, Linux, Mac, and Java.
Post Reply
iuricardoso
Posts: 2
Joined: Mon Feb 15, 2016 6:33 pm

Are the AES Crypt' C and Java versions incompatible?

Post by iuricardoso » Tue Feb 16, 2016 12:05 am

Hi,

My English is poor, so I apologize if this question was written with grammatical errors.

I'm trying to use the AES Crypt library in two applications, one coded in C and the other in Java, but the resulting encrypted message is different in both even using the same password coded in the UTF-16 charset. The Java application uses the AES Crypt version 1; the other one coded in C uses version 1.1.

The byte array of password is given below. It's the same for both applications:
[0] 109
[1] 0
[2] 101
[3] 0
[4] 100
[5] 0
[6] 101
[7] 0
[8] 105
[9] 0
[10] 114
[11] 0
[12] 111
[13] 0
[14] 115
[15] 0
[16] 50
[17] 0
[18] 54
[19] 0
[20] 57
[21] 0
[22] 55
[23] 0

The message that is being encrypted is the string "oi" (it means "Hi" in Portuguese). The byte array generated in Java is this one:
[0] 65
[1] 69
[2] 83
[3] 1
[4] 0
[5] -66
[6] 7
[7] 6
[8] 4
[9] -7
[10] 61
[11] -45
[12] 50
[13] 37
[14] 99
[15] 91
[16] -57
[17] 61
[18] -56
[19] 93
[20] 59
[21] -104
[22] 45
[23] -62
[24] -58
[25] -55
[26] 85
[27] 15
[28] -67
[29] 64
[30] 127
[31] 16
[32] 29
[33] -48
[34] 93
[35] -25
[36] -3
[37] -60
[38] -89
[39] 60
[40] 31
[41] -94
[42] 36
[43] 30
[44] 103
[45] 72
[46] 89
[47] -48
[48] 64
[49] -102
[50] 37
[51] -81
[52] 5
[53] 119
[54] 92
[55] -102
[56] -18
[57] -51
[58] -30
[59] 46
[60] -73
[61] 98
[62] -78
[63] -19
[64] 112
[65] -36
[66] 68
[67] -63
[68] -120
[69] -119
[70] -34
[71] -25
[72] 27
[73] -50
[74] -39
[75] -107
[76] 96
[77] -4
[78] 45
[79] 70
[80] -30
[81] 41
[82] 112
[83] -126
[84] -9
[85] 38
[86] 28
[87] 40
[88] 13
[89] 124
[90] -85
[91] 49
[92] 61
[93] 94
[94] -107
[95] -14
[96] -115
[97] -64
[98] -17
[99] -72
[100] -8
[101] -57
[102] 91
[103] -41
[104] 80
[105] 74
[106] -87
[107] -80
[108] -1
[109] 113
[110] 46
[111] -69
[112] -4
[113] -14
[114] -123
[115] -91
[116] -68
[117] 2
[118] 125
[119] -10
[120] -18
[121] -81
[122] 98
[123] 106
[124] 20
[125] 28
[126] -128
[127] -50
[128] 76
[129] -84
[130] -58
[131] 74
[132] 9
[133] 97
[134] -98
[135] -11
[136] -13
[137] 81
[138] -71
[139] 64
[140] 93
[141] -17
[142] -41
[143] 62
[144] 61
[145] -79
[146] 73
[147] -7
[148] -66
[149] 90

and the other one, generated in C, is this:
[0]: 65
[1]: 69
[2]: 83
[3]: 0
[4]: 2
[5]: 19
[6]: 82
[7]: 46
[8]: 125
[9]: 70
[10]: -43
[11]: -120
[12]: -18
[13]: 63
[14]: -87
[15]: 6
[16]: 106
[17]: -37
[18]: 74
[19]: -53
[20]: -14
[21]: 3
[22]: -104
[23]: 68
[24]: -32
[25]: -119
[26]: -58
[27]: -98
[28]: -86
[29]: 117
[30]: -47
[31]: 109
[32]: -89
[33]: -46
[34]: -127
[35]: 46
[36]: 124
[37]: -63
[38]: 57
[39]: -52
[40]: -98
[41]: 66
[42]: 8
[43]: 73
[44]: 30
[45]: -71
[46]: -109
[47]: -122
[48]: -34
[49]: 25
[50]: -95
[51]: -49
[52]: 18
[53]: -72
[54]: 76
[55]: 56
[56]: -93
[57]: -98
[58]: 44
[59]: 102
[60]: 7
[61]: 76
[62]: 62
[63]: -33
[64]: -6
[65]: -97
[66]: 97
[67]: 60
[68]: 86

Why generated bytes are different?
How to solve this problem?

User avatar
paulej
Posts: 524
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: Are the AES Crypt' C and Java versions incompatible?

Post by paulej » Tue Feb 16, 2016 5:39 am

It appears the Java code generates a version 1 file and the C code generates a version 2 file. However, the main reason for so much difference is that near the start of the file are some plaintext tag/value pairs and an encrypted session key and salt value. Thus, even the same file encrypted twice never looks the same --- even if you use the same C code.

iuricardoso
Posts: 2
Joined: Mon Feb 15, 2016 6:33 pm

Re: Are the AES Crypt' C and Java versions incompatible?

Post by iuricardoso » Wed Feb 17, 2016 5:11 pm

Thank you so much for the speedy reply.

So, are the versions different? I am currently using the libraries available on this site: https://www.aescrypt.com/download/

I need two libraries that generate outputs in the same version, one coded in Java and the other coded in C. Could you help me, indicating these two libraries?

User avatar
paulej
Posts: 524
Joined: Sun Aug 23, 2009 7:32 pm
Location: Research Triangle Park, NC, USA
Contact:

Re: Are the AES Crypt' C and Java versions incompatible?

Post by paulej » Thu Feb 18, 2016 8:59 am

You can definitely decrypt anything using the C version. The Java version should be compatible, but maybe it can't read the output from the C code due to being a version behind.

I'd have to test. But, you can easily test. Encrypt a file on Java and C and try to decrypt using the other tool.

Post Reply