re let s build software cryptophones for over the internet in c a t demon co uk graham toal gtoal gtoal com writes in article regq innn u gap caltech edu hal cco caltech edu hal finney writes i tried this code yesterday on my sparcstation elc it takes over seconds to compress seconds worth of speech this means that it needs to be optimized by over a factor of before it will be usable in even a half duplex mode ouch thanks for trying it the following program is a very quick hack i created a few months ago to determine whether a sun sparcstation ipc could perform real time full duplex encrypted audio with resulting data rates sustainable by today s modems this test program reads linearly encoded audio from the audio device compresses it with gsm compresses frames of bit samples recorded at khz into bits resulting in a hz frame rate encrypts it with des then reverses the process and sends the reconstructed audio back to the audio device the compressed encrypted audio stream is kbits s my sparcstation ipc not exactly a very fast machine these days certainly slower than an elc would just barely sustain this activity audio underruns would occcur but the speech was very intelligible i ran it as a real time process to get the best results remember though that this program is a quick hack and the performance can certainly be improved the audio compression routines can be ftp d from tub cs tu berlin de i believe look for gsm or toast i used eric young s des implementation but i no longer know where i got it from cheers greg cut here test program to see how much cpu it takes for secure digital audio written by g onufer greg cheers bungi com written on a sun ipc running solaris with a sun isdn s bus card and a speakerbox include stdlib h include unistd h include fcntl h include stdio h include sys types h include sys audioio h include stropts h include gsm h include des h boolean t svs audio init int fd audio info t prev info audio info t info if prev info null if ioctl fd audio getinfo prev info perror audio getinfo return b false audio initinfo info info record pause b true info play pause b true info play sample rate info play encoding audio encoding linear info play channels info play precision info record sample rate info record encoding audio encoding linear info record channels info record precision info record buffer size if ioctl fd audio setinfo info perror audio setinfo return b false if ioctl fd i flush flushrw perror i flush return b false audio initinfo info info record pause b false info play pause b false if ioctl fd audio setinfo info perror audio setinfo return b false return b true boolean t svs in int ifd gsm handle gsm byte buf gsm signal sample if read ifd sample sizeof sample sizeof sample fprintf stderr svs in short read n return b false gsm encode handle sample buf return b true boolean t svs out int ofd gsm handle gsm byte buf gsm signal sample if gsm decode handle buf sample fprintf stderr svs out gsm decode failed n return b false if write ofd sample sizeof sample sizeof sample fprintf stderr svs out short write n return b false return b true main gsm handle gsm frame frame int audiofd int option des cblock key ivec in ivec out des key schedule ks in ks out des cblock cbuf in cbuf out cbuf buf audiofd open dev audio o rdwr if audiofd perror open exit initialize gsm compression code if handle gsm create null fprintf stderr svs gsm create failed n exit option b true if gsm option handle gsm opt fast option fprintf stderr svs gsm option fast failed n exit initialize des code des random key key if des set key key ks in fprintf stderr svs des set key failed n exit if des set key key ks out fprintf stderr svs des set key failed n exit memset ivec in sizeof ivec in memset ivec out sizeof ivec out open audio device and configure it if svs audio init audiofd null exit for get samples bit linear hz and convert to a byte frame if svs in audiofd handle frame exit encrypt decrypt block des cbc encrypt frame cbuf out long ks in ivec in des encrypt des cbc encrypt cbuf out cbuf buf long ks out ivec out des decrypt memmove frame cbuf buf if if memcmp cbuf in cbuf buf fprintf stderr svs memcmp failed n exit endif take byte frame and convert to samples and play if svs out audiofd handle frame exit gsm destroy handle cut here
