1*** Settings ***
2Documentation    Module to test IPMI chipher functionality.
3Resource         ../lib/ipmi_client.robot
4Resource         ../lib/openbmc_ffdc.robot
5Library          ../lib/ipmi_utils.py
6Variables        ../data/ipmi_raw_cmd_table.py
7
8Test Teardown    FFDC On Test Case Fail
9
10*** Variables ***
11
12
13*** Test Cases ***
14
15Verify Supported Cipher List
16    [Documentation]  Execute all supported cipher levels and verify.
17    [Tags]  Verify_Supported_Cipher_List
18    :FOR  ${cipher_level}  IN  @{valid_cipher_list}
19    \  ${status}  ${output}=  Run Keyword And Ignore Error
20    ...    Run External IPMI Standard Command  power status  C=${cipher_level}
21    \  Should Be Equal  ${status}  PASS  msg=${output}  values=False
22
23
24Verify Unsupported Cipher List
25    [Documentation]  Execute all unsupported cipher levels and verify error.
26    [Tags]  Verify_Unsupported_Cipher_List
27    :FOR  ${cipher_level}  IN  @{unsupported_cipher_list}
28    \  ${status}  ${output}=  Run Keyword And Ignore Error
29    ...  Run External IPMI Standard Command  power status  C=${cipher_level}
30    \  Should Be Equal  ${status}  FAIL  values=False
31    ...  msg=ipmitool execution with cipher suite value of ${cipher_level} should have failed.
32
33
34Verify Supported Cipher List Via Lan Print
35    [Documentation]  Verify supported cipher list via IPMI lan print command.
36    [Tags]  Verify_Supported_Cipher_List_Via_Lan_Print
37    ${network_info_dict}=  Get Lan Print Dict
38    # Example 'RMCP+ Cipher Suites' entry: 3,17
39    ${cipher_list}=  Evaluate
40    ...  list(map(int, $network_info_dict['RMCP+ Cipher Suites'].split(',')))
41    Lists Should Be Equal  ${cipher_list}  ${valid_cipher_list}
42
43
44Verify Supported Cipher Via Getciphers
45    [Documentation]  Verify supported chiper list via IPMI getciphers command.
46    [Tags]  Verify_Supported_Cipher_Via_Getciphers
47    ${output}=  Run IPMI Standard Command  channel getciphers ipmi
48    # Example of getciphers command output:
49    # ID   IANA    Auth Alg        Integrity Alg   Confidentiality Alg
50    # 3    N/A     hmac_sha1       hmac_sha1_96    aes_cbc_128
51    # 17   N/A     hmac_sha256     sha256_128      aes_cbc_128
52
53    ${report}=  Outbuf To Report  ${output}
54    # Make list from the 'id' column in the report.
55    ${cipher_list}=  Evaluate  [int(x['id']) for x in $report]
56    Lists Should Be Equal  ${cipher_list}  ${valid_cipher_list}
57
58
59*** Keywords ***
60
61