diff --git a/transporthandler.cpp b/transporthandler.cpp
index 4479489..d570996 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -1,4 +1,5 @@
 #include "app/channel.hpp"
+#include "user_channel/cipher_mgmt.hpp"
 
 #include <arpa/inet.h>
 #include <netinet/ether.h>
@@ -185,6 +186,7 @@
     VLANId = 20,
     CiphersuiteSupport = 22,
     CiphersuiteEntries = 23,
+    cipherSuitePrivilegeLevels = 24,
     IPFamilySupport = 50,
     IPFamilyEnables = 51,
     IPv6Status = 55,
@@ -1672,6 +1674,34 @@
             // Accept any prefix value since our prefix length has to be 0
             return responseSuccess();
         }
+        case LanParam::cipherSuitePrivilegeLevels:
+        {
+            uint8_t reserved;
+            std::array<uint4_t, ipmi::maxCSRecords> cipherSuitePrivs;
+
+            if (req.unpack(reserved, cipherSuitePrivs) || !req.fullyUnpacked())
+            {
+                return responseReqDataLenInvalid();
+            }
+
+            if (reserved)
+            {
+                return responseInvalidFieldRequest();
+            }
+
+            uint8_t resp =
+                getCipherConfigObject(csPrivFileName, csPrivDefaultFileName)
+                    .setCSPrivilegeLevels(channel, cipherSuitePrivs);
+            if (!resp)
+            {
+                return responseSuccess();
+            }
+            else
+            {
+                req.trailingOk = true;
+                return response(resp);
+            }
+        }
     }
 
     if ((parameter >= oemCmdStart) && (parameter <= oemCmdEnd))
@@ -1930,6 +1960,24 @@
             ret.pack(dataRef(prefix));
             return responseSuccess(std::move(ret));
         }
+        case LanParam::cipherSuitePrivilegeLevels:
+        {
+            std::array<uint4_t, ipmi::maxCSRecords> csPrivilegeLevels;
+
+            uint8_t resp =
+                getCipherConfigObject(csPrivFileName, csPrivDefaultFileName)
+                    .getCSPrivilegeLevels(channel, csPrivilegeLevels);
+            if (!resp)
+            {
+                constexpr uint8_t reserved1 = 0x00;
+                ret.pack(reserved1, csPrivilegeLevels);
+                return responseSuccess(std::move(ret));
+            }
+            else
+            {
+                return response(resp);
+            }
+        }
     }
 
     if ((parameter >= oemCmdStart) && (parameter <= oemCmdEnd))
diff --git a/user_channel/cipher_mgmt.cpp b/user_channel/cipher_mgmt.cpp
index 19dca48..ca9c2d4 100644
--- a/user_channel/cipher_mgmt.cpp
+++ b/user_channel/cipher_mgmt.cpp
@@ -22,7 +22,6 @@
 
 #include <filesystem>
 #include <fstream>
-#include <include/ipmid/api-types.hpp>
 #include <phosphor-logging/log.hpp>
 
 namespace ipmi
@@ -174,4 +173,72 @@
     return ipmi::privList.at(static_cast<size_t>(value));
 }
 
+ipmi::Cc CipherConfig::getCSPrivilegeLevels(
+    uint8_t chNum, std::array<uint4_t, maxCSRecords>& csPrivilegeLevels)
+{
+    if (!isValidChannel(chNum))
+    {
+        log<level::ERR>("Invalid channel number", entry("CHANNEL=%u", chNum));
+        return ccInvalidFieldRequest;
+    }
+
+    for (size_t csNum = 0; csNum < maxCSRecords; ++csNum)
+    {
+        csPrivilegeLevels[csNum] = csPrivilegeMap[{chNum, csNum}];
+    }
+    return ccSuccess;
+}
+
+ipmi::Cc CipherConfig::setCSPrivilegeLevels(
+    uint8_t chNum, const std::array<uint4_t, maxCSRecords>& requestData)
+{
+    if (!isValidChannel(chNum))
+    {
+        log<level::ERR>("Invalid channel number", entry("CHANNEL=%u", chNum));
+        return ccInvalidFieldRequest;
+    }
+
+    Json jsonData;
+    if (!fs::exists(cipherSuitePrivFileName))
+    {
+        log<level::INFO>("CS privilege levels user settings file does not "
+                         "exist. Creating...");
+    }
+    else
+    {
+        jsonData = readCSPrivilegeLevels(cipherSuitePrivFileName);
+        if (jsonData == nullptr)
+        {
+            return ccUnspecifiedError;
+        }
+    }
+
+    Json privData;
+    std::string csKey;
+    constexpr auto privMaxValue = static_cast<uint8_t>(ipmi::Privilege::Oem);
+    for (size_t csNum = 0; csNum < maxCSRecords; ++csNum)
+    {
+        csKey = "CipherID" + std::to_string(csNum);
+        auto priv = static_cast<uint8_t>(requestData[csNum]);
+
+        if (priv > privMaxValue)
+        {
+            return ccInvalidFieldRequest;
+        }
+        privData[csKey] = convertToPrivLimitString(priv);
+    }
+
+    std::string chKey = "Channel" + std::to_string(chNum);
+    jsonData[chKey] = privData;
+
+    if (writeCSPrivilegeLevels(jsonData))
+    {
+        log<level::ERR>("Error in setting CS Privilege Levels.");
+        return ccUnspecifiedError;
+    }
+
+    updateCSPrivilegesMap(jsonData);
+    return ccSuccess;
+}
+
 } // namespace ipmi
diff --git a/user_channel/cipher_mgmt.hpp b/user_channel/cipher_mgmt.hpp
index 79afc23..f2ea9f3 100644
--- a/user_channel/cipher_mgmt.hpp
+++ b/user_channel/cipher_mgmt.hpp
@@ -16,6 +16,7 @@
 #pragma once
 #include "channel_layer.hpp"
 
+#include <ipmid/api-types.hpp>
 #include <ipmid/message/types.hpp>
 #include <map>
 #include <nlohmann/json.hpp>
@@ -44,6 +45,33 @@
                           const std::string& csDefaultFileName);
     CipherConfig() = delete;
 
+    /** @brief function to get cipher suite privileges from config file
+     *
+     *  @param[in] chNum - channel number for which we want to get cipher suite
+     * privilege levels
+     *
+     *  @param[in] csPrivilegeLevels - gets filled by cipher suite privilege
+     * levels
+     *
+     *  @return 0 for success, non zero value for failure
+     */
+    ipmi::Cc getCSPrivilegeLevels(
+        uint8_t chNum, std::array<uint4_t, maxCSRecords>& csPrivilegeLevels);
+
+    /** @brief function to set/update cipher suite privileges in config file
+     *
+     *  @param[in] chNum - channel number for which we want to update cipher
+     * suite privilege levels
+     *
+     *  @param[in] csPrivilegeLevels - cipher suite privilege levels to update
+     * in config file
+     *
+     *  @return 0 for success, non zero value for failure
+     */
+    ipmi::Cc setCSPrivilegeLevels(
+        uint8_t chNum,
+        const std::array<uint4_t, maxCSRecords>& csPrivilegeLevels);
+
   private:
     std::string cipherSuitePrivFileName, cipherSuiteDefaultPrivFileName;
 
