openGPMP
Open Source Mathematics Package
redpike.hpp
Go to the documentation of this file.
1 /*************************************************************************
2  *
3  * Project
4  * _____ _____ __ __ _____
5  * / ____| __ \| \/ | __ \
6  * ___ _ __ ___ _ __ | | __| |__) | \ / | |__) |
7  * / _ \| '_ \ / _ \ '_ \| | |_ | ___/| |\/| | ___/
8  *| (_) | |_) | __/ | | | |__| | | | | | | |
9  * \___/| .__/ \___|_| |_|\_____|_| |_| |_|_|
10  * | |
11  * |_|
12  *
13  * Copyright (C) Akiel Aries, <akiel@akiel.org>, et al.
14  *
15  * This software is licensed as described in the file LICENSE, which
16  * you should have received as part of this distribution. The terms
17  * among other details are referenced in the official documentation
18  * seen here : https://akielaries.github.io/openGPMP/ along with
19  * important files seen in this project.
20  *
21  * You may opt to use, copy, modify, merge, publish, distribute
22  * and/or sell copies of the Software, and permit persons to whom
23  * the Software is furnished to do so, under the terms of the
24  * LICENSE file. As this is an Open Source effort, all implementations
25  * must be of the same methodology.
26  *
27  *
28  *
29  * This software is distributed on an AS IS basis, WITHOUT
30  * WARRANTY OF ANY KIND, either express or implied.
31  *
32  ************************************************************************/
33 
34 #ifndef REDPIKE_HPP
35 #define REDPIKE_HPP
36 
37 #include <cstdint>
38 
39 namespace gpmp {
40 
41 namespace nt {
42 
48 class RedPike {
49  public:
56  void encrypt(uint32_t *x, const uint32_t *k);
57 
64  void decrypt(uint32_t *x, const uint32_t *k);
65 
66  private:
70  uint32_t CONST = 0x9E3779B9;
71 
75  int ROUNDS = 16;
76 
85  uint32_t rotl(uint32_t X, int R);
86 
95  uint32_t rotr(uint32_t X, int R);
96 };
97 
98 } // namespace nt
99 
100 } // namespace gpmp
101 
102 #endif
Class for encryption and decryption using the RedPike algorithm.
Definition: redpike.hpp:48
uint32_t CONST
Constant value used in the RedPike algorithm.
Definition: redpike.hpp:70
void decrypt(uint32_t *x, const uint32_t *k)
Decrypts the given data using the RedPike algorithm.
Definition: redpike.cpp:70
int ROUNDS
Number of rounds in the RedPike algorithm.
Definition: redpike.hpp:75
uint32_t rotl(uint32_t X, int R)
Performs left rotation on the given value.
Definition: redpike.cpp:40
void encrypt(uint32_t *x, const uint32_t *k)
Encrypts the given data using the RedPike algorithm.
Definition: redpike.cpp:48
uint32_t rotr(uint32_t X, int R)
Performs right rotation on the given value.
Definition: redpike.cpp:44
The source C++ openGPMP namespace.