Need help with windows audio driver

Hi, I’m new in driver development. I need to read data from an analog-to-digital converter on a sound card when the microphone is muted, if it is possible of course. As I understand, I should get a noise on the sound card. How could I do this at the driver level? Sorry for my English.

xxxxx@gmail.com wrote:

Hi, I’m new in driver development. I need to read data from an analog-to-digital converter on a sound card when the microphone is muted, if it is possible of course. As I understand, I should get a noise on the sound card. How could I do this at the driver level?

You can’t.  There is no single standard for how microphone muting is
accomplished, but you can sit down and think about how it might be
implemented.

Usually, the audio driver and the hardware are involved.  The audio
driver gets the mute request and sets a hardware register.  That
register either turns off the ADC, or turns the attenuation to maximum,
or substitutes a stream of zeros for the ADC output.  In any of those
cases, there is simply no data to be had.

Now, in some cases the microphone itself will have a “mute” button,
independent of the audio card.  In that case, the audio card won’t even
know there was a mute request; the data stream will still be flowing,
and any application could fetch it.

What on earth are you actually trying to do?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi, Tim.
I wanted to create a generator of true-random numbers obtained from the last bits of registers on the ADC of the sound card. I tried to use standard IPAs, such as DirectSound, waveform audio, but without the microphone, the applications does not work. So I thought about creating a driver. But I have no experience with them.

Most high quality random number generation really only need to generate a seed, for a pseudo random number generator. This is how you generate random numbers at a high bandwidth. The hardware methods tend not to be real fast at generating entropy.

You know, the OS has user mode APIs you can call to get high quality random numbers.

In the old days (the '90s) we used to generate “fairly good” random numbers by looking at two high frequency clocks from different timebases. Like for example one clock might be the CPU processor clock, and another clock was the periodic system interrupts (originating from a timer chip on the motherboard). You could spin the cpu counting some variable, and activate a timer event to fire periodically. When the timer fired you extract a bit or two from the cpu driven counter. The theory was each clock had a little intrinsic jitter and different thermal drift, so would never be synchronized.

Another really common method used was to ask the user to juggle the mouse while entropy was extracted from bits in the x/y position. I’m not sure this method would survive todays level of random number scrutiny as mechanical devices tend to have patterns of motion.

When the Internet was not as established, Silicon Graphics used a camera looking at lava lamps to seed random number generators, SGI even had a patent on this. Wikipedia says CloudFlair (in 2017) still does this, securing 10% of the Internet traffic (https://en.wikipedia.org/wiki/Lavarand).

If course today, many cpus have a random number instruction that returns a value generated by an electrical noise source, assuming you trust Intel.

Some data suggests there is no such thing as a random number. Research at Princeton (http://noosphere.princeton.edu/) produced 15 years of data that strongly indicate high quality random number generators are influenced by human consciousness. The scientist part of me finds the conclusion difficult to accept, but the data is pretty compelling, and the raw data is freely available for your own analysis.

I general, making excellent random numbers is a difficult problem, and for most developers it’s likely better to rely on some source that’s been very carefully scrutinized. For example, even if you could easily get the ADC converter data from a muted microphone, how do you know it doesn’t contain a very regular pattern from the power supply ripple? A LOT of crypto systems have proven to be insecure, because the source of the random numbers were discovered not to be very random. It seems very likely every developer of those systems believed they had a almost perfect source of entropy. Determining if numbers really are random is a tricky problem. As an example, GPS signals, which modern phones can easily receive, are 26 decibels (about 400 times) below the background noise level.

Jan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, February 19, 2018 11:16 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Need help with windows audio driver

Hi, Tim.
I wanted to create a generator of true-random numbers obtained from the last bits of registers on the ADC of the sound card. I tried to use standard IPAs, such as DirectSound, waveform audio, but without the microphone, the applications does not work. So I thought about creating a driver. But I have no experience with them.


NTDEV is sponsored by OSR

Visit the list online at: http:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:

To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:>

Hi Jan, thank you for responding.
The above is my task at work. And the boss wants to use the sound card. Alas, standard applications for working with a sound card are not suitable, since the presence of a microphone is necessary. So I decided to write a driver. I would like to find an example of a driver that would read the data from the ADC on a sound card, but unfortunately could not find it.

I find the suggestion that this is a usable source of random numbers not
very convincing. OTOH I could imagine a lot of interest in being able to
listen in to a microphone that the user believes to be muted.

On 20/02/2018 11:48, xxxxx@gmail.com wrote:

Hi Jan, thank you for responding.
The above is my task at work. And the boss wants to use the sound card. Alas, standard applications for working with a sound card are not suitable, since the presence of a microphone is necessary. So I decided to write a driver. I would like to find an example of a driver that would read the data from the ADC on a sound card, but unfortunately could not find it.


NTDEV is sponsored by OSR

Visit the list online at: http:
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at http:
></http:></http:></http:>

xxxxx@gmail.com wrote:

I wanted to create a generator of true-random numbers obtained from the last bits of registers on the ADC of the sound card. I tried to use standard IPAs, such as DirectSound, waveform audio, but without the microphone, the applications does not work. So I thought about creating a driver. But I have no experience with them.

No, your task is both hopeless and unnecessary.

It is hopeless because, unless you are the manufacturer of the audio
board, you have neither enough information nor enough control to do what
you ask.  You don’t know how the paths are engineered.  You don’t know
how “mute” is implemented.  And further, you don’t really have any idea
whether the ADC is truly random.

It is unnecessary because Windows already has crytpographically secure
random number generators that use system entropy to generate random
bits.  Those functions have been studied and vetted.  Look up SystemPrng
and BCryptGenRandom, both of which are available in kernel mode.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

xxxxx@probo.com wrote:

xxxxx@gmail.com wrote:
> I wanted to create a generator of true-random numbers obtained from the last bits of registers on the ADC of the sound card.
It is unnecessary because Windows already has crytpographically secure
random number generators that use system entropy to generate random
bits.  Those functions have been studied and vetted.  Look up SystemPrng
and BCryptGenRandom, both of which are available in kernel mode.

Allow me to follow up by paraphrasing Knuth from the Art of Computer
Programming, volume 2.  Unless you are a trained random  number
researcher, any random number generator you develop will not be random.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

>As an example, GPS signals, which modern phones can easily receive, are 26 decibels (about 400 times) below the background noise level.

To avoid a misconception, your phrase lacks “in a band N Hz wide”. Noise level depends on the bandwidth (also on the equivalent noise temperature of the receiver which for an uncooled device is 300+ K). One source states that typical RX power of a GPS receiver is -125 dBm. Suppose, the noise temperature of the receiver is 600 K, which produces -170 dBm of noise in 1 Hz bandwidth. Different bandwidth is required for acquisition and for tracking. To decode “navigation message”, you need 50-100 Hz bandwidth, although you need to scan wider range of frequencies to detect the signal (Doppler shift could be in 10000 Hz range). The correlation length of coarse acquisition code is 1 ms, which sets its equivalent bandwidth in order of 1 kHz. In 1 kHz bandwidth, the equivalent noise level becomes -140 dBm, which is still below the typical received signal by 15 dB.

Hi, thank you for all your respondings.
But I still have last question. Is it possible to read the data from the ADC of the sound card without load? And if yes, then how?

On Feb 20, 2018, at 11:25 PM, xxxxx@gmail.com wrote:
>
> Hi, thank you for all your respondings.
> But I still have last question. Is it possible to read the data from the ADC of the sound card without load? And if yes, then how?

I find this kind of message very frustrating. I’ve told you twice why this is impossible, and your response each time is “OK, I understand, but how can I do it?”

It’s not just one problem. There are MULTIPLE reasons why this cannot be made to work. First, the sound cards in your computer already have drivers. Those drivers maintain all of the registers and the state of the hardware. You cannot just go in and take control of the hardware when another driver is controlling it.

Second, even if you did have exclusive access, you don’t know what the registers are. There are many different types of audio devices in the world. You can’t trigger a transfer if you don’t know what registers to tweak. In the case of USB Audio devices, you don’t have access to the ADC at all – that’s all handled in the hardware, outside of the computer.

Third, there is no universal way for you to put the ADC into a “no load” condition. How would you do that? Would you ask the user to unplug the microphone? Most audio boards have “plug detection” to determine when a mic is present. When the mic is pulled, maybe they turn off the ADC. You don’t know.

Your boss had an interesting idea, but it cannot be made to work. If you want to implement your own source of entropy for random bits, you can certainly create your own piece of hardware, but that would be idiotic. The GOAL here is to generate truly cyptographically random bits. The operating system can already do that. Whatever you invent is going to be more expensive and less secure.

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.