I'm trying to find any tutorial (or a sample) how to write a virtual USB kernel driver. Any ideas?
What does that mean to you, exactly? Do you mean you want to write a driver that imitates a USB device? What kind of device?
If there's no USB involved, then there's really no reason to call it a "USB kernel driver". It's just a kernel driver. Right? A "virtual USB audio driver" doesn't ever talk to USB. It's just a "virtual audio driver".
Yes, good points. Thanks. I want to understand how to write a virtual FIDO2 device. For instance, something like a YubiKey security key, which is a physical USB device, but done entirely in software.
I asked in a different thread and someone gave me two links to existing Github projects. The problem is that those are quite large, with user-mode code written in Go, and for the kernel part using some other driver with a very little description of how it works.
My question is about a document or a tutorial that can explain how it's done. Otherwise it's hard to read someone else's large project and trying to understand it from just the code comments.
You're missing the point. The whole POINT of a FIDO2 device is to introduce a physical factor to the process -- a fingerprint or a gesture. A virtual device would not provide that physical factor, and thus would never be approved.
But to repeat what I said before, imitating a USB FIDO2 device has nothing to do with USB. Most of the FIDO2 USB keys appear as nothing more than a keyboard. You can inject keystrokes into the input system without dealing with USB (and, in most cases, without dealing in kernel mode at all). The key problem with your plan is that you would need to know how to create the correct pin for the date/time. That's the magic sauce here. You would have to know what PIN the login system expects, and you can't do that unless you are the vendor.