Wrote the cipher. part on C on Qt. Everything worked there. Now I want to screw it to Java in Android Studio, but such an error has appeared, although everything seems to be announced everywhere.

Error number 1. (native-lib.cpp file) enter image description here

Error number 2 enter image description here

MainAcrivity.java

import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity { String msg = "Hello from Java"; // Used to load the 'native-lib' library on application startup. static { System.loadLibrary("native-lib"); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Example of a call to a native method TextView tv = (TextView) findViewById(R.id.sample_text); tv.setText(stringFromJNI(msg)); } /** * A native method that is implemented by the 'native-lib' native library, * which is packaged with this application. */ public native String stringFromJNI(String msg); } 

native-lib.cpp

 #include <jni.h> #include <string> #include "gost34-12-15.h" #include "gost34-13-15.h" #include "main.cpp" std::string jstring2string (JNIEnv * env, jstring jStr); extern "C" JNIEXPORT jstring JNICALL Java_com_example_maxim_onlyforc_MainActivity_stringFromJNI( JNIEnv *env, jobject obj, jstring msg) { jstring msg2= (env, msg); std::string text = jstring2string(env, msg2); return env->NewStringUTF(text.c_str()); } std::string jstring2string (JNIEnv * env, jstring jStr) { if (!jStr) return ""; const jclass stringClass = env->GetObjectClass(jStr); const jmethodID getBytes = env->GetMethodID(stringClass, "getBytes", " (Ljava/lang/String;)[B"); const jbyteArray stringJbytes = (jbyteArray) env->CallObjectMethod(jStr, getBytes, env->NewStringUTF("UTF-8")); size_t length = (size_t) env->GetArrayLength(stringJbytes); jbyte* pBytes = env->GetByteArrayElements(stringJbytes, NULL); std::string ret = std::string((char *)pBytes, length); env->ReleaseByteArrayElements(stringJbytes, pBytes, JNI_ABORT); env->DeleteLocalRef(stringJbytes); env->DeleteLocalRef(stringClass); return ret; } 

main.cpp

 #include <jni.h> #include <string> #include "gost34-12-15.h" #include "gost34-13-15.h" unsigned char* jstring2char(JNIEnv * env, jstring); jstring crypto(JNIEnv *env, jstring msg) { // ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚Ρ‹ΠΉ тСкст для Π“ΠžΠ‘Π’ 34.13-15 \\ byte* text = jstring2char(env, msg); byte key[] = { // ΠΊΠ»ΡŽΡ‡ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}; byte IV[] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xce, 0xf0, 0xa1, 0xb2, //синхр. посылка 0xc3, 0xd4, 0xe5, 0xf0, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x90, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19}; init128Gost34_12_15(key); encrypt_decrypt_OFB(IV, text, sizeof (text)); close128Gost34_12_15(); closeGost34_13_15(IV); jstring newText = (*env).NewStringUTF((const char*) text); return newText; } unsigned char* jstring2char (JNIEnv * env, jstring jStr) { const jclass stringClass = env->GetObjectClass(jStr); const jmethodID getBytes = env->GetMethodID(stringClass, "getBytes", "(Ljava/lang/String;)[B"); const jbyteArray stringJbytes = (jbyteArray) env->CallObjectMethod(jStr, getBytes, env->NewStringUTF("UTF-8")); int len = env->GetArrayLength(stringJbytes); unsigned char* buf = new unsigned char[len]; env->GetByteArrayRegion(stringJbytes, 0, len, reinterpret_cast<jbyte*>(buf)); return buf; } 

gost34-13-15.h

 #ifndef GOST341315_H #define GOST341315_H typedef unsigned char byte; // -------------------------------------------------------------- /* НазначСниС: Π¨ΠΈΡ„Ρ€ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΈΠ»ΠΈ Ρ€Π°ΡΡˆΠΈΡ„Ρ€ΠΎΠ²Π°Π½ΠΈΠ΅ входящСго тСкста. Π’Ρ…ΠΎΠ΄Π½Ρ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: IV - синхр. посылка Π΄Π»ΠΈΠ½ΠΎΠΉ m (256 Π±ΠΈΡ‚ - 32 Π±Π°ΠΉΡ‚Π°) text - Π²Ρ…ΠΎΠ΄Π½ΠΎΠΉ ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚Ρ‹ΠΉ/ΡˆΠΈΡ„Ρ€ тСкст любой Π΄Π»ΠΈΠ½Ρ‹ size - Π΄Π»ΠΈΠ½Π° тСкста Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅: Π½Π΅Ρ‚ */ void encrypt_decrypt_OFB (byte* IV, byte* text, int size); // -------------------------------------------------------------- /* НазначСниС: ΠžΡ‡ΠΈΡΡ‚ΠΊΠ° массива синх. посылки. Π’Ρ…ΠΎΠ΄Π½Ρ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: IV - синхр. посылка Π΄Π»ΠΈΠ½ΠΎΠΉ m (256 Π±ΠΈΡ‚ - 32 Π±Π°ΠΉΡ‚Π°) Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅: Π½Π΅Ρ‚ */ void closeGost34_13_15(byte* IV); // -------------------------------------------------------------- #endif // GOST341315_H 

gost34-13-15.cpp

 #include "gost34-12-15.h" #include <cstring> #include <cstdio> #include <string.h> using namespace std; static int n = 16;; //static int m = 32; //static int s = 16; byte text128[16]; byte resultMSB_Y[16]; byte resultLSB[16]; static void MSB(byte* massive, int n); static void LSB(byte* massive, int n); void encrypt_decrypt_OFB (byte* R, byte* text, int size) { int q = size / n; int ostatok = size % n; for (int i = 0; i < q; i++) { arraycopy(text, i * n, text128, 0, n); MSB(R, n); encrypt128Gost34_12_15(resultMSB_Y); X(text128, resultMSB_Y); LSB(R, n); arraycopy(resultLSB, 0, R, 0, n); arraycopy(resultMSB_Y, 0, R, n, n); arraycopy(text128, 0, text, i * n, n); } if (ostatok != 0) { byte textLess128[ostatok]; byte resultMSBshort [ostatok]; arraycopy(text, (q - 1) * n, textLess128, 0, ostatok); MSB(R, n); encrypt128Gost34_12_15(resultMSB_Y); MSB(resultMSB_Y, ostatok); arraycopy(resultMSB_Y, 0, resultMSBshort, 0, ostatok); X(textLess128, resultMSBshort); arraycopy(textLess128, 0, text, (q - 1) * n, ostatok); } } static void MSB (byte* massive, int n) { arraycopy(massive, 0, resultMSB_Y, 0, n); } static void LSB (byte* massive, int n) { arraycopy(massive, n, resultLSB, 0, n); } void closeGost34_13_15(byte* R){ memset(R, 0, 32); } 

gost34-12-15.h

 #ifndef GOST341215_H #define GOST341215_H typedef unsigned char byte; //-------------------------------------------------------------- /* НазначСниС: Π‘ΠΎΠ·Π΄Π°Ρ‚ΡŒ массив ΠΈΡ‚Π΅Ρ€Π°Ρ†ΠΈΠΎΠ½Π½Ρ‹Ρ… ΠΊΠ»ΡŽΡ‡Π΅ΠΉ Π’Ρ…ΠΎΠ΄Π½Ρ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: current_key - ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅ΠΌΡ‹ΠΉ ΠΊΠ»ΡŽΡ‡ Π΄Π»ΠΈΠ½ΠΎΠΉ 32 Π±Π°ΠΉΡ‚Π° text - тСкст Π΄Π»ΠΈΠ½ΠΎΠΉ 16 Π±Π°ΠΉΡ‚ length_text - Ρ€Π°Π·ΠΌΠ΅Ρ€ тСкста Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅: Π½Π΅Ρ‚ */ void init128Gost34_12_15(byte* current_key);// , int length_current_key, byte* text, int length_text); //-------------------------------------------------------------- /* НазначСниС: ΠšΠΎΠΏΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ Π΄Π°Π½Π½Ρ‹Ρ… ΠΈΠ· массива masIn с ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ pos1 Π² массив masOut с ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ pos2. ΠšΠΎΠ»ΠΈΡ‡Π΅ΡΡ‚Π²ΠΎ символов Ρ€Π°Π²Π½ΠΎ length Π’Ρ…ΠΎΠ΄Π½Ρ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: masIn - массив, ΠΎΡ‚ΠΊΡƒΠ΄Π° ΠΊΠΎΠΏΠΈΡ€ΡƒΡŽΡ‚ΡΡ Π΄Π°Π½Π½Ρ‹Π΅; pos1 - Π² массивС masIn, с ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ ΠΊΠΎΠΏΠΈΡ€ΡƒΡŽΡ‚ΡΡ Π΄Π°Π½Π½Ρ‹Π΅; masOut - массив, ΠΊΡƒΠ΄Π° ΠΊΠΎΠΏΠΈΡ€ΡƒΡŽΡ‚ΡΡ ΠΈ Π·Π°ΠΏΠΈΡΡ‹Π²Π°ΡŽΡ‚ΡΡ Π΄Π°Π½Π½Ρ‹Π΅; pos2 - позиция Π² массивС masOut, с ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ вСдСтся запись: length - количСство ΠΏΠ΅Ρ€Π΅ΠΊΠΎΠΏΠΈΡ€ΠΎΠ²Π°Π½Π½Ρ‹Ρ… элСмСнтов */ void arraycopy(byte* masIn, int pos1, byte* masOut, int pos2, int length); //-------------------------------------------------------------- /* !!!ΠŸΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»ΠΈ, ΠΏΡ€Π΅ΠΆΠ΄Π΅ΠΌ Ρ‡Π΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ Π΄Π°Π½Π½ΡƒΡŽ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΡŽ, Π΄ΠΎΠ»ΠΆΠ½Ρ‹ ΠΎΠ΄ΠΈΠ½ Ρ€Π°Π· Π²Ρ‹Π·Π²Π°Ρ‚ΡŒ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΡŽ initK НазначСниС: Π¨ΠΈΡ„Ρ€ΡƒΠ΅Ρ‚ тСкст Π’Ρ…ΠΎΠ΄Π½Ρ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: msg - тСкст, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ ΡˆΠΈΡ„Ρ€ΡƒΠ΅Ρ‚ΡΡ; msg_size - Ρ€Π°Π·ΠΌΠ΅Ρ€ тСкста Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅ΠΌΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅: Π½Π΅Ρ‚ */ void encrypt128Gost34_12_15(byte* msg); //-------------------------------------------------------------- /* НазначСниС: Π’Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ Π₯, ΠΎΠ½Π° ΠΆΠ΅ - слоТСниС Π΄Π²ΡƒΡ… Π°Ρ€Π³ΡƒΠΌΠ΅Π½Ρ‚ΠΎΠ² ΠΏΠΎ mod2 Π’Ρ…ΠΎΠ΄Π½Ρ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: res_arg1 - ΠΏΠ΅Ρ€Π²Ρ‹ΠΉ массив, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π² сСбя пСрСзаписываСт Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ ΠΎΠΏΠ΅Ρ€Π°Ρ†ΠΈΠΈ; arg2 - Π²Ρ‚ΠΎΡ€ΠΎΠΉ массив, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ складываСтся ΠΏΠΎ mod2 с ΠΏΠ΅Ρ€Π²Ρ‹ΠΌ */ void X(byte* res_and_arg1, const byte* arg2); //-------------------------------------------------------------- /* НазначСниС: ΠšΠΎΠΏΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ Π΄Π°Π½Π½Ρ‹Ρ… ΠΈΠ· массива masIn с ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ pos1 Π² массив masOut с ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ pos2. ΠšΠΎΠ»ΠΈΡ‡Π΅ΡΡ‚Π²ΠΎ символов Ρ€Π°Π²Π½ΠΎ length Π’Ρ…ΠΎΠ΄Π½Ρ‹Π΅ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹: masIn - массив, ΠΎΡ‚ΠΊΡƒΠ΄Π° ΠΊΠΎΠΏΠΈΡ€ΡƒΡŽΡ‚ΡΡ Π΄Π°Π½Π½Ρ‹Π΅; pos1 - Π² массивС masIn, с ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ ΠΊΠΎΠΏΠΈΡ€ΡƒΡŽΡ‚ΡΡ Π΄Π°Π½Π½Ρ‹Π΅; masOut - массив, ΠΊΡƒΠ΄Π° ΠΊΠΎΠΏΠΈΡ€ΡƒΡŽΡ‚ΡΡ ΠΈ Π·Π°ΠΏΠΈΡΡ‹Π²Π°ΡŽΡ‚ΡΡ Π΄Π°Π½Π½Ρ‹Π΅; pos2 - позиция Π² массивС masOut, с ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ вСдСтся запись: length - количСство ΠΏΠ΅Ρ€Π΅ΠΊΠΎΠΏΠΈΡ€ΠΎΠ²Π°Π½Π½Ρ‹Ρ… элСмСнтов */ //void arraycopy(byte* masIn, int pos1, byte* masOut, int pos2, int length); //-------------------------------------------------------------- void close128Gost34_12_15(); #endif // GOST341215_H 

gost34-12-15.cpp

 #include "gost34-12-15.h" #include <cstring> #include <string.h> using namespace std; const byte pi[] = { // 0 1 2 3 4 5 6 7 252, 238, 221, 17 , 207, 110, 49 , 22 ,//0 251, 196, 250, 218, 35 , 197, 4 , 77 ,//1 233, 119, 240, 219, 147, 46 , 153, 186,//2 23 , 54 , 241, 187, 20 , 205, 95 , 193,//3 249, 24 , 101, 90 , 226, 92 , 239, 33 ,//4 129, 28 , 60 , 66 , 139, 1 , 142, 79 ,//5 5 , 132, 2 , 174, 227, 106, 143, 160,//6 6 , 11 , 237, 152, 127, 212, 211, 31 ,//7 235, 52 , 44 , 81 , 234, 200, 72 , 171,//8 242, 42 , 104, 162, 253, 58 , 206, 204,//9 181, 112, 14 , 86 , 8 , 12 , 118, 18 ,//10 191, 114, 19 , 71 , 156, 183, 93 , 135,//11 21 , 161, 150, 41 , 16 , 123, 154, 199,//12 243, 145, 120, 111, 157, 158, 178, 177,//13 50 , 117, 25 , 61 , 255, 53 , 138, 126,//14 109, 84 , 198, 128, 195, 189, 13 , 87 ,//15 223, 245, 36 , 169, 62 , 168, 67 , 201,//16 215, 121, 214, 246, 124, 34 , 185, 3 ,//17 224, 15 , 236, 222, 122, 148, 176, 188,//18 220, 232, 40 , 80 , 78 , 51 , 10 , 74 ,//19 167, 151, 96 , 115, 30 , 0 , 98 , 68 ,//20 26 , 184, 56 , 130, 100, 159, 38 , 65 ,//21 173, 69 , 70 , 146, 39 , 94 , 85 , 47 ,//22 140, 163, 165, 125, 105, 213, 149, 59 ,//23 7 , 88 , 179, 64 , 134, 172, 29 , 247,//24 48 , 55 , 107, 228, 136, 217, 231, 137,//25 225, 27 , 131, 73 , 76 , 63 , 248, 254,//26 141, 83 , 170, 144, 202, 216, 133, 97 ,//27 32 , 113, 103, 164, 45 , 43 , 9 , 91 ,//28 203, 155, 37 , 208, 190, 229, 108, 82 ,//29 89 , 166, 116, 210, 230, 244, 180, 192,//30 209, 102, 175, 194, 57 , 75 , 99 , 182 };//31 const byte pi_reverse[] = { 165, 45 , 50 , 143, 14 , 48 , 56 , 192, 84 , 230, 158, 57 , 85 , 126, 82 , 145, 100, 3 , 87 , 90 , 28 , 96 , 7 , 24 , 33 , 114, 168, 209, 41 , 198, 164, 63 , 224, 39 , 141, 12 , 130, 234, 174, 180, 154, 99 , 73 , 229, 66 , 228, 21 , 183, 200, 6 , 112, 157, 65 , 117, 25 , 201, 170, 252, 77 , 191, 42 , 115, 132, 213, 195, 175, 43 , 134, 167, 177, 178, 91 , 70 , 211, 159, 253, 212, 15 , 156, 47 , 155, 67 , 239, 217, 121, 182, 83 , 127, 193, 240, 35 , 231, 37 , 94 , 181, 30 , 162, 223, 166, 254, 172, 34 , 249, 226, 74 , 188, 53 , 202, 238, 120, 5 , 107, 81 , 225, 89 , 163, 242, 113, 86 , 17 , 106, 137, 148, 101, 140, 187, 119, 60 , 123, 40 , 171, 210, 49 , 222, 196, 95 , 204, 207, 118, 44 , 184, 216, 46 , 54 , 219, 105, 179, 20 , 149, 190, 98 , 161, 59 , 22 , 102, 233, 92 , 108, 109, 173, 55 , 97 , 75 , 185, 227, 186, 241, 160, 133, 131, 218, 71 , 197, 176, 51 , 250, 150, 111, 110, 194, 246, 80 , 255, 93 , 169, 142, 23 , 27 , 151, 125, 236, 88 , 247, 31 , 251, 124, 9 , 13 , 122, 103, 69 , 135, 220, 232, 79 , 29 , 78 , 4 , 235, 248, 243, 62 , 61 , 189, 138, 136, 221, 205, 11 , 19 , 152, 2 , 147, 128, 144, 208, 36 , 52 , 203, 237, 244, 206, 153, 16 , 68 , 64 , 146, 58 , 1 , 38 , 18 , 26 , 72 , 104, 245, 129, 139, 199, 214, 32 , 10 , 8 , 0 , 76 , 215, 116 }; void initK(byte* inKey); //подаСтся ΠΊΠ»ΡŽΡ‡ 32 Π±Π°ΠΉΡ‚Π° static void LSX(byte* key, const byte* arg); //процСсс Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΉ L, S ΠΈ Π₯: ΠΏΠΎΠ΄Π°ΡŽΡ‚ΡΡ 16 Π±Π°ΠΉΡ‚ ΠΊΠ»ΡŽΡ‡Π° static void L(byte*); //L ΠΏΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΠΎΠ²Π°Π½ΠΈΠ΅, Π½Π° Π²Ρ…ΠΎΠ΄ ΠΏΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ массив 16 Π±Π°ΠΉΡ‚: Π² ΠΎΠ΄Π½ΠΎΠΌ случаС Π½ΠΎΠΌΠ΅Ρ€ //элСмСнта i Π² Π²ΠΈΠ΄Π΅ массива, Π² Π΄Ρ€ΡƒΠ³ΠΎΠΌ случаС массив послС R прСобразования static void F(byte* masC, byte* x, byte* y); //F ΠΏΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΠΎΠ²Π°Π½ΠΈΠ΅, Π½Π° Π²Ρ…ΠΎΠ΄Π΅ массив ΠΈΡ‚Π΅Ρ€Π°Ρ†ΠΈΠΎΠ½Π½Ρ‹Ρ… констант masC 16 Π±Π°ΠΉΡ‚, //массивы ΠΏΠΎ 16 Π±Π°ΠΉΡ‚ Ρ… ΠΈ Ρƒ, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΡΠ²Π»ΡΡŽΡ‚ΡΡ Ρ€Π°Π·Π»ΠΎΠΆΠ΅Π½ΠΈΠ΅ΠΌ ΠΊΠ»ΡŽΡ‡Π° 32 Π±Π°ΠΉΡ‚Π° //Π½Π° К1 ΠΈ К2 ΠΏΠΎ 16 Π±Π°ΠΉΡ‚ static void S(byte* masLSX_XSL); //ΠΏΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΠΎΠ²Π°Π½ΠΈΠ΅ S, ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌΡƒ Π½Π° Π²Ρ…ΠΎΠ΄ поступаСт массив ΠΈΠ· 16 Π±Π°ΠΉΡ‚ послС Π₯ static byte mul_gf256(byte x, byte y); //функция mul static void R(byte* arg); //ΠΏΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΠΎΠ²Π°Π½ΠΈΠ΅ R, Π½Π° Π²Ρ…ΠΎΠ΄ поступаСт массив ΠΈΠ· 16 Π±Π°ΠΉΡ‚ static byte l(byte* arg); //ΠΏΡ€Π΅ΠΎΠ±Ρ€Π°Π·ΠΎΠ²Π°Π½ΠΈΠ΅ l // массив ΠΈΠ· l подстановок const byte lNumbers[] = { 148, 32 , 133, 16 , 194, 192, 1 , 251, 1 , 192, 194, 16 , 133, 32 , 148, 1 }; static byte iterK[10][16]; static byte masC[32][16]; static byte masLSX_XSL[16]; static bool isMasC = false; static void GET_MAS_C() { for(int i = 0; i < 32; i++) { memset(masC[i], 0, 15); masC[i][15] = (byte) (i + 1); L(masC[i]); } } void init128Gost34_12_15(byte* key) { if (!isMasC) { GET_MAS_C(); isMasC = true; } initK(key); } void initK(byte* inKey) { byte x[16]; byte y[16]; for (int i = 0; i < 16; i++) { iterK[0][i] = x[i] = inKey[i]; iterK[1][i] = y[i] = inKey[i + 16]; } for (int i = 1; i < 5; i++) { int q = 0; for (int j = 1; j < 9; j++) { F(masC[(8 * (i - 1) + j) - 1], x, y); } arraycopy(x, 0, iterK[2 * i], 0, 16); arraycopy(y, 0, iterK[2 * i + 1], 0, 16); } } void close128Gost34_12_15(){ for (int i = 0; i < 32; i++) memset(masC[i], 0, 16); for (int i = 0; i < 10; i++) memset(iterK[i], 0, 16); } void encrypt128Gost34_12_15(byte* text){ byte block[16]; arraycopy(text, 0, block, 0, 16); for (int i = 0; i < 9; i++) {//Π΄Π»ΠΈΠ½Π° 16 Π±Π°ΠΉΡ‚ LSX(iterK[i], block); memmove(block, masLSX_XSL, 16); } X(block, iterK[9]); arraycopy(block, 0, text, 0, 16); } static void F(byte* key, byte* arg1, byte* arg0) { LSX(key, arg1); X(masLSX_XSL, arg0); arraycopy(arg1, 0, arg0, 0, 16); arraycopy(masLSX_XSL, 0, arg1, 0, 16); } static void LSX(byte* key, const byte* arg) { memmove(masLSX_XSL, key, 16); X(masLSX_XSL, arg); S(masLSX_XSL); L(masLSX_XSL); } static void S(byte* arg) { for (int i = 15; i >= 0; i--) arg[i] = pi[arg[i]]; } static byte l(byte* arg) { byte sum = arg[15]; for (int i = 14; i >= 0; i--) sum ^= mul_gf256(arg[i], lNumbers[i]); return sum; } static void R(byte* arg) { byte z = l(arg); byte buffer[16] = { 0 }; arraycopy(arg, 0, buffer, 1, 15); arraycopy(buffer, 1, arg, 1, 15); arg[0] = z; } static void L(byte* arg) { for (int i = 0; i < 16; i++) R(arg); } void X(byte* arg1, const byte* arg2) { for (int i = 0; i < 16; i++) arg1[i] ^= arg2[i]; } static byte mul_gf256(byte x, byte y) { byte z = 0x0; while (y) { if (y & 1) z ^= x; x = (x << 1) ^ (x & 0x80 ? 0xC3 : 0x00); y >>= 1; } return z; } void arraycopy(byte* masIn, int pos1, byte* masOut, int pos2, int length) { for (int i = pos1; i < (length + pos1); i++) { //masIn[i] = masOut[pos2]; masOut[pos2] = masIn[i]; pos2++; } } 

2 answers 2

Usually, an unknown link is a symptom of the following problem:

  • No header is included with the announcement of the character;
  • A file with a symbol implementation ( c , lib or dll ) is not connected;
  • If the symbol implementation is in binary form ( lib or dll ), it is possible that this binary view is incompatible with the current compiler, for example, due to a mismatching bitness.

    It seems I decided, I really forgot to write right away. In general, as I understood it, the problem was that I did not register the used .cpp and .h files in CMakeList.

     add_library( # Sets the name of the library. native-lib # Sets the library as a shared library. SHARED # Provides a relative path to your source file(s). src/main/cpp/native-lib.cpp src/main/cpp/gost34-12-15.cpp src/main/cpp/gost34-12-15.h src/main/cpp/gost34-13-15.cpp src/main/cpp/gost34-13-15.h) 

    Here it is. The truth is now another problem arose. No errors, the program starts. But for some reason it is not encrypted.