Asterisk Implementation

I am currently working on Asterisk version 1.8 and have a few objectives that i want to achieve. So, i want to know somethings about Asterisk and its working. Please guide me as much as possible on the following:

  1. How and what method does Asterisk uses for securing the SIP Signalling? does it use Handshaking methods? Kindly explain.

  2. How does the SRTP features work and implemented? that is encryption of the RTP stream using the algorithms, (AES, IDEA or DES).

For both the above questions i need some reference to the source files (.c / .h). I want to study them and understand their implementation.

And Which source file actually takes the voice packets and puts them into RTP packets and sends them??

I am trying to write my own code for Encrypting RTP stream using AES, so any help in this regard would also be appreciated (I have already seen libSRTP)

  1. according to the RFCs
  2. use grep.