|
| 1 | +---------------------------------------------------------------------------------------------------- |
| 2 | +Copyright 2020 Brian Carey |
| 3 | +---------------------------------------------------------------------------------------------------- |
| 4 | +Tiny Encryption Algorithm (TEA) - Java Implementation |
| 5 | +For the JAVA class "TEAProgram.java" |
| 6 | +---------------------------------------------------------------------------------------------------- |
| 7 | +Licensing: |
| 8 | +---------------------------------------------------------------------------------------------------- |
| 9 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | +you may not use this file except in compliance with the License. |
| 11 | +You may obtain a copy of the License at |
| 12 | + |
| 13 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | + |
| 15 | +Unless required by applicable law or agreed to in writing, software |
| 16 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | +See the License for the specific language governing permissions and |
| 19 | +limitations under the License. |
| 20 | +---------------------------------------------------------------------------------------------------- |
| 21 | +NOTICE: |
| 22 | +---------------------------------------------------------------------------------------------------- |
| 23 | +The "TEA" ("Tiny Encryption") Algorithm and the successor "Corrected Block TEA" also known as |
| 24 | +"XXTEA or XTEA" was published 1994-1998 by Roger Needham, and David Wheeler. Roger Needham, and |
| 25 | +David Wheeler are here by understood and given complete recognition as the designers of the |
| 26 | +Tiny Encryption Algorithm that is being used in this program. |
| 27 | +---------------------------------------------------------------------------------------------------- |
| 28 | +Using this Program: |
| 29 | +---------------------------------------------------------------------------------------------------- |
| 30 | +1) *PLAINTEXT* |
| 31 | + |
| 32 | +For example, given the plaintext of: 0x12345678abcdef00 (Entries must be in hex) 64-bit max |
| 33 | + |
| 34 | +Split into left and right .... Left or "lText" ---> 0x01ca4567 | 0x0cabcdef <--- Right or "rText" |
| 35 | + ^ ^ |
| 36 | + | | |
| 37 | + (32-bits) + (32-bits) = 64-bits toal |
| 38 | + |
| 39 | +Where, "lText" contains the left block of the 64 bit plain text, 32-bits total |
| 40 | + |
| 41 | + static int lText = 0x01ca4567; <---- Left Text Block In Hex |
| 42 | + |
| 43 | + and, "rText" contains the right block of the 64 bit plain text, 32-bits total |
| 44 | + |
| 45 | + static int rText = 0x0cabcdef; <---- Right Text Block In Hex |
| 46 | + |
| 47 | + |
| 48 | +2) *KEY* |
| 49 | + |
| 50 | +For example, given the key of: 0xa56babcdffffffffffffffffabcdef01 (Key must be in hex) 128-bit max |
| 51 | + |
| 52 | +Enter key into the given array in 32 bit segments, must include "0x" in front of each segment |
| 53 | + |
| 54 | + static int key[] = {0xa56babcd, 0xffffffff, 0xffffffff, 0xabcdef01}; // 128-Bit Key |
| 55 | + ^ ^ ^ ^ |
| 56 | + | + | + | + | |
| 57 | + key[0](32-bits) key[1](32-bits) key[2](32-bits) key[3](32-bits) = 128 bits total |
| 58 | + |
| 59 | +3) Compile and run, must include package "com.Brian.TeaProgram;" in order to run |
| 60 | + |
| 61 | +***Since they keys and the the plaintext are NOT given by random I have attached some at the bottom |
| 62 | +to use these keys can also be found online or generated. |
| 63 | +---------------------------------------------------------------------------------------------------- |
| 64 | + |
| 65 | +Examples: Cyphertext generated is NOT random. You can use these examples for experimental purposes. |
| 66 | + |
| 67 | +---------------------------------------------------------------------------------------------------- |
| 68 | + | |
| 69 | +Plaintext: 0x123456789abcdef | |
| 70 | + | |
| 71 | +Key: 0xa56babcdf000ffffffffffffabcdef01 | |
| 72 | + | |
| 73 | +Cyphertext: 0x7556391b2315d9f8 | |
| 74 | + | |
| 75 | +----------------------------------------| |
| 76 | + | |
| 77 | +Plaintext: 0x123456789abcdef | |
| 78 | + | |
| 79 | +Key: 0xa56babcdffffffffffffffffabcdef01 | |
| 80 | + | |
| 81 | +Cyphertext: 0xfe18f8f3fcb8dcd3 | |
| 82 | + | |
| 83 | +----------------------------------------| |
| 84 | + | |
| 85 | +Plaintext: 0x123456789abcdef | |
| 86 | + | |
| 87 | +Key: 0xa56babcdffabffffffffffffabcdef01 | |
| 88 | + | |
| 89 | +Cyphertext: 0x97f78dcf1dba72ba | |
| 90 | +---------------------------------------------------------------------------------------------------- |
| 91 | + |
| 92 | +***This program is in an experimental stage and will be updated in the future. Please send any bugs |
| 93 | +or errors to https://github.com/Bri-dot-dev |
| 94 | + |
| 95 | +---------------------------------------------------------------------------------------------------- |
| 96 | + |
0 commit comments