react-native-fs-turbo 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,7 +69,7 @@ android {
69
69
  externalNativeBuild {
70
70
  cmake {
71
71
  cppFlags "-frtti -fexceptions -fstack-protector-all"
72
- arguments "-DANDROID_STL=c++_shared"
72
+ arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
73
73
  if (useEncryption) {
74
74
  arguments.add("-DRNFSTURBO_USE_ENCRYPTION=1")
75
75
  }
@@ -0,0 +1,150 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2019 SergeyBel
5
+ * Copyright (c) 2023 Jubal Mordecai Velasco
6
+ * Copyright (c) 2025 Sergei Kazakov
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+
27
+ #pragma once
28
+
29
+ #ifdef RNFSTURBO_USE_ENCRYPTION
30
+
31
+ #ifndef KRYPT_AES_HPP
32
+ #define KRYPT_AES_HPP
33
+
34
+ #include <cstring>
35
+ #include <exception>
36
+ #include <iostream>
37
+ #include "blockcipher.hpp"
38
+ #include "functions.hpp"
39
+
40
+ #ifdef USE_AESNI
41
+ #include <immintrin.h>
42
+ #include <stdio.h>
43
+ #elif defined(USE_ARM_AES)
44
+ #if defined(__arm__) || defined(__aarch32__) || defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM)
45
+ #if defined(__GNUC__)
46
+ #include <stdint.h>
47
+ #endif
48
+
49
+ #if defined(__ARM_NEON) || defined(_MSC_VER)
50
+ #include <arm_neon.h>
51
+ #endif
52
+
53
+ /* GCC and LLVM Clang, but not Apple Clang */
54
+ #if defined(__GNUC__) && !defined(__apple_build_version__)
55
+ #if defined(__ARM_ACLE) || defined(__ARM_FEATURE_CRYPTO)
56
+ #include <arm_acle.h>
57
+ #endif
58
+ #endif
59
+ #endif
60
+ #endif
61
+
62
+ namespace Krypt {
63
+ namespace BlockCipher {
64
+ /// Advance Encryption Standard.
65
+ ///
66
+ /// provides method of encryption and decryption.
67
+ /// @warning the method of this class only operates on a 16 byte array of unsigned char* or Bytes*
68
+ /// if you pass an array of unsigned char* in the method with less than 16 elements in it that will cause an
69
+ /// access overflow.
70
+ class AES : public BASE_BLOCKCIPHER {
71
+ private:
72
+
73
+ const static size_t Nb = 4;
74
+ size_t Nk;
75
+ size_t Nr;
76
+ #ifdef USE_AESNI
77
+ __m128i *RoundedKeys;
78
+ __m128i *DecryptionRoundedKeys;
79
+ #elif defined(USE_ARM_AES) && defined(__aarch64__)
80
+ uint8x16_t *RoundedKeys;
81
+ uint8x16_t *DecryptionRoundedKeys;
82
+ #else
83
+ Bytes *RoundedKeys;
84
+ #endif
85
+ #if defined(USE_ARM_AES) && defined(__aarch64__)
86
+ __attribute__((__target__("+crypto+aes")))
87
+ #endif
88
+ void KeyExpansion(const Bytes *key);
89
+
90
+ void SubBytes(unsigned char state[16]);
91
+ void InvSubBytes(unsigned char state[16]);
92
+
93
+ void ShiftRows(unsigned char state[16]);
94
+ void InvShiftRows(unsigned char state[16]);
95
+
96
+ void MixColumns(unsigned char state[16]);
97
+ void InvMixColumns(unsigned char state[16]);
98
+
99
+ void AddRoundKey(unsigned char state[16], unsigned char *key);
100
+
101
+ public:
102
+
103
+ /// encrypts a fixed 16 byte block from `plain` into `cipher`.
104
+ /// @param plain a pointer to an array of unsigned char*/Bytes* in heap this is
105
+ /// the array you want to encrypt.
106
+ /// @param cipher another pointer to an array of unsigned char*/Bytes* in heap
107
+ /// this is the array where the encrypted block will be stored.
108
+ #if defined(USE_ARM_AES) && defined(__aarch64__)
109
+ __attribute__((__target__("+crypto+aes")))
110
+ #endif
111
+ void EncryptBlock(Bytes *plain, Bytes *cipher) override;
112
+
113
+ /// decrypts a fixed 16 byte block from `cipher` into `recover`.
114
+ /// @param cipher a pointer to an array of unsigned char*/Bytes* in heap this is
115
+ /// the array you want to decrypt.
116
+ /// @param recover another pointer to an array of unsigned char*/Bytes* in heap
117
+ /// this is the array where the decrypted block will be stored.
118
+ #if defined(USE_ARM_AES) && defined(__aarch64__)
119
+ __attribute__((__target__("+crypto+aes")))
120
+ #endif
121
+ void DecryptBlock(Bytes *cipher, Bytes *recover) override;
122
+
123
+ /// initialize the round key from a key.
124
+ ///
125
+ /// @note this function is automatically called when you initialize and object of AES,
126
+ /// the only time you want to use or call this member method is when you want to change the
127
+ /// key and the roundKeys of an instance of an AES class.
128
+ void setKey(const Bytes *key, size_t keyLen);
129
+
130
+ /// @return 0 - portable, 1 - neon (aarch64, armv8), 2 - AES-NI (x86-64)
131
+ static constexpr int aes_implementation() {
132
+ #ifdef USE_AESNI
133
+ return 2;
134
+ #elif defined(USE_ARM_AES) && defined(__arm__) && defined(__aarch64__)
135
+ return 1;
136
+ #else
137
+ return 0;
138
+ #endif
139
+ }
140
+
141
+ /// constructor for AES.
142
+ AES(const Bytes *ByteArray, size_t keyLen);
143
+ ~AES();
144
+ };
145
+ } // namespace BlockCipher
146
+ } // namespace Krypt
147
+
148
+ #endif
149
+
150
+ #endif
@@ -0,0 +1,71 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2023 Jubal Mordecai Velasco
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ #pragma once
26
+
27
+ #ifdef RNFSTURBO_USE_ENCRYPTION
28
+
29
+ #ifndef AES_CONFIG_HPP
30
+ #define AES_CONFIG_HPP
31
+
32
+ // WIP
33
+
34
+ #if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__amd64__)
35
+ #include <immintrin.h>
36
+ #include <xmmintrin.h>
37
+ #define AES_IMPLEMENT_INTEL_AESNI
38
+ #elif defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM)
39
+ #if defined(__GNUC__)
40
+ #include <stdint.h>
41
+ #endif
42
+
43
+ #if defined(__ARM_NEON) || defined(_MSC_VER)
44
+ #include <arm_neon.h>
45
+ #endif
46
+
47
+ /* GCC and LLVM Clang, but not Apple Clang */
48
+ #if defined(__GNUC__) && !defined(__apple_build_version__)
49
+ #if defined(__ARM_ACLE) || defined(__ARM_FEATURE_CRYPTO)
50
+ #include <arm_acle.h>
51
+ #endif
52
+ #endif
53
+ #define AES_IMPLEMENT_ARM_NEON
54
+ #else
55
+ #define AES_IMPLEMENT_PORTABLE_CPLUSPLUS
56
+ #endif
57
+
58
+ #if defined(USE_AES_ARM_NEON)
59
+ #undef AES_IMPLEMENT_INTEL_AESNI
60
+ #undef AES_IMPLEMENT_PORTABLE_CPLUSPLUS
61
+ #elif defined(USE_AES_INTEL_AESNI)
62
+ #undef AES_IMPLEMENT_ARM_NEON
63
+ #undef AES_IMPLEMENT_PORTABLE_CPLUSPLUS
64
+ #else
65
+ #undef AES_IMPLEMENT_ARM_NEON
66
+ #undef AES_IMPLEMENT_INTEL_AESNI
67
+ #endif
68
+
69
+ #endif
70
+
71
+ #endif
@@ -0,0 +1,69 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2019 SergeyBel
5
+ * Copyright (c) 2023 Jubal Mordecai Velasco
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ #pragma once
27
+
28
+ #ifdef RNFSTURBO_USE_ENCRYPTION
29
+
30
+ #ifndef KRYPT_BLOCKCIPHER_HPP
31
+ #define KRYPT_BLOCKCIPHER_HPP
32
+
33
+ #include <cstring>
34
+ #include <exception>
35
+ #include <iostream>
36
+ #include "types.hpp"
37
+
38
+ namespace Krypt {
39
+ namespace BlockCipher {
40
+ class BASE_BLOCKCIPHER {
41
+ public:
42
+
43
+ size_t BLOCK_SIZE;
44
+
45
+ BASE_BLOCKCIPHER(size_t blockSize) : BLOCK_SIZE(blockSize) {
46
+ }
47
+
48
+ /// encrypts a fixed 16 byte block from `src` into `dest`.
49
+ /// @param src a pointer to an array of unsigned char*/Bytes* in heap this is
50
+ /// the array you want to encrypt.
51
+ /// @param dest another pointer to an array of unsigned char*/Bytes* in heap
52
+ /// this is the array where the encrypted block will be stored.
53
+ virtual void EncryptBlock(Bytes *, Bytes *) = 0;
54
+
55
+ /// decrypts a fixed 16 byte block from `src` into `dest`.
56
+ /// @param src a pointer to an array of unsigned char*/Bytes* in heap this is
57
+ /// the array you want to decrypt.
58
+ /// @param dest another pointer to an array of unsigned char*/Bytes* in heap
59
+ /// this is the array where the decrypted block will be stored.
60
+ virtual void DecryptBlock(Bytes *, Bytes *) = 0;
61
+
62
+ virtual ~BASE_BLOCKCIPHER() = default;
63
+ };
64
+ } // namespace BlockCipher
65
+ } // namespace Krypt
66
+
67
+ #endif
68
+
69
+ #endif
@@ -0,0 +1,80 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2019 SergeyBel
5
+ * Copyright (c) 2023 Jubal Mordecai Velasco
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ #pragma once
27
+
28
+ #ifdef RNFSTURBO_USE_ENCRYPTION
29
+
30
+ #ifndef KRYPT_BYTEARRAY_HPP
31
+ #define KRYPT_BYTEARRAY_HPP
32
+
33
+ #include <iostream>
34
+ #include <utility>
35
+ #include "types.hpp"
36
+
37
+ namespace Krypt {
38
+ class ByteArray {
39
+ public:
40
+
41
+ /// this is the Bytes* or unsigned char* that contains the elements of the array
42
+ Bytes *array;
43
+
44
+ /// the total element of the in the array
45
+ size_t length;
46
+
47
+ /// detach the heap allocated pointer inside of the ByteArray class instance.
48
+ /// @return raw pointer of unsigned char* or Bytes*.
49
+ Bytes *detach();
50
+
51
+ Bytes &operator[](size_t i);
52
+ const Bytes &operator[](size_t i) const;
53
+
54
+ ByteArray();
55
+
56
+ ByteArray(Bytes *heap_obj, size_t length);
57
+
58
+ // copy constructor
59
+ ByteArray(const ByteArray &other);
60
+
61
+ // move constructor
62
+ ByteArray(ByteArray &&other) noexcept;
63
+
64
+ // copy assignment
65
+ ByteArray &operator=(const ByteArray &other);
66
+
67
+ // move assingment
68
+ ByteArray &operator=(ByteArray &&other) noexcept;
69
+
70
+ ~ByteArray();
71
+ };
72
+
73
+ std::ostream &operator<<(std::ostream &outputStream, const ByteArray &instance);
74
+
75
+ std::istream &operator>>(std::istream &inputStream, ByteArray &instance);
76
+ } // namespace Krypt
77
+
78
+ #endif
79
+
80
+ #endif
@@ -0,0 +1,54 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2019 SergeyBel
5
+ * Copyright (c) 2023 Jubal Mordecai Velasco
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ #pragma once
27
+
28
+ #ifdef RNFSTURBO_USE_ENCRYPTION
29
+
30
+ #ifndef KRYPT_FUNCTIONS_HPP
31
+ #define KRYPT_FUNCTIONS_HPP
32
+
33
+ #include <iostream>
34
+ #include "types.hpp"
35
+
36
+ namespace Krypt {
37
+ Bytes xtime(Bytes b); // multiply on x
38
+ void SubDWordBytes(Bytes *a);
39
+ void RotDWord(Bytes *a);
40
+ void XorDWords(Bytes *a, Bytes *b, Bytes *dest);
41
+ void XorBlocks(unsigned char *a, unsigned char *b, unsigned char *c, unsigned int len);
42
+ void XorAesBlock(unsigned char *a, unsigned char *b, unsigned char *result);
43
+
44
+ void Rcon(Bytes *a, int n);
45
+ void printHexArray(unsigned char a[], size_t n);
46
+ void printHexVector(const std::vector<unsigned char> &a);
47
+
48
+ std::vector<unsigned char> ArrayToVector(std::unique_ptr<unsigned char[]> a, unsigned char len);
49
+ std::unique_ptr<unsigned char[]> VectorToArray(const std::vector<unsigned char>& a);
50
+ } // namespace Krypt
51
+
52
+ #endif
53
+
54
+ #endif
@@ -0,0 +1,131 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2019 SergeyBel
5
+ * Copyright (c) 2023 Jubal Mordecai Velasco
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ #pragma once
27
+
28
+ #ifdef RNFSTURBO_USE_ENCRYPTION
29
+
30
+ #ifndef KRYPT_MODE_OF_ENCRYPTION_HPP
31
+ #define KRYPT_MODE_OF_ENCRYPTION_HPP
32
+
33
+ #include <iostream>
34
+ #include "blockcipher.hpp"
35
+ #include "bytearray.hpp"
36
+ #include "padding.hpp"
37
+
38
+ namespace Krypt {
39
+ namespace Mode {
40
+ class MODE {
41
+ public:
42
+
43
+ BlockCipher::BASE_BLOCKCIPHER *Encryption;
44
+ Padding::NoPadding *PaddingScheme;
45
+
46
+ MODE() : Encryption(nullptr), PaddingScheme(nullptr) {}
47
+
48
+ virtual ByteArray encrypt(Bytes *, size_t, Bytes *) = 0;
49
+ virtual ByteArray decrypt(Bytes *, size_t, Bytes *) = 0;
50
+
51
+ virtual void blockEncrypt(Bytes *, Bytes *, Bytes *) = 0;
52
+ virtual void blockDecrypt(Bytes *, Bytes *, Bytes *) = 0;
53
+
54
+ virtual ~MODE() {
55
+ delete Encryption;
56
+ delete PaddingScheme;
57
+ }
58
+ };
59
+
60
+ /// Electronic Code Blocking.
61
+ template <typename CIPHER_TYPE, typename PADDING_TYPE>
62
+ class ECB : public MODE {
63
+ public:
64
+
65
+ ECB(const Bytes *key, size_t keyLen);
66
+ /// encrypts the whole plain array using ECB mode of encryption with a chosen BlockCipher and Padding.
67
+ /// @param plain pointer to a Bytes*/unsigned char* array, this is the array you want to encrypt.
68
+ /// @param plainLen this is the size of the *plain array.
69
+ /// @param iv for ECB passing an iv will not do anything so there is no need to provide this function an iv
70
+ /// array.
71
+ ByteArray encrypt(Bytes *plain, size_t plainLen, Bytes *iv = nullptr) override;
72
+ /// decrypts the whole cipher array using ECB mode of decryption with a chosen BlockCipher and Padding.
73
+ /// @param cipher pointer to a Bytes*/unsigned char* array, this is the array you want to decrypt.
74
+ /// @param cipherLen this is the size of the *cipher array.
75
+ /// @param iv for ECB passing an iv will not do anything so there is no need to provide this function an iv
76
+ /// array.
77
+ ByteArray decrypt(Bytes *cipher, size_t cipherLen, Bytes *iv = nullptr) override;
78
+
79
+ void blockEncrypt(Bytes *plain, Bytes *cipher, Bytes *iv = nullptr) override;
80
+ void blockDecrypt(Bytes *plain, Bytes *cipher, Bytes *iv = nullptr) override;
81
+ };
82
+
83
+ /// Cipher Block Chaining.
84
+ template <typename CIPHER_TYPE, typename PADDING_TYPE>
85
+ class CBC : public MODE {
86
+ public:
87
+
88
+ CBC(const Bytes *key, size_t keyLen);
89
+ /// encrypts the whole plain array using CBC mode of encryption with a chosen BlockCipher and Padding.
90
+ /// @param plain pointer to a Bytes*/unsigned char* array, this is the array you want to encrypt.
91
+ /// @param plainLen this is the size of the *plain array.
92
+ /// @param iv the initial array use for the XOR'ing operations during the CBC encryption.
93
+ ByteArray encrypt(Bytes *plain, size_t plainLen, Bytes *iv) override;
94
+ /// decrypts the whole cipher array using CBC mode of decryption with a chosen BlockCipher and Padding.
95
+ /// @param cipher pointer to a Bytes*/unsigned char* array, this is the array you want to decrypt.
96
+ /// @param cipherLen this is the size of the *cipher array.
97
+ /// @param iv the initial array use for the XOR'ing operations during the CBC decryption.
98
+ ByteArray decrypt(Bytes *cipher, size_t cipherLen, Bytes *iv) override;
99
+
100
+ void blockEncrypt(Bytes *plain, Bytes *cipher, Bytes *iv) override;
101
+ void blockDecrypt(Bytes *plain, Bytes *cipher, Bytes *iv) override;
102
+ };
103
+
104
+ /// Cipher Feedback.
105
+ template <typename CIPHER_TYPE, typename PADDING_TYPE>
106
+ class CFB : public MODE {
107
+ public:
108
+
109
+ CFB(const Bytes *key, size_t keyLen);
110
+ /// encrypts the whole plain array using CFB mode of encryption with a chosen BlockCipher and Padding.
111
+ /// @param plain pointer to a Bytes*/unsigned char* array, this is the array you want to encrypt.
112
+ /// @param plainLen this is the size of the *plain array.
113
+ /// @param iv the initial array use for the XOR'ing operations during the CFB encryption.
114
+ ByteArray encrypt(Bytes *plain, size_t plainLen, Bytes *iv) override;
115
+ /// decrypts the whole cipher array using CFB mode of decryption with a chosen BlockCipher and Padding.
116
+ /// @param cipher pointer to a Bytes*/unsigned char* array, this is the array you want to decrypt.
117
+ /// @param cipherLen this is the size of the *cipher array.
118
+ /// @param iv the initial array use for the XOR'ing operations during the CFB decryption.
119
+ ByteArray decrypt(Bytes *cipher, size_t cipherLen, Bytes *iv) override;
120
+
121
+ void blockEncrypt(Bytes *plain, Bytes *cipher, Bytes *iv) override;
122
+ void blockDecrypt(Bytes *plain, Bytes *cipher, Bytes *iv) override;
123
+ };
124
+ } // namespace Mode
125
+ } // namespace Krypt
126
+
127
+ #include "mode.cpp"
128
+
129
+ #endif
130
+
131
+ #endif
@@ -0,0 +1,148 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2019 SergeyBel
5
+ * Copyright (c) 2023 Jubal Mordecai Velasco
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ #pragma once
27
+
28
+ #ifdef RNFSTURBO_USE_ENCRYPTION
29
+
30
+ #ifndef KRYPT_PADDING_HPP
31
+ #define KRYPT_PADDING_HPP
32
+
33
+ #include <cstring>
34
+ #include <exception>
35
+ #include <iostream>
36
+ #include <utility>
37
+ #include "bytearray.hpp"
38
+
39
+ namespace Krypt {
40
+ namespace Padding {
41
+ class InvalidPadding : public std::exception {
42
+ public:
43
+
44
+ InvalidPadding(const char *info) : msg(info) {
45
+ }
46
+ const char *msg;
47
+ const char *what() const throw();
48
+ };
49
+
50
+ class InvalidPaddedLength : public std::exception {
51
+ public:
52
+
53
+ InvalidPaddedLength(const char *paddingSchemName) : msg(paddingSchemName) {
54
+ }
55
+ const char *msg;
56
+ const char *what() const throw();
57
+ };
58
+
59
+ /// default & base class for padding - pad the src with zeros.
60
+ class NoPadding {
61
+ public:
62
+
63
+ /** does nothing obviously. **/
64
+ virtual ByteArray AddPadding(Bytes *src, size_t len, size_t BLOCKSIZE);
65
+
66
+ /** does nothing obviously. **/
67
+ virtual ByteArray RemovePadding(Bytes *src, size_t len, size_t BLOCKSIZE);
68
+
69
+ virtual ~NoPadding() = default;
70
+ };
71
+
72
+ /// default & base class for padding - pad the src with zeros.
73
+ class ZeroNulls : public NoPadding {
74
+ public:
75
+
76
+ /** Pad the last block with zeros [reallocates memory].
77
+ * @return padded ByteArray generated from src.
78
+ * **/
79
+ ByteArray AddPadding(Bytes *src, size_t len, size_t BLOCKSIZE);
80
+
81
+ /** Removes the last 16 byte zeros [reallocates memory].
82
+ * @return padded ByteArray generated from src.
83
+ * **/
84
+ ByteArray RemovePadding(Bytes *src, size_t len, size_t BLOCKSIZE);
85
+
86
+ ~ZeroNulls() = default;
87
+ };
88
+
89
+ class ANSI_X9_23 : public NoPadding {
90
+ public:
91
+
92
+ /** Pad the `src` with zeros first, then sets the last byte value to the count of paddings added
93
+ * [reallocates memory].
94
+ * @return padded ByteArray generated from src.
95
+ * **/
96
+ ByteArray AddPadding(Bytes *src, size_t len, size_t BLOCKSIZE) override;
97
+
98
+ /** Removes the number of bytes [reallocates memory].
99
+ * @returns padded ByteArray generated from src.
100
+ * **/
101
+ ByteArray RemovePadding(Bytes *src, size_t len, size_t BLOCKSIZE) override;
102
+
103
+ ~ANSI_X9_23() {
104
+ }
105
+ };
106
+
107
+ class ISO_IEC_7816_4 : public NoPadding {
108
+ public:
109
+
110
+ /** Adds one `0x80` byte value, then pad the next remaining spaces with zeros [reallocates memory].
111
+ * @return padded ByteArray generated from src.
112
+ * **/
113
+ ByteArray AddPadding(Bytes *src, size_t len, size_t BLOCKSIZE) override;
114
+
115
+ /** removes padding [reallocates memory].
116
+ * - figures out the padding size by checking the sequence of zeros from the least significant to the most
117
+ * significant byte until it hits `0x80` byte value.
118
+ * @return padded ByteArray generated from src.
119
+ * **/
120
+ ByteArray RemovePadding(Bytes *src, size_t len, size_t BLOCKSIZE) override;
121
+
122
+ ~ISO_IEC_7816_4() {
123
+ }
124
+ };
125
+
126
+ class PKCS_5_7 : public NoPadding {
127
+ public:
128
+
129
+ /** Pad the `src` with the value of the padding count itself [reallocates memory].
130
+ * @return the new length of the padded `src`.
131
+ * **/
132
+ ByteArray AddPadding(Bytes *src, size_t len, size_t BLOCKSIZE) override;
133
+
134
+ /** removes padding [reallocates memory].
135
+ * - figures out the padding size by getting the value of the last byte.
136
+ * @return the new length of the un-padded `src`.
137
+ * **/
138
+ ByteArray RemovePadding(Bytes *src, size_t len, size_t BLOCKSIZE) override;
139
+
140
+ ~PKCS_5_7() {
141
+ }
142
+ };
143
+ } // namespace Padding
144
+ } // namespace Krypt
145
+
146
+ #endif
147
+
148
+ #endif
@@ -0,0 +1,208 @@
1
+ /*
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2019 SergeyBel
5
+ * Copyright (c) 2023 Jubal Mordecai Velasco
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ #pragma once
27
+
28
+ #ifdef RNFSTURBO_USE_ENCRYPTION
29
+
30
+ #ifndef USED_COMMON_TYPES_HPP
31
+ #define USED_COMMON_TYPES_HPP
32
+
33
+ #include <cstring>
34
+ #include <iostream>
35
+ #include <vector>
36
+
37
+ #define KRYPT_PRINT_HEX(PRINT_HEX_PARAM) \
38
+ std::cout.setf(std::ios::showbase); \
39
+ std::cout.setf(std::ios::hex, std::ios::basefield); \
40
+ std::cout << PRINT_HEX_PARAM << "\n"
41
+
42
+ namespace Krypt {
43
+ /// Just a typedef for the unsigned char type.
44
+ typedef unsigned char Bytes;
45
+
46
+ static constexpr Bytes sbox[256] = {
47
+ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0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, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05,
70
+ 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13,
71
+ 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
72
+ 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1,
73
+ 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b,
74
+ 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07,
75
+ 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
76
+ 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb,
77
+ 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63,
78
+ 0x55, 0x21, 0x0c, 0x7d,
79
+ };
80
+
81
+ // Galois Multiplication lookup tables
82
+ static constexpr Bytes GF_MUL_TABLE[15][256] = {
83
+
84
+ {},
85
+ {},
86
+
87
+ // mul 2
88
+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 0xe7, 0xe2, 0xe1, 0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd,
111
+ 0xb4, 0xb7, 0xb2, 0xb1, 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87,
112
+ 0x82, 0x81, 0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a,
113
+ 0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba, 0xfb, 0xf8,
114
+ 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea, 0xcb, 0xc8, 0xcd, 0xce,
115
+ 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda, 0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54,
116
+ 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a, 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62,
117
+ 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a, 0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20,
118
+ 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a, 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16,
119
+ 0x1f, 0x1c, 0x19, 0x1a},
120
+
121
+ {},
122
+ {},
123
+ {},
124
+ {},
125
+ {},
126
+
127
+ // mul 9
128
+ {0x00, 0x09, 0x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0x55, 0x5c,
138
+ 0x63, 0x6a, 0x71, 0x78, 0x0f, 0x06, 0x1d, 0x14, 0x2b, 0x22, 0x39, 0x30, 0x9a, 0x93, 0x88, 0x81, 0xbe, 0xb7,
139
+ 0xac, 0xa5, 0xd2, 0xdb, 0xc0, 0xc9, 0xf6, 0xff, 0xe4, 0xed, 0x0a, 0x03, 0x18, 0x11, 0x2e, 0x27, 0x3c, 0x35,
140
+ 0x42, 0x4b, 0x50, 0x59, 0x66, 0x6f, 0x74, 0x7d, 0xa1, 0xa8, 0xb3, 0xba, 0x85, 0x8c, 0x97, 0x9e, 0xe9, 0xe0,
141
+ 0xfb, 0xf2, 0xcd, 0xc4, 0xdf, 0xd6, 0x31, 0x38, 0x23, 0x2a, 0x15, 0x1c, 0x07, 0x0e, 0x79, 0x70, 0x6b, 0x62,
142
+ 0x5d, 0x54, 0x4f, 0x46},
143
+
144
+ {},
145
+
146
+ // mul 11
147
+ {0x00, 0x0b, 0x16, 0x1d, 0x2c, 0x27, 0x3a, 0x31, 0x58, 0x53, 0x4e, 0x45, 0x74, 0x7f, 0x62, 0x69, 0xb0, 0xbb,
148
+ 0xa6, 0xad, 0x9c, 0x97, 0x8a, 0x81, 0xe8, 0xe3, 0xfe, 0xf5, 0xc4, 0xcf, 0xd2, 0xd9, 0x7b, 0x70, 0x6d, 0x66,
149
+ 0x57, 0x5c, 0x41, 0x4a, 0x23, 0x28, 0x35, 0x3e, 0x0f, 0x04, 0x19, 0x12, 0xcb, 0xc0, 0xdd, 0xd6, 0xe7, 0xec,
150
+ 0xf1, 0xfa, 0x93, 0x98, 0x85, 0x8e, 0xbf, 0xb4, 0xa9, 0xa2, 0xf6, 0xfd, 0xe0, 0xeb, 0xda, 0xd1, 0xcc, 0xc7,
151
+ 0xae, 0xa5, 0xb8, 0xb3, 0x82, 0x89, 0x94, 0x9f, 0x46, 0x4d, 0x50, 0x5b, 0x6a, 0x61, 0x7c, 0x77, 0x1e, 0x15,
152
+ 0x08, 0x03, 0x32, 0x39, 0x24, 0x2f, 0x8d, 0x86, 0x9b, 0x90, 0xa1, 0xaa, 0xb7, 0xbc, 0xd5, 0xde, 0xc3, 0xc8,
153
+ 0xf9, 0xf2, 0xef, 0xe4, 0x3d, 0x36, 0x2b, 0x20, 0x11, 0x1a, 0x07, 0x0c, 0x65, 0x6e, 0x73, 0x78, 0x49, 0x42,
154
+ 0x5f, 0x54, 0xf7, 0xfc, 0xe1, 0xea, 0xdb, 0xd0, 0xcd, 0xc6, 0xaf, 0xa4, 0xb9, 0xb2, 0x83, 0x88, 0x95, 0x9e,
155
+ 0x47, 0x4c, 0x51, 0x5a, 0x6b, 0x60, 0x7d, 0x76, 0x1f, 0x14, 0x09, 0x02, 0x33, 0x38, 0x25, 0x2e, 0x8c, 0x87,
156
+ 0x9a, 0x91, 0xa0, 0xab, 0xb6, 0xbd, 0xd4, 0xdf, 0xc2, 0xc9, 0xf8, 0xf3, 0xee, 0xe5, 0x3c, 0x37, 0x2a, 0x21,
157
+ 0x10, 0x1b, 0x06, 0x0d, 0x64, 0x6f, 0x72, 0x79, 0x48, 0x43, 0x5e, 0x55, 0x01, 0x0a, 0x17, 0x1c, 0x2d, 0x26,
158
+ 0x3b, 0x30, 0x59, 0x52, 0x4f, 0x44, 0x75, 0x7e, 0x63, 0x68, 0xb1, 0xba, 0xa7, 0xac, 0x9d, 0x96, 0x8b, 0x80,
159
+ 0xe9, 0xe2, 0xff, 0xf4, 0xc5, 0xce, 0xd3, 0xd8, 0x7a, 0x71, 0x6c, 0x67, 0x56, 0x5d, 0x40, 0x4b, 0x22, 0x29,
160
+ 0x34, 0x3f, 0x0e, 0x05, 0x18, 0x13, 0xca, 0xc1, 0xdc, 0xd7, 0xe6, 0xed, 0xf0, 0xfb, 0x92, 0x99, 0x84, 0x8f,
161
+ 0xbe, 0xb5, 0xa8, 0xa3},
162
+
163
+ {},
164
+
165
+ // mul 13
166
+ {0x00, 0x0d, 0x1a, 0x17, 0x34, 0x39, 0x2e, 0x23,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4e, 0x40, 0x52, 0x5c, 0x06, 0x08, 0x1a, 0x14,
189
+ 0x3e, 0x30, 0x22, 0x2c, 0x96, 0x98, 0x8a, 0x84, 0xae, 0xa0, 0xb2, 0xbc, 0xe6, 0xe8, 0xfa, 0xf4, 0xde, 0xd0,
190
+ 0xc2, 0xcc, 0x41, 0x4f, 0x5d, 0x53, 0x79, 0x77, 0x65, 0x6b, 0x31, 0x3f, 0x2d, 0x23, 0x09, 0x07, 0x15, 0x1b,
191
+ 0xa1, 0xaf, 0xbd, 0xb3, 0x99, 0x97, 0x85, 0x8b, 0xd1, 0xdf, 0xcd, 0xc3, 0xe9, 0xe7, 0xf5, 0xfb, 0x9a, 0x94,
192
+ 0x86, 0x88, 0xa2, 0xac, 0xbe, 0xb0, 0xea, 0xe4, 0xf6, 0xf8, 0xd2, 0xdc, 0xce, 0xc0, 0x7a, 0x74, 0x66, 0x68,
193
+ 0x42, 0x4c, 0x5e, 0x50, 0x0a, 0x04, 0x16, 0x18, 0x32, 0x3c, 0x2e, 0x20, 0xec, 0xe2, 0xf0, 0xfe, 0xd4, 0xda,
194
+ 0xc8, 0xc6, 0x9c, 0x92, 0x80, 0x8e, 0xa4, 0xaa, 0xb8, 0xb6, 0x0c, 0x02, 0x10, 0x1e, 0x34, 0x3a, 0x28, 0x26,
195
+ 0x7c, 0x72, 0x60, 0x6e, 0x44, 0x4a, 0x58, 0x56, 0x37, 0x39, 0x2b, 0x25, 0x0f, 0x01, 0x13, 0x1d, 0x47, 0x49,
196
+ 0x5b, 0x55, 0x7f, 0x71, 0x63, 0x6d, 0xd7, 0xd9, 0xcb, 0xc5, 0xef, 0xe1, 0xf3, 0xfd, 0xa7, 0xa9, 0xbb, 0xb5,
197
+ 0x9f, 0x91, 0x83, 0x8d}};
198
+
199
+ /// circulant MDS matrix
200
+ static constexpr Bytes CMDS[4][4] = {{2, 3, 1, 1}, {1, 2, 3, 1}, {1, 1, 2, 3}, {3, 1, 1, 2}};
201
+
202
+ /// Inverse circulant MDS matrix
203
+ static constexpr Bytes INV_CMDS[4][4] = {{14, 11, 13, 9}, {9, 14, 11, 13}, {13, 9, 14, 11}, {11, 13, 9, 14}};
204
+ } // namespace Krypt
205
+
206
+ #endif
207
+
208
+ #endif
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-fs-turbo",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "React-Native library for working with Android/iOS file system, written using JSI and C++ TurboModules",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -20,6 +20,7 @@
20
20
  "android/CMakeLists.txt",
21
21
  "android/gradle.properties",
22
22
  "cpp/**/*.h",
23
+ "cpp/**/*.hpp",
23
24
  "cpp/**/*.cpp",
24
25
  "lib/commonjs",
25
26
  "lib/module",