LCOV - code coverage report
Current view: top level - src/sip - sdes_negotiator.h (source / functions) Coverage Total Hit
Test: jami-coverage-filtered.info Lines: 0.0 % 3 0
Test Date: 2026-06-13 09:18:46 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /*
       2              :  *  Copyright (C) 2004-2026 Savoir-faire Linux Inc.
       3              :  *
       4              :  *  This program is free software: you can redistribute it and/or modify
       5              :  *  it under the terms of the GNU General Public License as published by
       6              :  *  the Free Software Foundation, either version 3 of the License, or
       7              :  *  (at your option) any later version.
       8              :  *
       9              :  *  This program is distributed in the hope that it will be useful,
      10              :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      11              :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      12              :  *  GNU General Public License for more details.
      13              :  *
      14              :  *  You should have received a copy of the GNU General Public License
      15              :  *  along with this program. If not, see <https://www.gnu.org/licenses/>.
      16              :  */
      17              : #pragma once
      18              : 
      19              : #include "media/media_codec.h"
      20              : 
      21              : #include <stdexcept>
      22              : #include <string>
      23              : #include <vector>
      24              : 
      25              : using namespace std::literals;
      26              : 
      27              : namespace jami {
      28              : 
      29              : /**
      30              :  * General exception object that is thrown when
      31              :  * an error occurred with a regular expression
      32              :  * operation.
      33              :  */
      34              : class ParseError : public std::invalid_argument
      35              : {
      36              : public:
      37            0 :     explicit ParseError(const std::string& error)
      38            0 :         : std::invalid_argument(error)
      39            0 :     {}
      40              : };
      41              : 
      42              : enum CipherMode : uint8_t { AESCounterMode, AESF8Mode };
      43              : 
      44              : enum MACMode : uint8_t { HMACSHA1 };
      45              : 
      46              : struct CryptoSuiteDefinition
      47              : {
      48              :     std::string_view name;
      49              :     int masterKeyLength;
      50              :     int masterSaltLength;
      51              :     int srtpLifetime;
      52              :     int srtcpLifetime;
      53              :     CipherMode cipher;
      54              :     int encryptionKeyLength;
      55              :     MACMode mac;
      56              :     int srtpAuthTagLength;
      57              :     int srtcpAuthTagLength;
      58              :     int srtpAuthKeyLength;
      59              :     int srtcpAuthKeyLen;
      60              : };
      61              : 
      62              : /**
      63              :  * List of accepted Crypto-Suites
      64              :  * as defined in RFC4568 (6.2)
      65              :  */
      66              : 
      67              : static std::vector<CryptoSuiteDefinition> CryptoSuites
      68              :     = {{"AES_CM_128_HMAC_SHA1_80"sv, 128, 112, 48, 31, AESCounterMode, 128, HMACSHA1, 80, 80, 160, 160},
      69              : 
      70              :        {"AES_CM_128_HMAC_SHA1_32"sv, 128, 112, 48, 31, AESCounterMode, 128, HMACSHA1, 32, 80, 160, 160},
      71              : 
      72              :        {"F8_128_HMAC_SHA1_80"sv, 128, 112, 48, 31, AESF8Mode, 128, HMACSHA1, 80, 80, 160, 160}};
      73              : 
      74              : class SdesNegotiator
      75              : {
      76              : public:
      77              :     SdesNegotiator();
      78              : 
      79              :     static CryptoAttribute negotiate(const std::vector<std::string>& attributes);
      80              : 
      81              :     inline explicit operator bool() const { return not CryptoSuites.empty(); }
      82              : 
      83              : private:
      84              :     static std::vector<CryptoAttribute> parse(const std::vector<std::string>& attributes);
      85              : };
      86              : 
      87              : } // namespace jami
        

Generated by: LCOV version 2.0-1