CRDPA

Description

CRDPA (ContainedReality’s Data Protection Algorithm)

CRDPA is an ARX cipher with inspirations from SPECK.

CRDPA uses 56 rounds, uses a 256 bit key, and 128 bit block.

The word size is 32 bits to ensure it easily fits on 32 bit CPUs. In theory, this can be changed for the following parameters:

Word Size Block Size Key Size
16 64 128
32 128 256
64 256 512

I don’t know how this would affect the cipher, so I recommend only using 32 bit words.

Disclaimer

If you don’t know what you’re doing or until the cipher has been formally reviewed, just don’t use it. Use AES-256 instead.

I am not responsible for any data loss or security issues, if you choose to use this random cipher rather than AES, it is solely you who’s responsible for damages.

Go source

Full Go Package

Round Function

func round(a uint32, b uint32, c uint32, d uint32, k uint32, k1 uint32) (uint32, uint32, uint32, uint32) {
	a = bits.RotateLeft32(a, -8)
	a ^= k
	a += b

	b = bits.RotateLeft32(b, 3)
	b ^= a

	c = bits.RotateLeft32(c, -13)
	c ^= k1
	c += d

	d = bits.RotateLeft32(d, 7)
	d ^= c

	return b, c, d, a
}

Key Schedule

func keyschedule(key []byte) []uint32 {
	var roundkeys []uint32

	a := binary.LittleEndian.Uint32(key[0:4])
	b := binary.LittleEndian.Uint32(key[4:8])
	c := binary.LittleEndian.Uint32(key[8:12])
	d := binary.LittleEndian.Uint32(key[12:16])
	e := binary.LittleEndian.Uint32(key[16:20])
	f := binary.LittleEndian.Uint32(key[20:24])
	g := binary.LittleEndian.Uint32(key[24:28])
	h := binary.LittleEndian.Uint32(key[28:32])

    // ROUNDS = 56. so 56 * 2 = 112
	for i := 0; i < ROUNDS*2; i++ {
		roundkeys = append(roundkeys, a)

		a, b, c, d = round(a, b, c, d, uint32(i)^h, h)
		e, f, g, h = round(e, f, g, h, uint32(i)^d, d)

		a, e = e, a
	}

	return roundkeys
}

Encryption

func (crdpa *CRDPA) Encrypt(dst, src []byte) {
	a := binary.LittleEndian.Uint32(src[0:4])
	b := binary.LittleEndian.Uint32(src[4:8])
	c := binary.LittleEndian.Uint32(src[8:12])
	d := binary.LittleEndian.Uint32(src[12:16])

	for i := range ROUNDS {
		a, b, c, d = round(a, b, c, d, crdpa.roundkeys[2*i], crdpa.roundkeys[2*i+1])
	}

	binary.LittleEndian.PutUint32(dst[0:4], a)
	binary.LittleEndian.PutUint32(dst[4:8], b)
	binary.LittleEndian.PutUint32(dst[8:12], c)
	binary.LittleEndian.PutUint32(dst[12:16], d)
}

Security

I dunno. You’re kinda on your own figuring that out. I haven’t came up with any way to break it, doesn’t mean you or someone else won’t though.

Test Vectors

Encryption 1

key: 0000000000000000000000000000000000000000000000000000000000000000
plaintext: 41414141424242424343434344444444
ciphertext: 47d77a4a83a835dba98a97922b4dc209

Encryption 2

key: 4141414142424242434343434444444445454545464646464747474748484848
plaintext: 41414141424242424343434344444444
ciphertext: fee297915b1b8a8fdde3926020f15f17

Encryption 3

key: 4141414142424242434343434444444445454545464646464747474748484848
plaintext: 41414141424242424343434344444445
ciphertext: 61886362842efa11f62af400806aa3e3

Encryption 4

key: 6162636465666768696a6b6c6d6e6f707172737475767778797a616263646566
plaintext: 41414141424242424343434344444444
ciphertext: c3d0b3d2819962315c63064045018827

Keyschedule 1

key: 0000000000000000000000000000000000000000000000000000000000000000
0:      00000000
1:      00000000
2:      01000009
3:      0a490012
4:      579c4a71
5:      a758b4ab
6:      a80174c1
7:      efd17180
8:      6f1a2fb6
9:      58d557c1
10:     fca6598c
11:     6a00ab0d
12:     29a99b93
13:     e5f6146b
14:     46c7e227
15:     07946dd8
16:     28659e18
17:     3d7f6a0e
18:     11f2ff61
19:     42cce6a0
20:     caa85ad1
21:     41f78551
22:     ce7913f3
23:     ae474d0e
24:     8a0e5fda
25:     60f7910b
26:     916f0b12
27:     521091d2
28:     f4bc89be
29:     a859c2ca
30:     2ce70bd9
31:     ee5807ab
32:     24959739
33:     f8d1758a
34:     56fe2911
35:     07074d95
36:     b780f96c
37:     c9124a6e
38:     c06cafa9
39:     83a802d7
40:     06a62ae2
41:     5f458314
42:     0915e071
43:     bc860581
44:     affec84c
45:     232faabc
46:     14d69e9b
47:     d816ceb7
48:     fada9f5a
49:     d9f154c5
50:     56bf4a02
51:     95dfa313
52:     cb9e84ed
53:     f49ce65f
54:     6bbc39d7
55:     aaceeee1
56:     367a5995
57:     9259f1e5
58:     54b82ba7
59:     2bebf01a
60:     3d53cb15
61:     6af7c7dc
62:     35d9b95c
63:     c6875a51
64:     5cc269a9
65:     98fcb0a0
66:     4b1f80b8
67:     7c89ded0
68:     992cdadf
69:     2fa8e9c8
70:     54c0a55f
71:     acd3f6d0
72:     5fcaee4f
73:     a8691083
74:     e9970191
75:     1d3885d7
76:     252827ad
77:     66ea9368
78:     6dc0c912
79:     07b5ee0b
80:     135bafee
81:     5e942247
82:     bbd4e1ac
83:     4b4e93e2
84:     cbc3910d
85:     d3a9164d
86:     8131a909
87:     edb5802b
88:     f7bcef47
89:     7857b2af
90:     01647071
91:     af0dce6f
92:     eead6797
93:     a68ab9a9
94:     7ba9f2da
95:     9960006a
96:     475a0324
97:     d78ed070
98:     52ac1ac5
99:     c61e69aa
100:    dbece31f
101:    c90bcd93
102:    fbb9a679
103:    3e13d6bd
104:    2d7334fe
105:    d3d7c8f7
106:    f8fa45fb
107:    083e9e0f
108:    9b7109ff
109:    46af19a6
110:    c37f00c2
111:    6f931d86

Keyschedule 2

key: 4141414142424242434343434444444445454545464646464747474748484848
0:      66666666
1:      86868687
2:      2c2c2c26
3:      b333c4cd
4:      13d6616a
5:      ec151bd3
6:      f091cc95
7:      baf6bfbe
8:      9e885c3c
9:      35635a82
10:     87477647
11:     7e89f46c
12:     dbbd4c59
13:     702d4df0
14:     d099252a
15:     c1b13ef5
16:     2b946266
17:     d49f6d88
18:     3ceed5c3
19:     1a91b1ea
20:     305f5d4f
21:     006ed5a9
22:     d3a2fa65
23:     7c22ecad
24:     b2ee431b
25:     3dd3513f
26:     7b4eea67
27:     71d1f5bc
28:     e2f3f7cd
29:     c12d694c
30:     fa577065
31:     f0612213
32:     2c7b0a2a
33:     59cd7db9
34:     1f103a52
35:     6c2c0b47
36:     9f58b60b
37:     667d7f6c
38:     056c3a06
39:     1f65c7cc
40:     e7054afe
41:     9f87dfb9
42:     dcdaf877
43:     0063e356
44:     1e8a550a
45:     304f09fc
46:     190862d6
47:     927f97ee
48:     a7cf9c9f
49:     38d76bad
50:     3dfb3a58
51:     104622cb
52:     9f594990
53:     588f9e33
54:     024a3fa6
55:     e6843abe
56:     d68d737b
57:     01cc1e70
58:     90a8cf99
59:     38a1d870
60:     96f19451
61:     b9fd5769
62:     0cbb0866
63:     27b5eb58
64:     86d75221
65:     db84b48e
66:     4e3f72f4
67:     57a9b72f
68:     ee16fd03
69:     7f14e617
70:     8aab0e55
71:     83582f1d
72:     bbd519e2
73:     1c07d643
74:     85edc0fd
75:     7de42f56
76:     66176f1c
77:     81dab31d
78:     a714a10b
79:     2b8b1cdd
80:     79818757
81:     5fccccb4
82:     ef40e6c0
83:     b6cdaf1c
84:     6fa06669
85:     a501520d
86:     170221c2
87:     8d77eb68
88:     828aec5b
89:     6cbade68
90:     7d3fc873
91:     234875e2
92:     c368ca29
93:     157d27e6
94:     2a5ec806
95:     ebae1e37
96:     ebee57db
97:     16c4fe66
98:     47d9fc5e
99:     0f3fb7f7
100:    9d73f241
101:    ef61fa22
102:    e7576f29
103:    996ba5ff
104:    8ffba023
105:    5dde5abd
106:    68c16f06
107:    812b8a34
108:    2f4ba4db
109:    b908343a
110:    60c05499
111:    3f01c1cb