| OLD | NEW |
| 1 /* | 1 /* |
| 2 * ekt.c | 2 * ekt.c |
| 3 * | 3 * |
| 4 * Encrypted Key Transport for SRTP | 4 * Encrypted Key Transport for SRTP |
| 5 * | 5 * |
| 6 * David McGrew | 6 * David McGrew |
| 7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
| 8 */ | 8 */ |
| 9 /* | 9 /* |
| 10 * | 10 * |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 36 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 37 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 41 * OF THE POSSIBILITY OF SUCH DAMAGE. | 41 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 42 * | 42 * |
| 43 */ | 43 */ |
| 44 | 44 |
| 45 | 45 |
| 46 #include "srtp_priv.h" |
| 46 #include "err.h" | 47 #include "err.h" |
| 47 #include "srtp_priv.h" | |
| 48 #include "ekt.h" | 48 #include "ekt.h" |
| 49 | 49 |
| 50 extern debug_module_t mod_srtp; | 50 extern debug_module_t mod_srtp; |
| 51 | 51 |
| 52 /* | 52 /* |
| 53 * The EKT Authentication Tag format. | 53 * The EKT Authentication Tag format. |
| 54 * | 54 * |
| 55 * 0 1 2 3 | 55 * 0 1 2 3 |
| 56 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | 56 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 57 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 57 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 ekt_stream_init_from_policy(ekt_stream_t stream_data, ekt_policy_t policy) { | 141 ekt_stream_init_from_policy(ekt_stream_t stream_data, ekt_policy_t policy) { |
| 142 if (!stream_data) | 142 if (!stream_data) |
| 143 return err_status_ok; | 143 return err_status_ok; |
| 144 | 144 |
| 145 return err_status_ok; | 145 return err_status_ok; |
| 146 } | 146 } |
| 147 | 147 |
| 148 | 148 |
| 149 void | 149 void |
| 150 aes_decrypt_with_raw_key(void *ciphertext, const void *key, int key_len) { | 150 aes_decrypt_with_raw_key(void *ciphertext, const void *key, int key_len) { |
| 151 #ifndef OPENSSL |
| 152 //FIXME: need to get this working through the crypto module interface |
| 151 aes_expanded_key_t expanded_key; | 153 aes_expanded_key_t expanded_key; |
| 152 | 154 |
| 153 aes_expand_decryption_key(key, key_len, &expanded_key); | 155 aes_expand_decryption_key(key, key_len, &expanded_key); |
| 154 aes_decrypt(ciphertext, &expanded_key); | 156 aes_decrypt(ciphertext, &expanded_key); |
| 157 #endif |
| 155 } | 158 } |
| 156 | 159 |
| 157 /* | 160 /* |
| 158 * The function srtp_stream_init_from_ekt() initializes a stream using | 161 * The function srtp_stream_init_from_ekt() initializes a stream using |
| 159 * the EKT data from an SRTCP trailer. | 162 * the EKT data from an SRTCP trailer. |
| 160 */ | 163 */ |
| 161 | 164 |
| 162 err_status_t | 165 err_status_t |
| 163 srtp_stream_init_from_ekt(srtp_stream_t stream, | 166 srtp_stream_init_from_ekt(srtp_stream_t stream, |
| 164 const void *srtcp_hdr, | 167 const void *srtcp_hdr, |
| 165 unsigned pkt_octet_len) { | 168 unsigned pkt_octet_len) { |
| 166 err_status_t err; | 169 err_status_t err; |
| 167 const uint8_t *master_key; | 170 const uint8_t *master_key; |
| 168 srtp_policy_t srtp_policy; | 171 srtp_policy_t srtp_policy; |
| 169 unsigned master_key_len; | |
| 170 uint32_t roc; | 172 uint32_t roc; |
| 171 | 173 |
| 172 /* | 174 /* |
| 173 * NOTE: at present, we only support a single ekt_policy at a time. | 175 * NOTE: at present, we only support a single ekt_policy at a time. |
| 174 */ | 176 */ |
| 175 if (stream->ekt->data->spi != | 177 if (stream->ekt->data->spi != |
| 176 srtcp_packet_get_ekt_spi(srtcp_hdr, pkt_octet_len)) | 178 srtcp_packet_get_ekt_spi(srtcp_hdr, pkt_octet_len)) |
| 177 return err_status_no_ctx; | 179 return err_status_no_ctx; |
| 178 | 180 |
| 179 if (stream->ekt->data->ekt_cipher_type != EKT_CIPHER_AES_128_ECB) | 181 if (stream->ekt->data->ekt_cipher_type != EKT_CIPHER_AES_128_ECB) |
| 180 return err_status_bad_param; | 182 return err_status_bad_param; |
| 181 master_key_len = 16; | |
| 182 | 183 |
| 183 /* decrypt the Encrypted Master Key field */ | 184 /* decrypt the Encrypted Master Key field */ |
| 184 master_key = srtcp_packet_get_emk_location(srtcp_hdr, pkt_octet_len); | 185 master_key = srtcp_packet_get_emk_location(srtcp_hdr, pkt_octet_len); |
| 185 /* FIX!? This decrypts the master key in-place, and never uses it */ | 186 /* FIX!? This decrypts the master key in-place, and never uses it */ |
| 186 /* FIX!? It's also passing to ekt_dec_key (which is an aes_expanded_key_t) | 187 /* FIX!? It's also passing to ekt_dec_key (which is an aes_expanded_key_t) |
| 187 * to a function which expects a raw (unexpanded) key */ | 188 * to a function which expects a raw (unexpanded) key */ |
| 188 aes_decrypt_with_raw_key((void*)master_key, &stream->ekt->data->ekt_dec_key, 1
6); | 189 aes_decrypt_with_raw_key((void*)master_key, &stream->ekt->data->ekt_dec_key, 1
6); |
| 189 | 190 |
| 190 /* set the SRTP ROC */ | 191 /* set the SRTP ROC */ |
| 191 roc = srtcp_packet_get_ekt_roc(srtcp_hdr, pkt_octet_len); | 192 roc = srtcp_packet_get_ekt_roc(srtcp_hdr, pkt_octet_len); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 /* | 270 /* |
| 270 * if there is no EKT policy, then the other inputs are unaffected | 271 * if there is no EKT policy, then the other inputs are unaffected |
| 271 */ | 272 */ |
| 272 if (!ekt) | 273 if (!ekt) |
| 273 return; | 274 return; |
| 274 | 275 |
| 275 /* copy auth_tag into temporary location */ | 276 /* copy auth_tag into temporary location */ |
| 276 | 277 |
| 277 } | 278 } |
| 278 | 279 |
| OLD | NEW |