diff --git a/include/dsd.h b/include/dsd.h index 440a671..137da1c 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -751,9 +751,6 @@ uint16_t CRC15BitNXDN(uint8_t * BufferIn, uint32_t BitLength); uint16_t CRC12BitNXDN(uint8_t * BufferIn, uint32_t BitLength); uint8_t CRC6BitNXDN(uint8_t * BufferIn, uint32_t BitLength); void ScrambledNXDNVoiceBit(int * LfsrValue, char * BufferIn, char * BufferOut, int NbOfBitToScramble); -void NxdnEncryptionStreamGeneration (dsd_opts* opts, dsd_state* state, uint8_t KeyStream[1664]); - -void processMbeFrameEncrypted (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24], char ambe_keystream[49], char imbe_keystream[88]); //LEH dPMR void dPMRVoiceFrameProcess(dsd_opts * opts, dsd_state * state); @@ -767,7 +764,7 @@ uint8_t CRC8BitdPMR(uint8_t * BufferIn, uint32_t BitLength); void ConvertAirInterfaceID(uint32_t AI_ID, uint8_t ID[8]); int32_t GetdPmrColorCode(uint8_t ChannelCodeBit[24]); //LEH DMR -void ProcessDMR (dsd_opts * opts, dsd_state * state); +void ProcessDMR (dsd_opts * opts, dsd_state * state); void DMRDataFrameProcess(dsd_opts * opts, dsd_state * state); void DMRVoiceFrameProcess(dsd_opts * opts, dsd_state * state); //BPTC (Block Product Turbo Code) functions diff --git a/src/dsd_mbe.c b/src/dsd_mbe.c index 645d768..bfc5883 100644 --- a/src/dsd_mbe.c +++ b/src/dsd_mbe.c @@ -166,121 +166,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a } } -void processMbeFrameEncrypted (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char ambe_fr[4][24], char imbe7100_fr[7][24], char ambe_keystream[49], char imbe_keystream[88]) -{ - - int i; - char imbe_d[88]; - char ambe_d[49]; -#ifdef AMBE_PACKET_OUT - char ambe_d_str[50]; -#endif - - for (i = 0; i < 88; i++) - { - imbe_d[i] = 0; - } - - if ((state->synctype == 0) || (state->synctype == 1)) - { - // 0 +P25p1 - // 1 -P25p1 - - mbe_processImbe7200x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); - - DecipherData(imbe_d, imbe_keystream, imbe_d, 88); - - if (opts->mbe_out_f != NULL) - { - saveImbe4400Data (opts, state, imbe_d); - } - } - else if ((state->synctype == 14) || (state->synctype == 15)) - { - mbe_processImbe7100x4400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, imbe7100_fr, imbe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); - - DecipherData(imbe_d, imbe_keystream, imbe_d, 88); - - if (opts->mbe_out_f != NULL) - { - saveImbe4400Data (opts, state, imbe_d); - } - } - else if ((state->synctype == 6) || (state->synctype == 7)) - { - //mbe_processAmbe3600x2400Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); - - state->errs = 0; - state->errs2 = 0; - state->errs = mbe_eccAmbe3600x2400C0 (ambe_fr); - mbe_demodulateAmbe3600x2400Data (ambe_fr); - state->errs2 = state->errs; - state->errs2 += mbe_eccAmbe3600x2400Data (ambe_fr, ambe_d); - - memcpy(state->ambe_ciphered, ambe_d, sizeof(state->ambe_ciphered)); - DecipherData(ambe_d, ambe_keystream, ambe_d, 49); - memcpy(state->ambe_deciphered, ambe_d, sizeof(state->ambe_deciphered)); - - mbe_processAmbe2400Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); - - if (opts->mbe_out_f != NULL) - { - saveAmbe2450Data (opts, state, ambe_d); - } - } - else - { - //mbe_processAmbe3600x2450Framef (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_fr, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); - - state->errs = 0; - state->errs2 = 0; - state->errs = mbe_eccAmbe3600x2450C0 (ambe_fr); - mbe_demodulateAmbe3600x2450Data (ambe_fr); - state->errs2 = state->errs; - state->errs2 += mbe_eccAmbe3600x2450Data (ambe_fr, ambe_d); - - memcpy(state->ambe_ciphered, ambe_d, sizeof(state->ambe_ciphered)); - DecipherData(ambe_d, ambe_keystream, ambe_d, 49); - memcpy(state->ambe_deciphered, ambe_d, sizeof(state->ambe_deciphered)); - - mbe_processAmbe2450Dataf (state->audio_out_temp_buf, &state->errs, &state->errs2, state->err_str, ambe_d, state->cur_mp, state->prev_mp, state->prev_mp_enhanced, opts->uvquality); - -#ifdef AMBE_PACKET_OUT - for(i=0; i<49; i++) { - ambe_d_str[i] = ambe_d[i] + '0'; - } - ambe_d_str[49] = '\0'; - // print binary string - fprintf(stderr, "\n?\t?\t%s\t", ambe_d_str); - // print error data - fprintf(stderr, "E1: %d; E2: %d; S: %s", state->errs, state->errs2, state->err_str); -#endif - if (opts->mbe_out_f != NULL) - { - saveAmbe2450Data (opts, state, ambe_d); - } - } - - if (opts->errorbars == 1) - { - fprintf(stderr, "%s", state->err_str); - } - - state->debug_audio_errors += state->errs2; - - processAudio (opts, state); - if (opts->wav_out_f != NULL) - { - writeSynthesizedVoice (opts, state); - } - - if (opts->audio_out == 1) - { - playSynthesizedVoice (opts, state); - } -} - -/* This function decipher/decrypt data */ +/* This function decipher data */ static void DecipherData(char * Input, char * KeyStream, char * Output, int NbData) { int i; diff --git a/src/nxdn_lib.c b/src/nxdn_lib.c index d8060a8..3eb37e2 100644 --- a/src/nxdn_lib.c +++ b/src/nxdn_lib.c @@ -627,8 +627,6 @@ void NXDN_Elements_Content_decode(dsd_opts * opts, dsd_state * state, CurrentIV = CurrentIV << 8; } - /* Encryption is not supported in the public version, - * so do not compute the next IV */ } break; } /* End case NXDN_VCALL_IV: */ @@ -1043,67 +1041,5 @@ void ScrambledNXDNVoiceBit(int * LfsrValue, char * BufferIn, char * BufferOut, i } /* End ScrambledNXDNVoiceBit() */ -void NxdnEncryptionStreamGeneration (dsd_opts* opts, dsd_state* state, uint8_t KeyStream[1664]) -{ - uint32_t i = 0, j = 0, k = 0; - uint32_t LFSR = 0; - uint64_t CurrentIV = 0; - uint64_t NextIV = 0; - uint64_t TempIV = 0; - uint8_t Temp = 0; - - /* Remove compiler warning */ - /* - UNUSED_VARIABLE(opts); - UNUSED_VARIABLE(state); - UNUSED_VARIABLE(i); - UNUSED_VARIABLE(j); - UNUSED_VARIABLE(k); - UNUSED_VARIABLE(LFSR); - UNUSED_VARIABLE(CurrentIV); - UNUSED_VARIABLE(NextIV); - UNUSED_VARIABLE(TempIV); - UNUSED_VARIABLE(Temp); - */ - if((state->NxdnElementsContent.CipherParameterValidity)) - { - //fprintf(stderr, "Scrambler Encryption "); - - /* Scrambler encryption mode */ - if(state->NxdnElementsContent.CipherType == 0x01) - { - /* Encryption not supported in the public version - * Set the keystream to 0 */ - memset(KeyStream, 0, sizeof(uint8_t) * 1664); - - } /* End if(state->NxdnElementsContent.CipherType == 0x01) - Scrambler */ - /* DES Mode */ - else if(state->NxdnElementsContent.CipherType == 0x02) - { - /* Encryption not supported in the public version - * Set the keystream to 0 */ - memset(KeyStream, 0, sizeof(uint8_t) * 1664); - } /* End else if(state->NxdnElementsContent.CipherType == 0x02) - DES mode */ - /* AES Mode */ - else if(state->NxdnElementsContent.CipherType == 0x03) - { - /* Encryption not supported in the public version - * Set the keystream to 0 */ - memset(KeyStream, 0, sizeof(uint8_t) * 1664); - } /* End else if(state->NxdnElementsContent.CipherType == 0x03) - AES mode */ - else - { - /* No encryption required, simply set the keystream to "0" */ - memset(KeyStream, 0, sizeof(uint8_t) * 1664); - } - } - else - { - /* No encryption required or error, simply set the keystream to "0" */ - memset(KeyStream, 0, sizeof(uint8_t) * 1664); - } - -} /* End NxdnEncryptionStreamGeneration() */ - /* End of file */ diff --git a/src/nxdn_voice.c b/src/nxdn_voice.c index 8f7486d..ac0af8c 100644 --- a/src/nxdn_voice.c +++ b/src/nxdn_voice.c @@ -16,7 +16,6 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state) uint8_t StructureField = 0; uint8_t RAN = 0; uint8_t PartOfFrame = 0; - uint8_t KeyStream[1664] = {0}; char ambe7bytesArray[7] = {0}; int PartOfEncryptedSuperFrame = 0; @@ -26,7 +25,7 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state) } /* Start pseudo-random NXDN sequence after - * LITCH = 16 bit = 8 dibit + * LICH = 16 bit = 8 dibit * ==> Index 8 */ pr = (unsigned char *)(&nxdnpr2[8]); for (i = 0; i < 30; i++) @@ -87,13 +86,6 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state) } else fprintf(stderr, "(CRC ERR) - "); - /* Generate the key stream */ - NxdnEncryptionStreamGeneration(opts, state, KeyStream); - - //fprintf(stderr, "\nKeyStream = "); - //for(i = 0; i < 49; i++) fprintf(stderr, "%d", KeyStream[i]); - //fprintf(stderr, "\n"); - /* Determine the current part of superframe * (in an AES or DES encrypted frame, two superframes @@ -118,7 +110,7 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state) } /* Start pseudo-random NXDN sequence after - * LITCH = 16 bit = 8 dibit + + * LICH = 16 bit = 8 dibit + * SACCH = 60 bit = 30 dibit * = 76 bit = 38 dibit * ==> Index 38 */ @@ -144,26 +136,8 @@ void processNXDNVoice (dsd_opts * opts, dsd_state * state) y++; z++; } - //processMbeFrame (opts, state, NULL, ambe_fr, NULL); - processMbeFrameEncrypted(opts, state, NULL, ambe_fr, NULL, (char *)&KeyStream[(PartOfEncryptedSuperFrame * 4 * 4 * 49) + (PartOfFrame * 4 * 49) + (j * 49)], NULL); + processMbeFrame (opts, state, NULL, ambe_fr, NULL); - -#ifdef BUILD_DSD_WITH_FRAME_CONTENT_DISPLAY - if(state->printNXDNAmbeVoiceSampleHex) - { - /* Display AMBE frame content */ - /* Convert the 49 bit AMBE frame into 7 bytes */ - Convert49BitSampleInto7Bytes(state->ambe_deciphered, ambe7bytesArray); - fprintf(stderr, "\nVoice Frame %d/4 : ", j + 1); - fprintf(stderr, "E1 = %d ; E2 = %d ; Content = ", state->errs, state->errs2); - for(i = 0; i < 7; i++) fprintf(stderr, "0x%02X, ", ambe7bytesArray[i] & 0xFF); - //fprintf(stderr, "\n"); - } -#endif /* BUILD_DSD_WITH_FRAME_CONTENT_DISPLAY */ - -#ifdef NXDN_DUMP - fprintf(stderr, " "); -#endif } /* End for (j = 0; j < 4; j++) */ if (opts->errorbars == 1)