Quake II RTX doxygen  1.0 dev
tiny_encryption_algorithm.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2018 Christoph Schied
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18 
19 uvec2
20 encrypt_tea(uvec2 arg)
21 {
22  const uint key[] = {
23  0xa341316c, 0xc8013ea4, 0xad90777d, 0x7e95761e
24  };
25  uint v0 = arg[0], v1 = arg[1];
26  uint sum = 0;
27  uint delta = 0x9e3779b9;
28 
29  #pragma unroll
30  for(int i = 0; i < 16; i++) {
31  //for(int i = 0; i < 32; i++) {
32  sum += delta;
33  v0 += ((v1 << 4) + key[0]) ^ (v1 + sum) ^ ((v1 >> 5) + key[1]);
34  v1 += ((v0 << 4) + key[2]) ^ (v0 + sum) ^ ((v0 >> 5) + key[3]);
35  }
36  return uvec2(v0, v1);
37 }
uint
uint32_t uint
Definition: global_ubo.h:233
encrypt_tea
uvec2 encrypt_tea(uvec2 arg)
Definition: tiny_encryption_algorithm.h:20