Stream entropy for the Vernam cipher. Android Studio JAVA
Vernam cipher Android JAVA

Stream entropy

Inventing is interesting
      To exchange encrypted messages, the sender must have the encryption key, and the recipient of the messages must have the decryption key.
      With symmetric encryption, two parties exchange a key, with asymmetric encryption, the recipient sends the public key to the message sender. And the sender-receiver channel becomes known, not hidden
      There are technologies that allow you to create encryption keys "on both sides" without exchanging any information, without a synchronization channel. Those. it is not clear who, with whom and in what way exchanges information, what types of encryption are used. In this form, using XOR transforms becomes much easier.
      This is an interesting task for programmers. As an example, let's create a prototype application for an Android smartphone that will "listen" to a digital stream of Internet radio and wait for a predefined sequence of bytes to appear in it.
      After a given sequence of bytes, N bytes of the encryption key are selected from the stream. Where N is the length of the encrypted message. This is the simplest option that can provide commercial encryption strength. Next, we will improve the process of creating an encryption key. Then we will show how to use photo archives, audio files, speech synthesis, bulletin boards, news feeds as a source of entropy.
      The Vernam cipher is a symmetric encryption system invented in 1917 by Gilbert Vernam.
      A cipher is a type of one-time pad cryptosystem. It uses the Boolean XOR function.
      The Vernam cipher is an example of a system with absolute cryptographic strength.
      One of the disadvantages of using such a cipher is the need to have the same cipher pads at two points - transmitting and receiving.
      Those. first you need to create and deliver a notebook with one-time encryption pages to both points, and only then you can exchange information.
      In modern commercial conditions, this is not very convenient.
      If quantum technologies had reached a sufficient level of development and terabytes of quantum entangled particles could be stored in smartphones, the problem of updating encryption pages would become insignificant.
      However, this is still a long way off.
      However, one can try to develop a system for synchronous generation of random numbers at two points (at any number of points) without directly exchanging synchronization information.
      The principle of operation is as follows: the application listens to a digital stream (or several streams) of Internet radio and waits for a predefined digital sequence (a set of bytes) to appear. After that, N bytes are written to be used as a cipherpad page. Here N is the number of bytes in the encrypted message.
      This is the simplest kind of technology - a demonstration of the fundamental possibility and a stand for obtaining statistics.
      The process of selecting bytes to write from a stream can be greatly complicated.
      A separate task is to synchronize the receipt of a code page on the transmitting and receiving side without exchanging synchronization information.
      Part 1 Selecting a fragment of a digital stream for recording.
      Let's create an Android Studio Java project to get N bytes for a ciphertext page.
      In this form, the application found two matches in 5 minutes.
      A sequence of bytes was searched in the buffer
       public static byte[] efind = {0,1,5,3,7,3,6,12,4,3,7}; // We are looking for an array of bytes in the buffer. If found - write to Log
      This is the simplest test array of bytes to look up in the stream. A more interesting variant with "holes" - not significant byte positions in the array.
      For example, you can hold down the following array in the search
       public static byte[] efind = {0,1,x,5,3,7,x,3,6,x,12,4,x,3,7};
      Where the "x" position can be anything and does not affect the search result.
      After the given array of bytes is found in the stream (in this example, efind), N bytes of the stream are written to a separate array - the ciphertext page. Where N is equal to the number of bytes in the encrypted message.
      Moreover, the bytes of the encryption page can also be read from the stream not in a row, but according to a predetermined algorithm (for example, skipping bytes).
      In this way, one of the shortcomings of the classic Vernam cipher is immediately overcome - we can get the encryption key of the required length.
      The ability to listen to the digital stream on the side of the sender and receiver allows you to overcome another drawback of the classic Vernam cipher. You can receive a cipherpad page independently on both the sender and recipient sides.
      There is no need for a transmission channel for encryption notebooks.
      But! In order to get the same sequence of numbers for encryption / decoding from the sender and recipient, two application instances must start listening to the digital Internet stream at the same time.
      Otherwise, different points of coincidence with the given array can be found and, accordingly, different arrays are written for encryption.
      How to synchronize the moment of obtaining keys from the Internet stream, if there is no (for stealth) synchronizing channel?
      If you do not perform special manipulations with the Internet radio data stream (transmission of the synchronization code), then the problem can be solved in the following way.
      An array of bytes with a larger length is set in the search in the digital radio stream. For example, for this case, you can choose this:
      public static byte[] efindnn = {0,1,5,3,7,3,6,12,4,3,7,5,1,4};
      Such a sequence will have to wait much longer. It may be several days or weeks. Immediately after such a sequence is found,
      the stream is searched for a shorter sequence and the cipher page is written. With a very high probability, it will be the same on both sides - transmitting and receiving.
      Internet radio stream vulnerability.
      This is a commercially viable encryption mechanism.
      Internet radio can be listened to by anyone, and, in theory, "interested" clients can be identified. To increase the secrecy of the exchange of information, you can
      use a digital satellite TV channel.
      For projects with more serious encryption reliability by the Vernam code, a satellite noise channel should be used - a digital noise stream based on a hardware source (for example, thermal noise of a diode, etc.).
      In principle, it is possible to obtain absolute strength of encryption without the classic shortcomings of the Vernam code - the difficulties of obtaining and distributing by cipher pads.
      At the same time, it is impossible to track who receives the code from the satellite stream. To exclude the use of noise satellite channel technology for obtaining encryption keys by outside clients, you can use encryption of the noise stream with a strong asymmetric algorithm.
      If a special noise satellite channel is used, it is possible to synchronize the process of obtaining a cipher page in another way. In a noisy digital stream, certain combinations of numbers are excluded. The appearance of such combinations in a digital stream is an element of synchronization for all parties involved in the transmission and receipt of encrypted information.
      Stream Encryption Project with Vernam Algorithm
      The Vernam cipher is very fast and does not require a lot of hardware resources. It is possible to build a stream encryption system based on a special noise satellite channel.
      On the Internet, technology can be used in other ways. A distributed network of servers-sources of noise digital streams for public commercial encryption can be created.
      For more serious cryptography, you can create hidden noise streams that are encapsulated in public data.
Download GitHUB Project >>
      JAVA Application Prototypes  
RadioRANDGen >>
      Android Studio SOURCE CODE (03.06.2023)
      A prototype Java application that generates an encryption (decode) key from an Internet radio digital stream, encrypts a message (XOR), sends a message via SMS to itself, receives an SMS and decodes the text - in the repository
      To create a full-fledged messenger, it is enough to replace the phone number with the recipient's number, increase the number of bytes to search in (public static byte[] efind = {00,01,05,03,07,03,06,12,04};) by 2-3 (so that the keys are found once an hour), run the application at the sender and recipient at the same time and check the sender's phone number (so as not to process extra SMS).
      This type of messenger is not very convenient in real operation, but when the encryption key generation algorithm is upgraded, it can provide a high degree of message protection.
      Let's write a prototype application on Android Java for synchronous generation of encryption keys for the sender and recipient without using digital streams. To do this, we use the technology of converting text to speech - speech synthesis using Android. Let's record the speech in an audio file, select from it (according to our algorithm) 1024 bytes for encryption with the Vernam code.
      In real use, such a messenger is much more convenient than the previous one. The usage algorithm is as follows: the sender and the recipient have two identical Android smartphones with the same OS version (and TTS API version, respectively). The sender and receiver (for example) buy the same newspaper and use the first 25 words from the first note as the text to be converted to speech (sound file). The application generates independently original sound files for the sender of the message and the recipient. The borrowing from sound files is selected according to some algorithm no more than 1024 bytes for use in XOR transformation.
TTS encryption Project >>
      Synthesizing speech from text is an interesting technology for generating encryption keys. But there are inconvenient features there: you need to select sections of the audio file with different values, discard duplicate elements, you need to use the same codec with the same parameters. But in return, you will receive the same encryption keys in several independent places if you use the same text for synthesis.
      You can create the same keys for the Vernam cipher (cipher pad) in different places without using synchronization channels in other ways. Particularly interesting is the technology with huge programming objects. Then you can create very high quality keys.
      Programming applications with huge objects is a completely different area of programming. This will require a fairly significant period of preparation or an interested team of programmers.
Next PAGE >>  Thread splitting >>
      We will invent something else
      For example. How to use noise channels to transmit information or "analog speech" in cryptography.

Vernam entropy

Vernam cipher project
Stream generation of cipher-notebooks