Support username for IPMI default user account

The current support in IPMI is for the nameless account, which has
no username and only password associated with the account. In
ipmitool for the nameless account -U option is not needed. There are
management scripts which take a parameter for -U option and fails
if -U option is not supported by ipmitool option. This patch is to
support "admin" username for the default account. Once full fledged
user account management is in place, this change can be removed.

Change-Id: Idad73c0d04f189af66f2365424a68a637fe0e476
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/command/rakp34.cpp b/command/rakp34.cpp
index 71b1e52..37335a8 100644
--- a/command/rakp34.cpp
+++ b/command/rakp34.cpp
@@ -125,12 +125,12 @@
     auto sessPrivLevel = static_cast<uint8_t>(session->curPrivLevel);
 
     // User Name Length Byte
-    uint8_t userLength = 0;
+    auto userLength = static_cast<uint8_t>(session->userName.size());
 
     std::vector<uint8_t> input;
     input.resize(cipher::rakp_auth::BMC_RANDOM_NUMBER_LEN +
                  sizeof(rcSessionID) + sizeof(sessPrivLevel) +
-                 sizeof(userLength));
+                 sizeof(userLength) + userLength);
 
     auto iter = input.begin();
 
@@ -151,6 +151,9 @@
 
     // User Name Length Byte
     std::copy_n(&userLength, sizeof(userLength), iter);
+    std::advance(iter, sizeof(userLength));
+
+    std::copy_n(session->userName.data(), userLength, iter);
 
     // Generate Key Exchange Authentication Code - RAKP2
     auto output = authAlgo->generateHMAC(input);
@@ -187,7 +190,7 @@
 
     input.resize(cipher::rakp_auth::REMOTE_CONSOLE_RANDOM_NUMBER_LEN +
                  cipher::rakp_auth::BMC_RANDOM_NUMBER_LEN +
-                 sizeof(sessPrivLevel) + sizeof(userLength));
+                 sizeof(sessPrivLevel) + sizeof(userLength) + userLength);
     iter = input.begin();
 
     // Remote Console Random Number
@@ -207,6 +210,9 @@
 
     // User Name Length Byte
     std::copy_n(&userLength, sizeof(userLength), iter);
+    std::advance(iter, sizeof(userLength));
+
+    std::copy_n(session->userName.data(), userLength, iter);
 
     // Generate Session Integrity Key
     auto sikOutput = authAlgo->generateHMAC(input);